Speech and audio
ASR Decoding, Language Models, and Contextual Biasing
Cover greedy and beam decoding, external language models, lexicons, shallow fusion, contextual biasing, hotwords, and search errors.
By the end you can
- Define asr decoding, language models, and contextual biasing as an operational problem with explicit inputs, outputs, and boundaries
- Distinguish greedy decoding, beam search, and contextual biasing without treating them as interchangeable
- Trace the workflow from define the search space through audit search behavior
- Evaluate asr decoding, language models, and contextual biasing using oracle versus selected hypothesis error and evidence from difficult deployment slices
Editing G was more auditable than a prompt
A recognizer's neural model does not decide the transcript on its own. Decoding is a search. It looks for the sequence that scores best under acoustic or sequence-model scores. Usually external language evidence, a lexicon, a length term and a contextual bias are in that sum too. Change the search settings or the priors and the errors change, with the neural model untouched. That is why this lesson exists. The thing tuned last week may be the thing that decided what the microphone is reported to have heard.
Two of those ingredients matter most, because everything later turns on them. An external language model can make a transcript more plausible while making it less faithful to the acoustics. That is a documented shortcoming, and the failure-modes section below quotes the paper that named it. Context lists and hotwords are the second. They are hypotheses about what is likely to be said, not ground truth about what was said. Scope them to a user, a task, a stretch of time, a document state, or they are live everywhere. So the release question comes in two halves. Oracle versus selected hypothesis error asks what the search could have found. Rare-entity precision and recall asks what it did with the words that actually matter. Neither one on its own is a release decision.
None of this used to be so hard to look at. Before neural decoders, the language model was a separate object you could inspect and swap. Kaldi composes a decoding graph called HCLG out of four transducers: H holds the HMM definitions, C the context dependency, L the lexicon and G the grammar or language model. The composition runs on OpenFst, a weighted finite-state transducer library. Biasing a recognizer toward a contact list meant editing G. That is a far more auditable operation than a prompt. The thing that changed was a named object with a shape. Someone else could be handed it and asked what it now allowed.
Bias the search hard enough and the transcript reports what the system expected rather than what was actually said.
Visual
Give every hotword an expiry
Work on a decoder has a shape. It starts by defining the search space: units, lexicon constraints, language model, allowed outputs. It ends by auditing what the search actually chose — oracle hypotheses against selected ones, beam errors, insertions, rare entities, runtime cost. Between those two sits the step that hides the most. That is deciding how the scores are combined: acoustic against language model, hypothesis against bias list, tuned with length and coverage terms on validation data. It is also the step teams skip.
The third step, activating context, is not a hack bolted onto a decoder. It is a designed mechanism with a published payoff, so the warning that follows lands against a real gain rather than a straw one. A system called CLAS, published in 2018, optimises the ASR model jointly with embeddings of context n-grams instead of bolting a bias list onto a finished system. Its five authors report: “Across a number of tasks, we find that the proposed CLAS system outperforms the baseline method by as much as 68% relative WER, indicating the advantage of joint optimization over individually trained components.” The baseline it beat was shallow-fusion contextual biasing. Sixty-eight per cent relative is why nobody is going to give context injection up.
Which is exactly why the scoping step matters. Skip score combination and the assumptions built into the search space travel intact all the way to the audit, where they get inspected rather than questioned. A boost that never expires is one of those assumptions. It was set once, and nobody revisited it. By the time anyone reads the transcripts it looks like part of how the system hears, not a choice somebody made on a Tuesday. Task-specific names, contacts, products and phrases need an expiry and a provenance the moment they are switched on. What follows is what their absence looks like when it reaches a hospital.
- 01
Define the search space
Specify units, lexicon constraints, language model, and allowed outputs.
- 02
Combine scores
Tune acoustic, language, length, coverage, and contextual terms on validation data.
- 03
Activate context carefully
Use task-specific names, contacts, products, or phrases with expiration and provenance.
- 04
Audit search behavior
Compare oracle hypotheses, beam errors, insertions, rare entities, and runtime cost.
The search space you defined is the ground the later audit stands on, so a boundary drawn wrong there is inspected rather than questioned.
Example
One per cent of transcriptions contained sentences the audio never had
The rate has been measured. Roughly 1% of Whisper audio transcriptions contain entire hallucinated phrases or sentences that were never in the audio at all. Koenecke and four colleagues found that in 2024. Their abstract: “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.” Not a substituted word. Not a garbled name. Whole sentences with no acoustic evidence behind them. And 38% of those hallucinations included explicit harms: perpetuating violence, inventing associations, or implying false authority. One per cent sounds survivable until you multiply it, and until you read what the harmful third of it says.
Then multiply it. On 26 October 2024 the Associated Press reported that “Over 30,000 clinicians and 40 health systems, including the Mankato Clinic in Minnesota and Children's Hospital Los Angeles, have started using a Whisper-based tool built by Nabla” — a tool used for an estimated 7 million medical visits. The same investigation documented the part that matters most here. Nabla's tool erases the original audio, which makes transcript-to-audio comparison impossible. There is no oracle to compute, no lattice to inspect, no segment to replay. The claim “the transcript is what the microphone heard” has been made unfalsifiable by the product's own retention policy. Nabla replied on 28 October 2024 that it had annotated 7,000 hours of medical-encounter audio to train its own model, and that the transcript is not directly included in the patient record.
A report limited to oracle versus selected hypothesis error would have shown none of this. In the Nabla deployment it could not even be produced. Notice what the 1% figure required: someone holding the audio and the transcript side by side. Delete the audio and the measurement goes with it. The failure becomes not merely unmeasured but unmeasurable, and every downstream reader inherits a document with nothing to check it against.
- The decision this lesson is about spans greedy and beam decoding, external language models, lexicons, shallow fusion, contextual biasing, hotwords and search errors — everything in the system that is not the acoustic model. Any of it can put a sentence into a transcript that the audio never contained.
- The failure running underneath the whole comparison is tuning beam parameters on the final test set. It produces a number that describes the test set rather than the system: a sibling of the Nabla problem, where the setup destroys the evidence that would contradict the report.
- The evidence anyone thinks to ask for is oracle versus selected hypothesis error. It says nothing about the roughly 1% of Whisper transcriptions found to contain entire hallucinated phrases or sentences, and nothing about the 38% of those that carried explicit harms.
- The practical response is to keep contacts, catalog terms, locations and temporary meeting vocabulary in separate lists, so a boost meant for one never fires inside another. Then retain the audio long enough that a transcript can still be checked against it — which is exactly what the 7 million visits behind the AP investigation cannot be.
Example
What the search could have found
What the search could have found is one question. How hard it looked is a different one. Oracle WER answers the first and beam answers the second. Running them together is how a team concludes a decoder is doing well when it is only searching widely. Shallow fusion and hotword are the two doors through which an outside expectation enters the decision. The field defined the first for itself in a paper; the second is usually defined by whoever wrote the config file. The definition comes from a 2017 paper by Kannan and five co-authors: “Shallow fusion refers to log-linear interpolation with a separately trained language model at each step of the beam search.” On Google Voice Search, shallow fusion with a wordpiece neural LM gave a 9.1% relative word error rate reduction over their attention-based sequence-to-sequence baseline, and removed the need for second-pass rescoring. Each of the four terms below can require different proof, a different unit, and a different person to sign for it.
- A beam is the set of partial hypotheses an approximate search keeps alive while it works.
- Shallow fusion is “log-linear interpolation with a separately trained language model at each step of the beam search” — the authors' own words, worth a 9.1% relative WER reduction on Google Voice Search over their attention-based sequence-to-sequence baseline. It is worth restating in full, because “at each step” is where the acoustic evidence gets outvoted.
- A hotword is a phrase temporarily boosted because context says to expect it, and temporarily is the load-bearing word — it is the one a decoder loses when the boost is written once and never given an expiry.
- Oracle WER is the best error achievable among the set of hypotheses the search generated, which is why it is silent about a hallucinated sentence: the invented text is in the search space, and the search found it.
Example
Context helps four products for four reasons
Context is not one feature with one setting. It helps four products for four different reasons, and each of them tolerates a different kind of mistake. Medical and legal dictation and broadcast transcription need the same mechanism as the other two, under stricter conditions. A Whisper-based tool inside 40 health systems can be a success on its own dictation slice and a failure the moment roughly 1% of its output carries sentences the audio never held. The gains are real and published, which is what makes the trade genuine rather than rhetorical. A 2020 paper on personalising an RNN-T recognizer, by Le and five co-authors, reports: “We show that these combined techniques result in 15.4%-34.5% relative Word Error Rate improvement compared to a strong RNN-T baseline which uses shallow fusion and text-to-speech augmentation.” Every row below has its own units and its own burden of proof. The case above discharges neither.
- In medical and legal dictation, domain terms demand precision and provenance — and provenance is the half a tool that erases its own audio cannot supply at any recall.
- In personal assistants, contact names and app entities benefit from context scoped to one user, because one person's contacts are nobody else's vocabulary. That scoping was measured at 15.4%–34.5% relative WER improvement over a baseline already using shallow fusion and text-to-speech augmentation, which is why teams accept the insertion risk rather than merely asserting that context helps.
- In meetings, an agenda and a participant list can guide decoding temporarily, for as long as the meeting runs and no longer.
- In broadcast transcription, an external language model helps with names and can also rewrite spontaneous speech into something more fluent than what was said.
Steps
Tune a contextual decoder safely
Tuning a contextual decoder safely means scoping the boost and keeping the evidence that would convict it. The exercise is finished when another team can ask which data the beam settings were tuned on and get a straight answer, and can ask to hear the audio behind a disputed line and be given it.
Four moves carry the work. Create scoped context sets, separating contacts, catalog terms, locations and temporary meeting vocabulary, so a list built for one never fires inside another. Sweep bias strength and plot entity recall against false insertions. Those two curves move in opposite directions, and a single number hides which one you bought. Test adversarial acoustics — noise, and common words confusable with the boosted entities — since a boosted name becomes the cheapest thing to write down exactly where the audio is unclear. Add lifecycle controls: expire the context, log its source, and let users remove sensitive entries.
Then three notes, following the shape of the work. First, what does defining the search space assume? Then one counterexample to that assumption: a stretch of audio where it is wrong, the noisy segment the boost should never have reached. Then what auditing search behavior triggers once that segment turns up — whether the boost is narrowed, given a shorter life, or switched off for that context entirely. Note the precondition buried in step two. You need the segment. A pipeline that deletes the original audio, as the Nabla tool does, cannot run this exercise at all.
1. Create scoped context sets
Separate contacts, catalog terms, locations, and temporary meeting vocabulary.
2. Sweep bias strength
Plot entity recall against false insertions.
3. Test adversarial acoustics
Include noise and confusable common words.
4. Add lifecycle controls
Expire context, log its source, and allow users to remove sensitive entries.
Every hotword you inject should carry an expiry, a recorded source, and a way for the user to delete it; a bias list nobody can see or retract is a permanent edit to what the system will hear.
Example
A bigger beam that finds nothing new
An evaluation earns its place when it is able to contradict itself. Decoder latency, memory and partial stability will sometimes conflict with oracle versus selected hypothesis error, and that conflict is what the evaluation is for. The plainest version is a beam widened: the search looks harder, latency and memory rise, and the oracle barely moves. A bigger beam that finds nothing new is a cost with no result attached. Only a portfolio carrying both halves can show that this is what was bought.
The cleanest measurement of that gap comes from neural machine translation rather than ASR, and it should be read with that label attached. In 2019 Stahlberg and Byrne built an exact inference procedure, combining beam search with depth-first search. They used it to find the global best model scores under a Transformer base model for the entire WMT15 English-German test set. Their finding: “Surprisingly, beam search fails to find these global best model scores in most cases, even with a very large beam size of 100.” Worse for anyone who assumes a wider search is a better one: for more than 50% of the sentences, the model assigns its global best score to the empty translation. Search quality and model quality are two different quantities. Widening the beam moves you toward an optimum that, half the time in that setting, is a degenerate output nobody wants.
The portfolio should also state when the team abstains or falls back. Search settings fitted to the same data used for the final report are one of those conditions. A gain measured that way is not a gain anyone can ship.
- For the core task, the evidence is oracle versus selected hypothesis error.
- For how the system behaves in service, it is rare-entity precision and recall — the pair that would catch inserted entity names while the oracle stays quiet, and the pair that needs retained audio to be computable at all.
- The robustness slice is how insertions, deletions and substitutions change once fusion is switched on.
- Over the system's working life, the evidence is decoder latency, memory and partial stability — the costs a wider beam charges you whether or not it finds anything, as the beam of 100 illustrates in the machine-translation setting.
Report oracle versus selected hypothesis error together with decoder latency, memory, and partial stability.
Key idea
The language model overruled the acoustics
Any broad claim about how the search, the priors and the bias lists behave has to survive four conditions. Each is a place where a decoder that scored well in tuning starts producing text the audio does not support. Beam parameters are tuned on the final test set. Hotwords cause false insertions outside the intended context. Language-model preference erases dialectal or rare terms. Large beams increase latency without meaningful oracle gain.
Two of those have already appeared under their own names. The fourth is the beam of 100 that still missed the global optimum. The second and third are the two sides of what a hallucinated sentence in roughly 1% of Whisper transcriptions looks like from the inside. The third is not a suspicion. It is a documented shortcoming with a paper behind it. In 2017 Chorowski and Jaitly wrote this about attention-based sequence-to-sequence recognisers: “We observe two shortcomings: overconfidence in its predictions and a tendency to produce incomplete transcriptions when language models are used.” The same paper carries the other half of the bargain, and it is why nobody simply switches fusion off. With their fixes they reached 10.6% WER on Wall Street Journal without a language model and 6.7% WER with a trigram language model. The prior that distorts is the prior that pays.
When the prior wins the scoring contest, the transcript reads more like the language the decoder expected and less like what the speaker actually said. Nothing downstream records that a contest took place. A bias list left switched on for every user, every task and every document state does the same thing more crudely. It converts a guess about what might be spoken into an insertion the audio never contained.
Beam settings tuned on the final test set produce a number you cannot ship, and a language model that improves plausibility may be steadily overruling what the microphone captured.
Key takeaways
- Roughly 1% of Whisper audio transcriptions contained entire hallucinated phrases or sentences absent from the underlying audio, and 38% of those hallucinations carried explicit harms. Oracle versus selected hypothesis error would report none of it, since the invented text is in the search space and the search found it.
- Decoding is a search under acoustic or sequence-model scores, optional external language evidence, lexicons, length terms and contextual bias, so search settings and priors change the errors a system makes even when the neural model is untouched.
- A language model can improve plausibility while reducing acoustic faithfulness. Chorowski and Jaitly named the shortcomings as “overconfidence in its predictions and a tendency to produce incomplete transcriptions when language models are used”. The same 2017 paper reached 10.6% WER on Wall Street Journal without a language model and 6.7% with a trigram one. That is why context lists and hotwords must be scoped by user, task, time or document state instead of left permanently on.
- Greedy decoding, beam search and contextual biasing answer related but different questions, so a result from one settles nothing about the other two. Shallow fusion is “log-linear interpolation with a separately trained language model at each step of the beam search”, worth a 9.1% relative WER reduction on Google Voice Search, while CLAS beat a shallow-fusion biasing baseline by as much as 68% relative WER.
- Work on a decoder starts by defining the search space and ends by auditing what the search actually chose. Skip score combination in between and the first step's assumptions reach the audit unexamined — and if the deployment erases its own audio, as the Nabla tool used across 40 health systems and an estimated 7 million medical visits does, the audit cannot be run at all.
- Report oracle versus selected hypothesis error together with decoder latency, memory and partial stability, and keep rare-entity precision and recall beside them. Stahlberg and Byrne's exact-inference study of WMT15 English-German, in machine translation rather than ASR, found beam search missing the global best model score in most cases even at beam size 100, with the optimum being the empty translation for more than 50% of sentences.