Hoist special-token lookups in wav2vec2 decode paths and drop a dead filter in wav2vec2_phoneme - #47557
Merged
itazap merged 1 commit intoJul 31, 2026
Conversation
…r in wav2vec2_phoneme
Contributor
|
[For maintainers] Suggested jobs to run (before merge) run-slow: wav2vec2, wav2vec2_phoneme |
Contributor
CI recapDashboard: View test results in Grafana |
Collaborator
|
run-slow: wav2vec2, wav2vec2_phoneme |
Contributor
|
This comment contains models: ["models/wav2vec2", "models/wav2vec2_phoneme"] |
|
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. |
Sainava
pushed a commit
to Sainava/Sai-transformers
that referenced
this pull request
Aug 3, 2026
…filter in wav2vec2_phoneme (huggingface#47557) Hoist special-token lookups in wav2vec2 decode paths, drop dead filter in wav2vec2_phoneme
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.
What this does
Fixes #47556. Finishes the per-token special-token cleanup from #47425 for the wav2vec2 family.
Wav2Vec2CTCTokenizer.convert_ids_to_tokens: hoistset(self.all_special_ids)out of the id loop. The property rebuilds its list on every access, so the loop paid a rebuild per id.Wav2Vec2CTCTokenizer._decode: same hoist forself.all_special_tokensin the token loop.Wav2Vec2PhonemeCTCTokenizer._decode: delete a filter loop that never matches. It compares token strings againstall_special_ids(ints), andconvert_ids_to_tokenswas already called withskip_special_tokenspassed through, so even a type-corrected check would find nothing to remove.Numbers
20k ids, 205 special tokens (the MMS shape: one added special per language), M1 CPU:
Behavior
No output changes anywhere:
skip_special_tokensTrue/False, with base vocab, delimiter, added and special tokens in the input: identical. That is the proof the deleted loop was dead.Notes
#46578 (open) touches the same
convert_ids_to_tokensline to change word-delimiter handling. This PR does not change that logic either way; the two compose semantically and I am happy to rebase whichever lands second.AI-assisted; I reviewed every line and ran the tests and benchmarks above.