AI Wiki中文/EN

Exposure bias: when an imperfect prefix changes the next step

曝光偏差

Separate prefix distribution shift from inevitable failure, model recovery, and examine a scheduled-sampling counterexample.

On this pageIntuitionMathematics & methodImplementationLimitationsExercisesResearch connections

A wrong turn can change the route without ruining every later turn

Imagine an invented generator that should alternate 0 and 1. Training supplies correct earlier symbols. Generation supplies whatever the model has already emitted. If it repeats 0, its next input differs from the training prefix. What follows depends on the model: it might repeat forever, resume alternating, or end the sequence.

Exposure bias names a concern about this difference between training prefixes and generated prefixes. It is useful to identify the distributions involved before assuming a consequence. A change of prefix distribution does not by itself establish that error must increase at every position, that every generation failure has this cause, or that likelihood training is mathematically invalid. Bengio and colleagues describe the mismatch and propose mixing observed and model-generated inputs during training. Prefix selection, §2.4

Measure teacher-forced prediction, actual decoding and sensitivity to controlled prefix changes separately. A language model can assign a low probability to a particular reference continuation while generating another acceptable one. Conversely, fluent output may change a required fact. Specify the task and error definition before treating either observation as evidence about exposure bias.

Exact two-state calculations show accumulation, recovery and a periodic boundary. A separate sampled-prefix counterexample changes the fitted conditional objective; these are teaching models, not language benchmarks.
Exact two-state calculations show accumulation, recovery and a periodic boundary. A separate sampled-prefix counterexample changes the fitted conditional objective; these are teaching models, not language benchmarks.

Keep the conditional error and its weighting separate

Let h be a prefix state, d(h) its data probability and q(h) its probability under a chosen generation policy. Hold fixed a bounded conditional error g(h) between zero and one. Then:

D=∑hd(h)g(h),R=∑hq(h)g(h),R−D=∑h[q(h)−d(h)]g(h).D=\sum_h d(h)g(h),\qquad R=\sum_h q(h)g(h),\qquad R-D=\sum_h[q(h)-d(h)]g(h).

The gap can be positive, zero or negative. If d=[1,0], q=[0.8,0.2] and g=[0.1,0.9], D=0.1 and R=0.26. The ratio is 2.6, but it is undefined when D=0; even 0/0 is not evidence of equal nonzero performance. This finite diagnostic is an original teaching construction. He and colleagues compare data/model prefixes in open-ended generation and distinguish marginal continuation quality from conditional consistency; their paper’s full metrics are not implemented here. Quantification setting, §5

For a model of possible accumulation, call the current context either normal or deviated. Let epsilon be the probability of moving from normal to deviated, rho the probability of recovering, and e-t the probability of being deviated at step t. Total probability gives:

et+1=(1−et)ϵ+et(1−ρ)=ϵ+(1−ϵ−ρ)et.e_{t+1}=(1-e_t)\epsilon+e_t(1-\rho)=\epsilon+(1-\epsilon-\rho)e_t.

The state means current context deviation, not “the entire historical prefix was correct.” A past error cannot be erased from history, but its influence on current behavior may fade. For epsilon+rho>0, subtracting the fixed point gives the exact solution:

e∗=ϵϵ+ρ,et=e∗+(e0−e∗)(1−ϵ−ρ)t.e_* = \frac{\epsilon}{\epsilon+\rho},\qquad e_t=e_*+(e_0-e_*)(1-\epsilon-\rho)^t.

Convergence from every initial state requires the multiplier’s absolute value to be below one. At epsilon=rho=1 the process alternates; at epsilon=rho=0 it stays at its initial state. With no recovery and e0=0, e-t=1−(1−epsilon)^t. With recovery, deviation may approach a smaller value or initially decrease. This is a conditional toy result, not a theorem about all natural-language errors.

A proposed remedy can also change the target being fitted. Consider fair binary training pairs with x2=x1. Fix the model’s first-symbol marginal at the correct fair distribution. With probability r replace the first symbol by an independent model sample; otherwise keep the observed symbol. Keep the original second-symbol label in both cases. Rows of the resulting joint table identify the supplied prefix; columns identify the original label:

Jr=[12−r4r4r412−r4],q2∗=[1−r2r2r21−r2].J_r=\begin{bmatrix}\tfrac12-\tfrac r4&\tfrac r4\\\tfrac r4&\tfrac12-\tfrac r4\end{bmatrix},\qquad q_2^*=\begin{bmatrix}1-\tfrac r2&\tfrac r2\\\tfrac r2&1-\tfrac r2\end{bmatrix}.

To see why, the unchanged branch puts probability (1−r)/2 on each diagonal cell. The replacement branch adds r/4 to every cell. Every row has mass 1/2, so dividing by its mass gives the fitted conditional table. Minimizing cross-entropy gives this row distribution because:

−∑bJr(a,b)log⁡q(b∣a)=Jr(a)[H(Jr(⋅∣a))+DKL(Jr(⋅∣a)∥q(⋅∣a))].-\sum_b J_r(a,b)\log q(b\mid a) =J_r(a)\left[H(J_r(\cdot\mid a))+D_{\mathrm{KL}}(J_r(\cdot\mid a)\|q(\cdot\mid a))\right].

Terms with zero data probability contribute zero. Assigning zero model mass to an observed outcome gives infinite loss. Under the original uncorrupted data, the best conditional model for this modified objective has second-token NLL:

Lgold(r)=−log⁡(1−r/2),Lgold(0)=0,Lgold(1)=log⁡2.\mathcal L_{\mathrm{gold}}(r)=-\log(1-r/2),\qquad \mathcal L_{\mathrm{gold}}(0)=0,\quad\mathcal L_{\mathrm{gold}}(1)=\log 2.

At r=1 both conditional rows are [0.5,0.5], so the model loses the dependence between the symbols. This finite example illustrates the issue analyzed by Huszár: independent sampled prefixes paired with unchanged labels need not preserve the original likelihood objective. Our r is the probability of a model prefix; the papers’ epsilon is the opposite, the probability of using truth. The example fixes the first marginal, uses sampling rather than argmax, and does not prove that every schedule fails on every task. Two-symbol analysis, §4.1

Enumerate the cases instead of blaming every mistake on drift

The complete original program requires Python 3.12 and NumPy 1.26.4. It propagates the two-state probabilities exactly, builds the replacement experiment by enumerating events, and compares conditional objectives. It does not train a real language model.

"""Original finite examples: recoverable context deviation and scheduled sampling.

The Markov states describe current context, NOT an all-correct historical prefix.
No real-language benchmark or universal error-growth law is claimed.
"""
import json
import math
import numpy as np


def probability(x):
    if isinstance(x, (bool, np.bool_)) or not np.isscalar(x):
        raise ValueError('Expected a numeric probability')
    try:
        value = float(x)
    except (TypeError, ValueError, OverflowError) as exc:
        raise ValueError('Expected a numeric probability') from exc
    if isinstance(x, (str, bytes, complex)) or not math.isfinite(value) or not 0 <= value <= 1:
        raise ValueError('Probability must be finite and in [0,1]')
    return value


def deviation(epsilon, recovery, steps=20, initial=0.):
    """P(bad at t), including t=0; exact two-state distribution propagation."""
    epsilon, recovery, initial = map(probability, (epsilon,recovery,initial))
    if isinstance(steps,(bool,np.bool_)) or not isinstance(steps,(int,np.integer)) or not 0 <= steps <= 10000:
        raise ValueError('Use 0..10000 integer steps')
    values = [initial]
    for _ in range(steps):
        e = values[-1]
        values.append((1-e)*epsilon + e*(1-recovery))
    return np.asarray(values)


def scheduled_joint(model_prefix_probability):
    """Joint(input prefix, original target) for fair data with x2=x1.

    r is the probability of a fresh fair model prefix independent of the pair.
    q1 is fixed at the true fair marginal; only q2 is optimized. Sampling,
    not greedy argmax, is assumed. The supervised target is never rewritten.
    """
    r = probability(model_prefix_probability)
    joint = np.zeros((2,2))
    for original in (0,1):
        joint[original,original] += .5*(1-r)
        for replacement in (0,1):
            joint[replacement,original] += .5*r*.5
    return joint


def conditional_fit(joint):
    a = np.asarray(joint,dtype=float)
    if a.shape != (2,2) or not np.isfinite(a).all() or (a<0).any() or not np.isclose(a.sum(),1,rtol=0,atol=1e-12):
        raise ValueError('Expected a normalized 2 by 2 joint distribution')
    mass = a.sum(1,keepdims=True)
    if (mass == 0).any():
        raise ValueError('A zero-mass prefix has no identified conditional')
    return a/mass


