Allow no-timestamp Whisper decoding to use full context#2075
Open
Emre-Akgul wants to merge 1 commit into
Open
Conversation
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.
Summary
When Whisper timestamps are disabled, allow decoding to use the remaining text context instead of unconditionally limiting generation to half of
max_length.Timestamped decoding retains the existing limit.
This improves transcription completeness for languages that rely heavily on Whisper's byte-level fallback tokenizer, where relatively short text can consume a large number of decoder tokens.
Fixes #2074, #1856.
Reproduction
Using
faster-whisperwithlarge-v3:Before the fix, both test files stop at exactly 224 re-tokenized text tokens.
Armenian
Reference:
Output before the fix:
The replacement character at the end indicates that decoding stopped in the middle of a byte sequence.
Georgian
Reference:
Output before the fix:
Armenian and Georgian rely heavily on Whisper's byte-level fallback tokenizer. As a result, even relatively short audio samples can exhaust the existing 224-token generation limit.
The Armenian reference requires 285 text tokens, which exceeds the previous 224-token limit but fits within the available no-timestamp decoder context.
The Georgian reference requires 516 text tokens, which exceeds Whisper's complete decoder context. The full reference therefore cannot fit in a single decoding window, even after removing the artificial half-context limit.
Root Cause
Whisper generation currently sets:
decoding_options.max_length = std::min( total_max_length / 2, total_max_length - start_step );This applies the half-context limit even when the prompt explicitly contains
<|notimestamps|>.The half-context restriction is needed for timestamped decoding because timestamp tokens refer to positions in the audio window. It is unnecessarily restrictive when timestamps are disabled and the remaining decoder context can be used entirely for text generation.
Change
For prompts containing
<|notimestamps|>, use the entire remaining decoder context:Timestamped decoding retains the existing half-context behavior.
With the standard no-timestamp prompt, the patched decoder can use up to 445 returned positions. Timestamped decoding remains limited to 224 positions.
Results After the Fix
Armenian
Output after the fix:
The old output stopped at 224 tokens with:
The patched output completes normally after 261 decoder tokens, before reaching the maximum decoder-context allowance. It no longer ends in the middle of a byte sequence.
Georgian
Output after the fix:
The old output stopped at 224 tokens:
The patched decoder continues until the full 445-position allowance is exhausted, returning substantially more of the transcription.
The result still ends in the middle of a byte sequence because this sample requires more tokens than Whisper's complete 448-position decoder context can accommodate. This is separate from the previous artificial 224-token limit.
Interpretation
The Armenian sample demonstrates the intended behavior clearly: the transcription requires more than 224 tokens but fits within the remaining decoder context, so it can now complete normally.
The Georgian sample exceeds the model's complete decoder context even after the fix. It therefore remains truncated, but the decoder returns substantially more of the transcription than before.
Languages that rely heavily on byte-level fallback tokens should still be used with caution because they can exhaust Whisper's decoder context with comparatively short outputs. However, removing the unnecessary half-context restriction improves both transcription completeness and practical availability for these languages.
Validation
large-v3decoding was validated using the Armenian and Georgian samples above.