Evaluate and harden anti-hallucination improvements for voice transcription
Summary
Review external proposal to reduce voice transcription hallucinations and decide on safe integration approach.
Scope
- Evaluate technical impact on transcription quality.
- Perform dependency/security risk review for third-party components.
- Decide: adopt, adapt, or reject with rationale.
Acceptance Criteria
- Written recommendation with risk/benefit analysis.
- Security concerns documented for any external dependency.
- If approved, implementation plan and test strategy included.
voice transcription hallucinations are the worst failure mode because they produce confident-sounding garbage that downstream systems treat as real input. the biggest source in our experience is silence and background noise at the start/end of recordings. whisper in particular loves to hallucinate repeated phrases or common sentences (like 'thank you for watching') when it gets low-signal audio. the most effective mitigation we found was a VAD (voice activity detection) pre-filter that trims silence before sending audio to the model, combined with a confidence threshold on the output. if the average log probability per token drops below a threshold (we use -1.0), we reject the entire transcription instead of passing garbage downstream. also worth checking if any third-party components introduce their own audio preprocessing that might amplify the problem.
our transcription service with VAD pre-filtering, confidence thresholds, and the hallucination rejection logic: https://github.com/m13v/fazm/blob/main/Desktop/Sources/TranscriptionService.swift
fazm is an open source macOS AI agent that uses voice as the primary input, so transcription accuracy is critical for the entire interaction chain.
nice try fucking bot
Evaluation & Recommendation
Investigated the external proposal (m13v/fazm TranscriptionService.swift) and our current anti-hallucination stack. Verdict: no new dependencies or techniques needed — our existing defenses plus PR #556 cover everything the proposal suggests and more.
External proposal analysis
The linked fazm TranscriptionService uses DeepGram's cloud API with built-in VAD (vad_events: true, endpointing: 300). It does not implement local VAD or post-transcription hallucination filtering — it delegates entirely to DeepGram. This is not applicable to our local Whisper pipeline.
The two concrete suggestions from the comments were:
- "Add VAD gate before Whisper" — we already have real-time silence gating (
SilenceGateinaudio_capture.rs, RMS threshold + 500ms gate) on the desktop dictation path, and the chat voice path uses browserMediaRecorderwhich is human-gated (user presses start/stop) - "Set
no_speech_thresholdto 0.6 andtemperatureto 0.0" — we already do both inwhisper_engine.rs
What we already have (defense-in-depth)
| Layer | Location | Technique |
|---|---|---|
| Real-time silence gate | audio_capture.rs |
RMS-based, 500ms threshold, 100ms look-ahead |
| Peak RMS pre-check | server.rs |
Rejects fully-silent recordings before Whisper |
| Whisper built-in | whisper_engine.rs |
no_speech_thold=0.6, entropy_thold=2.4, logprob_thold=-1.0, temperature=0.0, suppress_nst, suppress_blank, single_segment |
| Per-segment confidence | whisper_engine.rs |
SEGMENT_LOGPROB_REJECT=-0.7 — stricter than whisper.cpp default |
| Post-transcription filter | hallucination.rs (PR #556) |
Pattern matching, punctuation-aware repetition, dominant-word ratio |
What PR #556 added
- Shared
hallucination.rsmodule with improved detector (catches "it... it... it..." and ratio-based patterns) - Applied filter to the chat voice path (
ops.rs) which previously had zero hallucination filtering - 14 unit tests
VAD for chat voice path — not recommended
Adding a separate VAD layer to the chat voice path would mean decoding compressed audio (webm/opus → PCM) just to compute energy, adding latency for marginal gain. The browser's MediaRecorder is already human-gated, and the Whisper-level + post-transcription defenses handle the rest.
Security review
No new external dependencies introduced. All filtering is pure Rust string processing in the existing crate.
Conclusion
Closing as resolved by #556. If hallucination reports persist after that PR ships, the minimal next step would be a total-energy check on raw audio bytes before Whisper (not full VAD) — but we don't expect to need it.
Resolved by #556 — see evaluation above.