Transformers, lesson 11
Turning logits into choices
Greedy picks, and how temperature sharpens or flattens the odds.
You need "Autoregressive generation": run the model, pick a token, append it, repeat. This lesson is about the pick.
Part 1. Always take the top
After "The cat sat on the", the model's top candidates are mat 0.41, floor 0.20, couch 0.12, bed 0.08. The simplest rule is to take the most likely token every time. Here that's "mat", no dice involved.
Greedy decoding
Taking the top-ranked token at each step, with no dice roll. In code it's an argmax: max over the probabilities, or over the logits, since softmax keeps their order.
Your turn
You run greedy decoding on the same prompt, with the same model, five times. What do you get?
That makes greedy a good fit for short answers where there's one right output: pulling a date out of an email, choosing a label from a fixed list, filling in a function name. Many APIs treat temperature 0 as greedy, and the second half of this lesson shows why.
Part 2. Why greedy repeats itself
Keep going with Pro
You've done the first part. Pro opens the rest of this lesson, and every other one.
- Why greedy repeats itself
- The best step isn't the best sentence
- Divide the scores first
- Sharper and flatter
Transformers overviewSpotted a mistake? Tell us.