AI & LLMs

Temperature

The decoding dial that flattens or sharpens the next-token distribution.

Temperature divides the logits before the softmax. Low temperature sharpens the distribution (safe, repetitive; near 0 is greedy); high temperature flattens it (diverse, eventually incoherent). Paired with top-k / top-p to control randomness.

Worked example: at T=0 the model always takes the argmax token — repeatable and safe; at T=1 it samples the raw distribution; at T=2 it flattens toward uniform and drifts into incoherence. Gotcha: temperature is randomness, not “creativity” — cranking it on a factual or code task does not make the model smarter, it makes it wrong more variably. For anything with a correct answer, keep it low; raise it only when you genuinely want diverse samples.