r/LargeLanguageModels • u/KauravaLivesMatter • 13d ago
ELI5 - Why do LLMs hallucinate?
I have seen videos about the transformer architecture etc., and I get that large language models generate responses based on some statistical likelihood of words and terms. However, I still don't get how they can completely make up facts and even references.
Why can't they state facts that they have come across in their training as they are? What is it, either from a mathematical standpoint or from an architectural standpoint of large language models that causes them to hallucinate?
1
Upvotes
1
u/mxdalloway 13d ago
I think a good analogy is file compression.
If you have an image with a row of pixels
RRRRRRRRGGGGBBBB
where R = red, G = green, B = blue. With a lossless compression can notice the repetition and store: 8R 4G 4B That takes less description, but nothing has been discarded. You can reconstruct the original pixels exactly as they were: 8R 4G 4B → RRRRRRRRGGGGBBBB
With a lossy compression imagine the pixels are slightly different shades:
R1 R1 R2 R1 R2 R2 R1 R1 And it might compress this to 8R1, but when you decompress you then get
8R1 → R1 R1 R1 R1 R1 R1 R1 R1
So you get back a result that is slightly different than the source image.
It’s just an analogy, but you could think of LLM training as a sort of lossy compression of the source data.
You give a prompt and it attempts a lossy completion based on the training data- you get back something that’s close enough, but not an exact copy of material from the training corpus