New Tool Radar

AI Concepts

How to Set a Seed for Reproducible LLM Output

Set a seed and a low temperature together, so the same prompt gives the same answer when you need to reproduce a result.

Schematic illustration with three step boxes: set the seed and temperature, run the same prompt twice, and record the pair.

A seed fixes the random choices in sampling, so the same prompt with the same seed should give the same output. It only works together with a low temperature: a seed at a high temperature still samples, and the output can differ. Use a seed when you need to reproduce a result for a test, a bug report, or an evaluation, not for everyday chat.

Before you start

An API or local inference setup that accepts a seed parameter, and a prompt you need to reproduce.

Set the seed and the temperature together

Set the seed to a fixed number, such as 0, and the temperature to 0. The seed fixes the sampling draws and the temperature removes most of the randomness, so the two together give the most reproducible output.

Keep the model version fixed too: a seed does not reproduce output across a different model or a different version of the same model.

Run the same prompt twice and compare

Send the identical prompt, seed and settings twice and compare the two replies character by character. Identical replies confirm the setup works; different replies mean something else varies, such as the model version or a server-side setting.

Repeat the check after any change to the model, the prompt, or the settings: reproducibility is a property of the exact combination, not of the seed alone.

Record the seed with the result

Write the seed, the temperature, the model name and version, and the prompt into the test record or the bug report. A result without its seed cannot be reproduced by the next person.

Use a different seed per test case if you want variety across cases, but keep one seed per case so each case stays reproducible.

Practice check: fictional Maple Corner evaluation, 5 prompts, seed 0

The table below is fictional practice material, worked out by hand from the stated settings. It is the expected result for the practice prompts, not a run of any model.

Setting Identical repeats Verdict
Seed 0, temperature 0 5 of 5 Pass – reproducible
Seed 0, temperature 1.0 2 of 5 Fail – seed alone is not enough
No seed, temperature 0 4 of 5 Pass, less strict
No seed, temperature 1.0 0 of 5 Fail – not reproducible

Seed 0 with temperature 0 reproduces all five prompts exactly. The same seed at temperature 1.0 reproduces only 2 of 5, so the seed needs the low temperature beside it.

Expected result. UNTESTED: the counts in the practice table are worked out by hand, not measured by running a model. Set a seed and temperature 0, run your own prompt twice, and compare the replies character by character.

Limits

  • A seed does not guarantee identical output across providers, model versions, or hardware: it is reproducibility for one exact setup.
  • Some providers treat the seed as a best effort, not a guarantee: check your provider’s documentation.

Sources

See all