def cross_entropy(joint, conditional):
    """Second-token NLL; zero assigned mass to an observed outcome gives infinity."""
    conditional_fit(joint)  # Validate, but do not replace the supplied model.
    a = np.asarray(joint,dtype=float); q = np.asarray(conditional,dtype=float)
    if q.shape != (2,2) or not np.isfinite(q).all() or (q<0).any() or not np.allclose(q.sum(1),1,rtol=0,atol=1e-12):
        raise ValueError('Conditional rows must sum to one')
    present = a > 0
    if (q[present] == 0).any():
        return math.inf
    return float(-np.sum(a[present]*np.log(q[present])))


def prefix_comparison(data_prefix, model_prefix, errors):
    """Expectation of the SAME bounded conditional error under two prefix laws.

    A ratio with zero data-prefix error is undefined, including 0/0.
    This is a finite diagnostic, not the paper's language-generation metric.
    """
    d = np.asarray(data_prefix,dtype=float); m = np.asarray(model_prefix,dtype=float)
    errors = np.asarray(errors,dtype=float)
    if d.ndim != 1 or not 1 <= len(d) <= 64 or m.shape != d.shape or errors.shape != d.shape:
        raise ValueError('Use 1..64 corresponding prefix states')
    for a in (d,m):
        if not np.isfinite(a).all() or (a<0).any() or not np.isclose(a.sum(),1,rtol=0,atol=1e-12):
            raise ValueError('Prefix probabilities must sum to one')
    if not np.isfinite(errors).all() or ((errors<0)|(errors>1)).any():
        raise ValueError('Conditional errors must be in [0,1]')
    baseline = float(d@errors); rollout = float(m@errors)
    return dict(data_error=baseline, model_error=rollout, gap=rollout-baseline,
                ratio=None if baseline==0 else rollout/baseline,
                ratio_status='undefined_zero_denominator' if baseline==0 else 'defined')


def demo():
    schedules = []
    gold = scheduled_joint(0)
    for r in (0,.25,.5,.75,1):
        joint = scheduled_joint(r); q = conditional_fit(joint)
        schedules.append(dict(model_prefix_probability=r, training_joint=joint.tolist(),
            q2=q.tolist(), correct_pair_probability=float(.5*np.trace(q)),
            gold_second_token_nll=cross_entropy(gold,q),
            perturbed_second_token_nll=cross_entropy(joint,q)))
    return dict(epsilon=.1, steps=20,
        no_recovery=deviation(.1,0).tolist(), recovery_point_four=deviation(.1,.4).tolist(),
        periodic_boundary=deviation(1,1,steps=6).tolist(), schedules=schedules,
        diagnostic=prefix_comparison([1,0],[.8,.2],[.1,.9]),
        zero_denominator=prefix_comparison([1,0],[.8,.2],[0,.9]))


if __name__ == '__main__':
    print(json.dumps(demo(), indent=2, allow_nan=False))

At epsilon=0.1 after 20 steps, deviation is 0.878423 without recovery and 0.1999998 with rho=0.4. Starting from a heavily deviated state can produce a decreasing trace. The periodic boundary is deliberately included so a graph cannot silently suggest that every parameter choice converges.

For r=0, 0.25, 0.5, 0.75 and 1, true second-token NLL is 0, 0.133531, 0.287682, 0.470004 and 0.693147. correct_pair_probability is the probability that a generated pair belongs to the set of equal-symbol pairs; it is not the chance of matching a separately drawn reference pair. No ratio with a zero denominator is serialized as a valid score.

Checks enumerate all short Markov paths, independently enumerate the replacement coin and sampled symbol, compare conditional objectives, and cover zero mass and periodic transitions. The recurrence takes O(T) time and stored output; retaining just the final state needs constant extra space. The two-symbol joint calculation is constant size. Bounds of 10,000 steps and 64 diagnostic prefix states keep the examples small.

A controlled prefix experiment still needs a defined task

When comparing real prefixes, hold the model, prompts, decoding budget and continuation horizon fixed. Record whether the intervention supplies ground truth, shuffles words, inserts random noise or uses the model’s natural outputs. Those changes produce different prefix distributions. Replacing the prefix and also changing the model would confound the comparison.

He and colleagues report limited, non-incremental distortion in their studied open-ended generation setting and propose self-recovery as an explanation. This is a scoped empirical result, not a guarantee for translation, factual consistency or arbitrary models. The publication and version are important: the source used here is the September 2021 v10, not an earlier differently titled draft. Abstract and study scope

