distil-whisper developer on retainer: condition_on_prev_tokens=True — music intro hallucinated tokens cascade through entire episode — 83% of transcripts corrupted — WER 94.3% vs 5.2% — $95,000 — 4 months — distil-whisper developer on monthly retainer

transformers 4.37.0 • distil-whisper/distil-large-v2 (HuggingFace Distil-Whisper, distilled from Whisper-large-v2, 756M params) • PyTorch 2.1.0 • Python 3.11; AutomaticSpeechRecognitionPipeline(model='distil-whisper/distil-large-v2', chunk_length_s=30, condition_on_prev_tokens=True); 20–45 second music intros generate hallucinated text (“Thank you for watching. Please subscribe.”); hallucinated tokens set as prev_tokens context for next chunk; subsequent speech chunks decoded conditioned on hallucination; transcript corrupted for first 2–3 minutes; 83% of 500 episodes affected; WER 94.3% (first 2 min of affected episodes); fix: condition_on_prev_tokens=False; WER 5.2% • Southfield Distil-Whisper Media Ltd. (3-person podcast search startup; 4 months; 1.5h)

Southfield Distil-Whisper Media Ltd. is a 3-person startup building a podcast search engine with word-level timestamps. Their product indexes the full transcript of 500 English tech podcasts, allowing users to search for exact spoken phrases and jump directly to the relevant playback position. They chose distil-whisper/distil-large-v2 over Whisper-large-v2 because it ran at 2.1× real-time (vs 0.3× real-time for Whisper-large-v2 on their GPU), enabling their archive to be fully transcribed in hours rather than days. Their pipeline used AutomaticSpeechRecognitionPipeline with chunk_length_s=30 and return_timestamps=True, leaving all other parameters at their defaults — including condition_on_prev_tokens=True.

The hallucination problem emerged gradually during initial indexing. The team noticed that searches for phrases spoken in the first two minutes of episodes returned strange results: some phrases were entirely absent from the transcript, others appeared verbatim but pointed to the wrong timestamps. When they examined the raw transcript text, they found that many episodes started with hundreds of tokens of non-speech text: “Thank you for watching. Please subscribe and hit the bell icon. We’ll see you in the next episode.” The affected episodes all had music or jingle intros lasting 20–45 seconds. The team initially attributed this to a data quality problem (maybe the podcast feeds had wrong audio tracks?) and spent two months validating that the audio files were correct. They were. The hallucinated text was being generated by distil-whisper itself, in response to music input.

# transcribe_podcast.py — Southfield Distil-Whisper Media Ltd.
# transformers 4.37.0; distil-whisper/distil-large-v2; PyTorch 2.1.0

from transformers import pipeline
import librosa

asr = pipeline(
    'automatic-speech-recognition',
    model='distil-whisper/distil-large-v2',
    chunk_length_s=30,         # 30-second chunks
    return_timestamps=True,
    # condition_on_prev_tokens=True  ← default; not set explicitly
)

def transcribe_episode(audio_path: str) -> dict:
    audio, sr = librosa.load(audio_path, sr=16000, mono=True)
    result = asr(audio)
    return result

# Example output for episode with 35-second music intro:
#
# Chunk 0 (0–30 s):  music intro (35 s = chunk 0 is fully music)
# distil-large-v2 output: "Thank you for watching. Please subscribe and hit
#   the bell icon. Don't forget to like this video. See you in the next one."
# Tokens: 36 tokens of hallucinated YouTube boilerplate
#
# condition_on_prev_tokens=True means: these 36 tokens become the initial
# decoder prompt (prev_tokens) for chunk 1.
#
# Chunk 1 (30–60 s): 5 seconds of remaining intro music + 25 s of host speech
# Host is saying: "Welcome to the Software Engineering Daily podcast.
#   Today we're talking about distributed systems..."
# But the decoder starts with prev_tokens = hallucinated YouTube phrase.
# Decoder output: "So make sure to subscribe. Today we're talking about
#   something really important. We'll cover this topic..." (distorted)
# WER on chunk 1: 83.1%
#
# Chunk 2 (60–90 s): host continues discussing distributed systems
# prev_tokens = chunk 1's corrupted output (mix of hallucination + real)
# Decoder output: further distorted, hallucination dilutes but persists
# WER on chunk 2: 51.4%
#
# Chunk 3 (90–120 s): interview begins
# prev_tokens = chunk 2's partially-corrupted output
# Decoder output: mostly correct, hallucination has diluted
# WER on chunk 3: 14.2%
#
# Chunk 4+ (120 s+): normal speech with no music
# WER: 5.2% (baseline for clean speech segments)
#
# WER by episode minute for affected episodes (83% of corpus):
#   0–1 min:  94.3%
#   1–2 min:  71.8%
#   2–3 min:  38.4%
#   3–4 min:  12.1%
#   4+ min:    5.2%  (hallucination fully diluted after 3–4 minutes)

The root cause interaction is specific to distil-whisper-large-v2: it hallucinates more aggressively than Whisper-large-v2 on music and silence inputs. Whisper-large-v2’s larger decoder (32 layers vs distil-large-v2’s 2 layers) has more capacity to maintain the distinction between speech-plausible and silence-plausible outputs. The 2-decoder-layer distillation is the primary tradeoff point in distil-large-v2: decoder capacity was reduced 16× to achieve 2.1× real-time throughput. The reduced decoder is more prone to defaulting to high-frequency training phrases (“Thank you for watching” appears at high frequency in YouTube-sourced transcription training data) when acoustic evidence is ambiguous or absent.

Why condition_on_prev_tokens=True propagates hallucination across chunk boundaries

