fix: Fix typical_p behaviour broken in recent change#27165
Merged
gante merged 1 commit intohuggingface:mainfrom Oct 31, 2023
Merged
fix: Fix typical_p behaviour broken in recent change#27165gante merged 1 commit intohuggingface:mainfrom
gante merged 1 commit intohuggingface:mainfrom
Conversation
A recent PR huggingface#26579 fixed an edge case out-of-bounds tensor indexing error in TypicalLogitsWarper, and a related behaviour change was made that we thought fixed a long-standing bug w.r.t. the token inclusion cutoff. However after looking more closely, I am pretty certain that the original logic was correct and that the OOB fix should have been made differently. Specifically the docs state that it should include the "smallest set of tokens that add up to P or higher" and so `last_ind` should actually be one more than the index of the last token satisfying (cumulative_probs < self.mass). We still need a max clamp in case that last token is the very last one in the tensor.
Contributor
Author
|
@gante sorry about this! I observed that it can actually make a significant difference to the output when typical_p is used. |
gante
approved these changes
Oct 31, 2023
Contributor
gante
left a comment
There was a problem hiding this comment.
Makes sense, after re-reading the docstring (which I should also have read when reviewing!). Thank you for the fix!
Contributor
|
(the CI failed for unrelated reasons, rerunning failed jobs) |
EduardoPach
pushed a commit
to EduardoPach/transformers
that referenced
this pull request
Nov 19, 2023
A recent PR huggingface#26579 fixed an edge case out-of-bounds tensor indexing error in TypicalLogitsWarper, and a related behaviour change was made that we thought fixed a long-standing bug w.r.t. the token inclusion cutoff. However after looking more closely, I am pretty certain that the original logic was correct and that the OOB fix should have been made differently. Specifically the docs state that it should include the "smallest set of tokens that add up to P or higher" and so `last_ind` should actually be one more than the index of the last token satisfying (cumulative_probs < self.mass). We still need a max clamp in case that last token is the very last one in the tensor.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
A recent PR #26579 fixed an edge case out-of-bounds tensor indexing error in TypicalLogitsWarper, and a related behaviour change was made that we thought fixed a long-standing bug w.r.t. the token inclusion cutoff.
However after looking more closely, I am pretty certain that the original logic was correct and that the OOB fix should have been made differently.
Specifically the docs state that it should include the "smallest set of tokens that add up to P or higher" and so
last_indshould actually be one more than the index of the last token satisfying(cumulative_probs < self.mass).We still need a max clamp in case that last token is the very last one in the tensor.