Dashboard

What Is a Seed in AI? Why Outputs Still Differ

A seed is the starting number behind an AI model's dice rolls. Set it and you get closer to repeatable output, but closer is the honest word.

Cecilia Iona
Cecilia Iona
Senior Editor, AI & Product
14 October 20261 min read

A seed is a starting number for the random choices a model makes while it writes. Give the same seed to the same setup and the dice land the same way. That is the theory. In practice, hosted AI models offer a seed as a best effort at repeatability, not a promise, and the gap between those two is where most of the confusion lives.

What a seed actually controls

A language model does not pick the next word. It produces a probability for every possible next token, and then a sampler picks one at random, weighted by those probabilities. If you want the background on that step, what temperature does in AI covers how the weights get sharpened or flattened first.

The sampler needs random numbers, and computers produce those from a starting value. That starting value is the seed. Same seed in, same sequence of random numbers out.

Here is a toy version you can run. Five candidate words, fixed weights, and a sampler that draws six times.

python
import random

tokens = ["blue", "green", "cloudy", "clear", "grey"]

def run(seed, weights, n=6):
    rng = random.Random(seed)
    return [rng.choices(tokens, weights=weights)[0] for _ in range(n)]

base = [0.40, 0.25, 0.15, 0.12, 0.08]
print(run(42, base))   # ['green', 'blue', 'blue', 'blue', 'cloudy', 'cloudy']
print(run(42, base))   # identical: same seed, same weights
print(run(7, base))    # ['blue', 'blue', 'cloudy', 'blue', 'green', 'blue']

Seed 42 gives the same six words every time. Seed 7 gives a different six. That is the whole feature.

Why the same seed can still give different text

The catch is the phrase "same weights". A seed fixes the dice. It does nothing about the probabilities the dice are rolled against. Change those slightly and the same dice can land on a different word:

python
shifted = [0.40, 0.22, 0.18, 0.12, 0.08]
print(run(42, shifted))  # ['cloudy', 'blue', 'blue', 'blue', 'cloudy', 'cloudy']

Same seed, first word changed from green to cloudy, because the probability bands moved. In a toy, the later draws are independent, so they happened to hold. In a real model every word becomes input for the next one, so one changed word sends the rest of the text somewhere else.

Real systems shift their probabilities in small ways for boring reasons:

  • The backend changes. OpenAI's cookbook says a seed makes the system "make a best effort to sample deterministically" and that determinism is not guaranteed. It also describes a system_fingerprint value that represents the backend configuration the model runs with, so you can tell when something underneath changed. If the seed, the request parameters and the fingerprint all match, outputs are expected to be mostly identical, not always identical. Source: OpenAI cookbook, reproducible outputs with the seed parameter.

  • The hardware changes. Floating point maths on a GPU can add numbers in a different order from run to run, and tiny differences compound. PyTorch's own documentation says completely reproducible results are not guaranteed across releases, individual commits or platforms, and that results may differ between CPU and GPU even with identical seeds. Source: PyTorch notes on randomness.

  • The request changes. Different prompt wording, a different token limit or a different model version moves the probabilities too.

What a seed is good for

A seed earns its place when you want repeatable comparison, not repeatable truth.

Situation

Set a seed?

Why

Comparing two prompt versions side by side

Yes

Removes one source of noise so differences are more likely to come from the prompt

Reproducing a bug report from a user

Yes, and log it

Gives you a fighting chance of seeing the same output

Unit tests that assert exact text

No

A best-effort seed will eventually fail the test for no reason you can fix

Production writing where variety is the point

No

You would be paying for the same sentence twice

Running an AI eval over many examples

Yes, plus repeat runs

Seed for comparison, repetition to see how much it still wobbles

A practical way to use one

  1. Pick a seed once and store it next to every run, along with the model name and settings.

  2. If the provider returns a backend identifier such as a fingerprint, store that too.

  3. When two runs differ, check the stored identifier before you blame your prompt.

  4. For anything that must match exactly, stop asking the model for exactness. Save the output the first time and reuse the saved copy.

That last step is the unglamorous one that actually works. If a block of text must never change, it belongs in your database, not in a fresh generation.

If this is part of a wider question about how models behave under the hood, how AI models work is the best place to continue.

At the far end of the dial, greedy decoding in AI removes sampling altogether.

The length of an answer, and so the number of random draws, is capped by max tokens.

Questions people ask

Does setting a seed make AI deterministic?

No. It makes the random sampling repeatable under identical conditions. The probabilities underneath can still shift with backend updates, hardware and request changes, so the output is more repeatable, not guaranteed.

Is temperature zero the same as using a seed?

They are different tools. Temperature reshapes the probabilities, and at zero the model leans toward always picking its top choice, which removes most randomness. A seed fixes the random numbers that remain. Many people use both when they want the most stable output a provider can offer.

Do all AI providers support a seed?

No. Support and wording vary by provider and model, so check the documentation for the one you use before building anything that depends on it.

Why does the same prompt give me a different answer each time?

Because the sampler is making weighted random choices, and nothing is fixing them unless you set a seed. The longer the answer, the more chances for the paths to split.

What seed value should I use?

Any whole number works. The value has no special meaning, only the fact that you reuse it.

How did this land?

About the author

Cecilia Iona
Cecilia Iona

Senior Editor, AI & Product

Cecilia leads the Swarmz editorial desk. She has spent a decade turning complex AI and product topics into writing people actually finish, and she owns the blog's quality bar.

Share

Get the next post in your inbox

One email a month. Product updates, engineering posts, and the best of Built with Swarmz.

I agree to receive emails about AI building tips and Swarmz product news. Unsubscribe any time.