4/29
Part 1 of 6 · Greedy decodingLearn and do

The best next token doesn't always start the best pair

Greedy has a second problem: it looks only one token ahead.

Greedy looks one step aheadInteractive
startA 0.6best next 0.30.6 × 0.3 = 0.18greedy's answerB 0.4best next 0.90.4 × 0.9 = 0.36dropped after step 1
Step 1 keeps only A, the larger first score: 0.6 against 0.4. B and its 0.9 follow-up are never scored. Greedy ends at 0.18.

Greedy compares only the first step, and 0.6 beats 0.4. It never scores what comes after B, so it can't know whether a pair that starts with B is the more likely one.

Beam search does. Switch the figure to a beam of width 2 to see it.

In the editor, first holds the figure's chances for the first token, A or B. second holds the chances of each next token, after A and after B. Set greedy_pair: the top first token, then its top second token, as (first, second, probability). Set best_pair: the most likely pair of all, found by trying every pair.