QUESTION 3 OF 10

How does temperature change token sampling?

Reveal the answer and explore the explanation.

03
EasyCoreVisual

How does temperature change token sampling?

Answer
Answer

Rescales logits before sampling; lower positive values sharpen the distribution.

Deeper understanding

Sampling typically applies softmax(logits/T) for T > 0. Lower temperature concentrates probability on higher logits; higher temperature spreads probability. It changes sampling behavior rather than supplying new facts or improving retrieval.

Practical example

Make stochastic generation less varied.

PythonRelated concept example
import torch
logits = torch.tensor([1., 2., 3.])
for t in [0.5, 1., 2.]:
    print((logits/t).softmax(0))

Higher temperature flattens the distribution.

Reference: Further reading ↗

Last 30 min revisionHigh-yield interview Q&As