Random seed

Also known as: seed

On this page 6

A random seed is the integer that initializes a pseudorandom number generator, and in generative AI it fixes every random choice a model makes during generation, from the initial latent noise in a diffusion model to the token draws of a sampled language model. Running the same model with the same seed, prompt and settings should reproduce the same output, while changing only the seed produces a new variation.

Seeds matter because modern generators are stochastic by design. The seed turns that randomness into something controllable: creators use it to revisit a good image, engineers use it to make experiments repeatable, and auditors use it to trace how a specific piece of AI-generated content was produced.

How a random seed controls generation

Computers produce randomness with a pseudorandom number generator (PRNG), a deterministic algorithm whose entire output stream depends on its starting state. The seed sets that state, so the same seed always yields the same sequence of numbers on the same implementation.

In a latent diffusion model such as Stable Diffusion, the seed generates the Gaussian noise tensor from which denoising begins. For a 1024 by 1024 pixel image, this is typically a latent of 128 by 128 values across four or more channels. That starting noise largely decides composition, pose and color layout, which is why one seed tends to keep the same overall arrangement even when the prompt changes slightly.

Stochastic samplers add fresh noise at every step, and those draws also come from the seeded generator. In a language model using temperature or top-p sampling, the seed determines which token is drawn from the probability distribution at each step. With greedy decoding, by contrast, no randomness is used and the seed has no effect.

The table below shows where randomness enters common generative systems and therefore what the seed governs.

Generator typeRandom element fixed by the seedVisible effect of a new seed
Diffusion modelInitial latent noise and sampler noiseNew composition and details
GANInput latent vectorDifferent face, object or scene
Sampled language modelToken draws at each stepDifferent wording and structure
Video diffusion modelSpatiotemporal noise volumeDifferent motion and framing
Training runWeight initialization and data orderSlightly different final model
What the seed controls in different generators

Seeds, determinism and reproducibility

A seed guarantees reproducibility only when everything else is identical. Bit-exact repetition requires the same model weights, prompt, sampler, step count, guidance scale, resolution, software versions and, often, the same hardware.

Several sources of drift are invisible to users. GPU floating-point arithmetic is not always associative, so parallel reductions can sum in different orders and produce tiny differences that grow over many denoising steps. Libraries such as PyTorch also generate noise differently on CPU and GPU, so a seed used on one device may not match the same seed on another.

FactorWhy it changes the outputHow to control it
Sampler or schedulerDifferent noise use and step mathRecord sampler name and settings
Device for noise generationCPU and GPU generators differGenerate noise on one fixed device
Library versionKernels and defaults changePin versions in the environment
Batch sizeNoise for each item comes from one streamUse a per-item generator
Nondeterministic kernelsParallel sums vary in orderEnable deterministic algorithms
Hosted API updatesProvider changes model or stackTreat API seeds as best effort
Factors that break seed reproducibility

Hosted language model APIs that accept a seed parameter usually describe it as best-effort determinism. Providers may return a system fingerprint so users can detect backend changes, but they rarely promise identical outputs across time.

Practical seed workflows in image generation

Creators treat the seed as a handle on a promising variation. A typical workflow generates a batch with random seeds, picks the strongest result, then locks that seed while refining the prompt, guidance or denoising strength.

StrategyHow it worksBest used for
Random seed per imageA new seed each generationExploring ideas broadly
Fixed seedOne seed kept constantComparing prompts or settings fairly
Sequential seedsSeed, seed plus one, and so onReproducible batches
Variation seedBlend a second noise into the firstSmall changes to a chosen image
Seed sweepRun a fixed list of seedsBenchmarking models and settings
Common seed strategies and when to use them

Fixing the seed is also the standard way to perform a controlled comparison. When testing classifier-free guidance values or sampling steps, holding the seed constant ensures that any visible difference comes from the setting under test rather than from new starting noise.

Limitations and common misconceptions

The most frequent misconception is that a seed stores the image. It does not: a seed is only a starting point, and the same number produces unrelated results in a different model or at a different resolution, because the noise tensor has a different shape.

  • Seed values are not ranked: seed 42 is not better or more neutral than any other number.
  • Character consistency across scenes cannot be achieved by seeds alone; it needs reference conditioning such as IP-Adapter or fine-tuning.
  • Temporal consistency in video comes from the model architecture, not from reusing one seed per frame.
  • Seeds are not a security feature: a fixed seed makes outputs predictable, which is undesirable where unpredictability matters.
  • Small prompt edits can still change a seeded image substantially, because conditioning alters every denoising step.

For research, reporting a single seed can be misleading. Results that hold for one seed may not generalize, so careful evaluations average over several seeds and report the variance alongside the mean.

A non-technical view

AI image and text generators use a dash of chance to produce variety. The random seed is the number that decides how that chance plays out. Think of shuffling a deck of cards in exactly the same way every time: the same shuffle always deals the same hand.

If someone shares the seed along with the same tool and settings, another person can recreate the same picture or answer. Changing the seed is like reshuffling the deck, which gives a fresh result from the same request.

A concrete example

An illustrator preparing book cover concepts generates 24 images from one prompt in a diffusion model, each with a random seed, at 30 sampling steps and a guidance scale of 7. One image, seed 1,839,204, has the ideal composition: a lighthouse on the left third and a storm sky filling the frame.

She locks that seed and changes only the prompt wording, testing “at dusk” against “at dawn” and adjusting the color palette. Because the starting noise stays the same, the lighthouse and horizon remain in place while lighting and mood change. After eight seeded iterations she delivers three consistent cover options to the publisher, and she records the seed, model version and sampler so the final artwork can be regenerated at higher resolution later.