Teacher-Forced Accuracy Is Not a Generation Score: Exposure Bias and the Two-Number Report
Teacher-forced accuracy overstates what a sequence model can do, because at inference the model reads its own outputs. Report free-running decode with whole-sequence metrics, and treat the gap between the two numbers as a diagnostic.

A formula recognizer can post a token accuracy above 90 percent and still get most formulas wrong. Neither number is a mistake. The first is teacher-forced accuracy: how often the model predicts the next token when it is handed the correct history. The second is what happens when the model has to write the whole expression itself.
Teacher-forced accuracy overstates what a sequence model can do, because at inference the model conditions on its own outputs, not the ground truth. The number worth reporting comes from free-running, autoregressive decode, scored on the whole sequence. The gap between the two numbers should not be hidden either. It tells you whether the model fails because sequences are long, or because it cannot recover from its own mistakes.
Image-to-LaTeX and handwritten math recognition make a good running example. A formula that is one token off does not compile to the same expression, and the benchmarks in that field were built around that fact.
What teacher-forced accuracy actually measures
Teacher forcing is a training technique. Ronald Williams and David Zipser gave it the name in their 1989 paper on training fully recurrent networks, describing a method already in use: wherever a target value exists, replace the unit's actual output with the teacher signal when computing what the network does next. In their experiments it was a practical aid. On oscillation tasks, only the teacher-forced version of the algorithm solved the problems in general.
The modern form is the same idea applied to tokens. During training, the decoder predicts token t from the gold tokens before t, not from whatever it would have generated. All positions can be trained in one pass, and the model never has to dig itself out of a bad prefix.
Teacher-forced accuracy is the metric that falls out of that setup for free: the share of positions where the top prediction matches the reference, given a gold prefix at every step. The Professor Forcing paper by Alex Lamb and colleagues supplies the vocabulary used in the rest of this post. A network runs in teacher-forcing mode when its inputs come from a training sequence and in free-running mode when its inputs are self-generated.
Teacher-forced accuracy answers a narrow question: given a perfect history, is the next token right? At inference there is no perfect history. Reporting that number as the model's quality describes a condition the model never operates in.

