Temperature – Mangrove

GlossaryLanguage models

Temperature

Definition: Temperature is a setting that controls how strongly a language model favors its most likely next tokens; lower values make it favor them more.

At each step, a language model gives every token in its vocabulary a score, called a logit, and the softmax function turns the scores into probabilities from which the next token is drawn. Temperature divides each logit before the softmax. Values below 1 skew the probabilities “towards high probability events” (Holtzman et al., 2019), and values above 1 produce a “softer”, more even distribution (Hinton et al., 2015). At temperature 0 the model always takes the most likely token, which is called greedy sampling. OpenAI’s Chat Completions API accepts values “between 0 and 2”, with a default of 1 (OpenAI API reference). Anthropic’s API accepted values from 0 to 1 (Anthropic API reference, archived May 2025), and its current documentation says Claude 4.7 and later models do not support the setting (Anthropic documentation).

Temperature 0 does not guarantee the same output twice. Anthropic’s glossary says that “even with temperature set to 0, the results will not be fully deterministic” (Anthropic glossary). In a post of 10 September 2025, Horace He and colleagues at Thinking Machines reported sampling 1,000 completions of one prompt at temperature 0 from the model Qwen3-235B-A22B-Instruct-2507 and getting 80 different completions. They traced the differences to server load: the number of requests a server processes together, called the batch size, depends on load and changes each request’s result. With computations rewritten so that batch size did not affect them, all 1,000 completions were identical (He, 2025). For example, a firm that reruns an agent’s prompt at temperature 0 to reproduce a past trading decision for an audit may get a different answer, and only a stored copy of the original output records what the agent decided.

The name comes from statistical physics, where a system at a low temperature strongly favors its low-energy states. In A Learning Algorithm for Boltzmann Machines (Cognitive Science, 1985), David Ackley, Geoffrey Hinton and Terrence Sejnowski described a network of simple units, which they called a Boltzmann machine, in which each unit switches on with a probability governed by “a parameter that acts like temperature”. They adapted the rule from an algorithm that Metropolis and co-authors introduced in 1953 to study thermodynamic systems, and that Kirkpatrick, Gelatt and Vecchi had applied in 1983 to problems of constraint satisfaction. Holtzman et al. (22 April 2019) cited the 1985 paper for temperature sampling and wrote that it “has been applied widely to text generation”.