Sub topic 14
Limitations: hallucination, knowledge cutoffs, and sensitivity to prompts
This chapter assumes you have read the earlier chapters on the pretraining objective, decoding and sampling, and context windows. You should be comfortable with softmax, probability distributions, and reading short NumPy code. The goal is to connect each common failure of a language model to the mechanism that causes it. Once you can name the mechanism, you can choose a mitigation instead of guessing.
Failures follow from the design
A language model is trained to minimize cross-entropy on next-token prediction. At inference it samples from a probability distribution over tokens, one token at a time. Nothing in that setup checks claims against the world. Nothing in it records when the training data ended. The model also reads its input as a token sequence, not as an intention.
Three limitations come directly from this:
- Hallucination: fluent output that is false or unsupported.
- Knowledge cutoff: the model knows nothing after its training data ends, and knows recent material poorly.
- Prompt sensitivity: small changes in wording or format change the output.
Hallucination
A hallucination is output that reads as confident and well formed but is false, invented, or unsupported by the input. Typical examples are citations to papers that do not exist, function names missing from a library, and wrong dates stated plainly.
Why it happens
The training loss rewards assigning high probability to the token that actually followed in the training text. It rewards plausibility given the context. It does not reward truth directly. Truth correlates with plausibility only because most text is written by people who tried to be accurate.
Several mechanisms add to this:
- Sparse facts. A fact seen once or twice in training is weakly encoded. The model learns the shape of an answer (a name, a year, a title) without learning the exact value.
- No abstention signal. Training text rarely contains "I don't know" at the point where a fact is needed. A prompt like "The paper that introduced X was written by" is nearly always followed by a name, so the model produces one.
- Compounding. Each generated token becomes input for the next. An early wrong detail makes later tokens consistent with the error instead of correcting it.
- Sampling. Sampling can choose a lower-probability token that happens to be wrong.
A worked example
The next snippet models a prompt, "The capital of Australia is", with four candidate tokens. The logits are chosen to mimic text statistics: large cities are mentioned often, so they get substantial probability. The snippet then measures how often sampling picks a wrong answer at two temperatures.
import numpy as np
tokens = ["Canberra", "Sydney", "Melbourne", "Auckland"]
logits = np.array([2.0, 1.6, 0.8, -1.0])
def softmax(z, temperature=1.0):
z = z / temperature
z = z - z.max()
p = np.exp(z)
return p / p.sum()
rng = np.random.default_rng(0)
for temperature in (1.0, 0.3):
p = softmax(logits, temperature)
draws = rng.choice(len(tokens), size=10000, p=p)
wrong = np.mean(draws != 0)
print(f"T={temperature}: P(Canberra)={p[0]:.2f}, wrong in samples={wrong:.2f}")At temperature 1.0 about half the samples are wrong. At 0.3, about a fifth are still wrong. Greedy decoding would pick "Canberra" here, but only because the logits were set that way. If the training text had mentioned Sydney more often in this context, greedy decoding would return "Sydney" every time, with full fluency.
Lowering temperature reduces random errors. It does not fix a distribution that favors a wrong answer.
Two kinds of hallucination
| Kind | Meaning | Example | Main remedy |
|---|---|---|---|
| Contradicts the source | The prompt contains the facts, and the output disagrees with them | A summary states a number that differs from the document | Better prompts, constrained output, automatic checks against the source |
| Unsupported by training | The needed fact is absent or weak in the weights | An invented citation | Retrieval, tools, human verification |
The first kind is easier to detect because you can compare against the input. The second kind needs an outside reference.
Confidence is not calibrated by default
A fluent tone says nothing about reliability. The token probabilities carry some signal: low probability on a key token often marks a guess. But the model's wording ("certainly", "as is well known") is just more generated text. Many applications that expose token log-probabilities use them to flag uncertain spans for review.
Knowledge cutoffs
Pretraining uses a corpus collected up to a certain date. The model's weights contain nothing about later events. Three details matter in practice:
- The effective cutoff is earlier than the stated one. The web keeps producing text about an event for months or years after it happens. Material from the last months before the cutoff is underrepresented, so the model knows it less well than older material.
- The model may not know its own cutoff. It cannot read a date from its weights. Asked what today's date is, it will guess from patterns in training data, and often guesses too early.
- Stale knowledge is stated as current. The model may describe a library's old API, a former office holder, or an outdated price as if it were current.
Post-training does not fix this. Instruction tuning teaches format and behavior on a small amount of data compared with pretraining. It adds few new facts and can encourage confident answers about things the model does not know.
Mitigations for stale knowledge
- Put current information in the prompt. The context window is the only place where the model can see new facts without retraining.
- Use retrieval: search an up-to-date source and insert the relevant passages into the prompt.
- Give the model tools, such as a search call or a clock, and let your application execute them.
- Tell the model the current date in the system prompt when dates matter.
Retrieval reduces hallucination only if the model uses the retrieved text. Models can still ignore it or blend it with remembered but outdated facts. Check outputs against the retrieved passages when accuracy matters.
Sensitivity to prompts
The model computes a distribution conditioned on the exact token sequence. Two prompts that mean the same thing to a person can be very different sequences. Known sources of variation:
- Wording. Rephrasing a question can change the answer, especially for tasks near the model's ability limit.
- Example order. In few-shot prompts, the order of examples and the label of the last example often bias the answer. Models tend to repeat the most recent pattern.
- Format and whitespace. A trailing space, a different delimiter, or a change from bullets to prose changes tokenization and therefore the input vectors.
- Position in the context. Information in the middle of a long prompt is often used less reliably than information at the start or end.
- Framing. Leading questions ("Why is X true?") push the model to produce justifications instead of checking the claim. This is a form of sycophancy, which preference tuning can strengthen when raters favor agreeable answers.
Randomness is not the only source of variation
Setting temperature to 0 (greedy decoding) removes sampling randomness. It does not guarantee identical outputs across runs. Batching, parallel floating-point reduction order, and hardware differences can change the last bits of the logits. When two top logits are nearly tied, a tiny difference flips the choice, and every later token then differs.
To measure prompt sensitivity, run several paraphrases of a prompt and compare the answers instead of trusting a single run:
import numpy as np
def answer_agreement(answers):
# answers: list of strings returned for paraphrased prompts
values, counts = np.unique(answers, return_counts=True)
top = values[counts.argmax()]
return top, counts.max() / len(answers)
paraphrase_answers = ["42", "42", "41", "42", "42"]
top, agreement = answer_agreement(paraphrase_answers)
print(top, agreement)An agreement of 0.8 means one paraphrase in five disagreed. Low agreement shows the task is unstable for this model. High agreement is encouraging but does not prove the answer is correct, because a model can be consistently wrong.
Other failure modes that share these roots
- Tokenization effects. The model sees subword tokens, not characters. Counting letters in a word, reversing a string, or exact character-level edits are harder than they look.
- Arithmetic and multi-step logic. The model produces one token per forward pass with a fixed amount of computation per token. Long calculations done "in one step" are unreliable. Asking for intermediate steps, or using a calculator tool, helps.
- Limited context. Text outside the context window is invisible. Within the window, long inputs dilute attention and raise the chance of missed details.
- Training data bias. The model reproduces gaps and skews in its corpus, including uneven coverage of languages and topics.
Choosing a mitigation
| Symptom | Likely cause | First thing to try |
|---|---|---|
| Invented citations or identifiers | Weak or absent fact, no abstention | Retrieval, plus verification of every reference |
| Outdated facts | Knowledge cutoff | Supply current data in the prompt or via tools |
| Answer changes with rewording | Prompt sensitivity | Test paraphrases, fix a tested template, add examples |
| Wrong arithmetic | One-pass computation | Calculator tool, step-by-step output |
| Contradicts the supplied document | Weak grounding | Ask for quotes from the source, check the quotes automatically |
| Different output at temperature 0 | Floating-point nondeterminism | Accept small variance, or compare outputs semantically |
Summary
Hallucination comes from an objective that rewards plausible continuations and a decoder that samples from them. Knowledge cutoffs come from frozen weights, and the effective cutoff is earlier than the nominal one. Prompt sensitivity comes from conditioning on exact token sequences. None of these is a bug you can patch inside the model. You manage them by supplying fresh facts through the context, testing prompts across variations, and verifying outputs where mistakes are costly.
Exercise
A model answers "The Eiffel Tower was completed in 1887" with high fluency. You rerun with temperature 0 and get the same answer. Does this show the answer is reliable? Explain using the mechanisms in this chapter.
Show answer
No. Temperature 0 only removes sampling randomness, so repeating the answer shows that the wrong token (1887 instead of 1889) is the highest-probability one. The training objective rewards plausible continuations, and a nearby year is plausible. A consistent answer can be consistently wrong. To check it, compare against an outside source or retrieve a reference.
Exercise
Your application asks a model for the current CEO of a company. The model names the CEO who held the job before the model's training cutoff, and the company has since changed leaders. Name the cause and give two fixes.
Show answer
The cause is a knowledge cutoff: the weights hold no information after training, and the model states stale facts as current. Fixes include retrieving a current source and inserting it into the prompt, giving the model a search tool, and stating the current date and requiring answers to cite the supplied text.
Exercise
Five paraphrases of a question produce the answers "A", "A", "B", "A", "C". What is the agreement score computed by the function in this chapter, and what does it tell you and not tell you?
Show answer
The most common answer is "A" with 3 of 5 responses, so the agreement is 0.6. It shows the task is unstable under rewording for this model. It does not show that "A" is correct, because the model could be consistently wrong, and it does not show which paraphrase is best.