Random Seed
A random seed initializes the pseudo-random generator that drives sampling at temperature > 0. Same seed + same prompt + same settings + same model + same runtime → same output.
Seed control is supported across most local-AI runtimes: llama.cpp's --seed, vLLM's seed= SamplingParams, Ollama's seed option in the request body. Setting -1 typically asks for a random seed each request.
Caveat from deterministic-decoding: even with a fixed seed, reproducibility across hardware or runtime versions is not guaranteed. Use seed for within-session reproducibility, not as a cross-system stability mechanism.
Practical example
Debugging a flaky agent pipeline built on Ollama, an operator notices the model occasionally emits malformed JSON on an otherwise-reliable extraction prompt. To isolate whether the failure is prompt-dependent or sampling noise, they pin seed: 42 in the request body and rerun the exact same prompt 20 times — if the output is now byte-identical every time, the original failure was a sampling-driven edge case at temperature > 0, not a prompt bug. They can then binary-search seeds to find one that reliably reproduces the malformed output for debugging, without needing production traffic. Note this reproducibility only holds within the same Ollama version and hardware; upgrading the runtime or switching from CUDA to Metal can shift results even with an identical seed and prompt.
Related terms
Reviewed by Eruo Fredoline. See our editorial policy.