Why is my LLM producing inconsistent results? Pin the seed — then check the batch
Why is my LLM producing inconsistent results? One GGUF asked five times gave five answers, one denying the other four. Seed 42 replays 3/3 — yet at temp 0 a batch change flipped a token.
Inconsistent LLM results come from sampling: at temperature > 0 each token is picked from a probability list, and no seed means fresh dice every run. One GGUF asked five times gave five answers, one denying the other four. Seed 42 replays 3/3.
Five runs are five independent draws, not one answer printed five times.
Why does my LLM give a different answer every time?
The model never "has" an answer: each slot holds a probability list, temperature reshapes it, one token wins. Run 2 said "not" where the other four said "Python" — one character, five universes.
run 1: " Python. Python is widely used in data science, web…"
run 2: "not Python, Java, or C++. It's actually a language that's
not even a progr…"
run 3: " Python. But there are other languages that are…"
run 4: " Python. But why? Python is a high-level, interpreted…"
run 5: " Python. Python has a lot of applications in web…"Same knob everywhere: seed:, options.seed, --seed. top_p narrows the dice; it does not pin them.
How do I make my LLM replies repeat exactly?
Name the roll: three runs with seed: 42 at temperature 0.7 gave 3/3 byte-identical replies. Generation speed wobbled 6.18 → 6.74 → 7.63 tok/s; the words did not.
curl http://localhost:8080/v1/chat/completions -d '{
"model": "qwen3:4b",
"messages": [{"role": "user", "content": "Explain GGUF quantization"}],
"temperature": 0.7,
"seed": 42
}'Why is temperature 0 still not deterministic?
Greedy decoding removes the dice, not the rounding. Floating-point addition is not associative, and summation order tracks batch width. We pinned temp=0, seed=42, server and prompt, then changed one flag:
| ask | -ub | temp | seed | output opens | vs -ub 512 |
|---|---|---|---|---|---|
| 1–2 | 512 | 0 | 42 | " Python. It is used in many…" | baseline, 2/2 identical |
| 1 | 8192 | 0 | 42 | " Python. It's used in many…" | FLIPPED — one token |
| 2–3 | 8192 | 0 | 42 | " Python. It is used in many…" | snapped back, 2/2 baseline |
Every knob said deterministic; batch shape moved one token, only on the cold server's first ask. Prompt cache and slot layout join the summation order. Flip caught, culprit not.
character spread in the thinking text for one fixed ask — 884 · 954 · 986 · 915 · 885 — with the hello never arriving.
- pin the seed everywhere you compare:
seed·options.seed·--seed - A/B tests: same seed, same flags, warm server — and re-run the pair; the -ub 8192 row is the warning
- temp 0 for extraction and evals — then diff the outputs anyway; batch shape can flip a token with the dice out of the picture
- cap thinking on "exact answer" asks (
think: false), or the budget dies first — 0/5 on our hello - grade on N ≥ 3 runs and read the median; a single run is one dice throw
- last tested 2026-11-11 · one fresh Arch VM, 4 threads · CPU bench, no VRAM claims · det-results-a.json
- Qwen3-4B Q4_K_M · 2,497,280,256 B · sha256 7485fe6f…df5 · llama-server 0.9.0-dev (b12110)
- five free-seed runs at temp 0.7 · seed 42 replay 3/3 · -ub 512 → 8192 flip on the cold ask