Why do LLMs hallucinate

3 min read

A language model hallucinates when it gives you a confident answer that is wrong. It does not lie. It has no idea it is wrong. It is guessing the next word, and the guess sounds right.

Think of it like a student who never read the textbook but is very good at sounding sure. Ask a question, and the student writes a smooth answer in the right tone, with the right shape, and the facts made up on the spot. That is what a model does. It predicts words, not truth.

Here are three real cases. First, a New York lawyer filed a court brief in 2023 with case citations ChatGPT had invented. The cases did not exist. The lawyer had asked for real cases, the model gave him fake ones in perfect legal format, and he filed them without checking. Second, Google's own Bard demo in February 2023 said the James Webb Space Telescope took the first picture of a planet outside our solar system. It did not. That was the first picture of an exoplanet, taken years earlier by a different telescope. Third, models routinely invent academic citations, a paper title, real sounding authors, a real sounding journal, and a year, for a paper that was never written.

The cause is simple. A model is trained to predict the next word. It is not trained to check facts. When it does not know something, it does not say so. It predicts the most likely next words, and the most likely next words often form a confident, fluent, wrong answer. Fluency and truth are two different things, and the model only optimises for fluency.

So before you trust an answer, run these five checks.

  1. Ask for a source, then open the source yourself. If there is no source, treat the answer as a draft.
  2. Check names, dates and numbers separately. Models get the shape right and the details wrong.
  3. Ask the same question in a fresh chat. If the answer changes, the first one was a guess.
  4. Check anything that sounds too neat. A perfect quote with no source is usually invented.
  5. Never trust a citation you have not opened. Fake citations are the most common hallucination.
CheckWhat it catches
Ask for a sourceMade-up facts with no backing
Check names and datesWrong details in a right sounding answer
Fresh chat, same questionAnswers that change every time
Too neat to be trueInvented quotes and statistics
Open every citationFake papers and fake cases
python
# A quick way to catch a shaky answer: ask twice, compare.
# If the facts change between runs, the model is guessing.
questions = ["When was the first exoplanet photographed?",
             "Who wrote the paper on attention in 2017?"]
for q in questions:
    print("Ask in a fresh chat:", q)

Try this

bash
python3 -c "print('Ask the same question in two fresh chats. If the facts change, the model is guessing.')"

Use the checklist, then read how attention works in Topic 5. Attention is the part that decides which words the model listens to, and that is where a lot of these mistakes start.

Sources

  • Steven Schwartz court filing, 2023: widely reported, including the court record.
  • Google Bard demo error, February 2023: reported at the time, Google acknowledged it.
  • Hallucination mechanism: next-word prediction with no fact checking, standard in LLM training literature.