Back to LLMs Mind Map
中文·English
LLMsID: decoding-strategies

Decoding Strategies

解码策略
🎯Core Definition
Decoding strategies decide how to pick the next token from the vocabulary distribution during generation. Greedy takes the argmax; beam search keeps the top-BB paths; temperature rescales the logits (T0T \to 0 recovers greedy, T>1T > 1 flattens the distribution for more randomness); top-k samples only among the kk highest-probability tokens; top-p (nucleus) samples from the smallest set whose cumulative probability exceeds pp. Standard order: temperature on the logits first, then top-p truncation, then sampling.
💡Use Cases
conversational and creative generation wants diversity and fluency — sampling (top-p + temperature + top-k); translation, summarization, code want deterministic output — greedy or a small beam; to suppress low-probability tokens while keeping randomness, top-p adaptively truncates by distribution shape.
Key Problems Solved
greedy argmax tends to repeat and loop with little diversity; pure sampling picks low-probability tokens, producing ungrammatical or factually wrong output. top-p adapts the candidate set to the distribution shape (large when flat, small when peaked), temperature controls logit sharpness, and the pair balances quality vs diversity; beam's BB parallel paths mitigate greedy myopia.
🎯5 High-Frequency Exam Points
1
Role of temperature; what do T=0 and T→∞ degenerate to?
2
top-p vs top-k? Why is top-p more adaptive?
3
Why temperature before top-p? What if the order is swapped?
4
Drawbacks of greedy and beam? Effects of beam size?
5
Sampling vs deterministic decoding: suitable tasks and the trade-off?
Updated 2026-08-12
🎯
Test Your Knowledge: Practice Questions for "Decoding Strategies"
Single choice pitfall questions with instant feedback and mistake tracking.
🚀 Start Card Practice
Previous CardPadding & PackingNext CardSpeculative Decoding (cross-module)

🔗 More LLMs Knowledge Cards

Agent & Tool CallingAlignment Tax & Preference DataScaled Dot-Product AttentionAttention Variants MHA/MQA/GQA