Correct Whisper's beam search scores computation#32336
Merged
ylacombe merged 2 commits intohuggingface:mainfrom Sep 12, 2024
Merged
Correct Whisper's beam search scores computation#32336ylacombe merged 2 commits intohuggingface:mainfrom
ylacombe merged 2 commits intohuggingface:mainfrom
Conversation
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
Contributor
|
Nice, that looks like the correct fix to me! I suspect that the other items (attentions, hidden states, logits) will have size (Also, for anyone wondering why the scores are not exactly the same, it's likely because of the logits processors |
sanchit-gandhi
approved these changes
Aug 1, 2024
ArthurZucker
approved these changes
Aug 27, 2024
Collaborator
ArthurZucker
left a comment
There was a problem hiding this comment.
should we merge this and close the issue?
5 tasks
Contributor
Author
|
Merging now |
BernardZach
pushed a commit
to BernardZach/transformers
that referenced
this pull request
Dec 5, 2024
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.
Fixes #32246
There have been many failing tests these past days with Whisper, so I'd probably wait for them to be fixed before merging this PR.
What does this PR do?
@cifkao made a great summary the current issue in #32246:
He also rightfully identified what was the origin of the issue:
The solution simply consists in taking the right
logits_scoresfor each of the generated tokens.Instead of taking the
batch_idx-thlogits_scoresout of thenum_beams * batch, we're now taking thebeam_idx-thlogits_scores.Reproduction results
I've recomputed the code snippet from #32246.
How to read the results:
The first set of scores are the scores corresponding to each generated tokens, as well as their beam index.
The second set of scores are the scores of a handmade forward pass of the generated tokens, they indicates the "true scores" that we should have.
Notice how in #32246, the scores coming from the 1-th beam index are different from the recomputed scores. It indicates that we selected the wrong scores.
Here, they're about the same, which indicates we selected the right beam indices.
Scores out of the generation:
Scores out of the forward:
** Code:**
cc @LysandreJik, @kamilakesbi and @sanchit-gandhi