Skip to main content
Interactive 3D/Beam Search vs Greedy Decoding
Beam Width
B3
Max Steps
Steps4
Vocab Size
Tokens8
Greedy
<s> → fast → mat → ran → ran
Best Beam
<s> → fast → mat → sat → ran
Step: 0/4
Active beams: 1

Beam Search vs Greedy Decoding - Interactive Visualization

Greedy decoding always picks the single highest-probability token at each step, which can miss better overall sequences. Beam search maintains B candidate sequences simultaneously, pruning to the top-B at each step by cumulative log-probability. This demo shows the full generation tree, making it clear why beam=1 equals greedy and wider beams find better sequences.

  • Generation tree: all candidate token paths shown as a branching tree with log-prob scores
  • Beam width slider: beam=1 is greedy, wider beams explore more of the probability space
  • Cumulative log-probability: paths ranked by sum of step log-probs, not just the last token
  • Winner path highlight: the highest-scoring complete sequence marked at each beam width

Part of the EngineersOfAI Interactive 3D - free interactive visualizations covering every major concept in machine learning and AI engineering. Hover any element for a plain-English explanation. No code required.