↑↓ move Enter open ⌘K find from any page 256 of 256 tabs
Loading the recording…

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.

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

  1. Robust Speech Recognition via Large-Scale Weak Supervision Alec Radford, Jong Wook Kim, Tao Xu, Greg Brockman, Christine McLeavey, Ilya Sutskever · ICML 2022 Whisper, the model this tab records: the multitask token format, the timestamp rules, beam search with temperature fallback and long-form transcription.
  2. Listen, Attend and Spell William Chan, Navdeep Jaitly, Quoc V. Le, Oriol Vinyals · arXiv 2015 An attention-based encoder–decoder that spells the transcript, the design Whisper scales up.
  3. Sequence to Sequence Learning with Neural Networks Ilya Sutskever, Oriol Vinyals, Quoc V. Le · NeurIPS 2014 Encoder–decoder generation with a left-to-right beam search over the decoder's outputs.
  4. Google's Neural Machine Translation System: Bridging the Gap between Human and Machine Translation Yonghui Wu, Mike Schuster, Zhifeng Chen, Quoc V. Le, Mohammad Norouzi, et al. · arXiv 2016 Length normalisation of beam-search scores, the reason finished hypotheses are compared per token.
  5. MLS: A Large-Scale Multilingual Dataset for Speech Research Vineel Pratap, Qiantong Xu, Anuroop Sriram, Gabriel Synnaeve, Ronan Collobert · Interspeech 2020 Multilingual LibriSpeech, the source of the French, German, Italian and Spanish clips.
  6. WhisperX: Time-Accurate Speech Transcription of Long-Form Audio Max Bain, Jaesung Huh, Tengda Han, Andrew Zisserman · Interspeech 2023 A follow-up to Whisper's sequential long-form decoding: segment by voice activity, transcribe in parallel, align words.
  7. Librispeech: An ASR corpus based on public domain audio books Vassil Panayotov, Guoguo Chen, Daniel Povey, Sanjeev Khudanpur · ICASSP 2015 The corpus of the long clip (dev-clean, 1272-128104-0000 to 0004).

See also