Speech and audio
Attention Encoder–Decoder Speech Recognition
Explain encoder–decoder ASR, attention, teacher forcing, exposure bias, decoding, coverage, and streaming limits.
By the end you can
- Define attention encoder–decoder speech recognition as an operational problem with explicit inputs, outputs, and boundaries
- Distinguish teacher forcing, autoregressive inference, and joint ctc–attention without treating them as interchangeable
- Trace the workflow from encode the utterance through search and constrain
- Evaluate attention encoder–decoder speech recognition using wer plus deletion, insertion, and repetition profiles and evidence from difficult deployment slices
Example
13,140 segments, 187 that reliably hallucinated
In 2023 a team pushed 13,140 AphasiaBank audio segments through the Whisper API. They went looking for text that was not in the audio at all. They found 187 segments that reliably hallucinated. On average 1.4% of transcriptions contained hallucinations. Their 2024 paper opens with the finding: "While many of Whisper's transcriptions were highly accurate, we find that roughly 1% of audio transcriptions contained entire hallucinated phrases or sentences which did not exist in any form in the underlying audio."
The rest of the count is what makes this a lesson rather than a curiosity. Of the 312 hallucinated transcriptions, 38% contained at least one explicit harm: 19% perpetuating violence, 13% inaccurate associations, 8% false authority. The burden was not spread evenly. The hallucination rate was 1.7% for speakers with aphasia against 1.2% for the control group. The invented text arrived most often for the speakers whose audio was hardest. It arrived for the speakers whose transcripts were least likely to be contested.
That is the failure this lesson is built around. Its name is worth fixing early: fluent continuation unsupported by audio. It is hard to catch because the usual report can be complete and still miss it. WER can be published in full, with deletion, insertion and repetition profiles broken out. An invented clause still sits inside the sentence, looking exactly like the words that were spoken.
- This lesson works through what an encoder–decoder recognizer is, how attention aligns it to the audio, why teacher forcing leaves an exposure bias behind, and what decoding, coverage and streaming cost once that gap is open.
- The failure to hunt for is the one measured above: entire hallucinated phrases or sentences that did not exist in any form in the underlying audio. Roughly 1% of transcriptions, with 38% of the hallucinated transcriptions carrying an explicit harm.
- The evidence that would expose it is WER read alongside separate deletion, insertion and repetition profiles. A single aggregate number hides which of the three actually happened. A rate averaged over all speakers hides which speakers paid — 1.7% against 1.2%.
- The practical probe is audio containing words that compete with one another under different language priors. Add disfluent or impaired speech of the kind AphasiaBank collects. A decoder leaning on its language model then has to show its hand.
Fluency is not acoustic grounding
The mechanism behind those hallucinated sentences is the architecture itself. An attention encoder–decoder maps audio to contextual encoder states. It then generates output tokens autoregressively while attending to those states. The difference from CTC is that the decoder conditions explicitly on the output history it has already produced. It knows what it just wrote, and it writes the next token partly to fit what came before. That is what buys flexible alignment, and flexible alignment is a real advantage on ordinary speech.
It is also the entire cost. And the cost is not a critic's characterisation. It sits on the limitations list of the system that was measured above. Whisper's own paper, under improved decoding strategies, writes: "They are a combination of failure modes of seq2seq models, language models, and text-audio alignment and include problems such as getting stuck in repeat loops, not transcribing the first or last few words of an audio segment, or complete hallucination where the model will output a transcript entirely unrelated to the actual audio." Skip, repeat, invent. Those three failures were named in 2022. They were named by the people who trained the model on 680,000 hours of labeled audio, about their own deployed system.
All three arrive most readily on long, noisy or out-of-domain audio. Standard full-context attention carries a second limit as well: it is not inherently streaming.
Work on such a system runs from encoding the utterance at one end to searching and constraining the output at the other. Name an owner at either end. Otherwise the search inherits assumptions that nobody is answerable for.
Buying flexible alignment means buying repeat loops, dropped words at the edges of a segment, and transcripts entirely unrelated to the audio — and a transcript that reads cleanly is exactly the one nobody checks against the recording.
Case
The paper that published its own losing margin
Nobody concealed any of this when the idea arrived. The first attention recogniser published its own losing margin. Listen, Attend and Spell reported 14.1% word error rate on a subset of Google voice search, with no dictionary and no language model. Rescoring the top 32 beams with a language model took it to 10.3%. The CLDNN-HMM system it was measured against sat at 8.0%. The architecture won later, on more data. On the day it was published it was behind.
Keep the middle number. Nearly four points of that word error rate came from a language model applied after the fact, to beams the acoustic model had already scored. That is the size of the language prior's pull, in a published measurement, on a system doing nothing unusual. Move that same force inside the decoder and give it the freedom to write. It produced the 187 AphasiaBank segments that hallucinated on demand.
Analogy
A translator consulting a moving highlight over a recording
A translator writes one word at a time, moving a highlight across the source. Every word already written influences the next one. That is the decoder: its own history to the left of the cursor, a highlight somewhere on the recording, one token at a time.
The highlight shows where the translator is looking. It is tempting to read attention weights the same way, as a record of what the model used. They are learned soft scores. Where they land is not a statement about what the model actually used. A translator who has stopped reading and started producing fluent sentences from memory is still moving the highlight across the page. The page they produce is the 1% that existed in no form in the underlying audio.
Autoregressive fluency must remain anchored to acoustic evidence.
Visual
What each search constraint actually bought: 11.0 to 10.0
The path from audio to transcript has three stages and one dependency worth stating plainly. Encoding the utterance produces the contextual states. Attending from the decoder consumes them. Then comes searching and constraining — beam width, coverage terms, any fusion with a language model. That is where a team finds out whether the assumptions behind the first stage held.
That last stage is not a tuning detail, and there is a published ledger for it. Whisper introduces the first constraint by naming the pathology it exists to suppress: "First, we use beam search with 5 beams using the log probability as the score function, to reduce repetition looping which happens more frequently in greedy decoding." A table in the same paper then prices the whole stack across seven long-form English datasets. Average WER was 11.0 under greedy decoding, 10.6 with beam search added, 10.2 with voice activity detection, 10.0 with previous-text conditioning, and 10.0 again with the initial timestamp constraint. Temperature fallback belongs to the same set of additions.
One point of word error rate, bought by five stacked heuristics. One of them exists solely because the decoder loops. That is the shape of the trade. The constraints are load-bearing, they are cumulative, and the last one moved the average not at all. Which side of that trade is correct depends on what a wrong transcript costs once it leaves the system. Nothing in the search code knows that.
1. Encode the utterance
Create acoustic states that summarize local and long-range context.
2. Attend from the decoder
Compute a context over encoder states for each output token.
3. Predict autoregressively
Condition the next token on prior generated tokens and attended audio.
4. Search and constrain
Use beam search, coverage, length, or monotonic mechanisms according to the product.
Search and constraints work on the encoder states as if they were right, and a badly encoded utterance returns a confident wrong transcript.
Example
Where the decoder's freedom pays, and where it costs
The decoder's freedom is not a defect waiting to be engineered away. It pays in some settings and costs in others. The four below differ mainly in how much audio the model has to hold at once before it commits to anything.
The hybrid CTC/attention paper put the diagnosis in one sentence in 2017: "Attention-based ASR, however, may be prone to include deletion and insertion errors (see Figure 3 and related discussions) because of its flexible alignment property, which can attend to any portion of the encoder state sequence to predict the next label." The advantage and the error mode are the same property.
- Offline transcription is where the freedom pays: the whole utterance is available, and rich language dependencies can improve readable output.
- Joint ASR trains CTC and attention together. The same paper measured the counterweight on CHiME-4 (18h, et05 real): joint CTC/attention multiobjective learning cut character error rate to 44.99%, against 47.58% for location-aware attention, 54.25% for content-based attention and 48.79% for CTC alone. The monotonic objective beat either attention mechanism, and CTC by itself, on noisy audio.
- Speech translation reuses the same encoder–decoder to generate another language directly. That is only possible because the decoder was never obliged to attend to the encoder states in order.
- Long-form audio is where the freedom costs most. Chunking and alignment constraints have to be imposed from outside to control drift, which is exactly what the 11.0 → 10.0 stack of decoding heuristics is.
Example
The histories it trains on, the histories it makes
Wherever a decoder writes its own history, the same four terms recur. They are one story rather than four definitions. Teacher forcing is how the decoder is trained. Exposure bias is what teacher forcing leaves behind. Coverage and beam search are the machinery built afterwards around that same gap. Coverage in particular has a documented origin. Chorowski and Jaitly built it as a fix for a named pathology, not as a general precaution.
- Teacher forcing trains an autoregressive decoder with the reference previous token, so at every step it is continuing a history that was correct.
- Exposure bias is the mismatch that follows: reference histories during training, model-generated histories at inference. It is where a plausible sentence starts extending itself.
- Coverage names the mechanisms and diagnostics intended to reduce skipped or repeated input regions. Chorowski and Jaitly opened their 2017 paper with the diagnosis: "We observe two shortcomings: overconfidence in its predictions and a tendency to produce incomplete transcriptions when language models are used." Their remedy was a constraint on the end-of-sequence (EOS) token's probability, plus label smoothing, plus a coverage term added to the beam-search score. It reached 10.6% speaker-independent WER on Wall Street Journal with no language model, and 6.7% WER with a trigram language model.
- Beam search is approximate search that keeps several high-scoring partial sequences rather than committing to one. It softens the damage of an early wrong token without undoing it. In Whisper's long-form recipe it is the heuristic added specifically to reduce repetition looping.
Comparison
Training history versus its own predictions
Three of those pieces answer different questions, and they are routinely waved through as though one clearance covered all of them. Teacher forcing is a training-time choice: it conditions training on the reference history. Autoregressive inference is a run-time fact: the model conditions on the history it generated itself. Joint CTC–attention is an architectural answer to the distance between the two.
The gap itself was stated plainly in 2015. The scheduled sampling paper put it in its abstract: "At inference, the unknown previous token is then replaced by a token generated by the model itself. This discrepancy between training and inference can yield errors that can accumulate quickly along the generated sequence." The authors never use the term "exposure bias". They describe the mechanism and propose a curriculum against it. Scheduled sampling gradually replaces the reference previous token with the model's own generated token during training. The decoder then learns on the histories it will actually have.
Read the two failure descriptions together. Errors that accumulate quickly along the generated sequence, from 2015. Getting stuck in repeat loops and complete hallucination, from 2022. Evidence that a decoder trains stably says nothing about how it behaves on its own predictions. A joint model that scores well on clean audio has not been tested where the gap actually opens. None of the three is cleared by what clears another.
Teacher forcing
Conditions training on the reference history.
- Decision focus: Encode the utterance
- Useful evidence: WER plus deletion, insertion, and repetition profiles
- Watch for: Fluent continuation unsupported by audio
- Best used when its assumptions are documented for attention encoder–decoder speech recognition
Autoregressive inference
Conditions deployment on the model’s own previous predictions.
- Decision focus: Attend from the decoder
- Useful evidence: Attention or alignment failures on long and noisy audio
- Watch for: Exposure bias between training and inference histories
- Best used when its assumptions are documented for attention encoder–decoder speech recognition
Joint CTC–attention
Combines complementary monotonic and autoregressive objectives or scores.
- Decision focus: Predict autoregressively
- Useful evidence: Beam-search sensitivity and confidence quality
- Watch for: Attention drift on long-form or repetitive audio
- Best used when its assumptions are documented for attention encoder–decoder speech recognition
Example
Count deletions and repetitions separately
No single number carries that. WER is one of four things a release should report, even split into deletion, insertion and repetition profiles. It is also the one most likely to be quoted alone. Recall what happened to Listen, Attend and Spell. 14.1%, 10.3% and 8.0% were all word error rates on the same task. Knowing them tells you nothing about which of those transcripts invented a clause. The other three lines are what keep the first from carrying a release claim by itself.
- The core task evidence is WER, reported with deletion, insertion and repetition profiles broken out rather than summed into one figure. Following the AphasiaBank study, add a hallucination count of its own: text that exists in no form in the audio is not a substitution error.
- The system behavior to document is attention and alignment failure on long and noisy audio, since that is where flexible alignment stops being an advantage. The 1.7% against 1.2% hallucination split between speakers with aphasia and the control group is what a per-slice reading finds and an average hides.
- The robustness slice is beam-search sensitivity and confidence quality: how far the transcript moves when the search changes — 11.0 to 10.0 across five stacked heuristics — and whether the model's confidence moves with it. Chorowski and Jaitly named overconfidence as one of the two shortcomings they had to fix.
- The lifecycle evidence is streaming delay, and Chiu and Raffel priced it. On the Wall Street Journal test set, with statistics over 8 trials, offline soft attention scored 14.2% best and 14.6 ± 0.3% average WER. Online MoChA (w=2) scored 13.9% best and 15.0 ± 0.6% average. The earlier hard monotonic attention scored 17.4%, and that paper's CTC baseline 33.4%. "This is the first time, to our knowledge, that an online attention mechanism matched the performance of standard (offline) soft attention." Matched on the best trial, and with double the standard deviation across trials. The streaming decision belongs beside the WER that motivated it, variance included.
A word error rate published without its deletion, insertion and repetition profiles, without a hallucination count, and without the variance that monotonic or chunked attention bought — 15.0 ± 0.6% against 14.6 ± 0.3% — is a number chosen for being quotable.
Steps
Trace an attention decoding failure
Take one fluent continuation the audio never supported and trace it end to end. Write down what encoding the utterance assumed. Write down the one counterexample that breaks the assumption. Then write down what searching and constraining did with it once it was already wrong.
The published work gives you the shape of the exercise. The AphasiaBank study isolated 187 segments out of 13,140 that hallucinated reliably. Reliably means the failure reproduced, which is what makes a trace possible at all. Chorowski and Jaitly traced incomplete transcriptions back to the interaction between the EOS token's probability and the language model, and only then added a coverage term. Both start from one reproducible bad output rather than from an aggregate.
The value is not the individual fix. It is that another team can afterwards challenge a clean-reading transcript without being told that it reads fine.
1. Select a noisy utterance
Use competing words with different language priors.
2. Inspect token history
Compare reference-conditioned and model-conditioned paths.
3. Inspect acoustic support
Check whether generated tokens attend to relevant frames.
4. Add a release control
Test CTC fusion, coverage, abstention, or user confirmation.
Once a fluent continuation is traced back to audio that never supported it, CTC fusion, coverage, abstention, and confirmation stop looking interchangeable.
Key takeaways
- A decoder that conditions on its own output history buys flexible alignment. It pays for it with what Whisper's own paper lists as the model's limitations: getting stuck in repeat loops, not transcribing the first or last few words of a segment, or complete hallucination unrelated to the actual audio.
- Coherent output is not evidence of acoustic grounding. Across 13,140 AphasiaBank segments, roughly 1% of Whisper transcriptions contained entire hallucinated phrases or sentences that existed in no form in the underlying audio. 38% of the 312 hallucinated transcriptions carried an explicit harm, and the rate ran 1.7% for speakers with aphasia against 1.2% for controls.
- Listen, Attend and Spell moved from 14.1% to 10.3% word error rate on language-model rescoring of 32 beams alone. That is the published size of a language prior's pull on a transcript, on the day the architecture still lost to CLDNN-HMM at 8.0%.
- Teacher forcing, autoregressive inference and joint CTC–attention answer related but different questions. Scheduled sampling described the training/inference discrepancy in 2015 as errors that accumulate quickly along the generated sequence. On CHiME-4 et05 real the joint objective cut character error rate to 44.99% against 47.58%, 54.25% and 48.79%.
- Attention weights are learned soft scores. Where they land is not a statement about what the model actually used. Flexible alignment — attending to any portion of the encoder state sequence — is precisely what makes deletion and insertion errors possible.
- Report WER with deletion, insertion and repetition profiles separated. Put it beside the streaming trade measured on Wall Street Journal, 14.6 ± 0.3% offline soft attention against 15.0 ± 0.6% online MoChA, and beside the decoding-heuristic ledger that moved long-form average WER from 11.0 to 10.0. Then name an owner at the encoding end and at the search end.