-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Learning to generate EOS tokens #1623
Comments
As I mentioned on out internal slack, we should probably add a line such as:
this needs to be removed before saving the model as otherwise generation is broken:
I tested these additions in h4 and it resolved many of the issues we saw with models trained with |
is this an issue when packing=True ? I also do find that the generations from the SFT model are quite wordy. |
@yananchen1989 I believe the answer is yes for packing=True & packing=False. I'm experiencing lack of predicting EOS on SFTTrainer fine-tuned models w/ using chat templates. Still doing testing, but it doesn't seem to be an issue when not using chat templates and using formatting_func instead. PEFT also seems to be a contributing factor. No PEFT and EOS is predicted correctly. W/ PEFT and EOS is not correctly predicted. |
Actually I am not even sure if setting the
|
yes, i agree that no matter packing is set or not, EOS token has not been properly predicted which causes lengthy output. |
@yananchen1989 FYI when packing is set this should not be a problem. See #1646 (comment). |
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread. |
@edbeeching and I noticed sometimes the trained SFT models do not learn to stop generations. In other words, the model never learn to generate EOS tokens.
Upon some digging, I noticed this is mainly an issue with the dataset preprocessing. In particular, if we simply pass a dataset like https://huggingface.co/datasets/timdettmers/openassistant-guanaco to the
SFTTrainer
, the trainer may not postpend the completion with an EOS token.If we run
for item1, item2 in zip(inputs["input_ids"][1], inputs["attention_mask"][1]): print(item1, item2)
at https://github.com/huggingface/transformers/blob/91d155ea92da372b319a79dd4eef69533ee15170/src/transformers/trainer.py#L3207, with our SFT example we getNotice how the pad token / eos token corresponds to attention mask = 0.
potential solution
This can be resolved if we add an eos token to the dataset itself. For example,
trl/examples/scripts/minimal/sft.py
Line 57 in dc012ea
Notice how the first eos token corresponds to attention mask = 1.
The text was updated successfully, but these errors were encountered: