✖

AI hallucination: why artificial intelligence confidently writes falsehoods

An AI hallucination is a moment when artificial intelligence writes something untrue just as confidently as something true: an invented year, a quotation nobody said, or a book that never came out. It is not a malfunction or a lie. The answers in ChatGPT and similar chatbots are written by a program called a language model. A language model does not look for the truth, but for a continuation of the text that sounds probable. Most of the time it comes to the same thing, because the texts the model learned from mostly tell the truth about well-known things. But as soon as the model does not know something, it fills in what only looks like the truth, and you cannot tell from the tone of the answer.

It is no mere curiosity, as two lawyers in New York found out in 2023. In the case Mata v. Avianca they presented the court with a filing that cited rulings found for them by ChatGPT. Not one of them existed; the model had made them up, citations included. On 22 June 2023 Judge P. Kevin Castel fined them and their law firm 5,000 dollars.

This part ends the series How artificial intelligence computes. You do not need to know the previous parts.

Why AI hallucinates: probable is not true

A language model writes text in pieces called tokens: a piece is a short word or part of a longer one. It looks at the text so far and, for every piece it knows, calculates a probability of how well it would fit as the next one (first part). It then draws one of them, attaches it to the end and carries on. The probabilities are calculated by the softmax function, and a higher probability comes up more often. Without the drawing, the model would sound mechanical and repeat the same turns of phrase over and over (why ChatGPT answers differently every time).

Take the beginning “The capital of Australia is”. For a smaller model the probabilities might look something like this. The numbers are made up for illustration, today’s large models answer this question correctly:

Above the bars the text The capital of Australia is. Three bars of probabilities: Sydney 0.46 (red, the highest, with a cross below it), Canberra 0.38 (green, with a tick below it) and Melbourne 0.16 (grey, with a cross below it) Above the bars the text The capital of Australia is. Three bars of probabilities: Sydney 0.46 (red, the highest, with a cross below it), Canberra 0.38 (green, with a tick below it) and Melbourne 0.16 (grey, with a cross below it)

The correct answer is Canberra, but the highest bar went to Sydney. How can that be? The model did not learn facts, it learned which words occur together in texts. Sydney is the largest Australian city and appears in texts about Australia much more often than Canberra. It therefore “fits” Australia better, even though the sentence “the capital of Australia is Sydney” is not common in texts. That is the heart of the matter: probability is not truth, and even the highest bar can be false. The random draw adds to this. Sydney comes up with a probability of 0.46, that is, in almost every other answer, and even if Canberra had the highest bar, the model would still occasionally draw a falsehood.

The model’s uncertainty, meanwhile, stays hidden in the numbers. The sentence “The capital of Australia is Sydney.” sounds exactly as confident as a true one.

When the model really does not know

Capital cities are still a good case, as there is a lot written about them. It is worse with facts that appear in texts once or not at all: the birthday of a lesser-known person, the title of a thesis, the page number in a book. The model picks up spelling, or the fact that an opening bracket is followed by a closing one, from millions of examples. But there is nowhere it can learn when your neighbour’s birthday is.

Researchers at OpenAI put this to the test in the paper Why language models hallucinate from September 2025. They asked a widely used chatbot for the date of birth of one of the authors, Adam Tauman Kalai. They got three answers, a different date every time, and not one was correct.

Inside the model, at such a moment, there is not one strong continuation competing but hundreds of weak ones: every date is about equally plausible. But it has to draw, and so one date comes up, and after it a whole confident sentence.

Why does the model not say “I don’t know”?

An answer of “I don’t know” would surely be more honest. According to the same OpenAI paper, part of the blame lies with the way models are trained and graded: guessing is rewarded, not admitted uncertainty. Models are compared in tests mainly by the number of correct answers, and that is also what they are fine-tuned for. It resembles a multiple-choice test where you get a point for a correct answer and zero for a wrong one and for a blank. If you have no idea, you should guess: a guess at a birthday has a 1 in 365 chance, a blank box a guaranteed zero.

It can even be calculated. Say the model takes a guess and is right with probability q. With 1 point for a correct answer and 0 for a wrong one, its average gain, that is, how many points it gets per question on average, is

q⋅1+(1−q)⋅0=q,

and that is more than the zero for “I don’t know”, however small q is. Guessing therefore always pays off. If, however, a point were deducted for a wrong answer, we would get

q⋅1+(1−q)⋅(−1)=2q−1,

which is positive only if q>12. Then it would pay to teach the model to guess only when it is more likely to be right than wrong. This is exactly what the paper proposes: to punish a confident error more than an admitted “I don’t know”.

OpenAI shows this with real figures in the paper, using the SimpleQA test of short factual questions. It compares two of its models, the newer gpt-5-thinking-mini and the older o4-mini:

model answered “I don’t know” correct wrong
gpt-5-thinking-mini 52% 22% 26%
o4-mini 1% 24% 75%

The older o4-mini got two percentage points more answers right, so in a ranking that counts only correct answers it looks better. But it almost never said “I don’t know”, and so it was wrong in three answers out of four.

A small error in every step

With a fact, one error is enough. But a calculation or a proof has many steps, and more errors can pile up in it. By a step we mean here one line of a calculation or one step of reasoning in a proof, not one word.

Say the model makes an error in each step with probability p, so a step is correct with probability 1 − p. For simplicity, let us assume that the errors in individual steps do not depend on one another, even though steps build on one another. Then the probabilities of the individual steps multiply, and a whole solution of n steps is correct with probability

(1−p)n.

We plug in an error of 1% per step, that is, p = 0.01. Two steps are correct with probability