A three-token worked example
Suppose the reference is A B C. At the first position a deterministic greedy model predicts X instead of A. Teacher forcing still supplies the gold prefix A for the second position and A B for the third. Free-running decoding instead supplies X, then whatever follows X.
| Position | Teacher-forced prefix | Free-running prefix | What is being tested |
|---|---|---|---|
| 1 | Start token | Start token | Identical input; both predict X, which is wrong |
| 2 | A | X | Prediction under the correct history versus recovery after an error |
| 3 | A B | The generated two-token prefix | Gold-prefix prediction versus the continuing generated trajectory |
The teacher-forced run might get positions two and three right and score 2/3 token accuracy. Both sequences still fail exact match because position one is wrong. The later free-running tokens show how the model behaves after that first error. This is a hypothetical example, not a measured model result.
Why teacher-forced accuracy overstates a sequence model
Two separate mechanisms inflate the number. They are often blurred together, and they call for different fixes.
A per-token average is not a per-sequence result
Token accuracy is an average over positions. A LaTeX string is an all-or-nothing artifact. The arithmetic below shows how far apart those can be. It is arithmetic under an independence assumption, not an empirical result: if every token were correct with the same probability , independently of every other token, the chance that all tokens are correct would be .
def all_correct(p, length):
"""P(every token correct) if token errors were independent."""
return p**length
for p in (0.90, 0.95, 0.99):
print(p, [f"{all_correct(p, t):.1%}" for t in (10, 25, 50, 100)])
| Tokens | p = 0.90 | p = 0.95 | p = 0.99 |
|---|---|---|---|
| 10 | 34.9% | 59.9% | 90.4% |
| 25 | 7.2% | 27.7% | 77.8% |
| 50 | 0.5% | 7.7% | 60.5% |
| 100 | under 0.01% | 0.6% | 36.6% |
Under that assumption, a model that is right 99 percent of the time per token gets a 100-token sequence fully right about a third of the time, and drops below even odds at about 69 tokens.
Real models do not follow this table, for two reasons that push in opposite directions. Errors are not independent. They concentrate in hard examples, so more sequences survive intact than predicts. And the per-token rate measured under teacher forcing is not the rate the model achieves once it is reading its own output. The table is useful for one thing only: it shows that a high per-token average does not, by itself, imply a high whole-sequence rate.
Exposure bias: the model has never read its own mistakes
The second mechanism is about what happens after the first error. Samy Bengio and colleagues described it in the 2015 scheduled sampling paper as a discrepancy between how the model is used at training and at inference. A mistake early in the sequence is fed back as input and "can be quickly amplified," because the model may be in a part of the state space it never saw in training.
Marc'Aurelio Ranzato and colleagues gave the problem its common name in Sequence Level Training with Recurrent Neural Networks: exposure bias, which "occurs when a model is only exposed to the training data distribution, instead of its own predictions." The same paper names a second mismatch that matters here. The training loss is at the word level, while the task is judged by sequence-level metrics. Their MIXER algorithm addresses both by starting from a cross-entropy model and annealing toward direct optimization of the sequence metric.
Imitation learning has a formal version of the worry. Ross, Gordon, and Bagnell note that a classifier with error rate under the expert's state distribution can make as many as mistakes in expectation over steps under the distribution its own actions induce. That is a worst-case bound from a different setting, not a measurement of any language or markup model. It does establish that compounding is a real possibility.
Does exposure bias matter as much as claimed?
The evidence is mixed, and that is the reason to measure it.
The scheduled sampling paper contains a clean example of the two numbers pointing in opposite directions. On TIMIT speech recognition, Bengio and colleagues report frame error rate two ways: next-step prediction with ground truth fed in, on the validation set, and beam-search decoding on the test set.
| Training regime | Next-step FER | Decoding FER |
|---|---|---|
| Baseline LSTM | 15.0 | 46.0 |
| Always sampling | 34.6 | 35.8 |
| Scheduled sampling 1 | 34.3 | 34.5 |
The baseline had the best teacher-forced number by a wide margin and the worst decoding number. The authors' explanation is that next-step prediction with ground-truth labels let the model pay disproportionate attention to the structure of the label sequence and too little to the acoustic input.
Other work argues the effect is often smaller than the standard story suggests. Tianxing He and colleagues, in Exposure Bias versus Self-Recovery (EMNLP 2021), fed language models ground-truth prefixes in place of model-generated ones and measured how much the continuation improved. They found the distortion "is limited, and does not seem to be incremental during the generation," with the gain from removing the prefix discrepancy at around 1 to 2 percent relative. They attribute this to a self-recovery ability: the model can produce reasonable text after a distorted history. The scope is narrow by the authors' own account. The study covers open-ended language generation, and they write that the results do not rule out exposure bias being more serious in other applications.
Florian Schmidt's 2019 paper, Generalization in Generation, argues that exposure bias does not point to a flaw in standard autoregressive training. In his account it is a question of generalization to unseen sequences, one that log-likelihood training and testing do not reveal. The proposed fixes have costs too. Lamb and colleagues, citing Ferenc Huszár, point out that scheduled sampling yields a biased estimator that may not converge to the correct model even with unlimited data and capacity.
The size of the effect depends on the task, the architecture, and the data. No paper in this list licenses assuming it is large, and none licenses assuming it is zero. He and colleagues did not settle the question by argument. They ran the model both ways and compared. Anyone reporting a sequence model can do the same.
How image-to-LaTeX benchmarks score the whole expression
Open-ended text has many acceptable continuations, which is part of why a language model can recover from an odd prefix. A formula has far less slack, and the field's benchmarks are built accordingly.
Yuntian Deng and colleagues introduced IM2LATEX-100K in Image-to-Markup Generation with Coarse-to-Fine Attention (ICML 2017): 103,556 rendered formulas paired with LaTeX source. Their core evaluation does not compare token strings at all. Because rendering is a many-to-one function, with different markup producing the same image, they render the predicted markup and check for an exact match against the gold image. BLEU on the markup is reported as a secondary, intrinsic text metric. Test-time output comes from beam search.
The two kinds of metric disagree in their results table. The classical INFTY system reaches a normalized BLEU of 66.65 with an exact match rate of 15.60 percent. Their attention model reaches 87.73 BLEU and 77.46 percent exact match. An overlap score in the high sixties sat on top of a system that rendered fewer than one formula in six correctly.
Handwritten recognition uses the same standard. The ICDAR 2019 CROHME competition report states that systems "are ranked based on the number of correctly recognized formulas (expression rate)." The organizers introduced a symbol-level label graph representation that year so that encoder-decoder systems emitting LaTeX could be scored alongside stroke-level systems. On the image-based task, the winning USTC-iFLYTEK entry recognized 77.15 percent of expressions correctly. Allowing a single symbol-label error raises that to 86.82 percent. Nearly ten points of expressions were one symbol away from correct and still counted as wrong.
In this field the ranking metric is the whole expression, produced by the system running on its own output. A teacher-forced token score is not on the leaderboard.
The gap between the two numbers is a diagnostic
Teacher-forced accuracy is still worth computing. It is cheap, it covers the full validation set in one pass, and it becomes informative once it sits next to free-running metrics from the same checkpoint.
One relationship is exact rather than empirical. With a deterministic model and greedy decoding, the free-running output matches the reference if and only if every teacher-forced prediction along that reference is correct, because the two runs see identical inputs until the first error. On the same examples, greedy exact match is therefore the share of sequences with zero teacher-forced errors. The distance from token accuracy to exact match is the aggregation effect from the table above. Exposure bias cannot move it. Exposure bias shows up in what happens after the first error: whether one wrong token costs one token or the rest of the sequence. That is what free-running edit distance measures.
Measuring both takes a few lines. This is a sketch; the helper names are placeholders:
# Teacher-forced: one pass, gold prefix at every step.
logits = model(image, tgt[:, :-1])
tf_token_acc = (logits.argmax(-1) == tgt[:, 1:])[mask].float().mean()
# Free-running: the model reads its own previous outputs.
pred = greedy_decode(model, image, max_len)
exact_match = mean(p == g for p, g in zip(strip(pred), strip(tgt)))
edit_dist = mean(
levenshtein(p, g) / max(len(p), len(g))
for p, g in zip(strip(pred), strip(tgt))
)
With the three numbers side by side, I would read the gap this way:
- High token accuracy, low exact match, low edit distance. This is consistent with relatively local errors. Inspect the failed expressions and their lengths before deciding which symbols or structures need work.
- High token accuracy, low exact match, high edit distance. Cascading errors are one possible explanation, but the pattern alone does not isolate exposure bias from recognition failures, truncation, or stopping behavior. Compare trajectories on the same examples to locate the first divergence and what follows it.
- Teacher-forced accuracy improving while free-running metrics stall or fall. Increased dependence on the gold prefix is a hypothesis to test. Keep the sample and decoding settings fixed before attributing the change to that mechanism.
The HMER image-to-LaTeX project on this site reports both numbers with their protocols attached. It is trained on rendered IM2LaTeX-100k expressions, not handwriting. Its Transformer checkpoint has a teacher-forced token accuracy of 91.5 percent on the full 8,370-example validation split, labeled as a diagnostic. Under autoregressive greedy decode on 256 validation samples, the same checkpoint scores BLEU-4 0.790, normalized edit distance 0.178, and exact match 21.9 percent. The protocols and samples differ, so the numerical gap cannot be attributed entirely to exposure bias. Most expressions are still not token-for-token correct even when BLEU is high. The earlier LSTM figures came only from teacher forcing and do not measure free-running generation quality.
The same project selects checkpoints on validation BLEU from generated output, not on validation loss. I would treat that as part of the protocol. Loss and teacher-forced accuracy are computed under gold prefixes, so a checkpoint chosen on them is chosen for a condition that will not exist at inference.
A reporting protocol for sequence models
The fix is cheap. It is mostly labeling.
- Name the protocol next to every number. "Token accuracy (teacher-forced)" and "exact match (greedy decode)" are different measurements.
- Headline the free-running result. Use the decode procedure that will ship, and state it: greedy or beam, beam size, length penalty, maximum length.
- Report a whole-sequence metric and a partial-credit metric together. Exact match or expression rate says how often the output is usable. Edit distance says how far off the failures are. BLEU alone can sit high over a low exact-match rate.
- State the sample. Which split, how many examples, and whether the teacher-forced and free-running numbers cover the same ones.
- Keep teacher-forced accuracy as a labeled diagnostic. Read it against the free-running numbers, never in place of them.
- Select checkpoints on generated output.
The principle is the one behind scoring agents on observable outcomes instead of plausible transcripts, covered in how to evaluate production AI agents: measure the system doing the thing it will be asked to do.
Report two numbers, each labeled with how it was produced. The headline belongs to the one generated the way the model will run. The other belongs beside it, to explain why the headline is what it is.
References
- Williams RJ, Zipser D. "A Learning Algorithm for Continually Running Fully Recurrent Neural Networks." Neural Computation 1:270–280, 1989.
- Bengio S, Vinyals O, Jaitly N, Shazeer N. "Scheduled Sampling for Sequence Prediction with Recurrent Neural Networks." arXiv:1506.03099, 2015.
- Ranzato M, Chopra S, Auli M, Zaremba W. "Sequence Level Training with Recurrent Neural Networks." ICLR 2016.
- Lamb A, Goyal A, Zhang Y, Zhang S, Courville A, Bengio Y. "Professor Forcing: A New Algorithm for Training Recurrent Networks." NIPS 2016.
- Ross S, Gordon GJ, Bagnell JA. "A Reduction of Imitation Learning and Structured Prediction to No-Regret Online Learning." AISTATS 2011.
- He T, Zhang J, Zhou Z, Glass J. "Exposure Bias versus Self-Recovery: Are Distortions Really Incremental for Autoregressive Text Generation?" EMNLP 2021.
- Schmidt F. "Generalization in Generation: A closer look at Exposure Bias." arXiv:1910.00292, 2019.
- Deng Y, Kanervisto A, Ling J, Rush AM. "Image-to-Markup Generation with Coarse-to-Fine Attention." ICML 2017.
- Mahdavi M, Zanibbi R, Mouchère H, Viard-Gaudin C, Garain U. "ICDAR 2019 CROHME + TFD: Competition on Recognition of Handwritten Mathematical Expressions and Typeset Formula Detection." ICDAR 2019.






