Natural Language Processing · free preview
Decoding and Sampling Strategies
Greedy decoding and its failure mode, random sampling, temperature, and the top-k and top-p truncations that balance quality and diversity.
1. Decoding and Sampling Strategies
Decoding and Sampling Strategies
2. Temperature and truncation
Temperature and truncation
3. Four decoders in NumPy
Four decoders in NumPy
4. Greedy decoding
A model's next-token distribution is fog , tide , gulls , horn . Which word does greedy decoding emit? Answer with the word.
5. Which way does the temperature bend the distribution?
A decoder divides logits by before the softmax. What happens to the probability of the leading token, and what generation quality changes with it?
6. Top-k renormalization
A distribution over four words is . Top-2 sampling keeps the largest, discards the rest, and renormalizes. Compute the new probability of the top word, rounding to three decimals.
7. Why the nucleus adapts
Two contexts both decode with top-p at 0.6. In context A the top two tokens hold 0.85 of the mass together, in context B the top five hold 0.55. What does the nucleus keep in each?
8. When greedy fails
Which task and decoder pairing is most defensible?
Practice this interactively
Free account · instant grading · spaced review that schedules itself.
Start this course for free