fix: encode() and decode() read vocab arrays in wrong direction#7
Merged
Conversation
5fa04e2 to
d807539
Compare
d807539 to
82a3ce4
Compare
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.
This PR fixes a bug where
FallbackModel::encode()andFallbackModel::decode()read from the wrong internal arrays, causing every lookup to miss and fall back to the unknown-token placeholder.Motivation and context
The
FallbackModelstores two vocabularies: a forward mapping from tokens to IDs, and a reverse mapping from IDs back to tokens. The class had these two arrays stored under variable names that suggested the opposite direction — soencode()was reading from the reverse map anddecode()was reading from the forward map. For CTC tokenizers like Wav2Vec2 where token strings are purely alphabetic characters (e.g.'e' → 5) and IDs are integers, both lookups silently returned nothing and fell back to<pad>or an empty string. This produced completely silent ASR output for every Wav2Vec2 pipeline.What's changed
encode()to read from the token→ID mapping instead of the reverse mapdecode()to read from the ID→token mapping instead of the forward mapBreaking changes
None.