Search

Search papers and lessons

Exposure Bias

Level 3 · 9 min read

Exposure bias is the gap between training a sequence model on true previous tokens and generating with its own, which lets early mistakes compound into drifting output.

On this page

  • Colour = topic mix
  • Calculus
  • Probability
  • Neural network basics
  • Linear algebra
  • Discrete math
  • Architectures
  • Sign in to see your progress

TL;DR

An autoregressive model is trained on true previous tokens but generates from its own. Once it makes a mistake, the history it sees is one it never practised on, so errors can compound and the output drifts. That mismatch is exposure bias.

Where you'll see it: long text generation from language models, the decoder of machine translation and captioning systems, and any rollout of a learned policy or world model that is fed its own predictions.

Intuition

A rehearsal with a safety net

Imagine learning to drive on a course where an instructor grabs the wheel every time you drift toward the kerb. You get through the course without ever drifting far, because the correction always happens before you are in trouble. On the real road nobody grabs the wheel. A small drift that you never learned to recover from now carries you into a lane you have never seen, and each new position makes the next correction harder.

Teacher forcing is the instructor. During training, the model is handed the correct previous token at every step, so it is never asked to continue from its own mistake. At generation time there is no instructor. The model conditions on what it actually produced, and that history can be one that never appeared in the training data. Exposure bias is the name for that difference between the training situation and the generation situation.

The word "exposure" refers to how much the model is exposed to its own errors during training. In the standard recipe, the answer is none.

Why it matters more over time

A single wrong token is not, by itself, a disaster. The problem is that every later token is predicted from a prefix that now contains the wrong token. If the model is good at recovering, the damage stays small. If it has never seen a recovery situation in training, it may keep producing text that is plausible locally but unrelated to the original intent, and the longer the output, the more chances there are to fall off the rails.

