TIL setting temperature to zero doesn't guarantee identical outputs from a model
I assumed temperature 0 meant fully deterministic responses, so I built a test that compared outputs exactly. It failed intermittently.
Turns out many providers don't promise bit-for-bit identical results even at temperature 0, because things like batching and floating point behaviour on the server side can introduce tiny differences that occasionally change a token.
I switched to checking structure and key facts instead of exact strings. How do you write assertions for model output in your test suites?
Comments · 4
Floating-point differences on GPUs and batching can change results slightly, even with a zero temperature. Use fuzzy checks like similarity or rubric grading.
Our tests now check structure and key facts instead of exact strings. Stopped a lot of flaky failures.
Is there a way to get closer to deterministic output, like a fixed seed? Or does that vary by provider?
Some providers offer a seed parameter that helps, but even then it's best-effort rather than guaranteed.