What temperature actually does to a softmax
I’d always read temperature as “makes the model more random”, which is true but not useful. It’s a divisor applied to the logits, before the softmax normalises them:
The key consequence: because is applied after the division, scaling the logits does not scale the probabilities proportionally. It changes the ratio between them. For two tokens, the odds ratio is
so the gap gets amplified as and flattened as .
- : the ratio blows up, all mass collapses onto the argmax — greedy decoding.
- : the distribution the model was trained to produce.
- : every exponent goes to , so — uniform.
The thing I’d been getting wrong: temperature is not a post-hoc reweighting of a fixed distribution. Applying it to probabilities rather than logits gives a genuinely different result.
Where I learned it
Re-derived it from the softmax definition after being unable to explain to someone why
temperature=0 is deterministic.