Skip to content

Beam Search

A generation strategy where the model does not follow a single path but keeps several hypotheses simultaneously. «Beam» refers to the width of the beam: how many candidates are kept in work.

How It Works

  1. The model predicts the next word — but instead of taking the single best option, it takes the top-N variants.
  2. Each variant is continued further.
  3. At each step, the N best sequences are selected again.
  4. At the end, the most probable chain is chosen.

Beam Search vs Greedy

Greedy Beam Search
Keeps hypotheses 1 N
Quality Lower Higher
Speed Faster Slower
Risk Local optimum Less

Where It Is Used

  • machine translation;
  • subtitles, speech recognition;
  • tasks where a smooth, plausible text is important.

Drawbacks

Long beam search generates «uniform» text — language models more often generate through sampling with temperature rather than through beam.

See Also

← All terms