Beam Search
A text generation strategy that explores multiple candidate sequences simultaneously, keeping the top-k most promising candidates at each step.
How It Works
Instead of greedily picking the best token at each step, beam search maintains k (the 'beam width') partial sequences. At each step, all possible next tokens for all beams are scored, and the top-k complete sequences are kept.
Tradeoffs
Beam search finds higher-probability sequences than greedy decoding but is more computationally expensive. Wider beams find better sequences but increase compute linearly. Beam search tends to produce repetitive, less diverse text.
Modern Usage
For creative text generation, sampling (temperature + top-p) is preferred over beam search. Beam search is still used for tasks requiring high precision like machine translation, summarization, and speech recognition.