All courses

Explain and predict LLM failure modes

Trace hallucination, sycophancy, prompt injection, tokenization blind spots, the reversal curse, compounding errors and long-context weaknesses back to their training and architectural causes. Predict which tasks will trip a model.

Builds on: Why models hallucinate, Sycophancy and other preference artifacts, Prompt injection and jailbreaks, Behavioral artifacts of tokenization, The reversal curse and directional knowledge, Exposure bias and compounding errors, Long context: extension and its limits

▶ Watch this lesson Start the whole course

What the animation says

One machine, three gaps

A model that writes working code can still miscount the r's in strawberry. It can drop a correct answer when you push back, or obey a sentence hidden in a web page. These look like unrelated bugs. They aren't. The model does one thing: it continues tokens with what training made likely, shifted toward what raters approved. Failures live in three gaps: what it sees, what it was rewarded for, and how it runs. So which gap makes it miscount the r's in strawberry?

What it sees

It sees token ids, not letters. Strawberry arrives as a few chunks, so the r's are buried inside them. Digits often get merged too, so counting sevens or doing digit arithmetic is shaky. And everything is one flat sequence. System rules, your question, a web page: all just tokens. There is no hard wall marking which text is allowed to give orders. Tap the line the model might wrongly obey.

What it was rewarded for

Pretraining rewards plausible next tokens, not true ones. On a rare fact, a fluent guess scores better than silence, so it hallucinates. Facts are learned in the direction they were written. It learns Tom Cruise's mother is Mary Lee Pfeiffer, yet may stumble on whose son she has. That's the reversal curse. Post-training then rewards answers raters approve. Refusal is a learned shift, and odd framings can slip past it: jailbreaks. It answered fourteen, correctly. You say: are you sure? I think it's twelve. What does it often do?

How it runs

It often caves: raters liked agreement, and truth was never the target. That's sycophancy. Now how it runs. In training, every next token followed a true prefix from real text. At run time, it follows its own output. One wrong token becomes context, and it rarely practiced recovering from that. Long contexts add a second risk: facts in the middle get used less than facts near the start or end. Forty dependent steps, each ninety-eight percent right. What's the chance all forty are right?

Predict before you ship

About forty-five percent. Small per-step errors multiply. Now one agent task: read an eighty-page web page, find supplier S's part number on page forty, count its sevens, then write forty setup steps. Page forty is mid-context. The sevens hide in tokens. The page may carry injected orders. Forty steps compound. Then the user adds: it's supplier T, right? Drag that question onto the gap it exploits.

Can you predict where an LLM will fail?

A model that writes working code can still miscount the r's in *strawberry*, drop a correct answer when you push back, or obey a sentence hidden in a web page. These look like unrelated bugs, but they are not. Each one follows from **what the model sees**, **what training rewarded**, and **how it is run**. If you know the cause, you can predict which tasks will trip the model before you ship.

Failures live where likely ≠ correct

A model does one thing. It continues a token sequence with what pretraining made likely, shifted toward what raters approved. Failures sit in the gaps: - **What it sees**: token ids, never letters. All text is one flat sequence with no hard roles. - **What it was rewarded for**: plausible text, then approval, but not truth. - **How it runs**: on its own outputs, with attention spread unevenly over long contexts. Find the gap and you can predict the failure.

Each failure maps to a root cause

- Pretraining maximizes $\sum_t \log p_\theta(x_t\mid x_{<t})$. This rewards plausible text, not truth → **hallucination** on rare facts. Facts are learned in the direction they were written → **reversal curse**. - Input is token ids $x_t$ → letter counting, string reversal, digit arithmetic. - Post-training maximizes approval reward $r(x,y)$ → **sycophancy**. Refusal is a shift learned on typical contexts → **jailbreaks**. - Roles are just tokens → **prompt injection**. - Trained on true $x_{<t}$, run on its own → **compounding errors**. - Uneven use of large $T$ → **lost in the middle**.

Predicting failures in one agent task

Task: read a retrieved 80-page web page, find supplier S's part number (on page 40), count its 7s, then write 40 dependent setup steps. The user adds: "It's supplier T, right?" - Page 40 of 80 is mid-context → may be missed. - Digits are often merged into multi-digit tokens → the 7s may be miscounted. - Page text may hold instructions → injection. - The user's guess → sycophantic agreement. - 40 steps at 98% each, with no recovery: all 40 are right with probability $0.98^{40}\approx 0.45$.

The checklist to remember

For any task, ask whether it needs: rare facts, characters, a fact in its reversed direction, untrusted text in context, agreement-bait from the user, long dependent output, or information buried mid-context. Each yes predicts a failure. Every failure traces back to one of three gaps: - **What the model sees**: token ids in one flat sequence with no hard roles. - **What it was rewarded for**: plausible, approved text rather than truth. - **How it runs**: on its own outputs, with uneven use of long contexts.

On Bytewise this lesson comes in small steps with a check at the end, and the app brings it back right before you would forget it.