Topic 3 of 4 · 5 min read
Seeds, temperature and what they do not fix
Goal: Explain why temperature 0 and a seed still allow different outputs and choose a test design that tolerates it.
Temperature 0 and a seed make output more repeatable, but no major hosted API promises identical text, so a test must not depend on it. Use these settings to reduce noise, never to remove the need for tolerance.
Check yourself · 1 of 3
A team sets temperature to 0 on a hosted API and sends the same prompt 30 times. What is a realistic outcome?
Why it matters
A common plan is "set temperature to 0, add a seed, keep exact-match tests". It works for a week, then fails, and the team is surprised. Knowing what these settings do saves that week.
What each setting does
- Temperature scales how sharply the model prefers its top token. At 0 it always picks the most likely one (greedy decoding). Near 0 is not the same as 0, and some APIs treat 0 specially or refuse it for some models.
- Seed fixes the random number generator used when sampling. It only matters when sampling is on. Not every provider exposes one, and those that do usually call it best effort.
- top_p and top_k limit which tokens can be drawn. They narrow the choice but do not remove randomness unless set extremely tight.
What they do not fix
- Serving differences. The Thinking Machines article shows that the same greedy request can produce different text because the numeric results depend on batch size and kernel choices on the provider's servers. You did not change anything, and the output still moved.
- Model updates. A seed means nothing across two sets of weights. Providers that expose a seed also expose a system fingerprint or version value, because the backend can change and break the match.
- Context. If retrieved text, tool output or the date changes, the seed cannot help.
- Different providers or hardware. An open-weight model you host yourself can be made much more repeatable on fixed hardware and a fixed software stack, but that is engineering you own, and it breaks on an upgrade.
How to design the test anyway
- Set temperature low for evals so noise comes from fewer places, and note the setting in the report.
- Still run N times and use a pass rate.
- Record the model version and any fingerprint field with every result; when a score moves, compare those first.
- For fixed-hardware self-hosted models, you may add a small number of exact-match canary tests. If the canary breaks after an upgrade, that tells you the stack changed.
Before and after
Before: temperature=0, seed=42 and assert out == golden. After a provider's infrastructure change, 4 of 60 tests fail and nobody can say why.
After: the same settings, plus 10 runs per case, a property check and the logged model fingerprint. The 4 failures now show a pass rate of 9 out of 10, and the fingerprint differs from last week's. The team reads the change as infrastructure, not regression.
What goes wrong
- Trusting "deterministic" in a settings page. Read the provider's note; most say mostly or best effort.
- Setting temperature 0 where diversity is the point. A brainstorming feature needs variation, and a test should check coverage across runs.
- Mixing a seed with a floating model alias.
Examples
Greedy, but not identical
outs = {ask(PROMPT, temperature=0) for _ in range(30)}
print(len(outs)) # often more than 1 on a hosted API
Thirty identical greedy requests can return a handful of distinct strings. This is why an exact-match assertion is fragile even with the safe-looking settings.
A canary on your own hardware
A team hosts an open-weight model on fixed GPUs and pins the library versions. They keep three exact-match canary prompts. After a driver upgrade two canaries fail, which tells them numerics changed before any quality score moved. The canaries guard the stack; they do not replace pass-rate tests.
Key points
- Temperature 0 picks the most likely token, but the same request can still return different text because of serving-side numerics.
- A seed fixes sampling randomness only; most hosted providers describe it as best effort.
- A seed cannot hold across model updates, changed context or different hardware.
- Low temperature is still worth using in evals, to cut noise, as long as tests also use runs and tolerances.
- Log the model version and any fingerprint field so a score change can be traced to an infrastructure change.
Common mistakes
- Believing temperature 0 guarantees identical text.
- Expecting a seed to survive a model version change.
- Using exact-match tests because a seed is set.
- Forcing temperature 0 on a feature whose value is varied output.
Check yourself · 2 of 3
What does setting a seed on an LLM request control?
Check yourself · 3 of 3
Your eval used temperature 0 and a seed, and scores shifted after a provider update. What would you check first?
Practice items, not counted towards your mastery.
Start here
- Defeating Nondeterminism in LLM Inference (Thinking Machines Lab) (opens in a new tab)ArticleFree
Shows why temperature 0 still gives different outputs: batch size changes the order of floating-point math.
- Adding Error Bars to Evals (Miller, 2024) (opens in a new tab)PaperFree
Standard errors and repeated sampling for eval scores, so a score change is read against its noise.
- Evaluation best practices (OpenAI) (opens in a new tab)DocsFree
A vendor's guidance on evaluating variable outputs with graders and enough samples.