Exposure bias and compounding errors
Explain that training always conditions on true prefixes while generation conditions on the model's own outputs. Explain why an early wrong token can derail everything after it unless the model has learned to recover.
Builds on: Autoregressive generation loop, Shifted targets and parallel training
What the animation says
Trained on truth
Training reports a low loss: given real text, the model predicts each next token well. Yet a long generated answer can drift, or build a whole page on one early slip. Same network, same task. So what differs? In training, every prefix is real text. That's called teacher forcing. If the model guesses Sydney here, the next step still sees the true word, Canberra. The mistake never enters its input. Now generation. The model writes Sydney. What does the next step see?
Exposure bias
Its own wrong word. In generation, the prefix is the model's own output. So the slip stays in the context for good, and every later step reads it. The model rarely saw text containing its own errors, so it often continues them as if correct. This mismatch is called exposure bias. The training loss only ever averages over true prefixes. It never measures the model on its own.
Small slips, long answers
Suppose a test on true prefixes shows a derailing token only zero point two percent of the time. So each token stays on track with chance ninety-nine point eight percent. With no recovery, an answer stays on track only if every token does. The chances multiply. For three hundred tokens, that's about e to the minus zero point six: roughly fifty-five percent. Now make it a thousand tokens. What share of runs stays on track?
Slips invite slips
About fourteen percent. A tiny per-token slip rate sank most of the long answers. And the real damage is worse than this count shows. After a slip, the prefix is unlike training text, so later predictions get less reliable. One slip invites more, and the answer keeps degrading. Even harmless oddities push a prefix away from real text and raise the slip chance. That's the compounding.
Simulating recovery
So how do long answers survive at all? Let's simulate a hundred thousand runs. This array holds one flag per run: on track or not. All start on. At every token, each run draws a random number u. An on-track run slips if u is below eps. An off-track run returns if u is below recover. We try recover at zero, then at one in ten. Which line lets a derailed run come back?
Recovery saves long outputs
The last line. Off-track runs come back when u falls below recover. Without recovery, about fifty-five percent are on track at token three hundred. With it, about ninety-eight. The share settles where leaving balances returning: slip rate times on equals recover times off. So on track is recover over recover plus slip rate: about ninety-eight percent. Training feeds true prefixes; generation feeds the model its own. The cure is mostly learning to recover.
Trained on truth, run on its own output
Two different kinds of prefix
99.8% per token, 14% per answer
Recovery is what saves long outputs
import numpy as np
rng = np.random.default_rng(0)
eps, n, trials = 0.002, 300, 100_000 # slip chance, length, runs
for recover in [0.0, 0.1]: # chance per token to get back
on = np.ones(trials, bool) # is each run on track?
for _ in range(n):
u = rng.random(trials)
on = np.where(on, u >= eps, u < recover)
print(recover, on.mean())
# 0.0 -> ~0.55 0.1 -> ~0.98
Remember this
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.
Bytewise
All courses