A team extracts fields from invoices with an LLM. They set temperature to 0 "for determinism" and write snapshot tests that compare the output string to a saved one. The tests pass locally and flake in CI. Down the hall, marketing sets temperature to 1.8 for "more creative" taglines and gets half-sentences with made-up words. Then both teams move to a newer model, and every request fails with a 400 error: the API no longer accepts the parameter.
The common misconception
"Temperature is a creativity dial: 0 makes the model deterministic and more accurate, a higher value makes it more imaginative, maybe even smarter." It's a reasonable reading of what developers see:
The docs say it. Google's Gemini guide describes temperature 0 as deterministic and says higher temperatures can lead to more diverse or creative results.
At low temperature, answers look stable and sober; at high temperature, they look varied and surprising.
The name suggests energy: heat things up and they move more.
It's a half-truth. Temperature really does trade predictability for variety. But it works on one thing only: how the next token is drawn from probabilities the model has already computed. The model's knowledge, reasoning and ranking of candidates stay exactly the same.
What actually happens
As covered earlier in this path, an LLM produces text in a loop: score every possible next , pick one, append it, repeat. Temperature lives entirely in the "pick one" step.
One distribution, reshaped
For each step, the network outputs a raw score, a logit, for every token in its vocabulary. Softmax turns those scores into probabilities. divides every logit by a number t before the softmax. Below 1, the gaps between scores grow, so the top tokens take almost all the probability. Above 1, the gaps shrink, so unlikely tokens get a real chance. At 0, implementations simply take the top token every time, which is called greedy decoding.
Notice what never changes: the order. A token the model scores first stays first at every temperature. Temperature can't promote a better answer the model doesn't already rank on top.
See it on toy numbers
This script applies three temperatures to four made-up logits and samples 1,000 tokens from each result.
Python · temperature.py
import numpy as np# Toy scores (logits) for the token after "Refunds are accepted within"tokens = np.array(["30", "14", "60", "banana"])logits = np.array([3.0, 2.0, 1.5, -1.0])def softmax(t): z = logits / t # temperature divides every logit e = np.exp(z - z.max()) return e / e.sum()rng = np.random.default_rng(0)for t in [0.2, 1.0, 2.0]: p = softmax(t) picks = rng.choice(tokens, size=1000, p=p) shares = " ".join(f"{w}:{x:.2f}" for w, x in zip(tokens, p)) print(f"t={t} {shares} banana x{(picks == 'banana').sum()}")# t=0.2 30:0.99 14:0.01 60:0.00 banana:0.00 banana x0# t=1.0 30:0.62 14:0.23 60:0.14 banana:0.01 banana x11# t=2.0 30:0.45 14:0.27 60:0.21 banana:0.06 banana x53# Floating-point addition isn't associative: the order changes the resultprint((0.1 + 0.2) + 0.3 == 0.1 + (0.2 + 0.3)) # False
"30" is first at every temperature. Raising t didn't produce a new idea; it made "banana" five times more frequent. And if training had made "60" the top token, temperature 0 would return the wrong number reliably.
Higher temperature: more of the tail, not more ideas
Holtzman and colleagues showed why the tail matters. When they sampled straight from a model's probabilities, the text drifted away from the prompt and stopped making sense. They blamed an "unreliable tail": tens of thousands of low-probability tokens that, added together, get picked too often. Their fix, (top-p), draws only from the smallest set of tokens holding most of the probability. Raising temperature does the opposite: it feeds the tail. What looks like creativity is a higher rate of unlikely tokens, and one odd token becomes context for every token after it.
Lower temperature: likelier, not truer
The top token is the one training made most probable, not one that was checked. When a model is wrong with confidence, the hallucination article in this path explains why, greedy decoding returns that wrong answer every time. Low temperature has its own failure mode too: on GPT-2 Large, Holtzman and colleagues found about 74% of greedy continuations ended stuck repeating a phrase, against 0.28% of human text. Google tells developers to keep earlier Gemini 3 models at default sampling settings to avoid degraded reasoning performance.
Temperature 0 isn't reproducible either
Atil and colleagues ran five models, including GPT-4o and Llama-3-70B-Instruct, at temperature 0, top-p 1 and a fixed seed, 10 times on eight tasks. Accuracy varied by up to 15% between runs, and no model returned identical strings consistently.
Researchers at Thinking Machines traced the main cause. They sampled one prompt 1,000 times at temperature 0 on Qwen3-235B and got 80 different completions. The math kernels on the GPU don't give bit-identical results for every batch size, and floating-point addition gives different bits in a different order, as the last line of the script shows. Your request is batched with whatever other traffic the server has, so its numbers shift slightly with load. When two candidates are nearly tied, a shift that small changes the winner, and everything after it diverges. They built batch-invariant kernels that made all 1,000 completions identical, at a cost in speed.
The newest models took the dial away
On Claude, models from Claude 4.7 on accept only the default sampling settings. In API version 2026-10-21, sending temperature, top_p or top_k returns a 400 error on every model, and Anthropic's migration guide says plainly that no other setting replaces a lowered temperature. Google's docs say Gemini 4 and Gemini 3.6+ ignore custom values for the same three parameters.
Myth
Reality
Higher temperature makes the model more creative
It samples more low-probability tokens; the model knows nothing new
Temperature 0 gives the correct answer
It gives the top-ranked token, right or wrong
Temperature 0 gives the same output every time
Served models varied across identical runs in published tests
Lower is always safer
Greedy decoding loops, and some providers warn against changing defaults
Temperature is always available to tune
Recent Claude and Gemini models reject or ignore custom values
How to apply it in your project
Find every sampling settingSearch your code, wrappers and gateway configs for temperature, top_p and top_k. Check which ones your current model still accepts before an upgrade turns them into errors.
Stop relying on temperature 0 for reproducibilityIf a result must be repeatable, such as an audit log or a cached answer, save it the first time and reuse it, keyed by the exact input.
Test properties, and run evaluations more than onceGrade structure and facts, not exact wording, and repeat a run before trusting a small difference between two prompts.
Get correctness from context and checksPut the facts in the prompt and verify numbers, IDs and dates in code. No sampling setting can make a model know something it doesn't.
Key takeaways
Temperature divides the logits before softmax: it reshapes the odds of the next token and never changes their order.
Higher temperature samples more of the unreliable tail; it doesn't add ideas or intelligence.
Temperature 0 means the likeliest token, which can be confidently wrong and can loop.
Served models aren't bit-for-bit reproducible at temperature 0, mainly because results depend on batching.
Recent Claude and Gemini models fix sampling at the defaults: steer with the prompt and check the output.
التعليقات (0)