By Sagi Shaier · 25 November 2026 · 6 min read
Why LLMs hallucinate, and their other failure modes
Where hallucination, memorized text and inherited bias come from in a large language model, and what to test before you put one in a product.
A hallucination is text from a large language model (LLM) that states something false or unsupported, written just as fluently as a true answer. It is a natural result of how these models are trained, not a rare bug. The same training also explains the other common failures: repeating private or copyrighted text, copying the slants of its training data, and answers that change when a prompt is reworded.
An LLM is a neural network trained to predict the next token of text, where a token is a whole word or a piece of a word. The examples below sometimes say "word" to keep them simple.
How an LLM learns in the first place
During pretraining, the model reads a huge collection of text called a corpus. It learns to predict each next token from the tokens before it. Nobody labels this data by hand. The text itself supplies the answer to every prediction, so this kind of training is called self-supervised. The model that comes out of this stage is called a base model.
The base model picks up grammar, facts and patterns of reasoning because they help it predict the corpus. Each failure in this post comes from that same process. The model learns whatever patterns help prediction, including false ones, biased ones and ones copied word for word.
Why LLMs hallucinate
What the model learns is real, but it is statistical and lossy. It stores patterns about what usually comes next, not a table of checked facts. For any prompt it predicts a probability for every possible next token, and nothing in that step checks whether the most likely continuation is true.
Compare a database with a language model. A database returns the record stored under a key, so a question about the tallest mountain returns "Everest" if that is what the record holds. A language model returns probabilities, and if its training text made a wrong answer look likely, the wrong answer comes out first.

The code below uses the probabilities from that last chart. The model's probabilities for the next token after "The tallest mountain is" put K2 first. Picking the most likely token, called greedy decoding, returns K2 every time. Sampling from the probabilities returns K2 about half the time and the right answer about a fifth of the time.
1import torch
2
3torch.manual_seed(0)
4candidates = ["K2", "Everest", "Kilimanjaro", "Denali"]
5probs = torch.tensor([0.51, 0.22, 0.16, 0.11]) # next-token probabilities after "The tallest mountain is"
6
7greedy = candidates[probs.argmax()]
8samples = torch.multinomial(probs, num_samples=1000, replacement=True)
9counts = torch.bincount(samples, minlength=len(candidates))
10
11print("greedy answer:", greedy)
12for name, c in zip(candidates, counts):
13 print(f"{name:12s} {c.item()} of 1000 samples")1greedy answer: K2
2K2 514 of 1000 samples
3Everest 223 of 1000 samples
4Kilimanjaro 142 of 1000 samples
5Denali 121 of 1000 samplesNeither way of choosing a token looks the answer up anywhere. The sentence that comes out reads the same whether it is right or wrong.
Hallucination also happens when the model fills a gap. Ask it to cite a paper on a topic and name the authors, and it can produce a title and author list with the right shape that matches no real paper. Citations are a common example because the format is easy to predict and the details are not.

Memorization and regurgitation
Training rewards prediction. A passage that appears many times or one that is unusual can leave traces in the model's weights. The model may then repeat that passage word for word, called regurgitation. It is most likely when a prompt starts close to the memorized text.
That creates copyright, privacy and security problems. Internet-scale corpora can contain licensed books, copied articles, personal details and leaked passwords. The model does not keep a link to the document each token came from, so its output carries no sign that it was copied.

Bias in, bias out
A web-scale corpus is not a balanced sample of human writing. Some groups and languages appear far more often than others. The same goes for dialects, jobs and opinions, and some appear mostly through stereotypes. If "engineer" sits next to "he" much more often than next to "she", predicting the corpus well means learning that pairing.
The model carries those patterns into the products built on it. Without checks, the same slant can show up in summaries, rankings and generated examples. A classifier that labels people's roles can repeat it too.

Prompt sensitivity
LLMs can do a new task from a few examples placed in the prompt, with no further training. This is called in-context learning, and it is brittle. Change the wording, the order of the examples or the labels, and the probabilities the model assigns to its answers can move a lot.
The chart below shows the same model scoring the same review three times. Only the prompt around it changed, and the probability of "positive" went from 0.68 to 0.46.

Prompting still works. A prompt that looked good on a few hand-picked inputs needs testing on many realistic ones before anyone relies on it.
The evaluation gap
A low validation loss, a strong benchmark score and a product that behaves well are three different claims. Validation loss says the model predicts held-out text better on average. A benchmark score says it did well on one dataset under one scoring rule. A product needs good behavior on the inputs people actually send, which neither number measures.

Evaluating an LLM system usually covers task accuracy, factuality and bias. It also covers refusals, latency, cost and monitoring after launch.
One base model, many inherited flaws
Many products are built on the same few base models. A model trained once on broad data and then reused for many tasks is called a foundation model. Sharing one base spreads its strengths, and it also spreads its blind spots. A bias or failure in the base can appear in a search tool, a tutor, a summarizer and a coding tool at once. This risk is called homogenization.

The same mechanism creates all of these
Put the pieces side by side and they share one cause. Pretraining learns the patterns in its corpus whether they are true or false. That includes biased, private and copyrighted text. Scaling the model up makes its output more fluent without making it more trustworthy.

What reduces these failures
Pretraining gives a base model broad skill with text. It does not by itself make the model follow instructions or tell the truth. It also does not teach it to refuse unsafe requests, cite sources or match a product's tone. That is why modern LLM work adds more steps after pretraining. Common ones are training on written example answers and training on human preferences between answers. Others retrieve documents to answer from, give the model tools, filter its outputs or run evaluation loops.

These steps reduce some failures without removing them, so a few mistakes are worth avoiding:
- Treating a confident answer as a checked one. An LLM gives no signal when its answer is a hallucination, so the facts behind a decision need a source.
- Testing a prompt on three examples and shipping it. Measure it on realistic inputs, and again whenever the wording changes.
- Pasting private data into prompts or training sets without thinking about where it can come back out.
- Trusting one benchmark number in place of a test on your own task.
Related concepts
Hallucination is one symptom of a model trained only to predict text. Getting from a base model to an assistant takes post-training, covered in pretraining vs post-training. Its first step is supervised fine-tuning on written example answers, covered in instruction tuning and SFT explained. How pretraining itself works is covered in how do LLMs work?
QuiddityML teaches LLM failure modes as their own concept in the Intro to NLP track, with exercises on why a model states a false fact with full confidence and on putting the checks for an LLM feature in order before it ships.