Repository navigation
fix(whisper): decode each window without the previous window's text - #35
Merged
Merged
Conversation
no_context=true only clears context between whisper_full calls. Inside one call whisper.cpp conditions every 30 s window on the text decoded so far, so a window that decodes into a repeated sentence hands that repetition to the next window as its prompt, and the loop replaces the rest of a long dictation. The entropy guard misses it: the timestamp tokens around each repeat lift the window just over entropy_thold. Set n_max_text_ctx to 0, or to the hint's token count + 1 when hints are set, so the pinned hint still reaches every window and no decoded text does. Clips under 30 s (one window) are unaffected. Measurements, trade-offs and rejected alternatives are in docs/design-notes.md; the earlier "cross-chunk prompt ruled out" line is marked partly superseded. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G7rq8KjcC7Y2vQ79CCoTo4
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.
Problem
A 5:50 dictation on local Whisper (
whisper-turbo-q5, auto-detect, no hints) was transcribed cleanly up to 3:12. From there it returned one short sentence 81 times and nothing else until the final two words. About 2.5 minutes of speech were lost. The result was identical on every run: the live dictation,zee -transcribe, and four directCtx.Transcriberuns.Cause
no_context = trueonly clears context betweenwhisper_fullcalls (whisper.cpp:6921). Inside one call, every 30 s window is still conditioned on the text decoded so far (:7111, up to 224 tokens). So the design-notes line that ruled out the cross-chunk prompt was based on a misreading of that flag.A
-DWHISPER_DEBUGtrace shows what happens. Every window from 207 s to 349 s decoded the same sentence withentropy = 2.46849, against anentropy_tholdof 2.40, so the temperature fallback never ran. The sentence's 8 text tokens alone score 2.07. The timestamp tokens around each repeat change value every time, and they lift the window just over the threshold. Each next window then starts from a prompt full of the repeated sentence and continues it with confidence (avg_logprobsbetween −0.25 and −0.13).Change
internal/whisper/whisper.go:n_max_text_ctx = 0, or the hint's token count + 1 when hints are set. The pinned hint still fills every window's prompt and no decoded text gets in. Clips under 30 s are a single window, so they decode exactly as before.Measurements
M4, 16 GB, macOS 27. Same clip, only
n_max_text_ctxchanged:Trade-offs, measured:
say -v Yelda): WER against the source text went from 6.2% to 7.5%. That is one word: "konşimento" → "con shimento".say -v Samantha): WER 3.3% both ways, with no word changes.Rejected alternatives (a small rolling context, a higher
entropy_thold, splitting at pauses) and the reasoning are written up indocs/design-notes.md, under "Why whisper decodes each window without the previous window's text". The old timestamps entry is marked partly superseded, following the repo convention.If you'd rather keep more punctuation, a 16–32 token rolling context also cleared this clip. I didn't choose it because a window that does loop would still pass its last repeats on to the next window.
Tests
go test -race ./...passes, with the whisper model present, soTestTranscribeKnownClipsran.🤖 Generated with Claude Code
https://claude.ai/code/session_01G7rq8KjcC7Y2vQ79CCoTo4