DX Heroes logo
#ai
#llm

What is LLM temperature?

Length: 

6 min

Published: 

November 19, 2026

What is LLM temperature?

What is LLM temperature?

LLM temperature is a sampling setting of a large language model. IBM's explainer What is LLM temperature? defines it in one line: "Temperature controls the randomness of text that is generated by LLMs during inference."

A model writes text one token at a time. For each step it gives every token in its vocabulary a probability, and then it picks one. Temperature reshapes those probabilities before the pick. IBM describes both directions. "A lower temperature essentially makes those tokens with the highest probability more likely to be selected", while "a higher temperature increases a model's likelihood of selecting less probable tokens".

Temperature usually comes with two other sampling settings:

  • Top-k "restricts the model's possible choices when random sampling to the top k most likely tokens" (IBM).
  • Top-p, also called nucleus sampling, keeps the smallest group of top tokens whose probabilities add up to p. The method comes from the 2019 paper The Curious Case of Neural Text Degeneration, which describes it as sampling "from the dynamic nucleus of the probability distribution" while "truncating the less reliable tail".

In plain words

Every time a model writes the next word, it has a ranked list of candidates. Temperature decides how adventurous the model is when it picks from that list. Turn it down and the model almost always takes the favourite, so answers become predictable and a little dull. Turn it up and the long shots get picked more often, so answers become more varied, and also more likely to drift off.

When temperature matters

The classic use is simple. A low temperature makes extraction, classification and other tasks with one right answer more consistent. A higher one gives brainstorming and copywriting more variety.

Two things complicate that picture.

  • Temperature 0 never meant identical answers. At temperature 0 the model should always take the most likely token, which makes sampling "theoretically deterministic". Thinking Machines showed in Defeating Nondeterminism in LLM Inference (Horace He, September 2025) that "LLM APIs are still not deterministic in practice". On their own inference setup, they sampled 1,000 completions at temperature 0 from Qwen3-235B and got 80 unique answers. The most common one came up 78 times.
  • The newest models drop the setting. Anthropic's guide Migrating to API version 2026-10-21 says that Claude 4.7 and later models already accept only the default values. On the new API version, "a request that sends temperature, top_p, or top_k returns a 400 error, even at the parameter’s default value". Google's notes for Gemini 3.6 Flash and 3.5 Flash-Lite say the three parameters "are deprecated and ignored". They add: "In future model generations, supplying these parameters returns an HTTP 400 error."

So temperature still matters when you run older or open-weight models, and when you read code written for them. On the newest hosted models it is going away. The Anthropic guide is explicit about what the new API version means for a request to an older model, such as Claude Sonnet 4.6, that lowered temperature for more consistent output. It "loses that effect. No other setting replaces it." Google points to a different lever: "To improve determinism, define a system instruction with explicit rules for your specific use case."

How we handle it

Our internal process engine runs company processes step by step, and some of those steps are a call to a Gemini model. The engine sends every model call with temperature 0. That alone would not make a step repeatable, and on the newest Gemini models the setting may not do anything at all. The engine relies on other checks:

  • A schema for the answer. The model has to return JSON that matches the step's output schema. An answer that is not valid JSON, breaks the schema or comes back truncated is rejected.
  • A capped retry. A rejected answer is retried at most twice by default, with the error quoted in the prompt so the model knows what to fix.
  • A business rule on top. An optional invariant checks the valid answer against the rules of the process. If it fails, the step fails without a retry, the run ends, and the engine undoes the effects of the steps that already finished, where a step defines how.
  • Golden cases. Model steps are tested with evals that replay recorded answers. Every recording is keyed by a hash of the whole request: model, system text, prompt, schema and temperature. A changed prompt, schema or temperature never replays an old answer.

Our headless agents, which run on a schedule with nobody watching, work on Claude. They set no sampling parameters at all. What we tune per job is the model and the effort level. Anthropic calls effort "the control for thinking depth, latency, and cost" on current Claude models. It sets how much the model thinks before it answers, and sampling stays at the model's defaults.

What to watch out for

  • Plan for variation. Even at temperature 0 the same input can come back with different answers, so run it several times before you rely on one of them.
  • Check what your model accepts before you migrate. Code that sends a low temperature can start failing on a newer model or API version. The fix is to remove the parameter, and then test whether the output is still consistent enough without it.
  • Consistency belongs in the design. A clear system prompt, a fixed output format, validation and retries do more for repeatable results than any temperature value.
  • A high temperature has a price. Picking less probable tokens more often also makes it more likely that the model drifts off topic or states something false. That false statement is an AI hallucination.
  • Measure on your own data. If you still run a model that accepts temperature, compare a few values on your own eval set and keep the one that scores best.

Related articles:

Want to stay one step ahead?

Don't miss our best insights. No spam, just practical analyses, invitations to exclusive events, and podcast summaries delivered straight to your inbox.