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

疑似大bug: RoformerForCasaulLM.prepare_inputs_for_generation: "past"参数应改名为"past_key_values" #45

Open
zjupeter opened this issue Apr 10, 2023 · 0 comments

Comments

@zjupeter
Copy link

zjupeter commented Apr 10, 2023

self, input_ids, past=None, attention_mask=None, token_type_ids=None, **model_kwargs

transformers模型的generate方法代码中,上文状态的参数名为past_key_values,不是past;
以transformers.GenerationMixin.sample方法为例,在其主循环while True中,在上一循环末尾会调用self._update_model_kwargs_for_generation 更新model_kwargs,此时更新进去的参数名为past_key_values;但到了下一循环调用self.prepare_inputs_for_generation时,又要从model_kwargs中取past参数,从而取不到,导致重复计算(基于更新了的input_ids重新算一遍上文状态),并且token_type_ids会一直取0,而不是预期的在生成第一个token时取0,此后一直取1。

@zjupeter zjupeter changed the title 疑似大bug: RoformerForCasaulLM.prepare_inputs_for_generation: "past"参数应改名为"past_key_value" 疑似大bug: RoformerForCasaulLM.prepare_inputs_for_generation: "past"参数应改名为"past_key_values" Apr 10, 2023
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

1 participant