Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Are llms truly non-deterministic?

My impression was that we inject some randomness intentionally to mimic it, but if you remove that factor you end up with a deterministic chat model.



In addition to Kamshak's note about parallel inference accumulating float errors differently due to order of operations, which makes LLMs theoretically non-deterministic at temperature 0, there is the issue of them being practically non-deterministic as-deployed, not just via temperature but because of inclusion of prior "turns" in context, variations in phrasing of prompts, etc.

It's also "non-deterministic" in the sense that if you removed all sources of non-determinism and asked "What is 1+1?" and received the answer "2" deterministically, that doesn't guarantee a correct answer for "What is 1+2?". Ie a variation in the input isn't correlated in a logical way with a variation in the output, which is somewhat fatal for computer programs, where the goal is to generalize a problem across a range of inputs.


There is also unintentional randomness due to the parallelism in inference (e.g. parallel matmuls added together on the GPU). Since it's multiplying floats every operation has rounding drift that accumulates differently depending on the order of operations. So even at temperature 0 you're not getting deterministic outputs


Because addition and multiplication are not associative with floats ?


The probability distribution over next tokens given previous tokens is deterministic. The sampling algorithm for that distribution is non-deterministic.


And sampling from a (now fixed) distribution can be made deterministic...

So the total generation of text from an LLM can be made fully deterministic. The problem for scientists is that we cant do that in the deployed systems...


You can set the temperature to zero in most APIs, which gives deterministic output. The only problem with that is some models produce inferior results with zero temperature, including lots of slop and AI-isms.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: