Repository navigation
Conversation
During long-form transcription on audio with prolonged silence, music, or low-energy speech, Whisper's autoregressive decoder can get trapped in a repetition loop. On silence, no_speech_prob often fails to reach the 0.6 threshold, leading to a hallucinated segment. Because last_ts_pos for the hallucinated segment is short, seek advances by only a few seconds while the hallucinated tokens are appended to prev_history_segments. In subsequent windows, the decoder is conditioned on this hallucinated prefix via <|startofprev|>, creating an unbroken autoregressive repetition loop that repeats across thousands of chunks. Fix this by: 1. Calling stop_on_repetition during the step loop to catch intra-chunk token repetition loops early. 2. Detecting repetitive segments across consecutive chunks within close temporal proximity (<=15s). 3. Dropping repetitive hallucinated segments, clearing prev_history_segments and prev_chunk_segments, resetting do_condition_on_prev_tokens = false, and advancing seek by the full chunk window to skip past the silent/attractor region.
This branch has not been deployed
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
During long-form transcription on audio with prolonged silence, music, or low-energy speech, Whisper's autoregressive decoder can get trapped in an attractor repetition loop:
no_speech_proboften fails to reach the 0.6 threshold, producing a hallucinated segment (e.g. repeated common phrases).last_ts_posfor the short hallucinated phrase is brief (often 1–2 seconds),seekonly advances by that small interval.prev_chunk_segmentsandprev_history_segments.<|startofprev|>. Since the background remains quiet, the model attends back to the prompt, outputting the exact same text again and again in an unbroken autoregressive loop across thousands of chunks.Changes
• Early repetition termination: In
whisper_run's step loop, calltranscribe::stop_on_repetitionongenerated_text_idsto catch intra-chunk repetitive token blocks early (aligning with other families in the codebase such as MOSS and Granite).• Inter-chunk duplicate suppression: Detect consecutive identical or near-identical segments within close temporal proximity (<= 15s). When detected:
prev_chunk_segmentsandprev_history_segments.do_condition_on_prev_tokens = falseto break the feedback chain.seekby the full chunk window (seek_num_frames) to jump past the silent attractor region.AI Assistance
I used an AI coding assistant to help draft and refine the C++ implementation for the repetition guard and context clearing logic. I reviewed the code diff and performed end-to-end transcription testing locally.
Validation
• Rebuilt universal dylib on macOS (AppleClang 17, Metal + CPU).
• Tested with long-form audio containing silence and music sections using
ggml-large-v3-turbo-q5_0.bin: