whisper: set no_context to prevent quality drift over a session#79
Merged
cjpais merged 3 commits intocjpais:mainfrom Apr 8, 2026
Merged
whisper: set no_context to prevent quality drift over a session#79cjpais merged 3 commits intocjpais:mainfrom
cjpais merged 3 commits intocjpais:mainfrom
Conversation
Whisper transcription quality degrades progressively over a long push-to-talk session: short clips get mis-recognized or returned empty, and language detection sticks to the previous language (e.g. RU→EN switches keep producing Russian). Reloading the model restores quality. The cause is whisper.cpp's default prompt_past behaviour — the last decoded tokens are fed back as a prompt for the next decode. That's the right thing for continuous speech (lectures, meetings) where consecutive segments are connected, but the wrong thing for push-to-talk and similar workloads where each call to transcribe is an independent utterance: stale prompt tokens bias the next decode. Short clips suffer most because they have less acoustic evidence to overcome the stale prompt; language switches suffer because the prompt is in the previous language and steers detection. Set no_context = true so each decode starts from a clean prompt. The user-supplied initial_prompt continues to work — it goes through a different field and is unaffected.
Owner
|
I think we can definitely add this, but I think we need to add it as an option for someone to change since this is a library. We can have the default be what you suggest |
Contributor
Author
|
Makes sense, thanks for the quick reply. I'll add it as a field on |
Per review, make no_context an opt-in field on WhisperInferenceParams so callers can override it for continuous-speech use cases (lectures, meetings, streaming) where carrying prompt_past across segments improves consistency. Default stays true — the right choice for independent utterances such as push-to-talk dictation, which is the case the previous commit fixed.
Contributor
Author
|
Done! Added WhisperInferenceParams { no_context: false, ..Default::default() }Thanks again for the quick review! Happy to tweak naming or docs if you'd prefer something different. |
Owner
|
Thank you! |
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
Whisper transcription quality degrades progressively over a long push-to-talk session in Handy:
I've been hitting this for a while and was reloading Handy a couple of times a day to clear it.
Cause
whisper.cpp's
whisper_fulldefaults to usingprompt_past— the last decoded tokens are fed back as a prompt for the next decode. That is the right thing for continuous speech (lectures, meetings) where consecutive segments are connected. It is the wrong thing for push-to-talk and similar workloads where each call totranscribeis an independent utterance: residue from prior, unrelated decodes biases the next one.Fix
Set
FullParams::set_no_context(true)inWhisperEngine::inferso each decode starts from a clean prompt. One line.The user-supplied
initial_promptis unaffected — it goes through a differentFullParamsfield. I verified this with the existingtest_prompt_product_namestest, which still passes (it asserts thatinitial_promptinfluences the output, and it does).Performance
If anything, slightly cheaper — fewer prompt tokens for the decoder to process at the start of each decode. No allocations, no API change.
Compatibility
Public API unchanged. If anyone needs the old behaviour for streaming or continuous-speech use cases, happy to expose
no_contextas an opt-in field onWhisperInferenceParamsin a follow-up.Testing
cargo test --features whisper-cpp— all 3 whisper tests pass (test_jfk_transcription,test_prompt_product_names,test_timestamps).