0.99⋅0.99=0.9801,

that is, about 98%. So far so good. For a hundred steps, though, we get

0.99100≈0.366,

so only about 37% of solutions come out correct. The chance falls to a half after roughly 70 steps (0.9969 ≈ 0.5), and after a thousand steps four thousandths of one per cent are left.

Graph: horizontally the number of steps n from 0 to 300, vertically the probability that the whole solution is correct, from 0 to 100%. The green curve for an error of 0.1% per step falls slowly and ends at about 74%. The red one for 1% falls faster, and the orange point at 100 steps shows 37%. The blue one for 5% drops almost to zero before a hundred steps Graph: horizontally the number of steps n from 0 to 300, vertically the probability that the whole solution is correct, from 0 to 100%. The green curve for an error of 0.1% per step falls slowly and ends at about 74%. The red one for 1% falls faster, and the orange point at 100 steps shows 37%. The blue one for 5% drops almost to zero before a hundred steps

A proof hundreds of pages long has thousands of steps, so even a tiny error rate will almost certainly show up somewhere. And one is enough. In October 2026 OpenAI withdrew from its mathematics repository three papers on the Hodge conjecture, one of the Millennium Prize Problems, because a single sign error broke the argument they stood on. A person checking thousands of lines would get tired just as the model does. We need a checker that does not get tired and skips nothing.

How AI in mathematics gets around this

Such a checker exists. Lean is a program into which a proof is written in a precise language, much like a computer program is written. Every step must follow from the previous ones by fixed rules of logic, and Lean checks this mechanically: it guesses nothing and nothing is “obvious” to it. The part that does the checking is small and carefully vetted. Artificial intelligence works with it in a loop:

Diagram: a blue box, language model, an arrow labelled proposed step leads to an orange box, Lean. From Lean a green arrow leads to a tick labelled accepted, next step and a green line back to the model. A red arrow leads to a cross labelled rejected and a red line labelled error message back to the model Diagram: a blue box, language model, an arrow labelled proposed step leads to an orange box, Lean. From Lean a green arrow leads to a tick labelled accepted, next step and a green line back to the model. A red arrow leads to a cross labelled rejected and a red line labelled error message back to the model

The model proposes a step and Lean checks it. A correct step passes and the model carries on with the next. Lean rejects a wrong one and returns an error message; the model reads it and tries again. The model can still go wrong, even more often than once in a hundred steps, but Lean will not accept a wrong step. Multiplying probabilities then stops being a problem: what Lean has accepted is checked, and failed attempts cost only time. If the model does not succeed, no proof comes out, but no wrong one does either.

For the curious, three real results with checking in Lean behind them:

  • At the 2025 International Mathematical Olympiad, the Aristotle system from Harmonic solved five problems out of six in Lean. The statements, however, were translated into Lean for it by humans.
  • In April 2026 the GPT-5.4 Pro model suggested an outline of a proof of one of the Erdős problems, mathematicians finished it, and the proof was then successfully verified in Lean.
  • In November 2026 Levent Alpöge of Anthropic, with the help of the Claude model, published a proof of the Riemann hypothesis in Lean, some 17 million lines long. The organisations behind Lean confirmed on 21 November that both the statement and the proof are correct. No person could read all of it, though, and a version written for humans does not exist yet (as of the beginning of December 2026).

Lean, however, guards only the logic, not whether we asked the right question. If the statement is written into Lean wrongly, the model will flawlessly prove something else. That is how artificial intelligence “solved” one of the Erdős problems only in the easier of the two versions that Erdős posed. The statement must therefore be read by a human. More in the article on Lean, in the section Where the catch is.

What this means for you

Outside mathematics there is no Lean watching over you. But a few rules will help:

  • Check facts, dates, names and numbers, especially the lesser-known ones. The rarer the fact, the more likely the model is to make it up.
  • Ask for sources and open them. An invented source looks as plausible as a real one, and it gives itself away only when you try to find it.
  • Let a program do the calculating. The model calculates by guessing the digits one piece of text at a time, and in a longer calculation it easily goes wrong. Many chatbots can write and run a short program that works out the result exactly; ask for one.
  • An instruction such as “if you don’t know, say you don’t know” and web search can help, but guarantee nothing. Check links from a search like any other source, too.
  • Do not go by the tone. A confident answer is no more reliable than a hesitant one. For a long solution, therefore, check the individual steps, not just the result.

The whole journey: how artificial intelligence computes

The series in six steps:

  1. Text is chopped into tokens, pieces of words, and each token is replaced by a vector, a long list of numbers in which words with a similar meaning lie close together (how ChatGPT works).
  2. The vectors pass through a neural network, billions of weighted sums (neural network).
  3. The network finds the right weights by learning from its own mistakes and going downhill with the error, step by step (gradient descent).
  4. From the scores at the end of the network, softmax makes probabilities, and the temperature decides how boldly it draws (softmax).
  5. So that the model knows what each word refers to, every word looks at the others and takes a weighted average of them (transformer and attention).
  6. And because this whole machine estimates what is probable, not what is true, it can confidently write something untrue as well (this part).

Underneath it all lies mathematics from secondary school and a little beyond: vectors, matrix multiplication, derivatives, the exponential and probability.

See also

Chapters: How ChatGPT and artificial intelligence work: the maths inside, Neural network: what it is and how it computes, Gradient descent: how a neural network learns, Softmax: how numbers become probabilities and what temperature is, Transformer and attention: how a model knows what a word refers to, AI hallucination: why artificial intelligence confidently writes falsehoods