02
Where the measure lives
A sampled trajectory induces the prefix states. The local loss arrives only after those states exist.
Turn trajectories into a distribution over visited prefixes
The autoregressive product tells us how a response is generated. To expose the measure beneath the loss, we need one more object: the distribution over prefixes induced by a response source.
Let be any distribution over prompt–response pairs. Its normalized prefix occupancy is
Sample a sequence from , give each of its visited positions weight , then ask how much mass lands on state .
length boundary This preserves GKD's per-sequence mean. Pooling all tokens across variable-length sequences would weight long responses more heavily. The toy fixes two evaluated positions and does not define a universal EOS rule.
Do not let five operations collapse into one verb
“Distill on student outputs” compresses an entire computation. Expanding it reveals where the source measure stops and the local derivative starts.
- 01SampleStudent emits a response token. The draw is discrete.
- 02VisitThe emitted token becomes part of the next prefix.
- 03EvaluateTeacher and student are queried at that same prefix.
- 04CompareA chosen local divergence returns a scalar in nats.
- 05UpdateDifferentiate local student logits; the sampled path stays fixed.
The separation is useful even if the real implementation fuses teacher and student forward passes. Conceptually, collection decides which states exist in the batch; the local loss decides how probability mass is compared at each state.
The toy makes one branch reproducible
OPD-TOY-001 At prefix x, the student distribution is [0.75, 0.25] in vocabulary order [A,B]. The contract supplies a uniform value of 0.8, so inverse-CDF sampling selects B and the next visited prefix is xB.
| Token | Student interval at x | This fixture |
|---|---|---|
| A | [0, 0.75) | not selected by u = 0.8 |
| B | [0.75, 1) | selected → xB |
xA occurrence as the off-policy comparison. That label belongs to how this occurrence was collected—not to the characters “xA.”The draw is fixed so we can audit every later number. It is still a sample realization, not the exact expectation over all student responses. At the same time, the displayed xA comparison should not be treated as intrinsically off-policy: another student draw could reach the same string.
Now place a divergence on the selected path
For each state on the selected response, query teacher and student at that identical context. GKD's token-distribution reduction is
The response selects the states. The symbol then compares two full next-token distributions at each one and returns a scalar.
The author manuscript's Eq. 2 uses exactly this position-average structure. It does not force to be reverse KL.
Cross the source measure with the local choice
Write for a fixed prompt–response distribution and for a behavior-policy snapshot. At collection, may equal the current student. During the canonical GKD-style update, the sampled response is held fixed:
is unitless and controls the expected contribution of student-generated output data. It does not occur inside the definition of forward or reverse KL.
| λ | Output source | Careful reading |
|---|---|---|
| 0 | fixed / supervised | Not automatically SeqKD: fixed Y may be ground truth or teacher-generated, and the local objective is declared separately. |
| 0.5 | mixed | Equal expected source weight. Algorithm 1 chooses a source for a batch, so a finite batch history need not contain an exact half. |
| 1 | student-generated | On-policy for the fresh behavior policy at collection; prompts still come from X. |
The paper evaluates these three settings and crosses them with forward KL, reverse KL, and several JSD coefficients. See §4, “GKD Variants.”
Detach the path, not the local student
Agarwal et al. state after Eq. 4 that they do not backpropagate through the student sampling distribution. In the toy, that means the 0.8 → B → xB branch is frozen during the update. It does not mean the student distribution at xB is constant.
prompt ; realized prefixes; teacher probabilities; vocabulary alignment; temperature; categorical outcome
student logits ; then student parameters through each state's network Jacobian
The next chapter performs precisely that fixed-state derivative.