Beam Search › Visualizing Beam Search
Language AI HandbookAll chapters Beam Search › Visualizing Beam SearchOne section · Sections in this chapter12 / 17 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
Let's build a visualization of the beam search tree to see how hypotheses are expanded and pruned.




These plots illustrate the beam search quality-compute curve directly. BLEU improves rapidly for small but plateaus and slightly reverses for large . Computation grows approximately linearly. The sweet spot for most production systems is to .

The visualization shows how each decoding strategy selects from the probability distribution. Beam search takes only the peak. Top-k always samples from the top 5, even if those tokens span a wide range of probabilities. Nucleus sampling adapts: here, with a peaked distribution, only 3 tokens are needed to cover 90% of the mass, so the nucleus is smaller than top-k.