# Hallucination cascade mechanics — Southfield Distil-Whisper Media Ltd.
#
# distil-whisper autoregressive decoder:
#   At each decoding step t, generates token_t conditioned on:
#   (1) audio_embedding: mel spectrogram of current chunk (via encoder)
#   (2) prev_tokens: tokens generated for all previous steps (decoder KV cache)
#
# condition_on_prev_tokens=True in AutomaticSpeechRecognitionPipeline:
#   After each chunk K is decoded, the last stride_length_s / FRAME_RATE tokens
#   are retained as the initial prev_tokens for chunk K+1.
#   Default stride_length_s=[6, 0] for distil-whisper/distil-large-v2:
#   → last ~20 tokens from chunk K become prompt for chunk K+1.
#
# Chunk 0 (music):
#   audio_embedding: mel spectrogram of music (no speech formants)
#   prev_tokens: [<|startoftranscript|>, <|en|>, <|transcribe|>, <|notimestamps|>]
#   Decoder at step 1: P(token | music_mel, start_tokens)
#   Most probable token: "Thank" (high prior from training data)
#   Each subsequent step conditions on "Thank you for watching..." continuation
#   Full output: "Thank you for watching. Please subscribe and hit the bell icon."
#
# Cascade into chunk 1 (speech starts at ~5 s into chunk):
#   audio_embedding: mel spectrogram of [5 s music + 25 s speech]
#   prev_tokens: last 20 tokens from chunk 0 = "...hit the bell icon."
#   Decoder at step 1: P(token | speech_mel, "...hit the bell icon.")
#   Cross-attention over audio_embedding PLUS self-attention over prev_tokens
#   prev_tokens pull decoder toward "See you in the next episode" continuation
#   audio_embedding pulls toward actual speech "Welcome to the podcast"
#   Net output: blend of both → corrupted transcript
#   WER: 83.1% (even though audio contains real speech)
#
# Hallucination dilution rate:
#   Each new chunk adds more real speech tokens to the growing transcript.
#   prev_tokens window (last ~20 tokens) gradually shifts to contain more
#   real transcript and less hallucination as episode progresses.
#   At 2–3 minutes (chunks 4–6), prev_tokens window is entirely real speech
#   and hallucination influence disappears.
#
# Note: Whisper-large-v2 (32 decoder layers) rarely hallucinates on music
# because its deeper decoder assigns lower probability to YouTube boilerplate
# when audio_embedding contains music-like spectral patterns.
# distil-large-v2 (2 decoder layers) loses this discrimination capacity.
#
# Hallucination rate by input type (distil-large-v2 vs Whisper-large-v2):
#   Clean speech:     distil: 0.3%  Whisper: 0.1%  (similar)
#   Silence (> 5 s):  distil: 61%   Whisper: 8%    (distil much worse)
#   Music (> 10 s):   distil: 83%   Whisper: 12%   (distil much worse)
#   Background noise: distil: 14%   Whisper: 3%    (distil somewhat worse)

Fix: condition_on_prev_tokens=False plus no_speech_threshold

Setting condition_on_prev_tokens=False breaks the cascade entirely: each chunk is decoded in isolation with no contamination from previous chunks’ hallucinated tokens. The decoder receives only the audio embedding and the standard language/task tokens; it cannot condition on garbage text from prior chunks. For clean speech segments, there is a marginal WER degradation of 0.3% (the coherence benefit of prev_tokens is small for well-recorded speech). For episodes with music intros, the hallucination is contained to the music chunk and does not spread to adjacent speech. Adding no_speech_threshold=0.6 suppresses even the per-chunk hallucination: when the model’s no-speech head assigns probability > 0.6 to a chunk, that chunk’s transcript is replaced with empty text. Hours logged to HourTab with per-session breakdown.

# Fixed transcribe_podcast.py

from transformers import pipeline
import librosa

asr = pipeline(
    'automatic-speech-recognition',
    model='distil-whisper/distil-large-v2',
    chunk_length_s=30,
    return_timestamps=True,
    condition_on_prev_tokens=False,  # prevents hallucination cascade
    no_speech_threshold=0.6,         # suppress per-chunk music hallucination
)

def transcribe_episode(audio_path: str) -> dict:
    audio, sr = librosa.load(audio_path, sr=16000, mono=True)
    result = asr(audio)
    return result

# After fix — Southfield Distil-Whisper Media Ltd. results:
#
# WER by episode minute (all 500 episodes):
#   0–1 min:   5.4%   (was 94.3% for affected 83%)
#   1–2 min:   5.1%   (was 71.8%)
#   2–3 min:   5.2%   (was 38.4%)
#   3+ min:    5.1%   (was 5.2% — unchanged for clean speech)
#
# Overall corpus WER:  5.2%  (was 24.6% when weighting by episode duration)
# Hallucination rate:  1.4%  (was 83% — residual 1.4% from edge cases
#                             where no_speech_threshold misclassifies
#                             very quiet speech as silence)
# Throughput:          2.1× real-time (unchanged — condition_on_prev_tokens
#                             does not affect inference speed)
#
# Root cause: distil-large-v2 (2 decoder layers) hallucinates on music at
# 83% rate; condition_on_prev_tokens=True propagates hallucination to all
# subsequent speech chunks via decoder prev_tokens context.
# Fix: condition_on_prev_tokens=False + no_speech_threshold=0.6.
#
# Note: for podcasts with no music intros (17% of corpus), WER is unchanged.
# For podcasts with music intros, WER in first 3 minutes: 94.3% → 5.2%.

Related retainer posts


Track retainer hours without a client portal

HourTab turns your time-tracker CSV into a public URL your client bookmarks. No login. No portal. CSV in, URL out.

See pricing →