New Tool Radar

AI Concepts

How to Get Reproducible Model Output with a Seed

Get reproducible model output by setting a seed, so the same prompt and settings give the same reply.

Schematic illustration of get reproducible model output with a seed: step one set the seed, step two run it twice, step three compare the replies.

A seed fixes the random choices in sampling, so the same prompt, model and settings produce the same reply on repeated runs. It is the way to make a model test repeatable: run a prompt with a seed, change one thing, and run it again, knowing the difference comes from your change and not from chance. A seed does not make the answer correct; it makes it repeatable.

Prerequisites

  • An API or runtime that accepts a seed parameter.
  • A test prompt and fixed sampling settings, including temperature above 0.
  • A way to save the two replies for comparison.

Steps

Step 1: Set the seed

Set the seed to a fixed number, such as 42, in the request, alongside the model and sampling settings. Keep every other setting identical between runs.

Step 2: Run it twice

Run the same prompt twice with the same seed and the same settings. Save both replies in full, not just a summary of them.

Step 3: Compare the replies

Compare the two replies word for word. With the same seed they should match. If they do not, something else changed: the model version, a parameter, or the provider’s handling of seeds.

Worked example: Bluebell Bakery slogan test

The fictional Bluebell Bakery tests a slogan prompt twice with seed 42 and temperature 0.7.

Run Seed Temperature Reply
Run 1 42 0.7 ‘Baked slow, shared warm.’
Run 2 42 0.7 ‘Baked slow, shared warm.’
Run 3, different seed 7 0.7 ‘Warm bread, warm mornings.’

Runs 1 and 2 with seed 42 give the same slogan, while seed 7 gives a different one, so the seed controls the repeatability.

Expected result. Two runs with the same seed and settings give identical replies, and a different seed gives a different reply. UNTESTED: this guide was not run against a live model or API. The worked example below is fictional practice material, and its result is the expected result, not a measured one.

Limits

  • Not every provider supports seeds, and some support them only for some models; check the API reference.
  • A seed does not freeze the model: a model version change can still change the output.
  • At temperature 0 the output is already deterministic, so a seed adds nothing.

Sources

See all