-
Notifications
You must be signed in to change notification settings - Fork 28.2k
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
Fix ExponentialDecayLengthPenalty negative logits issue #25594
Fix ExponentialDecayLengthPenalty negative logits issue #25594
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for detecting the issue, proposing a solution, and implementing it @pokjay 🔥 Contributions like yours make the ecosystem thrive!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! Thanks for the contribution 🤗
Thanks @gante and @ArthurZucker ! Could you please approve the documentation workflow? I’d like to verify the documentation looks as expected |
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. |
@gante Do I need to do anything more to get this merged? |
You could take into account the changes I suggested 😉 code related variable name are always put aroung codeblocks in our doc! |
@ArthurZucker oops, totally missed those! Committed those fixes now, Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI should go green once you rebase to main!
Fix tests which were broken and add validation of negative scores. Current test didn't take into account that ExponentialDecayLengthPenalty updates the score inplace, resulting in updates to base tested Tensor. In addition, the gt assert had empty Tensors due to indexing along the batch dimension. Test is currently expected to fail to show ExponentialDecayLengthPenalty issues with negative scores
In cases where the scores are negative, ExponentialDecayLengthPenalty decreases the score of eos_token_id instead of increasing it. To fix this issue we compute the penalty of the absolute value and add it to the original score.
Co-authored-by: Arthur <[email protected]>
188fb67
to
e27c496
Compare
@pokjay since we last spoke, we've added this file to the list of files to be doctested in our PR CI -- it seems like your example's outputs don't match the hardcoded outputs. Would you be able to double-check that? :) (as soon as this gets fixed, we can merge) |
@gante Fixed the issues, all checks pass! |
@pokjay thank you for iterating 💛 |
…25594) * Fix issues in test_exponential_decay_length_penalty Fix tests which were broken and add validation of negative scores. Current test didn't take into account that ExponentialDecayLengthPenalty updates the score inplace, resulting in updates to base tested Tensor. In addition, the gt assert had empty Tensors due to indexing along the batch dimension. Test is currently expected to fail to show ExponentialDecayLengthPenalty issues with negative scores * Fix ExponentialDecayLengthPenalty negative logits issue In cases where the scores are negative, ExponentialDecayLengthPenalty decreases the score of eos_token_id instead of increasing it. To fix this issue we compute the penalty of the absolute value and add it to the original score. * Add examples for ExponentialDecayLengthPenalty * Fix styling issue in ExponentialDecayLengthPenalty doc * Apply suggestions from code review Co-authored-by: Arthur <[email protected]> * Style and quality fix * Fix example outputs --------- Co-authored-by: Arthur <[email protected]>
What does this PR do?
In cases where the model logits are negative, ExponentialDecayLengthPenalty decreases the score of eos_token_id instead of increasing it.
To fix this issue we compute the penalty of the absolute value and add it to the original score, as described in #25416
The test was updated to check for negative logits.
In addition, this PR updates the class documentation and adds examples, as part of #24783
Fixes #25416
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
@gante