04
The derivation sheet
Every symbol, contribution, gradient, and rounding decision for OPD-TOY-001—open on the page.
Pin the symbols before the arithmetic
Epistemic status: invented deterministic teaching fixture. Natural logs; nats; vocabulary [A,B]; temperature 1; two evaluated positions; no explicit EOS.
| Symbol | Meaning | Shape / unit | Local derivative |
|---|---|---|---|
| fixed prompt | token sequence | held fixed | |
| visited prefix occurrence | one context | held fixed | |
| teacher distribution | ; unitless | held fixed | |
| student logits | differentiated | ||
| student distribution | ; unitless | differentiated | |
| local KL scalar | nats | derived | |
| student-output source fraction | [0,1]; unitless | chosen |
- Probability vectors are positive and normalized.
- The categorical
u = 0.8branch is detached. xAis fixed by provenance in the supplied comparison occurrence, not by its text.- Conditioned-path mixtures are not the full response expectation.
- Teacher probabilities are supervision, not a guarantee of truth or process causality.
Reverse KL, line by line
The A contribution is positive and the B contribution negative; KL non-negativity applies to their sum, not each term.
The teacher assigns only 0.1 to B, so the student's 0.4 weight produces the larger positive term.
Round the full-precision mean once. Averaging the displayed six-decimal components produces the tie 0.2210255; decimal round-half-up would show 0.221026 instead.
Forward direction, fixed route, and the expectation you did not sample
| Prefix | Reverse KL q ‖ p | Forward KL p ‖ q | Occurrence used by |
|---|---|---|---|
| x | 0.130812035941137 | 0.143841036225890 | both routes |
| xB | 0.311238679583058 | 0.226289161185359 | realized u = 0.8 student route |
| xA | 0.582685302043240 | 0.534110808710307 | supplied fixed route |
Same realized prefixes, different local direction. The route remains student-generated.
The supplied fixed route [x,xA] has mean reverse KL 0.356748668992188 and mean forward KL 0.338975922468099 nats. Mixing that one route with the realized student route gives a useful six-cell contrast—but not the exact expectation over all student responses.
This hypothetical branch expectation uses xA when the student itself draws A. It is not the contract's fixed u=0.8 sample receipt and still does not model EOS or later draws.
Analytic gradients meet finite differences
| State | Forward | Reverse |
|---|---|---|
| x | [0.25, −0.25] | [0.205989804125271, −0.205989804125271] |
| xB | [−0.3, 0.3] | [−0.430022272614733, 0.430022272614733] |
| xA | [−0.5, 0.5] | [−0.469054366516490, 0.469054366516490] |
Each vector has length two, units “nats per logit,” and sum zero. For the canonical two-state mean, keep state blocks separate:
Do not average gradients componentwise unless another toy deliberately shares one logit vector. A real network passes each block through its state-dependent Jacobian to common parameters.
MATH-LAB-001 perturbs frozen-state logits with central differences, step , and requires absolute error at most with relative tolerance exactly zero. The observed maximum is loaded from the generated receipt and audited separately.
Inspect the JSON receipt (local copy) · Read the independent Python source (local copy) · Read the Markdown sheet (local copy)
Change one coordinate without smuggling in the other
Now the one approved interaction. Predict before touching it: if the trajectory source stays at and only KL direction changes, should the on-policy label move?
toy numbersderived valuessourced separation All outputs use natural logs and report nats.
Static fallback active. Interactive controls require JavaScript. Every source × divergence state remains available in the complete matrix below.
0.0 fixed + 1.0 realized student
D_KL(student || teacher) at a held-fixed prefix
- Supplied fixed [x,xA]
- nats
- Realized student [x,xB]
- nats
- Conditioned-path mixture
- nats
- Local gradient at xB
- nats per logit · [A,B]
0.0 × 0.356748668992188 + 1.0 × 0.221025357762097
λ never selects KL direction. KL direction never changes provenance.
All six states · static fallback and cross-check
| Outer source coefficient | Local DKL(student ‖ teacher) | Local DKL(teacher ‖ student) | Provenance label |
|---|---|---|---|
| λ = 0Fixed route only | 0.356748668992188reverse KL · nats | 0.338975922468099forward KL · nats | fixed |
| λ = 0.5Equal conditioned-path coefficients | 0.288887013377143reverse KL · nats | 0.262020510586862forward KL · nats | mixed |
| λ = 1Realized student route only | 0.221025357762097reverse KL · nats | 0.185065098705625forward KL · nats | student / on-policy at collection |
Invariant 1: moving across columns changes the divergence, not provenance. Invariant 2: moving down rows changes source coefficients, not KL direction. Values mix the supplied fixed route with the realized u = 0.8 student route; they are not the full student-trajectory expectation.
What the gradient preview holds fixed
The prefix xB, teacher vector [0.9,0.1], vocabulary order [A,B], and temperature 1 stay fixed. Only the student logits move. Reverse default: [-0.430022272614733, 0.430022272614733]. Forward: [-0.300000000000000, 0.300000000000000]. Neither vector differentiates through the earlier categorical draw.
The table is not redundant decoration. It is the complete no-script and print path, and it makes every boundary state inspectable at once.