Why can't you evaluate a text-generating LLM the way you unit-test a sort() function?
- Because the model returns the same string every time, so a single assertion is redundant and wasteful
- Because the model can produce different valid phrasings for the same input, so exact-match assertions fail
- Because the model has no output to test until it has been fine-tuned on the specific evaluation set first
- Because the model's output is always numeric, so only statistical tests, never assertions, can apply to it
Why
A deterministic function returns one output per input, so an exact-equality assertion is a valid test. A generative model samples tokens from a probability distribution and can produce many different but equally correct phrasings for the same prompt. So an exact-match assertion would reject valid paraphrases and is the wrong tool. The same-string-every-time option is backwards; the whole issue is that outputs vary. The needs-fine-tuning option is wrong; models produce outputs without being trained on your eval set, and you should not train on it anyway. The always-numeric option is false; outputs are typically free text. The consequence is that evaluation must operate at the semantic level, tolerating surface variation while still catching real errors. Even at greedy decoding, outputs can vary slightly across API versions and hardware. This is the foundational reason LLM evaluation needs specialized methods rather than simple equality checks.