Worked examples — Teacher forcing
This page is a drill sheet. The parent note told you what teacher forcing is. Here we hunt down every distinct situation it can produce and work each one by hand, so no exam question or real project surprises you.
Before we start, one reminder of the only numbers we ever compute here.

Look at the red curve: it is flat and low on the right (confident-correct is cheap) and explodes on the left (a tiny probability on the truth is catastrophic). Every "cascade" story below is just this curve being visited at a bad .
The teacher-forcing ratio is the probability that, on any given step, we feed the model the ground-truth previous token instead of its own prediction. = full training wheels; = no wheels.
The scenario matrix
Every question about teacher forcing lands in one of these cells. The examples below are labelled with the cell they cover.
| # | Cell (the scenario class) | What makes it distinct | Example |
|---|---|---|---|
| A | , model always correct | best case, clean gradients | Ex 1 |
| B | , error at one step | cascade / compounding | Ex 2 |
| C | Same weights, TF loss vs inference loss | exposure-bias gap | Ex 3 |
| D | (scheduled sampling) | expected loss over coin flips | Ex 4 |
| E | Degenerate: sequence | no history exists at all | Ex 5 |
| F | Limiting: on truth | loss , why clip | Ex 6 |
| G | Real-world word problem (translation) | encoder context + free-run | Ex 7 |
| H | Exam twist: decay schedule algebra | find epoch where hits floor | Ex 8 |
Worked examples
Forecast: guess — will this total be closer to , , or ?
- Write the per-step loss. Why this step? Loss is defined only on the probability of the true target, and each step is independent because with every input is ground truth.
- Plug numbers. Why this step? Direct substitution — no history to worry about.
- Sum. Why this step? Total sequence loss is the sum over timesteps (from the chain-rule factorization: log of a product is a sum of logs).
Verify: every , so every term is positive and finite ✓. Average per-token loss , and — a sensible "average confidence" between and ✓.
Forecast: bigger or smaller than Example 1's ? By how much?
- Compute clean early steps. Why? The first steps still happen to be right, so their loss matches the TF numbers' shape.
- The mistake step . Why? Because at the model already fed itself a shaky input, its confidence on truth
Lcollapsed to . - The cascade step . Why? Having emitted a wrong token, the model is now in a state it never trained on — probability on truth
Ocrashes to . - Sum. Why? Same additive rule; the point is where the mass went.
Verify: — over worse, driven entirely by the last two terms sitting on the steep left arm of the loss curve in figure s01 ✓.

The bar chart makes the cascade visible: the first three bars barely differ between TF and FR; the last two tower under free running.
Forecast: is the gap additive (a subtraction) or multiplicative (a ratio) — and which is the "honest" number?
- Define the gap. Why? Exposure bias is literally the difference between the distribution the model was trained on (ground-truth history) and the one it faces at test time (own history).
- Plug in. Why? Both numbers are the same network, only the input source differs.
- Per-token view. Why? Absolute gaps grow with ; per-token normalizes so you can compare sequences of different lengths.
Verify: (inference must be at least as hard as training) ✓. The whole gap () equals the extra loss on steps 3–5 only: ✓ — confirming the gap lives entirely where histories diverged.
Forecast: halfway between and ? Guess the exact value.
- Write the expectation. Why? A random coin (the -flip) means the realized loss is a random variable; we report its mean.
- Substitute . Why? This is the curriculum "half-and-half" regime — the model trains on both clean and self-generated histories.
Verify: lies strictly between and ✓. Sanity limits: at formula gives (pure TF), at gives (pure free-run) ✓.
Forecast: true or false — " matters here."
- List the history. Why? Teacher forcing only ever affects the input fed as previous token; here has only the fixed
<START>, which is ground truth by definition. - Compute the loss. Why? One term, no cascade possible.
- Conclude. Why? Since no step ever consumes a predicted previous token, TF and free-run are identical.
Verify: setting or both give ✓. The exposure-bias gap for ✓ — degenerate case behaves as expected (no history to be biased about).
Forecast: roughly , roughly , or "infinite"?
- Evaluate. Why? Just read off the loss curve at a tiny — the steep left arm.
- Take the limit. Why? To see the failure mode of the exact formula.
- The fix. Why? An infinite loss gives infinite gradient and NaNs, so implementations clamp (e.g. ) or add a tiny : .
Verify: and ✓ round-trips. Clamped at : , finite ✓.
Forecast: will the training loss beat Example 1's ?
- Training loss (TF). Why? Encoder gives a fixed context ; each decoder step still gets ground truth as previous token.
- Inference divergence. Why? At test time no truth exists; the decoder feeds its own argmax. If argmax were
You, then at the model conditions onYou, a history it never trained on → possible "You is" nonsense. - Takeaway. Why? This is exactly the train/test mismatch of Cell C, now in a real MT setting.
Verify: ✓ (shorter, more confident sequence). , matching the geometric-mean confidence ✓.
Forecast: epoch , , or ?
- Solve the linear part . Why? The floor kicks in exactly when the decaying line crosses .
- Evaluate at . Why? , so we are still on the decaying line, not the floor.
Verify: at , so — floor just reached ✓. At , line gives but , so it stays floored ✓. ✓.
Recall Quick self-test
With and probs the total loss is? ::: The exposure-bias gap in Ex 3 (inference minus TF) is? ::: Expected step loss at mixing and ? ::: Epoch where first hits the floor? ::: For a sequence, does change the loss? ::: No — there is no predicted history to feed.