Temperature rescales the model's logits before softmax, controlling how 'sharp' or 'flat' the resulting distribution is.
P(token_i) = softmax(logit_i / T)
- T = 0: equivalent to greedy. The highest-logit token gets all the probability mass.
- T = 0.3 – 0.7: focused but not deterministic. Good for code, math, factual QA, agentic tasks.
- T = 1.0: use the raw distribution. Reasonable default for general chat.
- T > 1.0: more random and creative. T=1.5 or 2.0 can sometimes break out of repetitive patterns; very high temperatures produce incoherent text.
Temperature interacts with top-p. With T=0 it doesn't matter what p is — the same token always wins. With high temperature, top-p prevents wild outliers from dominating. The two together give you a tunable balance between stability and creativity.