Filter Whisper hallucinations (closes #5) - #11
Open
kenodressel wants to merge 12 commits into
Open
Conversation
Post-Whisper filter with two paths: consecutive-token/n-gram repetition detector, and exact-match phantom phrase set (with defaults + user-extensible list in dictionary.toml under [hallucinations]). Drops the transcription and shows a brief "Likely noise" menu-bar badge on match. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…rases Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ments Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…dy docstring Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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
Closes #5.
Whisper produces canned phrases (⚠️ "Likely noise" badge instead of pasting garbage.
"Thank you.","Untertitel im Auftrag des ZDF") and consecutive-token/n-gram repetition on noise, silence, or short audio. This change drops those after transcription and shows a briefsabbel/hallucinations.py: token/n-gram repetition heuristic + normalized exact-match against a 22-phrase default phantom set (English + German + bracketed music/applause + dots/notes).[hallucinations]section in~/.config/sabbel/dictionary.toml— hot-reloaded between recordings.apply_replacementsso phantom matches aren't broken by dictionary substitutions.Spec:
docs/superpowers/specs/2026-05-13-hallucination-filtering-design.mdTest plan
uv run pytest— 113 passing (39 new tests acrosstest_hallucinations.py+test_dictionary.py)make install-app):~/.config/sabbel/dictionary.tomlunder[hallucinations]→ picked up on next recording without restarttail /tmp/sabbel-runtime.logafter a noise rejection → showsFiltered hallucination: ...Known limitations
"you"and"Bye."are dropped (Whisper noise-bias phantoms). Acceptable for dictation; users dictating one-word messages should add a custom replacement if it bites."a b c d e a b c d e a b c d e") is not flagged. Spec caps n at 4 — extremely unlikely in practice.🤖 Generated with Claude Code