flowchart LR
  subgraph Training
    A1[true prefix] --> M1[model] --> P1[predict next token]
    P1 -. loss against true token .-> A1
  end
  subgraph Generation
    B1[model's own prefix] --> M2[model] --> P2[sample next token]
    P2 -->|appended to prefix| B1
  end

The training row never sees the model's own output as input. The generation row feeds the output back in, and that feedback loop is the thing the training row never practised.

The math

Setup

Let y∗=(y1∗,…,yT∗)\mathbf{y}^\ast = (y^\ast_1, \ldots, y^\ast_T) be a training sequence from the data distribution pdatap_{\text{data}}, and let pθ(yt∣y<t)p_\theta(y_t \mid y_{<t}) be the model's next-token distribution, where y<ty_{<t} is the prefix before position tt and θ\theta are the parameters of the model, as in Autoregressive Model.

Definition: Exposure bias

A mismatch between the prefixes used to train a sequence model and the prefixes it sees at generation time. Training conditions each prediction on the true prefix y<t∗y^\ast_{<t}. Generation conditions it on the model's own prefix y^<t\hat{y}_{<t}.

Training objective

Teacher-forced maximum likelihood, as described in Teacher Forcing, optimises

L(θ)=− Ey∗∼pdata[∑t=1Tlog⁡pθ(yt∗∣y<t∗)]\mathcal{L}(\theta) = -\,\mathbb{E}_{\mathbf{y}^\ast \sim p_{\text{data}}} \left[ \sum_{t=1}^{T} \log p_\theta\big(y^\ast_t \mid y^\ast_{<t}\big) \right]

Every term is evaluated under the true prefix. The model is never scored on the distribution of prefixes it creates for itself.

Generation

At inference the model samples

y^t∼pθ(⋅∣y^<t),y^<t=(y^1,…,y^t−1)\hat{y}_t \sim p_\theta\big(\cdot \mid \hat{y}_{<t}\big), \qquad \hat{y}_{<t} = (\hat{y}_1, \ldots, \hat{y}_{t-1})

so the prefixes come from the model's own distribution over sequences. The two prefix distributions differ as soon as y^<t≠y<t∗\hat{y}_{<t} \neq y^\ast_{<t} for some tt, and that happens almost always for long outputs.

How the errors compound

Ross, Gordon and Bagnell (2011) give the cleanest worst-case statement of the effect for imitation learning. If a classifier makes a mistake with probability ε\varepsilon on the states the expert visits, its total cost over TT steps, when run on the states it induces itself, can exceed the expert's by as much as T2εT^2 \varepsilon. The same paper notes that the quadratic growth is tight: there are problems where the extra cost really does grow as T2T^2. The sequence prediction example they attribute to Kääriäinen (2006) gives a mistake count of the form T2−1−(1−2ε)T+14ε+12\frac{T}{2} - \frac{1 - (1 - 2\varepsilon)^{T+1}}{4\varepsilon} + \frac{1}{2}, which behaves as Θ(T2ε)\Theta(T^2 \varepsilon) for small ε\varepsilon.

Read this as a scaling law, not a prediction for any particular language model. The intuition is that a mistake at step kk moves the model into states it was never trained on, so its error rate on the following steps is no longer ε\varepsilon. Errors that occur later in the sequence inherit the drift from earlier ones.

Worked examples

Example
Chance of a clean sequence under a constant error rate

This example uses illustrative numbers, not measured values from any model.

Suppose the model is right about each next token with probability 0.90.9, and that these chances are independent across steps (a simplification that exposure bias itself breaks).

  1. Probability that a 5-token output is entirely correct: 0.95=0.590490.9^5 = 0.59049.
  2. Probability that a 20-token output is entirely correct: 0.920=0.121580.9^{20} = 0.12158.
  3. Probability that a 50-token output is entirely correct: 0.950=0.005150.9^{50} = 0.00515.

Interpretation: even with a per-token accuracy that looks high, the chance that a whole output is clean falls off quickly with length. Exposure bias makes this worse, because after the first error the per-step accuracy is no longer 0.90.9. The independence assumption is the optimistic part of this calculation.

Example
Scaling of the quadratic bound

Take a per-step error rate ε=0.01\varepsilon = 0.01 measured under the true prefixes. The two scalings from the previous section give:

  1. Linear growth in TT (the ideal case, TεT\varepsilon): for T=10T = 10 this is 0.10.1; for T=100T = 100 it is 11.
  2. Quadratic growth in TT (the worst case, T2εT^2 \varepsilon): for T=10T = 10 this is 11; for T=100T = 100 it is 100100.
  3. Going from T=10T = 10 to T=100T = 100 multiplies the linear term by 1010 and the quadratic term by 100100.

Interpretation: the same local error rate can produce a tenfold or a hundredfold change in total mistakes as the sequence gets longer. The bound describes the worst case, so real models often sit well below it, but the direction of the effect is the reason long free-running outputs need a different training strategy.

Tradeoffs and failure modes

SituationProblemBetter choice
Short outputs, such as a classification label or a few tokensLittle room for drift to build upPlain teacher forcing is enough
Long free-running generationEarly errors push the model into unseen prefixesScheduled sampling, which mixes true and predicted tokens during training
The metric is a sequence-level score such as BLEUThe per-token loss does not optimise the metricSequence-level training, such as minimum risk training or policy gradient on the metric
Training data is clean and the model is already strongExtra machinery adds cost for small gainsKeep teacher forcing and check outputs for drift
Diverse outputs matter more than the single most likely oneSampling from a model with drift produces unusual textStronger decoding controls, such as Beam Search with a length or diversity penalty

Exposure bias is not the same as a model being bad at its task. A model can have a low teacher-forced loss and still generate poor long outputs. The fix is usually in how the model is trained on its own prefixes, not in more data or a bigger network.

One limitation is that the term describes a mismatch, not a single measurable quantity. Two models can have the same teacher-forced loss and very different free-running behaviour. Evaluating generation directly, with a sequence-level metric or with human judgement, is therefore part of diagnosing it.

History

Teacher forcing came from work on recurrent networks trained to predict sequences, and it was attractive because it made training simple and fast. Bengio, Vinyals, Jaitly and Shazeer (2015) proposed scheduled sampling for training recurrent sequence predictors: during training, the model's own predictions are substituted for some of the true tokens, with the substitution rate changing over the course of training so that the model gradually learns to recover from its own errors. Ranzato, Chopra, Auli and Zaremba (2016) argued for training with a sequence-level objective, so that the model is scored on whole generated sequences rather than on each token given the true prefix, and they used the term exposure bias for the mismatch in their discussion of the problem.

Ross, Gordon and Bagnell (2011) approached the same effect from imitation learning. Their analysis of the quadratic error growth under supervised training, and their algorithm that trains on the learner's own induced states, gave a formal account of why training only on expert states is fragile.

Check yourself

QuestionIn one sentence each, what prefix does the model see during training under teacher forcing, and what prefix does it see at generation time?Show answer

During training it sees the true previous tokens from the dataset. At generation time it sees the tokens it sampled itself. Exposure bias is the gap between these two prefix distributions.

QuestionA model gives the correct next token probability 0.80.8 at each of 10 independent steps. What is the probability that all 10 are correct, and what does this suggest about longer outputs?Show answer

The probability is 0.810=0.10740.8^{10} = 0.1074. Longer outputs have fewer chances to stay correct, so the probability that the whole output is clean decreases quickly with length. Exposure bias makes this worse because the per-step accuracy after an error is lower than 0.80.8.

QuestionWhy does training with the true prefix not, on its own, guarantee good long generations?Show answer

Training scores the model only on true prefixes. The model is never trained on the prefixes it creates after its own mistakes, so it has no practice recovering. The quality of the free-running output depends on the distribution over those self-generated prefixes, which the training objective never evaluates.

QuestionA translation decoder trained with teacher forcing produces a good first half of each sentence and then repeats words. Name the likely cause and one training change that targets it.Show answer

The likely cause is exposure bias: once the decoder generates a wrong or unusual token, the prefixes it sees are outside its training distribution, and errors compound. One change is scheduled sampling, which replaces some true previous tokens in training with the model's own predictions, so the decoder practises continuing from imperfect prefixes.

Sources