Sampling temperature

Also: temperature sampling, softmax temperature

When decoding by sampling, each logit zᵢ is divided by a temperature T before the softmax. Low T makes output focused and repetitive (T → 0 approaches greedy decoding); high T makes it more diverse but more likely to drift off topic.

P(i) = exp(zᵢ / T) / Σⱼ exp(zⱼ / T)

Softmax turns raw scores into probabilities that sum to 1

Example

With logits "sunny" 3.2 and "cloudy" 2.6, "sunny" is e^0.6 ≈ 1.8× as likely at T = 1, e^1.2 ≈ 3.3× at T = 0.5, and only e^0.3 ≈ 1.35× at T = 2.

See it in the lesson: Text Generation →

Related terms

More in Language & LLMs