One model reads the answer, then grades its own attempt token by token. On AIME25 (a set of hard maths contest problems), a 1.7B model rises from 36.7 to 43.9 from one 1,024-token rollout per problem.
See how a language model can teach itself to reason: the same weights play a student who sees only the question and a teacher who also sees the worked solution.
Pick who gives the feedback, then slide the slip to a different token. Watch where each method puts its learning signal. Then we build, piece by piece, the divergence, the two prompts, the clipping and the training loop underneath.
You need a rough idea of a probability (a number from 0 to 1 for how likely something is) and what a language model does (it gives every next token a probability). We build the rest from zero.
A reading for Lecture 6 of MIT MAS.S62 How to AI an AI for (Almost) Anything, Model Evolution. Paper: Siyan Zhao, Zhihui Xie, Mengchen Liu, Jing Huang, Guan Pang, Feiyu Chen and Aditya Grover (UCLA, HKU, Meta Superintelligence Labs), arXiv 2601.18734. Code: siyan-zhao/OPSD. Every idea is re-taught here in our own words and devices.
A toy: the student attempts the paper’s Figure 2 problem, the derivative of 3x² + 2x − 5 at x = 2, and slips on one token (0 means no slip). Each token has four candidate next tokens with made-up probabilities; the OPSD bar is the real forward KL, in nats, between the teacher’s and the student’s list. The idea and the Figure 2 problem are the paper’s; the numbers are illustrative.
Chapter 0
See why a student who may read the solution learns faster than one who is only told "wrong", and why that works for a language model
Two students sit the same maths exam. Both get question 7 wrong. The first student gets her paper back with a single mark: 0 out of 1. She does not know which line failed. She tries a fresh attempt, and another, and slowly finds a pattern in the marks.
The second student gets the worked solution. She reads it, then looks at her own page. “My third line went wrong. I wrote 5x where it should be 6x.” She fixes that one habit and moves on. She learned more from one page than the first student learned from ten marks.
Most training of reasoning models today treats the model like the first student. This paper treats it like the second. The surprise is that the second student does not need a better teacher. She uses her own brain, once she has read the answer.
A language model reads text and gives every possible next piece of text, a token, a probability. A reasoning model writes a long chain of such tokens, its working, before it states a final answer. Post-training is the stage after the model has read most of the internet. It teaches the model to reason well on hard problems, such as competition maths.
The paper names three common ways to do this. The first is supervised fine-tuning (SFT): show the model good worked solutions and train it to copy them. The second is reinforcement learning with verifiable rewards (RLVR): let the model attempt problems, check each final answer by program, and reward the attempts that were right. The most used RLVR method is GRPO (group relative policy optimization). The third is knowledge distillation: a large teacher model supervises a smaller student.
Each way has a weakness. Chapter 2 takes them apart one by one. For now, hold on to the two weaknesses of RLVR that the paper stresses.
First, RLVR is expensive. For each problem, GRPO samples a whole group of attempts. Each attempt is a rollout: one full run of the model, from the question to its last token. In the paper’s setup that is 8 rollouts per problem, each allowed up to 16,000 tokens.
Second, the feedback is thin. A single number, the reward, covers the whole rollout. A 5,000-token attempt gets the same 0 whether it failed on token 12 or token 4,990. And if all 8 rollouts in a group fail, or all succeed, the method has nothing to compare, so it learns nothing from that problem.
Training sets already hold the answers. A maths dataset has a question and a worked solution. RLVR uses only the final answer, and only to say right or wrong. SFT uses the solution but only as text to copy. Neither uses it the way the second student did.
The paper’s method is called On-Policy Self-Distillation, or OPSD. Take one model. Make it play two roles. As the student, it sees only the question and writes an attempt. As the teacher, it sees the question and the reference solution, and then reads the student’s attempt. At every token, the teacher says how likely it would have been to write that token. The student is trained to move toward the teacher.
The extra thing the teacher sees is called privileged information: information that exists during training but will not exist when the model is used. The teacher is not a bigger or smarter model. It is the same weights with a longer prompt.
Use the hero above if you have not yet. Compare the two modes on the same slip. The final-answer method colours all ten tokens the same. The teacher method lights up the one token that went wrong. That difference, a signal at every token instead of one for the whole attempt, is what the paper calls a dense signal.
Dense feedback also changes the bill. The next device counts the tokens that each method must generate for one problem. Use the paper’s own settings (Table 6), then try your own.
Two bars show the tokens sampled for one problem under the paper’s GRPO and OPSD settings. The third bar is yours. Move the sliders for your own rollouts and length.
The GRPO and OPSD rows are the paper’s Table 6: 8 generations of up to 16,000 tokens against 1 generation of up to 1,024. These are caps, not averages; real rollouts can be shorter. The teacher’s pass over the student’s tokens is not counted, because it reads tokens instead of writing them (Chapter 3).
Look at the first two bars. GRPO may write up to 128,000 tokens for one problem. OPSD writes at most 1,024. That is about 125 times fewer. The paper’s Figure 3 reports the same trend in practice: at equal training steps, OPSD generates far fewer tokens, yet scores higher.
One honest note before we go on. Fewer tokens generated does not mean fewer tokens processed. The teacher still reads the student’s tokens plus the reference solution. It only does not write anything new. Reading is cheaper than writing, and Chapter 3 shows why.
This lesson follows the paper in the order you would need to rebuild it. Each chapter adds one mechanism, and each one maps to a part of the hero.
Chapter 1
Learn what a next-token list is, then score how far apart two such lists are with the KL divergence
You are writing out a solution: “the derivative of 3x² is 6x, so f′(x) = 6x + …” What comes next? You would write “2” almost every time. Now ask a friend who has not studied calculus. She might say “5”, or “x”, or shrug. You and she hold different beliefs about the same next symbol. This chapter makes that idea exact, because the whole paper is about comparing two such beliefs.
A language model reads a prefix, the text so far, and outputs one number for every token in its vocabulary. The vocabulary V is the fixed set of tokens the model knows. Real vocabularies hold well over a hundred thousand tokens. The output numbers are first raw scores, called logits. A function called softmax turns them into probabilities: it raises e to each score, then divides by the total, so all values land between 0 and 1 and add to 1.
The result is a distribution: a list of probabilities that adds to 1. The paper writes the model’s distribution at position n as p(· | prefix). The dot means “any token”. In data-flow terms, one position gives a vector of shape [V]. A whole answer of N tokens gives a table of shape [N, V]: one distribution per position. Keep that table in mind. The paper’s loss is computed on it.
Two things set this vector: the model’s weights, written θ, and the prefix. Change either and the list changes. In Chapter 3 we will keep θ fixed and change only the prefix. That single trick is OPSD.
How do we score the gap between two lists? Start with surprise. If a model gives a token probability p, seeing that token surprises it by −ln p. A token with p = 1 has zero surprise. A token with p = 0.05 has surprise about 3.0. The unit is the nat, because we use the natural logarithm.
Now suppose the world follows list T (the teacher) but you believe list S (the student). You will meet tokens at T’s rates, and be surprised at S’s prices. Your average surprise is the sum over tokens of T(v) times −ln S(v). A perfect believer, S = T, has a smaller average: the sum of T(v) times −ln T(v). The difference is the extra surprise caused by believing the wrong list. That difference is the KL divergence.
The formula comes straight from the average-surprise difference: T(v)(−ln S(v)) minus T(v)(−ln T(v)) equals T(v) ln(T(v)/S(v)). Three facts follow. The KL is never negative. It is exactly 0 only when the two lists match. And it is not symmetric: swapping T and S gives a different number.
Take five candidate tokens after “f′(x) = 6x +”: “2”, “5”, “x”, “3”, “0”. Say the teacher, who has seen the solution, gives them 0.90, 0.05, 0.03, 0.015, 0.005. A student without the solution gives 0.60, 0.20, 0.10, 0.06, 0.04. The terms of DKL(T ∥ S) are:
0.90 ln(0.90/0.60) = +0.365 0.05 ln(0.05/0.20) = −0.069 0.03 ln(0.03/0.10) = −0.036 0.015 ln(0.015/0.06) = −0.021 0.005 ln(0.005/0.04) = −0.010
The sum is 0.228 nats. Nearly all of it comes from the first token: the student is not confident enough in “2”. The other four terms are small and negative. The student gives too much weight to the wrong tokens, but the teacher barely uses them, so they cost little.
Now swap the roles. DKL(S ∥ T) weights each term by the student’s rates. The wrong tokens, which T makes unlikely, now get weight 0.20, 0.10, 0.06 and 0.04. The sum is 0.321 nats. Same two lists, different number. Play with it below.
The warm bars are the teacher’s fixed list. The blue bars are the student’s. Slide the student’s belief in “2”, then choose how the student spreads the rest. Watch both KL numbers.
Illustrative lists over five tokens, not the model’s real vocabulary. The teacher list (0.90, 0.05, 0.03, 0.015, 0.005) is made up for this lesson. The KL formula is exact, in nats. The worked example in the text uses its own student list (0.60, 0.20, 0.10, 0.06, 0.04), so its numbers differ from this device’s presets.
Try “All on 5” with P(“2”) at 0.60. The student gives “5” about 0.40 and the other three tokens only 0.0001 each. DKL(T ∥ S) is then 0.527 nats, and most of it comes from the starved tokens “x”, “3” and “0”, which the teacher still uses. DKL(S ∥ T) is 0.586 nats, and nearly all of it comes from the 0.40 piled on “5”, which the teacher gives only 0.05. The two directions punish different mistakes. Chapter 4 uses that fact to explain which direction the paper picks.
In the paper, the student’s list is pS(· | x, ŷ<n) and the teacher’s is pT(· | x, y*, ŷ<n). Both are read at the same position n of the same attempt ŷ. The prefix x is the question; y* is the reference solution; ŷ<n is the student’s own tokens so far. That is all the notation you need for the next chapters.
Chapter 2
Compare copying, trial and reward, and teacher feedback, and see exactly what each one throws away
You have a shelf of solved problems. Each one is a question x and a worked solution y*, the reference answer written out step by step. The paper writes the shelf as a dataset S of (x, y*) pairs. In its experiments, run on Qwen3 (an open family of language models, here the 1.7B, 4B and 8B sizes), S is the maths part of the OpenThoughts data, up to 30,000 problems with step-by-step reasoning. The question is how a model should learn from that shelf. Three answers exist before this paper.
Supervised fine-tuning trains the model to write y* given x. At each position n of y*, the model sees the true earlier tokens and must predict the next one. The paper calls this off-policy imitation: the data comes from someone else’s policy, not from the model itself. A policy here just means the way a model chooses its next token.
The trouble is the mismatch. During training the model always reads a perfect prefix. At test time it reads its own prefix, which may hold a slip. It has never practised recovering from its own slips. Small errors then pile up as the answer grows. This is called exposure bias, or distribution mismatch.
A quick feel for the scale, with made-up numbers: if a model slips on 1 token in 100, then over 1,000 tokens the chance of no slip at all is 0.991000, about 0.004%. Long chains nearly always wander off the path that training showed. The paper reports a second harm: the reference solutions are concise, so SFT also shortens the model’s reasoning. In Table 2, SFT lowers the average score of every model, for example Qwen3-8B from 61.8 to 59.8.
Reinforcement learning fixes the mismatch: the model trains on its own attempts. For each problem x, GRPO draws G rollouts o1 to oG. A program checks each final answer against y* and gives reward ri = 1 if right, 0 if wrong. Then it asks, for each rollout, whether it did better than its group:
A worked case with G = 8. Three rollouts are right, five are wrong. The mean is 3/8 = 0.375. The standard deviation, taking the group as the whole population, is the square root of 0.375 × 0.625, which is 0.484. A right rollout gets (1 − 0.375) / 0.484 = +1.29. A wrong one gets (0 − 0.375) / 0.484 = −0.77. The update then raises the probability of every token in the right rollouts and lowers it for every token in the wrong ones. (The paper’s Eq. 4 also clips the update and, in general, can add a KL penalty; the paper’s GRPO run sets that penalty to 0 in Table 6.)
Now the two weaknesses the paper names. One: the same advantage lands on every token. A wrong rollout of 5,000 tokens may have gone wrong at token 40, yet all 5,000 get pushed down. Two: if all 8 rewards match, the standard deviation is 0 and every advantage is 0. The step teaches nothing, although the 8 long rollouts were still paid for. Try it.
Set how often one rollout is right, then press Draw 8 rollouts. Bars show each rollout’s advantage. The curve below shows how often a whole group gives zero signal.
Illustrative: rollouts are treated as independent draws with one shared chance of being right, which real problems only roughly obey. The chance that all 8 match is p⁸ + (1 − p)⁸, exact under that assumption. The paper’s Figure 3 reports that over half of GRPO’s batches had zero reward spread within 100 steps on its setup.
At 50% the curve is almost flat at the bottom: all 8 match in under 1% of groups. At 10% it climbs to 43%. Hard problems, which are the ones a reasoning model most needs to learn, are the ones where almost every rollout fails and nothing is learned. The paper names this the vanishing gradient signal.
There is one more way to get dense feedback inside RL: train a process reward model (PRM), a second model that scores each step of a solution. The paper notes why this is rarely done. Labels for each step are prohibitively expensive and hard to scale, because a person or a strong model must judge every line of every solution. So the usual RLVR recipe keeps the single end-of-answer reward, and its weaknesses stay.
A third line of work, on-policy distillation, keeps the good part of RL (the student trains on its own rollouts) and swaps the sparse reward for dense help. A separate teacher model reads the student’s rollout and gives its next-token list at every position. The student is trained to match those lists on the tokens it actually wrote. The paper writes this as Eq. 3. The weakness is plain: you need a teacher, often a larger one, and it does not use y* at all.
Table 1 of the paper puts the four methods side by side on four properties. A tick means the method has the property.
| Property | SFT / off-policy distillation | GRPO | On-policy distillation | OPSD |
|---|---|---|---|---|
| On-policy data | no | yes | yes | yes |
| Dense learning signal | yes | no | yes | yes |
| Low sampling cost | yes | no | yes | yes |
| No external teacher | yes | yes | no | yes |
OPSD is the only column with every box ticked. Whether that makes it better in practice is what Chapters 7 and 8 test. First we need the mechanism: how can the same model be its own teacher?
Chapter 3
Build the student and the teacher from the same weights by changing only what each one reads, then follow the data through one training example
Picture a tutoring session. A pupil works a problem on a whiteboard, writing line by line. The tutor stands behind her holding the answer key. The tutor does not take the pen. She only watches each line appear and, at each line, thinks: “Given that I know the answer, would I have written that?”
That is the whole mechanism. The only odd part is that pupil and tutor are the same person with the same brain. One of them has the answer key open and one does not.
A language model’s output depends on two things: its weights θ and the text it reads. OPSD keeps θ identical and changes the text. The paper defines both policies from the one model pθ:
The student prompt is the question and an empty answer slot. The teacher prompt is the question, the solution, and a short instruction. The paper’s Figure 2 shows both for the problem “Find the derivative of f(x) = 3x² + 2x − 5 at x = 2”.
Look at the last instruction. It asks the teacher to solve the problem “using your own approach”. The paper explains why: this gives a natural point to start reading the student’s answer. The teacher reads the solution, then begins its own attempt. Instead of letting it write, we put the student’s tokens there.
Only the student generates. Given x, it samples an answer ŷ = (ŷ1, …, ŷN), one token at a time, from pS(· | x). This is the on-policy part: the text being graded is the text the student itself produced, including its slips.
Then both policies score that same text. The paper says the teacher “doesn’t generate tokens” and does its rationalization “implicitly through prefilling”. Prefilling means running the model once over a whole given text. This is the same single pass used to train on any text. The pass returns a next-token list at every position at once.
This is why the teacher is cheap. Writing 1,000 tokens needs 1,000 sequential steps, each waiting for the last. Reading 1,000 given tokens needs one parallel pass. The teacher’s cost is a long input, not a long output.
Now count the shapes. Let Lx be the question length, Ly the solution length, Li the instruction length, and V the vocabulary size. The student pass reads Lx + N token ids. The teacher pass reads Lx + Ly + Li + N. Each pass keeps only the logits at the N answer positions, each of shape [N, V]. At row n, both rows are conditioned on the same student tokens ŷ<n. They differ only in whether y* sits in front. Step through it.
Press Next to move down the six stages. The highlighted stage shows what runs and the shapes involved. Change the student’s length N to see the shapes change.
The stages are the paper’s Figure 1 and Algorithm 1. Lengths are illustrative: question 80 tokens, solution 400, instruction 40; the vocabulary is set to 150,000, a typical size, not the paper’s exact figure. N is capped at 1,024 in the paper’s runs.
Two details matter for implementation. First, the paper’s algorithm fixes the teacher to the initial model, not the one being updated. It reports this stabilises training and acts as a mild brake on drifting away from the start. So the teacher is a frozen copy of the starting model. With LoRA (Chapter 6), switching the new adapter off is one way to get it; the paper does not say how its code does this. Second, the gradient flows only through the student’s logits. The teacher’s list is a fixed target, as if it were a label.
Nothing in training makes the teacher wiser. Its edge comes from the hint. The paper’s bet is that explaining a given answer is easier than finding it, a view it supports by citing earlier work (Naor, 1996; Sun et al., 2024) that evaluation is often easier than generation. A student who reads the solution can see why each step holds, and so can tell when a token in someone else’s attempt leads away from it.
This bet can fail. If the problem is too hard for the model to follow even with the solution beside it, the teacher cannot grade well. The paper lists this as a limit (Chapter 8).
Here is the failure to watch for, as symptom, measurement and fix. The symptom: training runs but the model does not improve. The measurement: the per-token divergence is near zero everywhere, which means the teacher and the student give the same lists. That happens if the solution never reached the teacher’s prompt, for example because a template dropped it. The fix is to print one teacher prompt and check that y* sits in it. A teacher that ignores the hint is just the student again, and the loss has nothing to say.
Chapter 4
Write the training objective, choose which direction of divergence to minimise, and see why the paper picks forward KL
The student has written an attempt. Now we need one number that says how far the student is from the teacher, so that gradient descent can shrink it. A loss is that number: training moves the weights to make it smaller. This chapter builds the loss in three small steps.
At position n of the attempt ŷ, the student gives a list pS(· | x, ŷ<n) and the teacher gives pT(· | x, y*, ŷ<n). Chapter 1 gave a way to score the gap, a divergence D. For the whole attempt, average D over its |ŷ| positions:
Over a batch B of rows the loss is the mean of ℓ. The paper sets the objective as L(θ) = E[ ℓ(x, y*) ] where the attempt ŷ is drawn from the student (Eq. 8). Gradients flow only through pS. The teacher list is a constant target.
Note what the sum does. Each token gets its own term. A slip at token 40 raises the term at position 40 and perhaps a few after it. Positions that were fine add almost nothing. This is the dense credit assignment from the hero, now as an equation.
Why compare entire lists? Because a list says more than a choice. If the student wrote “5” and the teacher gave “5” probability 0.05, we learn “5” was unlikely. The full list also says that “2” had 0.90 and “x” had 0.03. The student learns what to prefer, not only what to avoid. The paper calls this full-vocabulary logit distillation and uses it in all main runs. Chapter 6 compares it with using only the written token.
The paper lets D be forward KL, reverse KL, or a blend called the generalised Jensen-Shannon divergence (JSD) with weight β between 0 and 1:
How does this relate to plain KL? A small check, our own and not in the paper. Write m = pS + β(pT − pS). When β is small, m is almost pS. So DKL(pT ∥ m) is close to DKL(pT ∥ pS), and the second term is a tiny square. Hence JSDβ ≈ β · DKL(pT ∥ pS), forward KL. By the mirror argument, when β is close to 1, JSDβ ≈ (1 − β) · DKL(pS ∥ pT), reverse KL. In between it blends.
The two directions behave differently. Forward KL, DKL(pT ∥ pS), weights each term by the teacher’s rate. It punishes the student hard for giving almost nothing to something the teacher likes. The student learns to cover every option the teacher might take. Reverse KL, DKL(pS ∥ pT), weights by the student’s rate. It punishes the student for putting weight where the teacher puts none. The student learns to commit to one of the teacher’s choices. When the student is too simple to copy the teacher exactly, the difference is visible. Try it.
The warm bars are a teacher with two favourite answers. The student can only make one bell shape. Choose a divergence, then press Fit the student.
Illustrative: twelve ordered options, a teacher made of two bumps (55% near option 3, 45% near option 9), and a student restricted to one bell. The fit is a search over every bell centre and width on a fine grid, so it is the true best bell for each divergence. A real model is not restricted like this; the lesson is only which direction pulls where.
Under forward KL the bell stretches wide and puts 41% of its mass in the gap between the bumps, where the teacher puts 12%. Under reverse KL it sits on one bump. In this toy, JSD at 0.5 lands on the same wide bell as forward KL. Neither shape is wrong; each answers a different question.
Which does the paper choose? It tests them on AIME25 with Qwen3-1.7B (Table 3), all with the same clipping from Chapter 5. Scores are Avg@12 accuracy in percent (the mean accuracy over 12 sampled answers per problem), from a base of 36.7.
| Divergence | Step 50 | Step 100 |
|---|---|---|
| Forward KL | 43.9 | 41.1 |
| Reverse KL | 37.5 | 35.0 |
| JSD (β = 0.5) | 36.9 | 39.0 |
Forward KL wins at both checkpoints, so the paper uses it everywhere after this. Note also that forward KL falls from 43.9 at step 50 to 41.1 at step 100. The paper does not give a reason for that dip; Chapter 7 returns to it when we read how results are chosen.
Chapter 5
Find out why filler words can swamp the maths in the loss, and how a per-token cap fixes it
Imagine a maths tutor who marks every disagreement between herself and the pupil with equal anger. The pupil writes “Okay, so let me think”. The tutor would have written “First, note that”. She spends her whole red pen on those words. The one line where the pupil mis-added two numbers gets a single small tick.
That is the failure this chapter fixes. The loss from Chapter 4 adds up disagreement over all tokens. If the model’s habits for linking words differ between the two prompts, those disagreements can drown out the disagreements about the maths.
The paper sorts tokens into three groups, using keyword lists in its Appendix C. Style tokens are reasoning connectives and hedges, such as “maybe”, “let”, “wait”, “so”, “but”, “however”, “first” and “check”. Math tokens are words such as “prime”, “logarithm”, “equation”, “sum”, “fraction” and “maximum”. Everything else is “other”. Then it measures the mean forward KL, teacher to student, within each group (Table 5, averaged over 10 problems).
One more setting enters here. The Qwen3 models have a thinking mode (TM): on, the model writes a long self-reflective chain of thought before answering; off, it answers directly. The student and the teacher can each use either mode, which gives four pairings. Here are the style and math numbers for each. (The paper also lists “other”; its values lie between 0.08 and 0.29.)
| Student / teacher | 1.7B style | 1.7B math | 4B style | 4B math | 8B style | 8B math |
|---|---|---|---|---|---|---|
| TM-off / TM-off | 0.68 | 0.12 | 0.61 | 0.06 | 0.56 | 0.05 |
| TM-on / TM-off | 0.51 | 0.10 | 0.41 | 0.05 | 0.33 | 0.05 |
| TM-on / TM-on | 0.51 | 0.09 | 0.50 | 0.04 | 0.42 | 0.04 |
| TM-off / TM-on | 0.85 | 0.14 | 0.92 | 0.10 | 0.79 | 0.06 |
Read the table in two passes. Down any column, the last row has the highest math KL for all three sizes: a student in direct mode with a teacher in thinking mode. That is the pairing the paper adopts for every main experiment. Across any row, style KL is far bigger than math KL, by 5 to 13 times. For the chosen row at 1.7B, the ratio is 0.85 to 0.14, about 6 to 1.
Why is style so large? One reading, ours rather than the paper’s: a teacher who has just read a solution is in a different “voice” and so favours different connecting words, even when the maths is not at issue. Those word choices are cheap to disagree on but easy to measure.
The paper keeps the sum but caps each term. First write the divergence as a sum over positions n and vocabulary entries v. For a general f-divergence, the term for one pair is:
A worked case at one position, with made-up numbers. The teacher gives “wait” 0.30 and the student 0.03: ℓ = 0.30 ln(10) = 0.691. The teacher gives the maths token “sum” 0.08 and the student 0.06: ℓ = 0.08 ln(1.33) = 0.023. A cap τ = 0.2 leaves “sum” alone and shrinks “wait” from 0.691 to 0.2. The math term now has a bigger share of what is left. Move the cap and watch.
Each bar is how much one token adds to the loss at a single position. Warm outlines mark style tokens. Slide the cap τ and see how the share of style tokens changes.
Illustrative: six tokens at one position with made-up teacher and student probabilities (wait 0.30 vs 0.03, so 0.25 vs 0.05, let 0.15 vs 0.02, 6x 0.12 vs 0.08, sum 0.08 vs 0.06, prime 0.04 vs 0.03). The contributions are exact forward-KL terms for those numbers. The paper does not state its value of τ and says it did not tune it. Sliding to the far right means no cap.
With no cap, the three style tokens carry 94% of the six-token total. With τ = 0.2 they carry 88%, and with τ = 0.05 they carry 64%. The cap does not erase style. It stops any single token from taking the whole signal.
Why does that matter for training? The paper says OPSD converges within about a hundred steps. A few huge terms early in training can push the weights hard toward changing connecting words. The paper’s Figure 4, for Qwen3-1.7B on AIME24, shows that without clipping performance degrades, and with clipping training stays stable. The paper gives no numbers for this figure in the text, only the finding.
The failure, then, in three parts. The symptom: accuracy degrades as training goes on. The measurement: the Figure 4 curve with no clipping drops while the clipped one holds. The fix: cap every term at τ. What to log in your own run: the mean KL for style, math and other tokens, as in Table 5, and the fraction of terms that hit the cap. If most terms hit the cap, τ is too low and you have thrown away the signal; if none do, the cap is doing nothing.
Chapter 6
Put the pieces together as code, read the paper’s settings, and count what the full-vocabulary loss costs in memory
You now hold every part. This chapter assembles them into the loop that ran the experiments, the way you would write it. First the recipe in words, then the code, then the one engineering question that the code raises: how much memory does a table of logits take?
Algorithm 1 is short. While training has not converged, repeat: take a minibatch of (x, y*) pairs. For each pair, sample one rollout ŷ from the student. Compute the token-wise divergence along that rollout, averaged over its length. Average over the minibatch, take a gradient step on θ. That is all. There is no reward model, no verifier, no group of rollouts, and no second network.
The settings in the paper’s Table 6, for OPSD against GRPO, show the practical difference:
| Setting | GRPO | OPSD |
|---|---|---|
| Learning rate | 5 × 10−6 | 5 × 10−6 |
| Effective batch size | 32 | 32 |
| LoRA rank r / alpha | 64 / 128 | 64 / 128 |
| Max completion length | 16,000 | 1,024 |
| Generations per prompt | 8 | 1 |
| Sampling temperature | 1.2 | 1.1 |
| KL coefficient | 0.0 | not used |
| Training steps | 500 | 100 |
LoRA (low-rank adaptation) trains a small add-on of rank r instead of the whole model: here two small matrices per target layer. The targets are the attention projections (q, k, v, o) and the feed-forward projections (gate, up, down). Everything ran on 8 A100 or H100 GPUs, with the AdamW optimiser, bfloat16 numbers, gradient checkpointing (re-compute to save memory) and Flash Attention 2. For scoring, the paper evaluates in thinking mode at temperature 1.0, top-p 0.95, up to 38,912 new tokens, and reports the mean of 12 samples per problem (Avg@12).
This sketch is our own, written to match the paper’s description. It is not the authors’ code (theirs is at the repository linked in the hero). Read the shape comments: that is the data flow.
pythondef opsd_step(model, batch, tau, max_new=1024): losses = [] for x, y_star in batch: s_ids = tok(student_prompt(x)) # [Lp] question only with torch.no_grad(): y_hat = model.generate(s_ids, max_new_tokens=max_new, temperature=1.1) # [N] the only sampling N = len(y_hat) Lp = len(s_ids) s_logits = model(cat(s_ids, y_hat)).logits[Lp-1 : Lp+N-1] # [N, V] grads ON t_ids = tok(teacher_prompt(x, y_star)) # [Lx+Ly+Li] adds the solution Lt = len(t_ids) with torch.no_grad(), initial_weights(model): # frozen starting policy t_logits = model(cat(t_ids, y_hat)).logits[Lt-1 : Lt+N-1] # [N, V] one pass log_ps = s_logits.log_softmax(-1) # [N, V] log_pt = t_logits.log_softmax(-1) # [N, V] term = log_pt.exp() * (log_pt - log_ps) # l[n, v] = pT * log(pT / pS): forward KL term = term.clamp(max=tau) # pointwise clip (Ch 5) losses.append(term.sum(-1).mean()) # sum over v, mean over n loss = torch.stack(losses).mean() # mean over the batch loss.backward(); optimizer.step(); optimizer.zero_grad()
Three lines carry the idea. generate is the only slow call. The teacher’s forward pass sits under no_grad, so it stores nothing for a backward pass. The line log_pt.exp() * (log_pt - log_ps) is Chapter 1’s KL formula, one entry per position and vocabulary entry.
Look at the shapes: [N, V], twice. The paper warns of this directly: full-vocabulary distillation “incurs higher peak memory usage due to storing vocabulary-sized logits at every position”. A cheaper variant uses only the token the student actually wrote. For each position, take the advantage An = log pT(ŷn) − log pS(ŷn), treat it as a constant, and minimise − the average of An log pS(ŷn). This is Eq. 9. It needs two numbers per position, not two lists. Count the difference.
Two bars on a log scale: the bytes for the student and teacher logit tables, and the bytes for the sampled-token variant. Change the length, the vocabulary size and the number of sequences.
Arithmetic, not a measurement: bytes = tables × B × N × V × 2 for 16-bit numbers. Two tables (student and teacher), and no counting of activations, the softmax copy or optimiser state, so real peaks are higher. The sampled-token variant stores two 16-bit numbers per position. V is an illustrative size, not the paper’s.
At the defaults the full tables take about 2.5 GB. The sampled-token variant takes about 16 KB. The ratio equals V, because each position stores V numbers against one. What does the extra memory buy? The paper compares the two on Qwen3-4B, with a 2,048-token budget and pass@8 as the score (a problem counts as solved if any of 8 sampled answers is right) (Table 4):
| Loss variant | AIME25 | HMMT25 |
|---|---|---|
| Full-vocabulary logit distillation | 84.1 | 60.0 |
| Sampled-token distillation | 82.1 | 57.3 |
The full table wins by 2.0 and 2.7 points. That is a consistent gain, but a modest one, on a single model size. The paper concludes that exposing the full teacher distribution gives richer supervision, at the price of memory. Appendix D adds a useful reading of Eq. 9: it is a policy gradient with a dense reward rn = log pT − log pS at every token. STaR (see the STaR paper lesson) is also a policy gradient, but with a 0 or 1 reward for the whole answer.
Why is the teacher the initial model? Picture the target as a moving goalpost. If the teacher were the current student plus the hint, every update would also move the target, and the two could drift together. A frozen teacher keeps the target still. The paper says this stabilises training and keeps the model near where it started. The cost, our reading rather than the paper’s: the teacher never improves, which may limit how far the student can go.
Why sample at temperature 1.1? A higher temperature spreads the student’s draws, so the rollouts visit more varied prefixes, and the teacher scores them all. The paper gives the number (1.1 for OPSD, 1.2 for GRPO) but does not run an ablation on it, so treat it as a setting that worked, not a finding.
Finally, the memory failure, as symptom, measurement and fix. The symptom: an out-of-memory error at long answers. The measurement: the two tables from the device above, plus the softmax copies, which grow with N and V. The fix, ours and not the paper’s: compute the loss on chunks of positions, so only part of the table exists at one time, or use the sampled-token variant when memory is the limit.
Chapter 7
Read the main results table cell by cell, work out the gaps yourself, and learn which caveats to keep in mind
A results table is a claim with a long list of conditions. Before we read the numbers, we should know what was run. Three models of the Qwen3 family, the instruct-tuned 1.7B, 4B and 8B, were trained on up to 30,000 maths problems with step-by-step solutions (the maths part of OpenThoughts). Three contests test them: AIME 2024, AIME 2025 and HMMT 2025, which are hard high-school competition sets. The score is Avg@12: sample 12 answers per problem at temperature 1.0 with up to 38,912 new tokens, and report the mean accuracy.
Four rows are compared per model. Base is the starting model. SFT copies the solutions, on the same number of samples as OPSD. GRPO is reinforcement learning with the settings from Chapter 6. OPSD is the paper’s method.
| Model and method | AIME24 | AIME25 | HMMT25 | Average |
|---|---|---|---|---|
| Qwen3-8B base | 75.8 | 65.6 | 43.9 | 61.8 |
| + SFT | 72.3 | 64.2 | 42.9 | 59.8 |
| + GRPO | 76.4 | 68.9 | 46.7 | 64.0 |
| + OPSD | 77.8 | 70.8 | 45.8 | 64.8 |
| Qwen3-4B base | 74.9 | 66.4 | 42.2 | 61.2 |
| + SFT | 70.2 | 62.3 | 43.4 | 58.6 |
| + GRPO | 75.6 | 68.1 | 44.4 | 62.7 |
| + OPSD | 76.4 | 68.3 | 46.1 | 63.6 |
| Qwen3-1.7B base | 51.5 | 36.7 | 23.1 | 37.1 |
| + SFT | 48.4 | 36.3 | 22.7 | 35.8 |
| + GRPO | 51.1 | 38.3 | 23.7 | 37.7 |
| + OPSD | 57.2 | 43.9 | 29.2 | 43.4 |
Try the explorer below, then read the four patterns we found.
Choose a model size and a benchmark. Bars show Table 2 exactly. The axis starts above zero so small gaps show; its start is printed in the corner.
Every value is the paper’s Table 2 (Avg@12, temperature 1.0, 38k tokens). Bar lengths are drawn from the printed axis start, not from zero, so compare the numbers, not the visual ratios.
Pattern 1: SFT hurts. It falls below the base model in 8 of the 9 cells, and its average is lower for every model, for example 61.8 to 59.8 at 8B. The paper blames the concise style of the reference solutions: SFT shortens the model’s reasoning at test time.
Pattern 2: OPSD beats the base everywhere. Average gains are +3.0 at 8B, +2.4 at 4B and +6.3 at 1.7B (64.8 against 61.8, 63.6 against 61.2, 43.4 against 37.1). GRPO’s gains over the base are smaller: +2.2, +1.5 and +0.6.
Pattern 3: OPSD is level with or ahead of GRPO, with one exception. It leads in eight of nine cells. The exception is HMMT25 at 8B, where GRPO scores 46.7 against 45.8. The paper’s summary says OPSD matches or exceeds GRPO “in every setting”; the averages support that, but not that one cell. The biggest gap is at 1.7B: 43.4 against 37.7.
Pattern 4: the small model gains most. The paper says nothing more about why. A plain reading: a smaller model has more room to improve, and a larger model might need a harder dataset. That is a guess, not a result.
Figure 3 plots accuracy against gradient steps and against total tokens generated, for Qwen3-1.7B at equal effective batch size. At the same step count, OPSD uses far fewer tokens and scores higher on all benchmarks. Its rightmost panel shows why GRPO stalls: more than half of GRPO’s batches have zero reward spread within 100 steps, so those batches give no gradient. The caps from Chapter 0 (1,024 against 16,000 tokens, 1 against 8 rollouts) give a ceiling of about 125 times fewer sampled tokens per problem.
The setup also gives a size for the training run. 100 steps at a batch of 32 is about 3,200 problems at one rollout each. GRPO's 500 steps is 16,000 problems at 8 rollouts each. These are our products of the paper's settings, not reported figures.
Never trust an average you cannot rebuild. For Qwen3-8B with OPSD, add 77.8, 70.8 and 45.8 and divide by 3: 194.4 / 3 = 64.8, which matches the table. For GRPO, 76.4 + 68.9 + 46.7 = 192.0, and 192.0 / 3 = 64.0. The 0.8 gap between the averages comes from AIME24 (+1.4 for OPSD) and AIME25 (+1.9), partly cancelled by HMMT25 (−0.9). So the 8B average edge is two wins and one loss, and it is small enough that a single hard contest could flip it.
The table is more useful when you read it as a story about failures. GRPO’s failure, as symptom, measurement and fix. The symptom: its score stalls, and at 1.7B it ends at 37.7 against a base of 37.1. The measurement: more than half of its batches have zero reward spread within 100 steps (Figure 3), so those batches give no gradient. The paper also reports a risk of entropy collapse, where the model’s outputs become less varied, and performance can fall in later steps. The fix the paper offers: a dense loss that does not depend on reward spread.
SFT’s failure. The symptom: scores fall below the base in 8 of 9 cells. The measurement: the reference solutions in this data are concise, and the paper says SFT shortens the model’s reasoning at test time. The fix: OPSD uses the same solutions only as a hint in the teacher’s prompt, so the student’s own long style is kept and the solution becomes, in the paper’s words, a dense learning signal through rationalization. The data is the same; the way it is used differs.
Three conditions shape the table. First, the checkpoint choice. For OPSD the paper evaluates every 20 steps up to 100 and reports the best. For GRPO it reports the peak within 500 steps. Both choose the highest of several, which favours the reported number a little, and the text gives no error bars or seed counts. Chapter 4’s Table 3 showed how much a method can move between step 50 and step 100: 43.9 to 41.1.
Second, the dataset. The paper's own diagnosis is that on this OpenThoughts maths data, most GRPO groups have no reward spread. Our guess, not a result: a dataset with more medium-difficulty problems might help GRPO more. Third, scale. Nothing here goes beyond 8 billion parameters. Chapter 8 returns to that.
Chapter 8
Test your guesses against the paper’s ablations, then list what the paper does not show
An ablation removes or swaps one design choice and measures what changes. If the method needs a part, the score drops without it. The paper runs five ablations, and you have already met each in passing. Here we gather them, and you try to predict them first.
Divergence (Chapter 4, Table 3). Forward KL lifts AIME25 for the 1.7B model from 36.7 to 43.9 at step 50. Reverse KL reaches 37.5 and JSD at 0.5 reaches 36.9. Forward KL is kept.
Thinking modes (Chapter 5, Table 5). Four student and teacher pairings were measured on how much KL lands on maths tokens. The pairing of a direct-mode student with a thinking-mode teacher gives the most, so it is kept.
Pointwise clipping (Chapter 5, Figure 4). On the 1.7B model, AIME24 performance degrades without clipping and stays stable with it. The paper calls this important because training converges within about a hundred steps.
Generation length (Figure 5). The student’s answers were capped at 1,024 or 4,096 tokens, on the 1.7B model with full-vocabulary distillation. Longer answers did not give consistent gains on AIME24 or AIME25. The paper explains it this way: as the student’s prefix grows, later tokens become easier for the teacher to predict, so those positions give little signal. It also notes that earlier tokens may act as the key branching points of a reasoning chain. This is a hypothesis, not a measurement; the paper says Lu and Lab (2025) saw a similar effect.
Loss variant (Chapter 6, Table 4). Full-vocabulary beats sampled-token by 2.0 on AIME25 and 2.7 on HMMT25 for the 4B model (84.1 and 60.0, against 82.1 and 57.3), at the cost of memory.
Choose one of four paper results. Make your guess, then see the paper’s numbers.
Pick a question, then pick the option you expect to score higher. The bars stay hidden until you guess.
All numbers are the paper’s: Table 3 (AIME25, Qwen3-1.7B, step 50), Table 4 (AIME25, Qwen3-4B, pass@8), Table 2 (Qwen3-8B average) and Table 5 (Qwen3-1.7B, mean KL on math tokens). Bars start from the printed axis value, not from zero.
Appendix A lists three limits in the authors’ own words. First, scale: experiments stop at 8 billion parameters. The paper leaves open whether the trend holds beyond 8B. Second, no correctness check: the framework does not use whether the student’s final answer is right. Matching the teacher is the only goal. Mixing in a verifiable reward could add a second signal. Third, problem difficulty: if a problem is beyond what the model can understand even with the solution in view, the teacher gives no useful supervision. The authors suggest a curriculum, starting easy and getting harder as the model improves, so that problems stay at the edge of what the model can do.
These are our own, not the paper’s. Each is something the text leaves open.
Take the leakage question. A simple experiment, again ours and not in the paper: train two students, one whose teacher prompt holds the true solution and one whose prompt holds a solution to a different problem. If both gain the same, the hint is not what helps. If only the first gains, the teacher is really using the solution. You would also log the mean divergence per token in each case. A correct hint should concentrate divergence on the student’s slips. A wrong hint should spread it everywhere.
What would count as a failure, in measurable terms? Rising training accuracy with flat or falling test accuracy would suggest the student is matching the phrasing of y* and not its logic. A rising fraction of terms at the cap would say the teacher and student have drifted apart. A falling answer length with falling scores would mirror what the paper saw for SFT.
The related-work section places OPSD among several ideas. Context distillation (Snell et al., 2022) also uses one model as both roles, but it trains on the teacher’s sampled text, which is off-policy. STaR and ReST generate rationales from hints, keep the ones that reach the right answer, and fine-tune on them: hard labels, with a sequence-level signal. In-context editing (Qi et al., 2025) does soft distillation from the student’s samples, but for knowledge editing. The paper also names two concurrent works: SDPO (Hübotter et al., 2026), which uses environment feedback as the privileged information, and SDFT (Shenfeld et al., 2026), which applies on-policy self-distillation to continual learning. Our STaR lesson and on-policy distillation lesson cover two of the parents.
Chapter 9
Keep the numbers, the terms, the checklist and the core code on one page, and find where to read next
You can now rebuild On-Policy Self-Distillation from memory. This page is the part to keep.
Reinforcement learning with verifiable rewards trains a reasoning model on its own attempts, but it samples many long rollouts and gives one number to a whole attempt. Supervised fine-tuning gives dense help, but only on someone else’s text. OPSD takes one model and prompts it twice. The student sees the question and writes one attempt. The teacher, the same weights with the reference solution added to its prompt, reads that attempt in one pass and gives its next-token list at every position. The student is trained to match the teacher on the full vocabulary, using forward KL, with each (position, token) term capped at τ. Gradients pass only through the student. On Qwen3 at three sizes, 100 steps from one 1,024-token rollout per problem matched or beat GRPO on average, and beat SFT everywhere on average.
| What | Number | Where |
|---|---|---|
| Sampling per problem | OPSD 1 × 1,024 tokens; GRPO 8 × 16,000 | Table 6 |
| Training length | OPSD 100 steps; GRPO 500 steps; batch 32 | Table 6 |
| LoRA, learning rate | rank 64, alpha 128; 5 × 10−6 | Table 6 |
| Qwen3-1.7B, average of three benchmarks | base 37.1; GRPO 37.7; OPSD 43.4 | Table 2 |
| Qwen3-4B, average | base 61.2; GRPO 62.7; OPSD 63.6 | Table 2 |
| Qwen3-8B, average | base 61.8; GRPO 64.0; OPSD 64.8 | Table 2 |
| SFT on the same samples | below base on 8 of 9 cells | Table 2 |
| Forward KL vs reverse KL vs JSD, AIME25 step 50 | 43.9 vs 37.5 vs 36.9 (base 36.7) | Table 3 |
| Full-vocabulary vs sampled-token, pass@8 | 84.1 vs 82.1 (AIME25); 60.0 vs 57.3 (HMMT25) | Table 4 |
| Style vs math KL, direct student and thinking teacher, 1.7B | 0.85 vs 0.14 nats | Table 5 |
| GRPO batches with zero reward spread | more than half within 100 steps | Figure 3 |
The whole loss, apart from sampling, in a function of two logit tables. This is our sketch, not the authors’ code.
pythondef opsd_loss(s_logits, t_logits, tau): # s_logits, t_logits: [N, V] at the N answer positions; t_logits has no grad log_ps = s_logits.log_softmax(-1) log_pt = t_logits.log_softmax(-1) l = log_pt.exp() * (log_pt - log_ps) # [N, V] p_T * log(p_T / p_S) return l.clamp(max=tau).sum(-1).mean() # sum over V, mean over N def opsd_loss_sampled(s_logits, t_logits, y_hat): # the cheaper variant (Eq. 9): only the written token, as a policy gradient lp_s = s_logits.log_softmax(-1).gather(-1, y_hat[:, None]).squeeze(-1) # [N] lp_t = t_logits.log_softmax(-1).gather(-1, y_hat[:, None]).squeeze(-1) # [N] adv = (lp_t - lp_s).detach() # constant: no gradient through the advantage return -(adv * lp_s).mean()
This paper is the assigned reading for Lecture 6, Model Evolution. In our reading, it shows one concrete way a model’s weights can change using nothing but its own judgement plus data you already own. For the same course, TTRL removes the answer key altogether and uses a majority vote as the reward, and Lecture 7 carries on with reinforcement learning in practice.
All the ideas in this lesson are the work of Siyan Zhao, Zhihui Xie, Mengchen Liu, Jing Huang, Guan Pang, Feiyu Chen and Aditya Grover (UCLA, HKU and Meta Superintelligence Labs). Read the original at arxiv.org/abs/2601.18734; their code is at github.com/siyan-zhao/OPSD. We re-taught it in our own words and toys, and marked every illustrative number as such. Where we made a derivation or a guess of our own, the text says so.
Try the Present studio or Teach to explain the idea back in your own words. Then go back to the hero and slide the slip again: you now know what lights up the bar, and why the other method cannot.