[DataCollatorForCompletionOnlyLM] Warn on identical eos_token_id
and pad_token_id
#988
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
This PR displays a warning message when the values of
pad_token_id
andeos_token_id
are identical. This is to prevent unexpected behavior during multi-turn training.After the multi-turn data training with DataCollatorForCompletionOnlyLM, I encountered an issue where the model continued generating outputs even after the assistant's turn had been completed. This issue was due to the equivalence of the tokenizer's eos token and pad token by default in some model, resulting in the eos token not being properly trained.
For instance, in the torch_call() function within data_collator.py, the pad_token_id is converted to ignore_id(-100).
If the multi-turn data is formatted as shown below, and
eos_token_id
andpad_token_id
are identical, the eos_token would not be properly trained. This could lead to a scenario where the model continuously generates both user and assistant turns without recognizing the end of sequence (eos) token.Suggestion
In case of Vicuna, they set pad_token to unk_token. Would it be a solution?