Whisper: architecture, task tokens and decoding boundaries
Whisper
Connect weak supervision and encoder–decoder design to pinned preprocessing, task formats and long-form failure controls.
whisperA plausible sentence is not proof that someone said it
After background noise, a recognizer produces a grammatical sentence. Fluency does not establish that the sentence occurred in the audio. An encoder–decoder uses acoustic evidence and previously generated text; weak evidence may still lead to plausible but incorrect continuation. Whisper’s model card acknowledges unspoken-text and repetition failures, presenting part of the explanation as an author hypothesis rather than a proven unique mechanism. Model-card limitations
Whisper is a family of encoder–decoder models trained on large-scale weakly supervised audio–text pairs. The original paper reports approximately 680,000 hours of multilingual, multitask supervision and studies transfer without separately fine-tuning for every evaluation dataset. That zero-shot setting does not guarantee equal reliability across arbitrary languages, devices or contexts, nor establish the absence of every possible training-data overlap. Training and evaluation scope
We explain architecture, task tokens, numerical preprocessing and long-form decoding, then check several easily confused contracts with a small program. It has no Whisper weights and does not recognize speech. Supplied Mel power and synthetic decoding diagnostics help explain why a real system needs these conditions.
One audio segment, several conditional outputs
The original models process 30-second windows. Audio at 16 kHz uses 25 ms windows and 10 ms hops to form 80-band Mel input. Two width-three convolution layers with GELU precede the Transformer encoder; the second convolution uses stride 2 to reduce temporal positions. The autoregressive decoder reads encoder representations through cross-attention. The paper distinguishes sinusoidal encoder positions from learned decoder positions. Architecture and front end
Targets contain language, task and timestamp tokens as well as text. The model can condition on text from a preceding window. The paper states that this supplied previous context is excluded from training loss while other target tokens are predicted. For participating positions , the idea is:
This expresses conditional prediction with previous-context loss masked, not every normalization or task weight in training code. It differs from CTC’s framewise outputs and collapse, and from RNN-T’s two-axis blank lattice. Whisper predicts text and special-token sequences. Timestamps belong to the output format; this objective alone does not guarantee accurate alignment.
A multilingual transcription prefix can include startoftranscript, input language and transcribe. Translate requests translation into English; changing the language slot does not specify an arbitrary target language. Notimestamps is appended for text-only output. The pinned tokenizer converts these symbols into vocabulary IDs. We display only symbolic names and an en/zh/es teaching subset, not complete BPE or all supported languages. Prefix construction
Preprocessing has version and scale conventions too. The paper uses the term log-magnitude, while the inspected audio.py squares STFT magnitude before multiplying by a stored Mel bank:
This raw-FFT power path is not interchangeable with the separate teaching example that divides by FFT length and doubles interior one-sided energy bins. The repository accepts 80- or 128-band banks, which must match the loaded model’s input configuration. It does not imply that every original-paper model uses 128 bands. Pinned front end
For Mel power , the code applies an absolute floor, a floor eight decimal orders below the matrix peak, and an affine transformation:
All maxima except the peak are elementwise. Powers [10⁻¹², 10⁻⁴, 1, 100] become [−0.5, 0, 1, 1.5]; silence becomes −1.5. The paper’s approximate −1 to 1 scale is therefore not a hard code clamp. The peak couples frames within the processed matrix: power 10⁻⁸ alone maps to −1, but alongside a power 100 frame it maps to −0.5. Floors and scaling
Time geometry is directly checkable. A 30-second, 16 kHz window and 160-sample hop give the following counts, with the second convolution halving temporal positions:
The 20 ms timestamp grid is not an upper bound on alignment error. The original long-form procedure shifts windows using predicted timestamps rather than blindly concatenating arbitrary chunks. Incorrect preceding text can influence later output. Timestamp format and long-form audio
Long-form inference uses several heuristics. Let be average log probability, no-speech probability and compression ratio. Under the pinned default thresholds, retry is:
Low log probability or high repetition triggers retry, but high no-speech probability together with low log probability cancels retry. Skipping a segment uses a separate condition: only log probability strictly above −1 cancels no-speech skipping. Equality must therefore be retained:
Here is attempt temperature. The skip branch continues to the next window before later context-reset logic. Only retained segments reach that check. The paper describes conditioning below 0.5, while pinned code resets above 0.5; we preserve the implementation’s equality boundary. These thresholds are decoding policies, not proof that a sentence is correct. Retry, skipping and preceding context
Run inspectable contracts without pretending to infer speech
The complete Python/NumPy program transforms supplied 80/128-band Mel power with 1–64 frames, constructs symbolic prefixes for a small language subset, quantizes supplied times to 20 ms, and chooses among supplied decoder diagnostics. Midpoint ties-to-even is our teaching quantizer’s convention, not an acoustic prediction. Compression ratios and log probabilities are synthetic inputs; no text compression or decoder is executed.
"""Whisper numerical input and decoding-policy contracts, without model weights.
Given Mel power and synthetic decoder diagnostics. Not waveform inference, BPE,
a Transformer implementation, or a measurement of transcription quality.
"""
import json
import numpy as np
def normalize_mel(power):
raw=np.asarray(power)
if np.iscomplexobj(raw):raise ValueError('Real Mel power required')
x=np.asarray(raw,float)
if x.ndim!=2 or x.shape[0] not in (80,128) or not 1<=x.shape[1]<=64 or not np.isfinite(x).all() or (x<0).any() or (x>1e12).any():raise ValueError('Use80 or128 bands,1–64 frames, finite powers0–1e12')
logs=np.log10(np.maximum(x,1e-10));peak=float(logs.max());floored=np.maximum(logs,peak-8)
return dict(features=((floored+4)/4).tolist(),log_peak=peak,dynamic_floor=peak-8)
def prefix(language='en',task='transcribe',timestamps=False):
if language not in ('en','zh','es') or task not in ('transcribe','translate') or type(timestamps) is not bool:raise ValueError('Teaching subset: en/zh/es; transcribe/translate; boolean timestamps')
result=['<|startoftranscript|>',f'<|{language}|>',f'<|{task}|>']
if not timestamps:result.append('<|notimestamps|>')
return result
def timestamp_grid(seconds):
raw=np.asarray(seconds)
if np.iscomplexobj(raw):raise ValueError('Real times required')
x=np.asarray(raw,float)
if x.ndim!=1 or not 1<=len(x)<=32 or not np.isfinite(x).all() or (x<0).any() or (x>30).any():raise ValueError('Use1–32 segment-relative times within0–30seconds')
ticks=np.rint(x/.02).astype(int);values=ticks*.02
return dict(ticks=ticks.tolist(),seconds=values.tolist(),error=(values-x).tolist(),rounding='nearest, midpoint ties to even; a teaching quantizer, not model predictions')
def decision(avg_logprob,no_speech_prob,compression_ratio,temperature=0.,condition_on_previous=True):
values=[avg_logprob,no_speech_prob,compression_ratio,temperature]
if any(isinstance(v,bool) or not isinstance(v,(int,float)) for v in values) or not np.isfinite(values).all() or not -100<=avg_logprob<=0 or not 0<=no_speech_prob<=1 or not 0<=compression_ratio<=100 or not 0<=temperature<=1 or type(condition_on_previous) is not bool:raise ValueError('Invalid bounded decoder diagnostics')
low=avg_logprob< -1.;silent=no_speech_prob>.6;repetitive=compression_ratio>2.4
retry=(low or repetitive) and not (silent and low)
# Pinned implementation uses > to cancel skipping, so equality at -1 matters.
skip=silent and not (avg_logprob> -1.)
return dict(retry=retry,skip=skip,reset_prompt=(not skip) and ((not condition_on_previous) or temperature>.5),low_logprob=low,high_no_speech=silent,repetitive=repetitive)
def select_attempt(attempts,condition_on_previous=True):
if not isinstance(attempts,(list,tuple)) or not 1<=len(attempts)<=6:raise ValueError('Supply1–6 synthetic attempt records')
trace=[]
for i,row in enumerate(attempts):
if not isinstance(row,dict) or set(row)!={'avg_logprob','no_speech_prob','compression_ratio'}:raise ValueError('Three named decoder diagnostics required')
temperature=i*.2;state=decision(**row,temperature=temperature,condition_on_previous=condition_on_previous);trace.append(dict(attempt=i,temperature=temperature,**state))
if not state['retry']:break
# A short supplied schedule is an explicit teaching configuration.
return dict(selected=len(trace)-1,trace=trace,exhausted=bool(trace[-1]['retry']),skip=trace[-1]['skip'],reset_prompt=trace[-1]['reset_prompt'])
def demo():
power=np.tile([1e-12,1e-4,1.,100.],(80,1));normal=normalize_mel(power);quiet=np.full((80,1),1e-8);loud=np.full((80,1),100.)
attempts=[dict(avg_logprob=-2.,no_speech_prob=.2,compression_ratio=3.),dict(avg_logprob=-.5,no_speech_prob=.2,compression_ratio=1.2)]
return dict(input_power_first_band=power[0].tolist(),normalized_first_band=normal['features'][0],log_peak=normal['log_peak'],dynamic_floor=normal['dynamic_floor'],silence_first_band=normalize_mel(np.zeros((80,2)))['features'][0],
context=dict(quiet_alone=normalize_mel(quiet)['features'][0],quiet_with_loud=normalize_mel(np.hstack([quiet,loud]))['features'][0]),
prefixes=dict(transcribe=prefix('zh'),translate=prefix('zh','translate'),timestamped=prefix('en',timestamps=True)),timestamps=timestamp_grid([0,.031,1.009,29.999,30]),
geometry=dict(sample_rate=16000,window_samples=480000,mel_hop=160,mel_frames=3000,encoder_stride=2,encoder_frames=1500,timestamp_seconds=.02),
attempts=select_attempt(attempts),silent=decision(-2.,.9,3.),confident=decision(-.2,.9,1.),threshold=decision(-1.,.9,1.),exhausted=select_attempt([attempts[0]]*6),prompt_boundary=[decision(-.2,.1,1.,temperature=t) for t in [.5,.6]])
if __name__=='__main__':print(json.dumps(demo(),ensure_ascii=False,indent=2,allow_nan=False))
select_attempt examines temperatures 0, 0.2 and so on, stopping when a record no longer requests retry. There are at most six attempts, with explicitly shorter teaching schedules allowed. If the schedule ends while retry is still required, exhausted=True preserves that failure state instead of calling the last attempt successful. High no-speech probability does not skip confident text; at log probability exactly −1, skip and retry can differ.
Postprocessing uses time and returned storage for bands. Prefix construction is constant-sized, timestamp quantization and diagnostic selection . These are not complete Whisper inference complexity or speed measurements. Actual use must match model, sample rate, bank, tokenizer, decoder settings and hardware budget, then evaluate representative audio and failures.
Later versions do not inherit every original number
The model card dates the original series to September 2022, large-v2 to December 2022, large-v3 to November 2023 and turbo to September 2024. Later models are not just renamed files. Original data scale, model specifications and experimental results cannot be applied to every version without qualification. The inspected card still says “9 models” while including a turbo row; we do not adopt that stale total. Versions and model card
Some language counts and translation-hour figures also differ between paper and card. We use only the total explicitly attributed to the original paper rather than combining them into falsely exact statistics. Reported hallucinations and differences across lower-resource languages and accents motivate evaluation. The card’s causal explanation is an author hypothesis, not something this program validates.
Temperature fallback, beam search, no-speech thresholds and preceding context can mitigate certain errors, but paper Table 5 does not improve monotonically on every dataset. Fluency, average log probability and repetition measures cannot replace checking the audio. Whisper also does not guarantee reliable speaker identity or arbitrary audio classification. Those uses are not evaluated here.
Use boundary values to inspect the implementation
-
Understanding. Does zh plus translate mean translation into Chinese?
Answer: No. Zh identifies the input language; translate requests English output. Language and task are different slots. Our example displays the format without translating.
-
Calculation. Why does zero Mel power yield −1.5 rather than −1 under the pinned postprocessing?
Answer: The absolute floor gives log 10 value −10. The peak-minus-eight floor is lower and changes nothing. The affine step is , not a hard clamp to [−1, 1].
-
Boundary. With no-speech probability 0.9, average log probability exactly −1 and compression ratio 1, does the segment retry or skip?
Answer: It does not retry, but it skips. Retry tests strictly below −1; canceling skip requires strictly above −1. Equality reaches different branches.
-
Transfer. If the final temperature attempt remains repetitive, does ending the procedure establish a correct transcript?
Answer: No. Exhaustion terminates a policy, not uncertainty. Our example retains exhausted; a real project needs audio checks, error analysis and fallback handling. Thresholds cannot prove that words were spoken.
Retain versions and distinguish local checks from a full model
The ICML 2023 paper supplies architecture, task and long-form context. Audio.py, transcribe.py, tokenizer.py and the model card at the pinned August 2026 commit support implementation and version details. No upstream code or model weights were run. Original mathematics and finite diagnostics do not demonstrate official-model compatibility, recognition accuracy, speed or real timestamp quality.
Make a prediction, then check
What does exhausting the temperature fallback schedule establish?
Learning objectives
- Explain the encoder–decoder and multitask target format.
- Distinguish the original paper from later versions and code conventions.
- Compute log-Mel floors and time geometry.
- Test retry, skip and context-reset boundaries without overstating accuracy.
Prerequisites & connections
Explore related knowledge →References
- Robust Speech Recognition via Large-Scale Weak Supervision
Alec Radford, Jong Wook Kim, Tao Xu, Greg Brockman, Christine McLeavey, Ilya Sutskever · 2023 - Whisper audio preprocessing at commit86098128
OpenAI Whisper contributors - Whisper transcription fallback and context at commit86098128
OpenAI Whisper contributors - Whisper task-prefix construction at commit86098128
OpenAI Whisper contributors - Whisper model card at commit86098128
OpenAI Whisper contributors
Version1 · Editorial status: Recorded technical checks completed
View technical check record (AI)
Codex · 2026-09-13 · Single AI author checked scoped ICML2023 architecture, weak supervision, multitask prefixes and long-form policies alongside pinned2026-08-31 audio.py/transcribe.py/tokenizer.py/model-card sections. Distinguished paper scale wording, actual log-Mel floors, version/month and conflicting card statistics, strict retry/skip equality and conditional prompt reset. Six paired equations and four explained exercises. Original supplied-Mel and diagnostic calculations, not STFT, BPE, model weights, corpus accuracy or latency replication.
- Checked supplied-power features[-0.5,0,1,1.5], silence−1.5, prefix semantics, frame/time geometry, exact−1 skip/retry difference, skipped-segment reset exclusion and exhausted fallback.
- Four computed SVGs bind exact bilingual MDX. The five-topic group passed eleven numeric/encoding checks and 30 isolated language/width cases with four fallback fonts; ten actual screenshots inspected by the AI author. Literal-prose AST checked before freezing. Full article browser acceptance is separate; no human peer review.
- After rendered review, inserted missing spaces before English reference citations. Verified an exact whitespace-only transformation, unchanged formulas/program and preserved frozen article/test payloads; see editorial/corrections/011h-citation-spacing.
Source locations checked:
- Robust Speech Recognition via Large-Scale Weak Supervision · Read introduction scope, sections2.2/2.3 and3.2, appendixA.1. Visually inspected pages3 and14 including Table5; no benchmark numbers replicated. Pin the ICML2023 version and distinguish paper wording from repository preprocessing/threshold details.
- Whisper audio preprocessing at commit86098128 · Read constants, pad/trim excerpt,80/128 filter-bank support and lines133–157 STFT magnitude squared and log/floor/affine processing. Our program starts with supplied Mel power, not waveform/official filter-bank inference. Snapshot2026-08-31; no upstream code execution.
- Whisper transcription fallback and context at commit86098128 · Read lines196–227 retry,293–310 skip and498–507 context reset. Strict threshold equalities and skip-before-reset preserved. Synthetic diagnostics only; compression and neural decoding not run. Snapshot2026-08-31; no upstream code execution.
- Whisper task-prefix construction at commit86098128 · Read lines142–159 SOT/language/task sequence and238–240 notimestamps append. Symbolic teaching subset en/zh/es only; no BPE/vocabulary-ID compatibility claim. Snapshot2026-08-31; no upstream code execution.
- Whisper model card at commit86098128 · Read lines10–34 versions/dates,51 data and56–64 limitations. The nine-model prose is stale relative to the added turbo row; some language/hour statistics differ from the paper. Scope dates by month; causal explanations remain author hypotheses. Snapshot2026-08-31; no upstream code execution.
Related topics