Pick a concrete input and say what the equation should give before you read the math.
Foundation reference
Beam Search & Structured Decoding
Beam search is the usual decoder for tasks with one intended output, such as machine translation; the sequence-to-sequence translation model of Sutskever et al. (2014) and Google's GNMT system (Wu et al., 2016) both used it.
Study guide
Where to start
Beam search looks for the single most probable sequence instead of sampling from the model; why does that suit translation but produce generic, repetitive text in open-ended generation (Holtzman et al., 2020)?
How to study this pagePredict · Check · Generalize · Continue
Work through the math, then read the cited papers for the original argument.
Identify the part of the idea that survives a change of notation or model, so you can recognize it in another paper or system.
Use the prerequisites and related concepts at the end of the page to fill the next gap.
Why It Matters for Modern Models
- Beam search is the usual decoder for tasks with one intended output, such as machine translation; the sequence-to-sequence translation model of Sutskever et al. (2014) and Google's GNMT system (Wu et al., 2016) both used it.
- It makes the trade-off between search and cost explicit: greedy decoding keeps one hypothesis and can miss a better sequence whose first token looked worse, while a beam of B hypotheses costs about B times as much computation per step.
- Searching harder for the most probable sequence does not always give better text. In translation, quality eventually fell as the beam grew wider, mainly because the outputs became shorter (Koehn & Knowles, 2017); in open-ended generation, maximizing likelihood gives bland and repetitive text (Holtzman et al., 2020).
Questions to Think About
- Why can a wider beam give worse translations, and how is that connected to models that assign high probability to short or even empty outputs (Koehn & Knowles, 2017; Stahlberg & Byrne, 2019)?
- How does length normalization change which finished sequence wins, and what does the exponent α trade off?
Core Math
Beam search looks for the most probable output sequence for an input while keeping only the best partial sequences (the beam) at each step. A partial sequence is scored by its log-probability:
At step , every sequence in the beam is extended by every token in the vocabulary, and the highest-scoring extensions are kept. With this is greedy decoding; as grows it approaches an exact search for the most probable sequence.
Each extra token adds a negative log-probability, so the raw score favours short outputs. Length normalization divides by a power of the length when comparing finished sequences:
Google's GNMT system used a smoothed version, dividing by (Wu et al., 2016). Diverse beam search splits the beam into groups and penalizes a group for choosing tokens that earlier groups chose, so that the returned sequences differ from one another (Vijayakumar et al., 2018).