The greedy trap — be the decoder yourself
Here is a tiny language model as a menu: after each word it offers a few next words with real probabilities. Build a 5-word sentence by clicking. A sentence's total probability is the product of its steps — so a tempting first word can lead you downhill. Try to beat the greedy strategy (always take the top bar).
Click a bar to pick the next word. Four picks finish the sentence.
Keep B sentences alive — watch beams survive and die
Beam search's fix: at every step, expand all surviving candidates, score each by cumulative log-probability, keep only the top B ("the beam"), kill the rest. Set the beam width, then step through the tree. Gold = alive, grey = pruned. Width 1 is exactly greedy; width 5 keeps every option in this toy world.
Scores are cumulative log-probs: log(0.4) + log(0.5) + … — higher (closer to 0) is better. Adding logs = multiplying probabilities.
The comeback — beam finds what greedy threw away
Same toy model, head to head. Greedy's line starts higher — it took the locally best word. Then the beam's second-choice path overtakes it and never looks back. Greedy can't recover, because it discarded "moon" at step one and there is no undo.
Five shades of beige — the blandness collapse
Now ask for a story. This toy storyteller has one high-probability backbone and many quieter alternatives. Run beam search: all B "different" beams converge on near-clones of the safest sentence, differing by a word or two. Then sample 5 stories at temperature 1 and compare the diversity score — computed live from word-by-word agreement.
Short, safe and wrong — the length bias
One more honest failure. Every extra token multiplies in a probability ≤ 1, so longer sentences always score lower — and raw beam search happily truncates your translation. Below are four candidate translations of the same sentence, with per-token probabilities. Drag the length-penalty α and watch the winner flip.