Decoding Temperature › Summary
Language AI HandbookAll chapters Decoding Temperature › SummaryOne section · Sections in this chapter9 / 11 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
Temperature controls the sharpness of the probability distribution during language model sampling. By dividing logits by a temperature parameter before softmax, we can make the distribution more peaked (low ) or more uniform (high ). The mechanism is mathematically clean: temperature amplifies or compresses logit differences, which exponentiates into multiplicative changes in probability ratios.
Key takeaways:
- preserves the learned distribution. Lower values sharpen it; higher values flatten it.
- approaches greedy decoding (argmax). approaches uniform random sampling.
- Practical ranges typically fall between 0.1 and 2.0, with most applications using 0.3 to 1.2.
- Task matters: Factual and code generation prefer low temperature. Creative writing benefits from higher values.
- Temperature controls the quality-diversity trade-off: more diversity comes at the cost of coherence.
- Temperature affects all tokens uniformly, which can be limiting when you want selective diversity.
- The probability ratio between any two tokens is , so temperature acts by rescaling the effective logit gap between all pairs of tokens.
- Entropy of the output distribution increases monotonically with temperature. This provides a precise measure of how much randomness temperature introduces.
Temperature is often combined with top-k and nucleus (top-p) sampling to get finer control over the output distribution. These techniques, covered in the following chapters, truncate the distribution before sampling, preventing temperature from giving meaningful probability to highly unlikely tokens. The combination of temperature (which controls how peaked the distribution is) and top-p sampling (which cuts off the tail of the distribution) is one of the most effective and widely used generation strategies in practice.