LLM & Transformer Fundamentals·Question 55 of 109Advanced

Beam search is standard in machine translation. Why is it rarely used for open-ended LLM generation?

Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.

Model answer: the part to lead with

Beam search maintains the B highest-scoring partial sequences, expanding each with candidate next tokens and keeping the global top B by cumulative log-probability - approximate maximum-a-posteriori decoding for the full sequence, fixing greedy's myopia (a locally suboptimal token can win later).

Full worked answer

Beam search maintains the B highest-scoring partial sequences, expanding each with candidate next tokens and keeping the global top B by cumulative log-probability - approximate maximum-a-posteriori decoding for the full sequence, fixing greedy's myopia (a locally suboptimal token can win later).

It works in translation/ASR/constrained summarisation because those tasks have a narrow set of acceptable outputs tightly determined by the input - the highest-likelihood sequence is genuinely likely to be the best answer, and beam sizes of 4-10 reliably help. The output distribution is low-entropy for good reason.

For open-ended generation it fails for a deeper reason than cost - the mode of the distribution is not what you want. Holtzman et al. ("The Curious Case of Neural Text Degeneration") showed high-likelihood text from LLMs is degenerate: repetitive, generic, self-looping (repetition self-reinforces, so a repeating beam keeps scoring well), while natural human text is consistently lower-probability under the model - humans routinely choose "surprising" continuations, and there are astronomically many good continuations, each individually improbable. Maximising sequence likelihood chases a mode that corresponds to bland, loop-prone text; sampling from the (truncated) distribution matches the entropy profile of natural language. In short: open-ended quality ≈ a sample from a well-shaped distribution; translation quality ≈ the argmax of a peaked one.

Secondary but real practical reasons: beam search multiplies KV cache memory and compute by B - expensive precisely where the KV cache is already the binding constraint - and it serializes poorly in batched serving stacks (vLLM and friends treat it as a second-class citizen). Length bias (log-prob sums favour short sequences, requiring length normalization hacks) adds more friction.

Where beam-shaped ideas persist: constrained decoding (forcing outputs into a grammar/JSON schema), some structured-output and speech pipelines, and - reframed - best-of-n sampling with a verifier or reward model replacing likelihood as the ranking function, which fixes exactly the "likelihood ≠ quality" failure and is core to test-time-compute methods.

What a good answer covers

  • It works in translation/ASR/constrained summarisation because those tasks have a narrow set of…
  • The output distribution is low-entropy for good reason
  • For open-ended generation it fails for a deeper reason than cost - the mode of the distribution is not…
  • ("The Curious Case of Neural Text Degeneration") showed high-likelihood text from LLMs is degenerate
  • Maximising sequence likelihood chases a mode that corresponds to bland, loop-prone text; sampling from…

Interviewer follow-ups to expect

  1. Why does likelihood diverge from quality specifically for open-ended tasks - what's the entropy argument?

  2. Why does best-of-n with a reward model succeed where beam search fails?

  3. What's length bias in beam search?

Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep