From predictions to a transcript
Whisper is an encoder–decoder transformer that reads 30 s of log-mel spectrogram and writes text one token at a time. The Transformer Explainer's Speech tab draws its network and the Tokenization Explainer's Whisper tab its front end and vocabulary. This tab is about what happens between the decoder's predictions and the finished transcript: the special tokens that set the language and the task, the rules that keep the output well formed, greedy decoding against beam search, and how audio longer than 30 s is read window by window.
The checkpoint is openai/whisper-base (72.6 M parameters). The long clip is five consecutive LibriSpeech dev-clean utterances of one chapter, 1272-128104-0000 to 0004, joined into 62.5 s; the wav2vec 2.0 tab's clip comes from the same chapter. Four Multilingual LibriSpeech test utterances, in French, German, Italian and Spanish, are the language examples. Every decode here is the drawer's code calling the unmodified model, checked token for token, and beam for beam, against transformers' generate.
The prompt: language and task
The decoder never starts from nothing. Its first input is <|startoftranscript|>, and its first prediction is the language: one of 99 language tokens. Keeping only those tokens and normalising gives a language identifier for free, shown in Language and task:
where are the logits after the start token. On the first 30 s of the long clip <|en|> gets 99.98 %; the four MLS clips go to <|fr|> (98.1 %), <|de|> (99.2 %), <|it|> (98.6 %), <|es|> (99.2 %). After the language comes the task: <|transcribe|> writes what was said, <|translate|> writes it in English whatever the language spoken, and <|notimestamps|> asks for text alone. The same audio and language token with the other task token gives the two lines under the clips. In the paper's results translation improves steeply with model size; this base model's translations are rough, as the four clips show.
Rules: what may come next
Before choosing, Whisper's decoder removes tokens that would break the output's format, setting their logits to . 88 tokens (symbols and special tokens that never belong in a transcript) are always removed; a space and <|endoftext|> cannot come first. With timestamps on, text is bracketed by timestamp tokens, one per 20 ms from <|0.00|> to <|30.00|>, and four more rules apply: a window's first token is a timestamp no later than <|1.00|>; timestamps come in pairs (a closing one directly followed by the next opening one), so after a lone timestamp only another timestamp or the end may follow; time never goes back; and when all timestamps together are likelier than any single text token,
only timestamps are allowed. In the Greedy decoding strip the note under each step says which rule shaped it.
Greedy and beam search
Greedy decoding writes the likeliest allowed token at every step. Beam search keeps 5 running sequences ranked by their summed log-probability. Each step extends every beam by every allowed token and keeps the 10 best extensions; those that write <|endoftext|> become finished hypotheses, ranked by their summed log-probability divided by their length,
so that short outputs are not favoured just for having fewer factors below 1. The rest continue, and the search stops when no running beam can still beat the worst of 5 finished ones. The Beam search strip shows the running beams at each step, which beam each came from, and the finished ones.
On the long clip greedy decoding gets 16 of 156 words wrong and the beam 13, after Whisper's English normaliser on both sides. Neither is uniformly better: the beam turns greedy's “upgards” into “up guards” and “a shampoo and” into “a shampooer and”, but both repeat a word where a window boundary cut through a segment: greedy writes “like a” before 58.92 s and “a shampoo” after it, the beam “after all, and” before 29.36 s and “and can discover” after it.
Long-form: 30 s windows
The encoder always reads exactly 30 s, so a longer recording is transcribed window by window. A window starts at seek, is decoded with timestamps, and its segments are kept. If its output ends with a lone timestamp, there was nothing more to say and the next window starts after it. Otherwise the last segment may be cut off mid-word: it is dropped, and the next window starts at the last timestamp pair, so the same audio is read again with its full context. Long-form: 30 s windows draws this for the 62.5 s clip: greedy decoding moves on at 29.40 s, 58.92 s, the beam at 29.36 s, 58.68 s, in 3 windows each. The last window holds less than 30 s and is padded with zeros.
OpenAI's own transcribe adds two things this recording leaves off, as transformers does by default: the previous window's text as a prompt after <|startofprev|>, which keeps names and style consistent, and a fallback that re-decodes a window at higher temperature when its output is too repetitive or too unlikely.
Where it came from
Attention-based encoder–decoders for speech, such as Listen, Attend and Spell (2015), wrote characters with a decoder that attends over audio features, and beam search with length normalisation came from neural machine translation. Whisper (2022) trained such a model on 680,000 hours of weakly labelled audio and folded language identification, translation and timestamps into one token format, so one decoder does all of them. Its long-form procedure inspired follow-ups such as WhisperX, which transcribes voice-activity segments in parallel and aligns words with a phoneme model. The wav2vec 2.0 tab shows the other classic decoder: CTC, which writes one symbol per frame and needs no attention between audio and text.
Papers
- Robust Speech Recognition via Large-Scale Weak Supervision Whisper, the model this tab records: the multitask token format, the timestamp rules, beam search with temperature fallback and long-form transcription.
- Listen, Attend and Spell An attention-based encoder–decoder that spells the transcript, the design Whisper scales up.
- Sequence to Sequence Learning with Neural Networks Encoder–decoder generation with a left-to-right beam search over the decoder's outputs.
- Google's Neural Machine Translation System: Bridging the Gap between Human and Machine Translation Length normalisation of beam-search scores, the reason finished hypotheses are compared per token.
- MLS: A Large-Scale Multilingual Dataset for Speech Research Multilingual LibriSpeech, the source of the French, German, Italian and Spanish clips.
- WhisperX: Time-Accurate Speech Transcription of Long-Form Audio A follow-up to Whisper's sequential long-form decoding: segment by voice activity, transcribe in parallel, align words.
- Librispeech: An ASR corpus based on public domain audio books The corpus of the long clip (dev-clean, 1272-128104-0000 to 0004).