A poor rollout can also reflect insufficient model capacity, optimization, decoding or an unsuitable evaluation target. Scheduled sampling’s appeal does not remove the need to specify which conditional labels remain appropriate after a prefix is altered. Conversely, the binary counterexample does not rule out every method that trains on generated contexts. Test the proposed objective and intervention, not just the method’s name.

Predict what an intervention can actually show

  1. In the finite prefix diagnostic, d=[1,0], q=[0.8,0.2] and g=[0.1,0.9]. Compute D, R and the gap.

Answer: D=0.1, R=0.8×0.1+0.2×0.9=0.26, gap=0.16. This isolates changed weighting of fixed conditional errors, not a change in the errors themselves.

  1. With epsilon=0.1, rho=0.4 and e0=0, compute e1 and e2. Does the limiting value equal one?

Answer: e1=0.1 and e2=0.1+0.5×0.1=0.15. The limit is 0.1/0.5=0.2. Recovery prevents this particular state probability from approaching one.

  1. At r=0.5, what does the fitted second-symbol distribution predict after prefix 0? What is its true second-token NLL?

Answer: It predicts [0.75,0.25]. The original data always follows 0 with 0, so NLL is −log(0.75)=0.287682, instead of zero for the exact original conditional.

  1. An engineer labels the Markov state “some previous token was wrong” but allows it to return to “no previous token was wrong.” What needs fixing?

Answer: The state definition. Historical error occurrence is irreversible. Use a recoverable current-context state if recovery is intended, or keep an absorbing state when studying whether any earlier error occurred.

Separate the proposal, its critique and the measured consequence

Read Bengio and colleagues for the input-mixing procedure, Huszár for the idealized two-symbol critique, and He and colleagues for a limited empirical prefix-comparison study. Huszár’s linked v1 says it was under review at ICLR 2016; this article does not claim conference acceptance. None of these sources makes our small Markov model a validated account of all text generation.

Make a prediction, then check

Can a recoverable Markov state mean that some earlier token was ever wrong?

Choose one answer

Learning objectives

  • Compare fixed conditional errors under different prefix distributions.
  • Derive accumulation, recovery and periodic boundary cases.
  • Enumerate a sampled-prefix objective that loses dependence.
  • Keep toy counterexamples and empirical scope distinct.

Prerequisites & connections

Explore related knowledge →

References

  1. Scheduled Sampling for Sequence Prediction with Recurrent Neural Networks
    Samy Bengio, Oriol Vinyals, Navdeep Jaitly, Noam Shazeer · 2015
  2. How (not) to Train your Generative Model: Scheduled Sampling, Likelihood, Adversary?
    Ferenc Huszár · 2015
  3. Exposure Bias versus Self-Recovery: Are Distortions Really Incremental for Autoregressive Text Generation?
    Tianxing He, Jingzhao Zhang, Zhiming Zhou, James Glass · 2021

Version1 · Editorial status: Recorded technical checks completed

View technical check record (AI)

Codex · 2026-09-12 · Single AI author checked six paired equations and four explained exercises against Bengio sampling, Huszar v1 two-symbol critique and scoped He v10 open-ended generation findings. Independent Markov-path and replacement-coin enumeration verify accumulation/recovery/periodic boundaries and fixed-fair-first-marginal sampled-prefix counterexample. Current deviation is not historical error occurrence; sampled-prefix r is opposite the source truth probability. Undefined ratios, gold NLL and label dependence checked. No argmax theorem, universal error law or real-model replication claimed.

  • Single AI author checked six paired equations and four explained exercises against Bengio sampling, Huszar v1 two-symbol critique and scoped He v10 open-ended generation findings. Independent Markov-path and replacement-coin enumeration verify accumulation/recovery/periodic boundaries and fixed-fair-first-marginal sampled-prefix counterexample. Current deviation is not historical error occurrence; sampled-prefix r is opposite the source truth probability. Undefined ratios, gold NLL and label dependence checked. No argmax theorem, universal error law or real-model replication claimed.
  • Four computed SVGs bind exact bilingual MDX. The four-topic group passed eight numeric/encoding checks and24 isolated language/width cases with four fallback fonts; eight actual screenshots inspected by the AI author. Literal-prose AST checked before freezing. Full article browser acceptance is separate; no human peer review.

Source locations checked:

Related topics

No matches. Try a synonym or acronym.

0 results shown

Wrap the whole query in double quotes for a phrase match.