Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't anyone see a problem with the code about the prompt construction for BERT-style transformer??? #40

Open
lovekittynine opened this issue Nov 21, 2022 · 2 comments

Comments

@lovekittynine
Copy link

if 'gpt' not in self.args.model_name and 'megatron' not in self.args.model_name:
    # BERT-style model(bert风格句子构造, CLS开头, SEP结尾)
    return [[self.tokenizer.cls_token_id]  # [CLS]
            + prompt_tokens * self.template[0]
            + [self.tokenizer.mask_token_id]  # head entity
            + prompt_tokens * self.template[1]
            + self.tokenizer.convert_tokens_to_ids(self.tokenizer.tokenize(' ' + x_h))  # [MASK] (tail entity)
            + (prompt_tokens * self.template[2] if self.template[
                                                       2] > 0 else self.tokenizer.convert_tokens_to_ids(['.']))
            + [self.tokenizer.sep_token_id]
            ]

我不知道理解的对不对?按照论文中的意思,这里head entity中的mask_token_id和tail entity中x_h的编码id是不是写反了呢?因此对于bert-style的finetune实际上是在用head entity去预测head entity?而并非是head entity去预测tail entity??? @Life-0-1 @#12 @#15 @Xiao9905

所以用bert尝试复现的效果不行的,有没有可能是因为这里呢?

@Xiao9905
Copy link
Member

@lovekittynine

谢谢你的指出。此处的code是为LAMA knowledge probing设计的,确实应该理论上是反过来才符合正常的(h, r, t)顺序。但是此处并非是用head预测head,可以参考此处代码,mask的位置是on-the-fly确定的。实际上这个code是一个历史遗留问题,当时是为了测试调换顺序会对performance产生什么影响;结论是似乎用了tuning之后就没有什么影响了,因此忘记修改了回来。

此外,另两个issue似乎提及的主要是few-shot learning的问题,使用的并非LAMA这部分的code。

@lovekittynine
Copy link
Author

@Xiao9905 感谢回复,是这样子的,虽然顺序反了,还是用的head entity去predict tail entity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants