Temperature Sampling
A parameter that scales how sharply a model favors its most likely next token, trading determinism for variety.
Temperature sampling is a parameter, usually a small non-negative number like 0 to 2, that reshapes a language model's probability distribution over its next Token before a choice is sampled from it. At temperature near zero, the distribution collapses toward always picking the single highest-probability token — effectively greedy decoding, which is deterministic (or close to it) and repeats the same output on the same input. At higher temperatures, the distribution flattens, less-likely tokens get real odds of being chosen, and the output becomes more varied — and, past a point, less coherent, since low-probability tokens exist at the tail for a reason.
The term borrows the physics metaphor directly: it's the same softmax-with-temperature formulation used in statistical mechanics, where higher temperature means higher entropy in the resulting distribution. Setting temperature to 0 doesn't strictly guarantee identical output every time in practice — floating-point nondeterminism and batched-inference effects on real serving infrastructure can still produce small variation even at the deterministic extreme, which is one flavor of Nondeterminism worth knowing about before assuming temperature 0 means reproducible.
The practical rule of thumb is that temperature should track the task's tolerance for variety: code generation, Structured Output, and anything with one correct answer wants it low, because the goal is precision, not diversity; creative writing, brainstorming, and anything sampling for breadth wants it higher, because premature convergence on the single most likely continuation is exactly the failure mode to avoid there. Temperature is usually one of several sampling controls (top-p / nucleus sampling and top-k are the other common ones), and they compose — temperature reshapes the whole distribution while top-p and top-k truncate which part of it is even eligible to be sampled from.
See also4
Large Language Model
A neural network trained to predict text, used as a general-purpose instruction-following system.
Agents & Language Models32 connections
Nondeterminism
The property that identical inputs may produce different outputs, and what it costs to test around.
Agents & Language Models23 connections
Structured Output
Constraining a model to emit data conforming to a declared schema rather than free text.
Agents & Language Models12 connections
Constrained Decoding
Restricting a model's next-token choices to those a formal grammar permits.
Agents & Language Models11 connections
Linked from2
- Fine-TuningAgents & Language Models
Continuing to train an already-trained model on a narrower dataset to specialize its behavior, instead of prompting the base model.
- QuantizationAgents & Language Models
Storing a model's weights at lower numeric precision to shrink memory and speed inference, at some cost to accuracy.