Natural Language Processing · 免费预览

解码与采样策略

贪心解码及其失效模式、随机采样、温度,以及在质量与多样性之间取得平衡的 top-k 和 top-p 截断。

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 0.330.33, tide 0.220.22, gulls 0.210.21, horn 0.240.24. Which word does greedy decoding emit? Answer with the word.

5. Which way does the temperature bend the distribution?

A decoder divides logits by τ=4\tau = 4 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 [0.5,0.3,0.15,0.05][0.5, 0.3, 0.15, 0.05]. Top-2 sampling keeps the 22 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?

进入交互式练习

免费注册 · 即时批改 · 自动安排间隔复习。

免费开始这门课