AI Glossary Term

What does “Beam Search” mean?

Definition

A decoding algorithm that keeps the top several candidate sequences at each step to find higher-probability outputs.

How Beam Search works

Diagram for Beam Search, a branching tree starting from "Start": p=0.5: 'The cat'; keep: 'The cat sat'; drop: 'The cat is'; p=0.3: 'A cat'; keep: 'A cat sat'; drop: 'A cat ran'.keep'The catsat'drop'The catis'p=0.5'The cat'keep'A catsat'drop'A catran'p=0.3'A cat'Start

Example

With a beam width of 3, the decoder keeps the three best partial sentences at each step instead of committing to one word at a time, then returns the highest-scoring full sentence.

Why it matters

It often finds higher-probability sequences than greedy decoding. It tends to produce repetitive, less natural text in open-ended chat, so it is more common in translation.

Common questions

What is beam width?

The number of candidate sequences kept at each step.

Beam search vs sampling?

Beam search is deterministic and seeks likely sequences. Sampling adds randomness for variety.

Does it cost more?

Yes, roughly in proportion to the beam width.

Learn more in our free guides

Test yourself

See also