Model Evolution 1

A model learns from a copy, a score or a critic. Let it write one wrong answer. The copy never sees the mistake, the score hides it, and the teacher marks the exact token.

Learn how a model changes its own weights: reinforcement learning, distillation and training at test time, and why some updates make a model forget what it knew.

Pick a teacher, then drag the slider to move the mistake along the attempt. Watch how much each teacher can tell the student about it. Then we build, piece by piece, everything underneath: policy gradients, PPO, human feedback, GRPO, test-time learning, distillation and forgetting.

You need a rough idea of what a probability is (a number from 0 to 1 that says how likely something is) and what a language model does (it writes one word at a time). We build the rest from zero.

Based on Lecture 6 and the guest lecture of MIT MAS.S62 How to AI an AI for (Almost) Anything (Fall 2026, Week 7, Model Evolution 1), taught by Paul Liang of the MIT Multisensory Intelligence group, with a guest lecture by Idan Shenfeld. Lecture slides (PDF). Every idea is re-taught here in our own words and devices.

Grade one attempt three ways

4

The task is the toy problem “find the roots of x² − 9” (the guest lecture’s own example), cut into eight tokens. The three feedback styles are the lecture’s comparison table: SFT copies the teacher’s solution token by token, RL gets one score from the environment, distillation gets a grade on every token. The per-token gaps in nats (a unit of surprise) are illustrative, not measured. Slide 39.

Chapter 0

Why a Model Must Keep Learning

See why changing the weights is the deepest way to improve an AI, and meet the three signals that can drive the change

You deploy a coding assistant on Monday. By Friday it has made the same kind of mistake forty times, in the same project, for the same team. You told it the fix each time. On Monday morning it knows nothing about any of that.

The assistant is not broken. It simply does not learn from its day. Every chat starts from the same frozen model. The weeks before this lecture in the course covered the ways to work around that: better prompts, better memory, better tools, a better harness (the code that wraps the model and feeds it text). This week goes one level deeper. It changes the model itself.

Intelligence as the speed of learning

The guest lecture opens with a view of intelligence. Do not define it by what a system can do today. Define it by how well it can learn. Three reasons make this matter for AI built now.

The first is personalization: a system that adapts to each person’s tastes. The second is specialization: to solve a hard problem, a system must absorb the papers, the context and the domain knowledge around it. The third is the next scaling frontier. The slide says deployed AI now processes more than 300 trillion tokens per day, roughly a web-scale training corpus every day. That is a flood of experience, and today almost none of it changes the model.

Two ways to keep learning

The guest lecture sorts every answer into two families. Memory-based approaches leave the weights alone and change what the model can read. The slide lists in-context learning (examples and notes placed in the prompt), external memory, retrieval (RAG), recurrent networks and state-space models, and the harness. The slide calls this family established but limited.

Parameter-update approaches change the weights themselves: fine-tuning, adapters (small trained add-ons), model editing and merging, and new algorithms. The slide calls this family open research. The rest of this lesson lives there. The weights are where a lesson can last, so an update is worth more than a note, if it can be done safely.

The lecture roadmap: three methods for reasoning

Lecture 6 narrows the question. A model reads an input, writes some reasoning steps, then writes an output. How can we make the steps better? The slide gives three methods.

  1. Direct prompting, no training. Ask the model to think step by step (chain of thought, or CoT). The weights do not change.
  2. Supervised fine-tuning (SFT). Train the model to copy example solutions. This assumes you already have reasoning traces: written-out solutions.
  3. Reinforcement learning (RL). This is the focus of the day. It assumes no traces, but it does need a reward function: a rule that scores the reasoning and the answer.

The lecture then adds two more ideas on top of these. Distillation learns from a teacher that grades each token. Test-time training keeps learning while the model is in use. The slide ends on one picture that holds the whole day: the type of feedback on one axis, the update algorithm on another, and what is updated (all the weights, or a small adapter) on a third. Chapter 11 returns to it.

Logistics, in one paragraph: Homework 2, on harness evolution, is due two weeks after the lecture, and the project midterm report and presentation are on October 28. The slide asks for processed datasets, baselines, error analysis and a better idea, and it asks you to keep reading papers for ideas at the same time.

Match the signal to the method

Each method needs a different raw material. That is the cheapest way to remember them: ask what you actually hold in your hands. Pick a situation below and see which method it fits.

What do you hold?

Each button is a situation. The matching row lights up and says what that method needs. Try all five.

A teaching map, not a rule: real projects mix methods, and the lecture’s own table of feedback types (Chapter 11) is richer. The five methods and what each needs follow slides 4, 37 to 40 of Lecture 6.

Notice the order of the rows. Each row asks for something harder to get than the one above it, and gives back something richer. A prompt is free but changes nothing. Worked solutions are costly, because someone must write them. A checker is cheap to run, but it gives only one number. A teacher that grades every token is the richest signal. A hint lets a model act as its own teacher, which is the last idea of the lecture.

The road

The lecture follows the history of the field, and so does this lesson. We start with RL, because the other two methods are best understood against it. Each chapter ends with a quiz.

  1. RL from zero: policy, reward, return, and why copying experts is not enough.
  2. The policy gradient: Pong from pixels, REINFORCE and the baseline.
  3. Critics and PPO: the advantage, and updates kept small.
  4. Human feedback: the reward model, the pipeline, and DPO.
  5. GRPO and DeepSeek-R1: a baseline from a group, and rewards from rules.
  6. What RL buys and breaks: pass@k, reward hacking, and the R1-Zero critique.
  7. Learning at test time: majority-vote rewards, self-rewarding models, test-time training.
  8. Distillation: a teacher that grades every token, and why on-policy matters.
  9. Forgetting and RL’s Razor: why some updates erase old skills.
  10. Self-distillation: a model that teaches itself from a hint.
  11. The whole lecture on one page: numbers, code and what comes next.
You have no written solutions, but you can run a program that says whether a final answer is right. Which method from the roadmap fits?

Chapter 1

Reinforcement Learning From Zero

Turn a game of trial and reward into five plain parts, and see why copying an expert is not enough

You are teaching a puppy to fetch. You cannot explain the steps. You cannot move its legs for it. You can only watch what it does, and then give a treat or give nothing. After many tries the puppy works out which actions lead to treats.

That is reinforcement learning (RL): learning from trial and a reward, with no teacher who shows the right move. The learner is the agent. The thing it acts upon is the environment. A treat is a reward, a number the environment hands back after an action. Everything in this lecture, from game bots to the chatbots you use, rests on this loop.

The five parts of the loop

The lecture writes the loop as a Markov decision process (MDP). The name is heavy. The idea is light. It lists the pieces you need before a learner can start.

  1. States S. Everything the agent can know about the situation right now. A chess board is a state.
  2. Actions A. The moves it may make. In chess, the legal moves.
  3. Transition P(s′ | s, a). The chance of landing in state s′ after action a in state s. In chess against a fixed opponent, this is the opponent’s reply.
  4. Reward r(s, a, s′). The score for that step. Often it is zero until the very end.
  5. Start state s0, discount γ, horizon H. Where the game begins, how much a later reward is worth, and how many steps it may last.

The learner needs one more thing, and it is the thing we train. A policy, written π(a | s), is the rule that picks an action in each state. It gives every action a probability. The policy is the agent’s whole behavior in one function.

Return and the goal

One reward tells you little. What matters is the total over a whole game. The return adds up the rewards along the way, but it weighs a later reward a little less. The discount γ (gamma, a number between 0 and 1) sets how much less: a reward t steps away counts γt times its size.

G(τ)
The return of one trajectory τ (tau): the full list of states, actions and rewards from one game.
∑t=0H
Add up the terms from the first step (t = 0) to the last (t = H, the horizon).
γt
The discount. With γ = 0.9, a reward ten steps away counts 0.910 = 0.35 of its size.
rt
The reward the environment gives at step t.
π* = argmax E[G]
The goal: find the policy π that makes the expected (average) return as large as possible. “argmax” means “the choice that gives the largest value”.

Take a short example. A game lasts three steps. The rewards are 0, 0 and 1, and γ = 0.5. Step by step: 0 × 1 = 0, then 0 × 0.5 = 0, then 1 × 0.25 = 0.25. The return is 0.25. If the single reward arrived one step sooner, the return would be 0.5. Sooner is worth more, and γ sets by how much.

A language model is a policy

Now put a language model into the loop. This mapping is the key to the whole lesson, so it is worth taking slowly.

The state is the prompt plus every token written so far. It is a list of integers, one per token, so its shape is [t] and grows by one each step. The action is the next token, one choice from the V entries of the vocabulary. The policy is the model itself: it takes the state and returns a probability for each of the V tokens, shape [V]. The transition is trivial and fully known: the chosen token is simply appended. An episode ends when the model writes its end-of-text token. The reward usually comes only at that last step: a score for the whole response.

This last point is the source of the hardest problem in the lecture. Suppose the model writes 400 tokens and then a checker says “correct”. Which of the 400 choices deserves the credit? The treat arrives at the end, and the puppy must work out which of its many moves earned it. This is the credit assignment problem. Try it below.

Hand out the credit

A response has eight tokens. The checker gives its score after the last token. Each bar is the return seen by one token. Drag γ, then flip the verdict.

0.90

Illustrative: one reward of +1 or −1 after token 8, and the return of token t is γ to the power (8 − t). Language-model training often sets γ = 1, so every token gets the same return, which is the case at the right end of the slider.

Slide the discount to 1. Every bar becomes the same height. All eight tokens get the full verdict, the careful ones and the careless ones alike. At γ = 0.9 the first token sees only 0.48 of the reward, and the last sees all of it. A lower γ gives a rough guess at who deserves credit: the closer to the reward, the more credit. It is a guess, not a measurement. The next chapters give better answers.

Why not just copy an expert?

You may ask why we need a reward at all. If we have an expert, record what the expert does and train the model to predict it. The lecture calls this imitation learning: collect expert trajectories (a human driver, a video of a demonstration) and run ordinary supervised learning to predict the expert’s action. It is simple, and the slide lists three problems.

  1. Distribution mismatch. The learner trains on states the expert visited. Once deployed, it visits its own states, which look different.
  2. Hard to recover from suboptimal states. The expert rarely drifts off the road, so the data holds no example of getting back on it.
  3. Expert trajectories are not always available. Nobody can write out the best move for every situation, and for new problems there is no expert at all.

A driver who trained only on perfect driving is the picture to keep. The first time a wheel slips onto the grass, nothing it has seen says what to do. Chapter 8 returns to the first two problems, because they are exactly what goes wrong when a student model learns by copying a teacher.

The failure mode: one score for everything

The symptom: training runs, rewards go up a little, then the model stops improving, although many of its answers are close to right. The measurement: look at the return each token receives. In a long response with a single final reward, every token gets almost the same number. The good steps and the bad steps move together. The fix is to measure each choice against what was expected, so that only the surprising parts of a response get pushed. That idea is the baseline of Chapter 2 and the critic of Chapter 3.

A language model writes 400 tokens and a checker gives one score at the end. Why is learning from this score hard?

Chapter 2

The Policy Gradient

Learn to play Pong with no labels: replay what you did, push up the moves that won, and push down the ones that lost

Picture a network that plays Pong. Each frame of the game is an image. The network looks at it and answers one question: move the paddle up or down? Its only feedback is the score. It sees +1 when it scores a point and −1 when the other side does. The lecture asks the natural question: can we train a network with this?

Compare it with an easy problem first. Suppose a coach had labelled every frame with the right move. Then you would use ordinary supervised learning: for each frame xi and its label yi, make the network’s probability of that label as large as possible. The standard tool is to maximize the sum of log p(yi | xi), the “log likelihood”. The slide states the catch in one line: we do not have the labels.

Act first, then label your own moves

The trick is to make the labels yourself, from your own play. Let the network play, following its current policy (the rule that picks a move). Run three games. The network makes thousands of up-or-down choices in each. At the end, game 1 was a win, and games 2 and 3 were losses.

Now treat each game’s moves as if they were labels. After a win, the moves it made look like good labels. So maximize log p of those moves, as in supervised learning. After a loss, do the opposite: maximize minus one times the log p. That pushes the probability of those moves down. In the slide’s colors, a win gives a green block of arrows to copy, and a loss gives red blocks of arrows to avoid.

Write the outcome as a number ri (+1 for a win, −1 for a loss) and both cases become one formula. The lecture’s general case is to maximize the sum over moves of ri times log p(yi | xi). This is the policy gradient, and the algorithm built on it is called REINFORCE.

∇θ J(θ)
The direction in which to nudge the weights θ (theta) to raise the expected return J. A gradient is a list of slopes, one per weight.
∑t
Add up over every step of the game.
r(τ)
The reward of the whole game τ: +1 for a win, −1 for a loss. The same number weights every move in that game.
∇θ log πθ(at | st)
The direction that makes the move at more likely in state st.

The slide gives the reading in two lines. If r(τ) is positive, increase the probability of the moves taken. If r(τ) is negative, decrease it. That is the whole algorithm: play, score, then raise or lower the likelihood of what you did.

The lecture also shows REINFORCE with ε-greedy exploration (epsilon-greedy). Early on the policy is poor, so the agent should often try random moves. As the policy improves, it samples more from the policy and explores less.

One step by hand

Take the simplest policy: a single number θ (theta), where the probability of “up” is p = 1 / (1 + e−θ). Start at θ = 0, so p = 0.50. For this policy the direction that raises log p(up) is exactly (1 − p) = 0.50. Let the step size be 0.5.

The agent plays “up” and wins, so r = +1. The change is 0.5 × (+1) × 0.50 = +0.25, and θ becomes 0.25. Now p = 1 / (1 + e−0.25) = 0.562. One win moved “up” from 50% to 56.2%. Had it lost, the change would be −0.25 and p would fall to 43.8%. Each real network does this to millions of weights at once, but the arithmetic is the same.

Too noisy to trust

The slide ends on a warning: this suffers from high variance. Variance means the answer swings from one batch to the next. A win might have come from luck, from the opponent’s mistake, or from one great move among a thousand ordinary ones. REINFORCE credits all the moves alike. Run it twice with different random luck and the two runs can end up in different places. Try it.

Run eight games of luck

A policy chooses “up” or “down”. Up wins 70% of the time and down wins 40%. Each line is one run of REINFORCE showing how often it picks up. Drag the number of games, switch the baseline on, and compare how far apart the eight lines end.

60

Toy problem, exact math: p(up) = 1 / (1 + e−θ), reward 1 for a win and 0 for a loss, step size 1, so the update is θ += (r − b) × ((1 if the move was up, else 0) − p). The baseline b is a moving average of past rewards, as the slide suggests, starting at 0.5. Both modes use the same random draws. Slides 9 to 17.

Watch the lines. Without a baseline, some runs shoot up fast and others sink toward the wrong move. A run can lock itself onto “down”: it plays down, down wins 40% of the time, and each of those wins pushes “down” up again. The reward is never negative, so every win reinforces whatever was just played.

Compare with what you expected

The lecture’s cure starts from one sentence: the raw reward may not be very meaningful. What matters is whether a reward is higher or lower than what you expect. A win in a game you nearly always win says little. A win in a game you nearly always lose says a great deal.

So subtract a baseline b, your expected reward, and push by the difference. The formula becomes (r(τ) − b) in place of r(τ). The lecture suggests the simplest baseline: an exponential moving average of the rewards seen so far. A move now earns a push up only if the result beat the average, and a push down if it fell short. Switch the baseline on in the device and compare how the eight lines end.

The baseline does not bias the answer. On average it pushes in the same direction. It only removes the noise that every game shares, as when a bathroom scale reads 2 kg heavy for everyone and you subtract the 2 kg. The signal stays, and the variance shrinks.

Data flow of one training step

For a language model the same step is a few lines. A batch of B responses, each T tokens long, gives token ids of shape [B, T]. The model returns log-probabilities for the chosen tokens, shape [B, T]. A checker returns one reward per response, shape [B]. Subtract the batch’s average reward from each reward to get the advantage, shape [B]. Multiply, sum, and call backward. The loss is minus the mean of (advantage × log-probability). The minus sign is there because optimizers minimize, and we want to maximize.

The failure mode in one line: the symptom is runs that learn at wildly different speeds. The measurement is the spread of final results across random seeds, the quantity the device reads out. The fix is a baseline now, and a learned one in Chapter 3. The policy gradients lesson derives the log-derivative trick behind the formula in full.

Why does subtracting a baseline from the reward help REINFORCE?

Chapter 3

Critics, Advantages and PPO

Grade each move against a learned expectation, then take only small, safe steps

You get 72 on an exam. Is that good? If the class average was 50, yes. If it was 90, no. A raw score means little without an expectation. The baseline of Chapter 2 was a crude version of this idea, one average for the whole game. The lecture now makes it sharper: the expectation should depend on where you are.

Two value functions

The slide defines two questions a model can answer, both about future reward. Q(s, a) asks: if I take action a from state s, how much total reward should I expect? V(s) asks: how much total reward should I expect from state s at all, before I choose?

Take a chess position. V is how good the position is for you, on average. Q is how good it is after one particular move. If Q for your move is higher than V for the position, the move beat the average. The lecture calls the gap the advantage.

A(s, a)
The advantage: how much better action a is than the average action in state s. Large and positive means “we are happy”. Small or negative means “we are unhappy”.
Q(s, a)
The expected total reward if you take action a in state s and then play on.
V(s)
The expected total reward from state s, averaged over what the policy would do.

Now the policy gradient uses A in place of the raw reward. The estimator is the sum of (Q(st, at) − V(st)) times the gradient of log π(at | st). A move is pushed up only if it was better than the position’s average, and pushed down if it was worse. This is the baseline idea with a baseline that knows the state.

Actor and critic

Who computes V? A second network. The lecture calls the pair actor-critic. The actor is the policy: it decides what to do. The critic is a value network: it judges how good a state or an action is. The slide’s picture shows a game-playing network with one shared body and two heads, a policy head and a value head (from the A3C paper, Mnih et al., ICML 2016).

The data flow is simple. For each state, the critic returns one number V(s), shape [1]. It trains like a regression: its target is the return that actually followed, and its loss is the squared gap. The actor then uses the critic’s numbers to compute advantages. The two models improve together, each one a little behind the other.

Why small steps

There is one more danger. The policy gradient says which way to move, but not how far. Step too far on a noisy batch and the policy can jump to a place where it plays badly. Then the next batch comes from that bad policy, and the damage compounds. The lecture names two fixes from the same author, John Schulman.

  1. Trust region policy optimization (TRPO, 2015). Limit the KL divergence between the new and old policy. KL divergence is a distance for probability distributions: zero when they match, larger as they differ.
  2. Proximal policy optimization (PPO, 2017). A cheaper way to get the same effect: clip the update, so that a move cannot change its probability by too much in one go.

The slide pictures a hiker on a mountain path. The trust region is the small circle around the current point. You may move inside it and no farther. The rule in one line: restrict each update to be small, and training stays stable.

The clipped objective

PPO compares the new policy to the old one with a ratio: the new probability of the action divided by the old probability. When nothing has changed, the ratio is 1. The objective takes the smaller of two terms.

LCLIP(θ)
The score we climb. Higher is better.
Et
The average over the steps in a batch.
rt(θ)
The ratio πθ(at | st) / πold(at | st). The slide notes that at θ = θold it equals 1.
At
The advantage from the critic.
clip(r, 1−ε, 1+ε)
Force the ratio to stay between 1 − ε and 1 + ε. The PPO paper uses ε = 0.2, so the ratio is held between 0.8 and 1.2.

Work two cases with ε = 0.2. A move had probability 0.30 and now has 0.42, so r = 0.42 / 0.30 = 1.4.

Case one: the advantage is +1, a good move. The two terms are 1.4 × 1 = 1.4 and clip(1.4) × 1 = 1.2 × 1 = 1.2. The minimum is 1.2. Past r = 1.2 the objective stops growing, so its gradient is zero. The policy has already raised this move enough, and there is nothing more to gain by raising it more.

Case two: the advantage is −1, a bad move whose probability rose. The terms are 1.4 × (−1) = −1.4 and 1.2 × (−1) = −1.2. The minimum is −1.4. The clip does not help here. The full penalty stays, and the gradient pushes the probability back down. The min makes the objective pessimistic: it never rewards the policy for going too far, and never lets it off for a mistake. Drag the ratio and see both cases.

Clip the update

The dashed line is the plain objective, ratio times advantage. The solid line is PPO’s clipped objective. The dot is your ratio. Choose a good or a bad move, then drag the ratio across the clip edges.

1.40
0.20

Exact formula, advantage fixed at +1 or −1 for clarity. The default ε = 0.2 is the value used in the PPO paper (Schulman et al., 2017). Slide 20.

The failure mode: the symptom is a reward curve that climbs, then falls off a cliff. The measurement is the ratio, or the KL to the old policy, drifting far from its start. The fix is the clip, a smaller learning rate, or a penalty on KL. PPO is the engine behind the human-feedback pipeline in Chapter 4. The RL algorithms lesson covers the family in more depth.

With ε = 0.2, a move has advantage +1 and its probability ratio is 1.4. What does the PPO objective do?

Chapter 4

Human Feedback and the Reward Model

Teach a model what people prefer when no one can write down the perfect answer

Ask a model for a short note about Cambridge. It writes two versions. One says Cambridge is a historic city in Cambridgeshire, England, on the River Cam, about 55 miles north of London, and gives its population. The other says it is a tiny village in northern England with no historical significance. You do not need to write the perfect note to see which is better. You can compare them in a second.

That is the gap this chapter fills. Chapters 1 to 3 assumed a reward function, a program that scores an output. For “write a good answer” there is no such program. But people can rank answers. The lecture’s method turns those rankings into a reward.

The five steps

The slide calls the method reinforcement learning from human feedback (RLHF), after Christiano et al. (NeurIPS 2017). It has five steps.

  1. Step 0. Pretrain the language model, then fine-tune it on examples (SFT). This gives a model that can write sensible answers.
  2. Step 1. For each prompt, treat the model as a policy and sample several responses.
  3. Step 2. Humans rank those responses by quality.
  4. Step 3. Train a reward model to predict the human ranking, given a full response.
  5. Step 4. Use RL (PPO, or GRPO from Chapter 5) to fine-tune the model to maximize the reward model’s score.

The reward model is the trick. Humans cannot write a gold answer for every prompt, and they cannot rate every training sample. So we train a model to stand in for them. Once trained, it scores any response in milliseconds.

Why compare, not rate

You might ask people to give each answer a score from 1 to 10. The lecture says why that fails: human preferences are noisy and uncalibrated. One person’s 7 is another’s 4. A person may rate the same answer differently tomorrow. Comparisons are steadier. Almost everyone agrees which of two answers is better, even when they would disagree on its number.

So the training data is a set of pairs: a winner and a loser for the same prompt. The reward model gives each response a single number r̂, the reward. Then it turns the two numbers into a probability that the first response wins. The lecture’s formula is the standard one for this, a softmax over the two scores (it turns any two numbers into two chances that add to 1).

P[σ1 ≻ σ2]
The probability that response σ1 is preferred over response σ2. The symbol ≻ reads “is preferred to”.
exp r̂(σ1)
e raised to the reward score of response 1. This makes any score, even a negative one, a positive number.
exp r̂(σ1) + exp r̂(σ2)
The total of both. Dividing by it makes the two probabilities add to 1.

The slide gives the Cambridge example numbers: the historic-city note scores 8.0, and the tiny-village note scores 1.2. The gap is 6.8. The probability is 1 / (1 + e−6.8) = 1 / (1 + 0.0011) = 0.9989. The model says the good note wins 99.89% of the time. To train it, we minimize the minus log of the winner’s probability: −ln(0.9989) = 0.0011. If the model had ranked them the wrong way round, the loss would be 6.8 or more, and the update would be large.

Train a reward model

Two responses have reward scores. The curve turns their gap into the chance that A wins. Say who the human preferred, then press Train one step and watch the scores move apart.

1.2
8.0

The scores 8.0 and 1.2 are the lecture’s Cambridge example (slide 23); here they start the wrong way round for the human’s pick. The loss is −ln of the winner’s probability. A training step moves each score by (1 − p) × 1.0, the exact gradient of that loss for a step size of 1.

Start the device as it opens: the human prefers A, but the model scores B far higher. The probability that A wins is near zero and the loss is large. Each step moves the scores most when the model is most wrong, and less as it gets it right. That is the gradient of the loss: a surprise-sized push.

The RL part: PPO with three models

Step 4 runs the actor-critic machinery of Chapter 3 with three models. The actor is the language model from step 0. The reward model is trained and then frozen. It reads a full response and returns one number. The critic is a value network, still learning. It reads a partial response and predicts V(s), how good the state is so far.

One training round, from the slide, in data-flow terms:

  1. Generate. The actor writes B responses of up to T tokens. Shape [B, T].
  2. Score. The reward model gives each full response one reward. Shape [B].
  3. Compute advantages. The critic’s values, shape [B, T], turn the final reward into a per-token advantage A(s, a) = Q(s, a) − V(s). Shape [B, T].
  4. Optimize the policy. Update the actor with the PPO objective: a KL term plus the clip, to penalize large changes.
  5. Update the value. Train the critic to predict values better on partial responses.

The KL term has a second job. It keeps the model close to its SFT starting point, so that it cannot drift into strange text that merely fools the reward model. We return to that danger in Chapter 6.

DPO: skip the reward model and the RL

The pipeline is heavy: up to four models in memory (the actor, the reward model, the critic and a frozen copy of the starting model for the KL term) and a tricky loop. Direct preference optimization (DPO, Rafailov et al., NeurIPS 2023) asks whether we can skip it. The slide is blunt: DPO is not actually doing reinforcement learning. It does not infer rewards from the preference data. It directly increases the likelihood of preferred responses and decreases the likelihood of the others.

It is closer to supervised learning, which the lecture also calls offline preference optimization. “Offline” means the responses were written ahead of time, not by the model as it trains. The paper’s loss compares how much the model has raised the winner against a frozen reference copy, and how much it has raised the loser: it asks the model to raise the winner more.

The failure mode of the whole pipeline: the symptom is answers that score higher and higher but read worse. The measurement is the gap between the reward model’s score and fresh human ratings. The fix is the KL leash, fresh comparisons from the current model, or, as in Chapter 5, a score that a program can check. The reward and alignment lesson goes deeper into reward models.

In RLHF, why do we train a reward model from rankings instead of asking humans to score every training sample?

Chapter 5

GRPO and DeepSeek-R1

Grade each answer against its own classmates, and let a program do the grading

A teacher sets one hard question and eight students answer. How should she decide who did well? One way hires a second teacher, a critic, who has watched many classes and knows what a typical answer scores. That is PPO’s critic, and it is costly: the critic is a whole extra network, about as big as the student.

There is a cheaper way. Look at the eight answers you already have. If three are right and five are wrong, then a right answer is above the class average and a wrong one is below. No second teacher is needed. The class itself is the baseline.

Group relative policy optimization

This is GRPO, group relative policy optimization, the method behind DeepSeek-R1. The slide states the key difference from PPO: GRPO forgoes the value model. It estimates the baseline from the average reward of a group of responses to the same prompt. The slide adds the price: it needs a large group size for the baseline to be accurate.

The lecture lists three differences from the PPO of Chapter 4.

  1. A group of responses is used to compute the advantage and the gradient update.
  2. No learned value function. The advantage comes from simple statistics of the rewards over the group.
  3. No reward model. GRPO uses rule-based verifiers: programs that check an answer. The slide lists binary checks, test cases, length and format.

The advantage of response i, among G responses, is its reward minus the group’s mean reward, divided by the group’s standard deviation (a measure of how spread out the rewards are). Dividing by the spread puts every prompt on the same scale.

Ai
The advantage of the i-th response in the group. It replaces the critic’s A(s, a).
ri
The reward of response i, for example 1 if a checker accepts the answer and 0 if it does not.
mean(…)
The average reward over the G responses to this prompt. This is the baseline.
std(…)
The spread of those rewards. If all rewards are equal, the spread is zero and there is nothing to learn from.

Work it with G = 8 and three correct answers. The mean is 3 / 8 = 0.375. The spread is the square root of 0.375 × 0.625, which is 0.484. A correct answer gets (1 − 0.375) / 0.484 = +1.29. A wrong answer gets (0 − 0.375) / 0.484 = −0.775. Check: 3 × 1.29 and 5 × (−0.775) both come to about 3.87, so the advantages add to zero. Rare successes earn a large push. The common failures earn a smaller push down.

Grade a group on a curve

Each dot is one sampled answer to the same question. Green is a right answer, red a wrong one. Bars show each answer’s advantage. Choose the group size, then drag the number of right answers.

3

Exact statistics with the population standard deviation and a 0 or 1 reward. Real systems add a small constant to the spread to avoid dividing by zero. Slide 26.

Drag the count to 0 or to the full group. Every bar vanishes. When all answers are right, or all are wrong, there is no “better than the others”, so the prompt teaches nothing. This is why training sets for GRPO favor problems of middle difficulty: some right, some wrong.

DeepSeek-R1: rewards from rules

The reading for this session is DeepSeek-R1: Incentivizing Reasoning Capability in LLMs via Reinforcement Learning. Its boldest model, R1-Zero, applies GRPO straight to a pretrained base model, with no SFT first. The reward comes from rules only: one checks whether the final answer is correct, and one checks that the model writes its thinking in the expected format. The paper reports that on the AIME 2024 math contest, R1-Zero’s first-try accuracy (pass@1) rose from 15.6% to 71.0% during training, and to 86.7% when it voted over many samples. Its answers also grew longer, as the model learned to think for more steps.

The released R1 adds a small supervised stage and further rounds to fix readability. The existing DeepSeek-R1 lesson walks through the full pipeline. What matters here is the recipe: sample a group, check each answer with a program, and push toward the answers that beat the group.

Contrast: 1,000 examples and a word

Does reasoning need RL? s1: Simple Test-Time Scaling offers a very different route. It builds a small set of 1,000 hard questions with worked reasoning traces, and runs plain SFT on a base model. The paper’s second idea is budget forcing: control how long the model thinks at answer time. To make it think longer, the decoder suppresses the end-of-thinking token and appends the word “Wait”. To make it stop, the decoder forces the end token. The paper reports that the resulting model beat OpenAI’s o1-preview on competition math by up to 27%.

So there are two ways to get long reasoning. RL discovers it from a reward. SFT on a few traces teaches it, and a decoding trick extends it. The roadmap in Chapter 0 lists both roads: SFT on traces, and RL from a reward. Chapter 6 asks which one really adds new ability.

The failure mode of GRPO: the symptom is training that stalls, because most prompts return all-right or all-wrong groups. The measurement is the share of groups with zero spread. The fix is to filter prompts by difficulty, or to raise G so that rare successes appear. The lecture’s other warning is that a program is only as good as its rules. Chapter 6 shows how a model finds the holes.

A group of 8 answers to one question has a reward of 1 for every answer. What does GRPO learn from that prompt?

Chapter 6

What RL Buys, and What It Breaks

Measure what reinforcement learning really adds to a model, and see how a model learns to game its own score

A school pays students for every book they read. Soon one student reads very short picture books, thirty a day, and wins the prize. The rule was a proxy: the school wanted love of reading, and it measured books. The student did what the rule said, not what the school meant.

Reinforcement learning has the same weakness. It is an optimizer, and an optimizer follows the number you give it. The first half of this chapter is about what happens when the number is wrong. The second half asks a harder question: when RL works, what exactly has the model gained?

Reward hacking

The lecture’s slide states the problem in two lines. Models learn to maximize reward, and that does not always align with the real objective. So be careful when you design the reward, because simpler rewards tend to be more robust. It gives two examples.

The first is from OpenAI’s write-up of faulty reward functions, in a boat-racing game. An RL agent scored 20% higher than humans by exploiting a loophole: it repeatedly knocked over respawning targets in an isolated lagoon, instead of finishing the race. The second is a language model that hacked a chess engine so that it could win. In both cases the agent did exactly what the score rewarded.

Now see how it can happen with a verifier, the kind of program Chapter 5 trusts. Suppose a checker accepts an answer if it “contains the number 12”. The right answer to a ticket-price question is $12. A model that writes “$12 or $18” passes too. Hedging is cheaper than solving. Under GRPO, hedged answers score 1, so the group’s advantage favors them, and the model learns to hedge. The fix is a stricter check, such as an exact match on one final answer. The example is illustrative, but the pattern is real: every hole in a verifier is a lesson the model will learn.

Did RL add new ability?

Now suppose the reward is sound, and accuracy rises. Is the model smarter, or only more reliable at what it could already do? A paper on the reading list asks exactly this: Does RL Really Incentivize Reasoning Capacity in LLMs Beyond the Base Model? (Yue et al.).

The tool it uses is pass@k. Sample k answers to a problem. If at least one is right, the problem counts as solved. If a model gets a problem right with probability p on each try, then pass@k = 1 − (1 − p)k. At k = 1 it is the usual accuracy. At large k it asks something different: can the model ever solve this?

The paper reports a pattern. At small k, models after RL beat their base models. At large k, the base models catch up and can pass them. RL, the authors conclude, makes the model better at sampling the right answer, but the answers it finds were already inside the base model’s reach. They also report that distillation from a stronger teacher can bring in truly new ability. Try the pattern in a toy.

Sample more, solve more

Ten toy problems. The base model solves each with a small but real chance. RL makes easy problems nearly certain, and gives up on the hardest. Drag the number of samples and watch the two curves cross.

1

Illustrative: the ten per-problem success chances are made up to show the shape of the pattern Yue et al. report; they are not their data. Base: 0.55, 0.45, 0.35, 0.25, 0.15, 0.08, 0.04, 0.02, 0.01, 0.005. After RL: 0.97, 0.93, 0.85, 0.70, 0.40, 0.12, 0.02, 0, 0, 0. The curve is the exact average of 1 − (1 − p)k.

At k = 1, RL looks like a huge win: 39.9% against 19.1%. By k = 8 the curves meet. At k = 1,024 the base model solves nearly every problem and the RL model is stuck at 70%, because it stopped trying the three hardest. RL sharpened the model onto what it could already do.

Where the reasoning comes from

A second reading, Understanding R1-Zero-Like Training: A Critical Perspective (Liu et al.), examines the recipe from Chapter 5. It reports that some base models already show strong reasoning habits before any RL. Training did not create them from nothing. It also finds a bias in GRPO’s loss: the way it averages over length makes wrong answers longer. The authors propose a fix, called Dr. GRPO, that removes the bias and keeps the accuracy with shorter outputs. Longer thinking after RL is therefore not always more thinking that helps.

A third reading takes the question to a larger setting. Scaling Test-Time Compute Without Verification or RL is Suboptimal compares two ways to train a model for longer thinking. In one, you distill from expert traces and there is no reward check at all. In the other, you use a verifier or reward, as RL does. The paper shows that as the test-time budget grows, the verifier-based methods keep improving while the verifier-free ones fall behind. Our lesson page on that paper has the details. The message matches the chapter: a trusted check is worth more than a pile of examples.

Together these readings give one picture. RL with a good reward is cheap and strong at sharpening a model toward what a checker accepts. It is weaker at teaching new knowledge. And everything depends on the reward. The failure mode runs: the symptom is a score that climbs while real quality does not; the measurement is a held-out test the optimizer never saw, or pass@k at large k; the fix is a simpler, stricter reward, a KL leash to the base model, or a stronger teacher, which is the topic of Chapter 8.

A model after RL beats its base model at pass@1, but the base model wins at pass@256. What is the best reading?

Chapter 7

Learning at Test Time

Let a model improve while it works, using rewards it makes for itself

You sit an exam with no answer key, and nobody will tell you your grade. You can still do something clever. Work each problem five times in your head. If four of your five attempts agree, that answer is probably right. Then you study the pattern of your own agreement, and your next attempts get sharper.

The lecture calls this family test-time training: updating a model at the moment it is used, on the very problems it faces. Test time just means “when the model is deployed”, as opposed to training time. Everything so far assumed a fixed training set and a fixed reward. Here the data is the test itself, and the reward must come from somewhere else.

Test-time RL: the vote is the reward

The first method is TTRL: Test-Time Reinforcement Learning (Zuo et al., NeurIPS 2025). The slide sums it up: learn from self-generated and changing reward signals, with a majority vote across multiple sampled responses.

Here is the loop, with its data flow. Take one unlabeled question. Sample N responses from the model. Pull out each final answer, giving N short answers. Count them. The most common answer, the majority vote, becomes a stand-in for the truth. Each response whose answer matches it gets reward 1, and the rest get 0. Then run GRPO from Chapter 5 on those rewards. No label was used at any point.

This looks like cheating: the model grades itself. Why would it work? Because wrong answers tend to scatter, and right answers tend to agree. Suppose a question has one right answer and many wrong ones. Each time the model errs, it errs in a different way. So even if the model is right only 30% of the time, the right answer can still be the single most common one. The vote is more accurate than any one sample. Test it.

Vote on your own answers

A question has one right answer and four wrong ones. Set how often one sample is right and how many samples you vote over. The bars show the votes from one draw; the number below counts many draws.

30%
8

Toy model: the four wrong answers are equally likely, and ties go to the first answer counted. The percentage is the share of 4,000 seeded draws in which the vote lands on the right answer. It is a model of why voting helps, not a measurement from the TTRL paper.

Set a single sample at 30% and vote over 8: the vote is right far more often than 30%. Raise the samples, and it climbs. Now drag one sample below about 20%, where the right answer stops being the most common one. The vote turns against you. A reward built from the vote then pushes the model toward a wrong answer with full confidence.

The TTRL paper reports that models trained this way gain a great deal on hard math benchmarks, with no labels at all. The failure mode is the one the device shows. The symptom is a model that grows surer and still wrong. The measurement is how often the vote matches a held-out answer. The fix is more samples, a stronger base model, or an external check where one exists.

A model that judges itself

A second reading goes further. Self-Rewarding Language Models (Yuan et al., 2024) removes the human-trained reward model of Chapter 4. The same model plays two roles. As a writer, it produces several answers to a prompt. As a judge, it scores them with a rubric it is prompted with, the “LLM-as-a-Judge” trick. The best and worst answers become a preference pair, and training uses DPO from Chapter 4. Then the improved model does the next round, and it is a better judge as well as a better writer. The paper reports that a Llama 2 70B model after three such rounds beat several strong closed models on the AlpacaEval 2.0 leaderboard.

Updating weights on the examples in front of you

Another family, the lecture says, adapts a model to the deployment distribution. The slide cites Akyurek et al. (ICML 2025), The Surprising Effectiveness of Test-Time Training for Few-Shot Learning. A few-shot task comes with a handful of demonstration pairs. The usual approach is in-context learning: paste the pairs into the prompt and hope. Test-time training instead runs a few gradient steps on those pairs. The slide’s verdict: test-time training beats in-context learning, data augmentation helps, and task-specific adapters help. An adapter is a small set of extra weights trained for one task, so the base model stays untouched.

The next slide extends the idea to feedback in words. OpenClaw-RL (Wang et al.) takes text feedback, such as a critique from a user, and designs reward models that translate natural-language critiques into executable reward signals for reinforcement learning. In short, the reward is built from what a person says.

Discovery: training while you search

The lecture then returns to a theme from earlier weeks: LLMs that evolve their own context to solve open-ended problems, such as hard optimization puzzles, code and science. The earlier recipe is “LLMs as optimizers”. A frozen solution model proposes a solution. An external verifier scores it. An archive keeps good parent solutions, and the loop repeats. No weights change.

TTT-Discover (Yuksekgonul et al., 2026) keeps the loop but trains the solution model during the search. Its input is the task, a parent solution and the parent’s score. Its output is a complete new solution, from the same trainable model each time. The verifier’s score becomes the RL reward. A companion paper (Jiang et al., 2026), “Evolving in Thought Space”, trains a small model at test time and reports better discoveries. The lecture’s contrast is exact: in one design the model is frozen at test time, in the other it is trained at test time.

In test-time RL, where does the reward come from when there are no labels?

Chapter 8

Distillation: A Teacher Who Grades Every Token

Learn from a stronger model by letting it grade your own attempts, one token at a time

An apprentice chef wants to learn from a master. The first way: the master cooks a dish, and the apprentice copies the recipe, the steps and the plating. The second way: the apprentice cooks, and the master tastes it bite by bite. “This sauce is fine. This one is too salty. Here you went wrong.” Both help. They teach different things.

The lecture opens this section with the main weakness of RL. It gives only small bits of reward as a training signal: often one number for a whole attempt. A response of 400 tokens, and a single score. The question is how to learn from dense feedback, where every token gets a say.

Way one: copy the teacher

The classic recipe is teacher-student distillation: a large, strong teacher model trains a smaller or weaker student. The lecture also calls this SFT, or instruction tuning, when the teacher’s text is used as training data. The teacher writes a solution, token by token: w1*, w2*, w3*, w4*. The student is trained to produce the same tokens, one position at a time, each time looking at the teacher’s earlier tokens.

The slide lists what this gives and what it lacks. The student becomes very good at imitating the teacher’s answers. But it never sees its own mistakes, and so it never learns how the teacher would correct them. This is the “distribution mismatch” of Chapter 1 in new clothes. During training the student always sees clean, teacher-written prefixes. At test time it sees its own prefixes, which contain its own slips. Watch how fast that gap opens.

Drift off the teacher’s path

At each token the student matches the teacher’s choice with some chance. The curve is the chance it is still on the teacher’s path. Everything above the curve is a prefix the student never saw in training. Drag both sliders.

95.0%
20

Illustrative: it assumes the student matches the teacher independently at each token, so the chance of a clean path of n tokens is q to the power n. Real errors are correlated, but the shape of the gap is the point. Slide 37.

At 95% per token, the student is still on the teacher’s path after 20 tokens only 35.8% of the time. The other 64.2% of the time it is in a state that copying never covered. A longer response makes it worse. Reasoning chains run to hundreds of tokens.

Way two: let the teacher grade you

The fix is on-policy distillation. “On-policy” means the student learns from text it wrote itself, the text its current policy produces. The slide, citing Agarwal et al. (ICLR 2024), shows the order of events.

  1. The student writes its attempt: w1, w2, w3, w4.
  2. The teacher scores that attempt. It reads the student’s tokens and says how likely it would have been to write each one.
  3. The student copies the teacher’s scores, by moving its own probabilities toward the teacher’s.

The distance being minimized is a reverse KL divergence, KL(πs ‖ πt) = Ex ∼ πs[ log πs(x) − log πt(x) ]. Read it from the right: take samples x from the student, and for each one ask how much more likely the student found it than the teacher did. If the student is far more confident than the teacher, the gap is big, and that token gets pushed down.

The slide shows the whole update in five lines. Here is the same thing with the shapes written out.

pythonrollout = student.sample(prompt)                              # [B, T] token ids the student wrote
s_lp = student(rollout).log_softmax(-1).gather(-1, rollout[..., None]).squeeze(-1)   # [B, T]
t_lp = teacher(rollout).log_softmax(-1).gather(-1, rollout[..., None]).squeeze(-1)   # [B, T]
rkl  = s_lp - t_lp                                            # [B, T] per-token reverse KL
loss = (rkl.detach() * s_lp).mean()                           # scalar
loss.backward(); optimizer.step()

Work one attempt of four tokens by hand. The student’s log-probabilities for its own tokens are −0.2, −0.5, −1.1 and −0.3. The teacher’s log-probabilities for the same four tokens are −0.3, −0.4, −3.4 and −0.4. Subtract: the per-token gaps are +0.1, −0.1, +2.3 and +0.1. The mean is 0.6. Token 3 stands out. The student wrote it with moderate confidence, but the teacher thought it very unlikely, 3.4 nats against 1.1 (a nat is a unit of surprise). That one token takes almost all of the push. The detach call means the gap acts as a weight, and the gradient flows through the student’s own log-probability, as in the policy gradient of Chapter 2. In fact, this loss is a policy gradient whose reward is minus the gap, given to every token.

Three teachers, side by side

The lecture ends this part with one table. Two questions separate the three methods. Who writes the text? And what feedback comes back?

SFTRLDistillation
Policy: who writes?Teacher writes the solutionStudent writes an attemptStudent writes an attempt
Feedback: what comes back?Student copies the solution, token by tokenThe environment grades the attempt, one scoreThe teacher grades the attempt, every token

On-policy distillation takes the best of each column: RL’s habit of learning from the student’s own attempts, and SFT’s dense, token-level signal. Go back to the instrument at the top of the page and slide the mistake along the attempt. The distillation row marks the exact token; the RL row cannot. The existing On-Policy Distillation lesson builds the full method and its results.

The failure mode: the symptom is a student that reads fluently but derails on long answers. The measurement is the per-token gap along its own rollouts, or accuracy as a function of length. The fix is to train on the student’s own samples. The catch is that a teacher must exist. The next two chapters ask what to do when it does not.

What does on-policy distillation fix that plain teacher-student SFT does not?

Chapter 9

Forgetting and RL’s Razor

Find out why teaching a model one new skill can erase others, and why learning from your own attempts forgets less

A student crams for a chemistry exam. She passes it. A week later she cannot do the algebra she knew perfectly well before. Her head has only so much room, and the new material pushed the old out.

Neural networks do the same. The guest lecture, by Idan Shenfeld, names it: catastrophic forgetting, the phenomenon where a network loses previously learned information when it is trained on a new task. This matters now because the whole lecture is about updating weights. Every update you make for a new skill risks erasing an old one.

An experiment: RL against SFT

The guest lecture sets up a clean test. Take a base model. Teach it a new task in one of two ways: SFT or RL. Then measure two things. One is accuracy on the new task. The other is the average score on a set of unrelated tasks, the old skills. Train several models at different strengths and plot each one as a point. The best methods lie on the upper right: high on both. The slide calls the outer edge of the points the Pareto frontier.

The slides show the result on three setups. A Qwen 3B-Instruct language model was trained on the Open-Reasoner-Zero math dataset, with SFT annotations from R1. A robot policy, OpenVLA, was trained in the SimplerEnv simulator, with SFT annotations from RT-1. And a small three-layer network was trained on a parity task after pretraining on FashionMNIST. The pattern is the same in all three. In the math chart, read off the slide, the RL points stay flat at about 0.58 on old tasks while new-task accuracy climbs. The SFT points slide down, to about 0.54 by the time new-task accuracy is about 0.62. Same new skill, but SFT paid for it with the old ones. The paper is RL’s Razor: Why Online Reinforcement Learning Forgets Less (Shenfeld et al., 2025), and it is on this session’s reading list.

One number that predicts forgetting

The slide asks the obvious next question: so RL forgets less, but why? A good answer is a measurement that predicts forgetting whatever the method, an “objective-agnostic” variable. The lecture’s candidate is the KL divergence from Chapter 3, between the base policy π0 and the fine-tuned policy π, measured on the new task’s inputs.

Ex ∼ τnew
The average over prompts x taken from the new task.
KL(π0 ‖ π)
How far the fine-tuned model’s answer distribution has moved from the base model’s, on that prompt. Zero means no change.

The slide’s claim: forgetting is almost perfectly predicted by this number. In the chart for the small network, every method, SFT or RL, falls on one curve of old-task score against KL. Plotted against the new-task learning instead, the methods spread apart. The distance moved is the thing that costs.

Why RL moves less

There are many policies that solve the new task. Some are close to the base model, and some are far. RL samples answers from the model’s own current distribution, and it only reinforces the ones that earn reward. So it starts from what the model already does, and nudges probability toward what works. The paper names the consequence RL’s Razor: among all the ways to solve the new task, on-policy RL tends to find the one closest to the base policy in KL.

SFT has no such pull. It trains on answers written by someone else, so it drags the model toward that author’s style, whatever the distance. Let us see this with a toy where the maths is exact. Treat each policy as a bell curve with a fixed width. For two such curves the KL divergence is just half the squared distance between their centers.

Take the shortest road

The dot at the left is the base policy. The shaded zone is where the new task is solved. RL stops at the nearest solved point. SFT is dragged to the annotator’s point. Drag the annotator’s style away from the base policy.

3.0

Toy, with exact maths: each policy is a unit-width Gaussian in 2D, so KL(π0 ‖ π) = half the squared distance between centers, in nats. The new task is solved when the first coordinate is at least 3. RL ends at (3, 0), the nearest solved point. Forgetting is drawn proportional to KL because the guest lecture finds KL predicts it; the exact proportion in real models is not shown here. Slides 19 to 24.

With the offset at 3, RL ends 4.5 nats from the base policy and SFT ends 9.0. Both solve the task. SFT moved twice as far, so the toy predicts it forgets more. Drag the offset to 0 and the two meet. That matches a later slide: SFT trained on annotations that already lie close to the model’s own distribution forgets much less. The method label is not the cause. The distance is.

On-policy against off-policy

The lecture writes the two objectives next to each other. The policy gradient is the minus sum of R(x, y) log π(x, y), with the answers y drawn from π itself. The cross-entropy loss is the minus sum of log π(x, y), with the answers drawn from a fixed expert π*. The only visible difference is under the sum: who wrote the answers. On-policy means the learner’s own samples. Off-policy means somebody else’s.

The guest asks which of two differences matters: the use of negative examples (the RL loss pushes bad answers down), or the use of the learner’s own samples. The slides test both and the takeaway is clear: to learn without forgetting, do on-policy learning. This echoes Chapter 8, where on-policy distillation fixed the same flaw in SFT.

The failure mode: the symptom is a model that gets better at the new task and worse at old ones. The measurement is the old-task score next to the new-task score, plus the KL to the base model on new-task prompts. The fix is on-policy training, a KL penalty to the base model, or mixing old data back in.

According to the guest lecture, which single quantity best predicts how much a model forgets after fine-tuning?

Chapter 10

Self-Distillation: A Model That Teaches Itself

Turn a hint into a teacher, and turn what a model can do with a hint into what it can do without one

You solve a problem and get it wrong. A friend looks at your work. She has the textbook open to the right page. She does not hand you the answer. She points at the exact line where your steps went off, and says why. You learn much more than from a bare “wrong”.

Now imagine the friend is you, with the textbook open. That is self-distillation. The lecture asks a sharp question: if we want a model to improve itself, we do not want to be limited by a stronger teacher model that may not exist. Where can a teacher come from? The answer is that the same model, given more information, is a better teacher than the model without it.

More than a number

The guest lecture’s second part begins with a recap. The main takeaway of the first part: to learn without forgetting, learn on-policy. But on-policy RL is limited to scalar rewards, one number per attempt. Yet the world offers richer signals: textual feedback, hints, detailed instructions and more.

A model already knows how to use such signals in one way. It is in-context learning: the ability of a large model to change its behavior based on its context. The context need not be examples. Feedback, rewards, hints and instructions all work. The slide adds the catch: the effect is transient. Clear the context and the lesson is gone.

The idea in one example

The slide uses a tiny case. The prompt x is “what are the roots of x² − 9?”. The context c is a hint: use the identity a² − b² = (a − b)(a + b). Sample a response y from the model given only x, written π(· | x), and the solution is incorrect. Sample from the model given both, π(· | x, c), and it is correct.

The same weights, two different behaviors, and the only difference is a hint in the prompt. The question is how to make the weights behave as if the hint were always there. Self-distillation answers it with the on-policy recipe of Chapter 8, where the teacher is the model plus the context.

  1. The student writes an attempt from the prompt alone: y1 ∼ π(· | x), then y2 given x and y1, and so on.
  2. The same model, now reading the hint too, scores every token of that attempt: π(· | x, y1, c).
  3. The student moves toward the teacher’s scores, token by token, with the reverse-KL loss of Chapter 8.

The data flow is the same as before, with one change. Both models are one set of weights. The student pass runs on the sequence [x, y]. The teacher pass runs on [x, c, y], and the logits of the y part are used. The teacher gets no gradient. Only the student pass does. Try it on the quadratic.

Open the textbook

The student wrote the eight tokens below, and its last one is wrong. The bars show how much the model, reading a hint, disagrees with each token. Drag the hint from nothing to full.

100%

Illustrative numbers in nats, not measured from a model: at full hint, the per-token gap between the student’s log-probability and the hinted model’s is 0, 0, 0, 1.6, 0.9, 0.1, 0.1 and 3.1. The slider scales every gap linearly. The hint and the problem are the guest lecture’s own example (slide 40).

With no hint, every bar is zero. The model, asked to grade itself, finds nothing wrong, because it holds the same beliefs that wrote the attempt. With the hint, two spots light up: the fourth token, where the model would have factored the expression, and the last, where “±9” should have been “±3”. An RL score on this attempt would be one number, 0. Here the signal is eight numbers, and it points at the cause.

What the papers show

Two readings put this into practice. In Self-Distilled Reasoner (Zhao et al., ICML 2026), the teacher is the student plus privileged information, extra feedback the student does not get at test time. The slide shows a runtime error from a failed program: a ZeroDivisionError on one line of code. That one line of dense feedback is exactly what a scalar reward throws away.

Reinforcement Learning via Self-Distillation (Hübotter et al., ICML 2026) is the same idea applied across a whole training run. The caption on the slide describes it: the model asks a question, writes an answer, receives feedback, and then, rather than appending the history to its context window, it updates its weights, encoding the context-conditioned policy directly into the plain one. The chart on the slide compares this method (SDPO) with GRPO on LiveCodeBench v6. Read off the chart, SDPO climbs to about 0.49 in accuracy while GRPO levels off near 0.41, over the same 20,000 generations. A second chart shows the gap holding across Qwen3 models of several sizes. These are approximate readings of a figure, not table values.

Learning new skills without forgetting old ones

Now join Chapter 9 to this one. On-policy learning forgets less. Self-distillation is on-policy, and it works from demonstrations, not only from rewards. The guest’s own paper, Self-Distillation Enables Continual Learning (Shenfeld et al., 2026), tests it where forgetting hurts most. The setup: a Qwen2.5 7B-Instruct model is trained in sequence on three skills. First tool use (ToolAlpaca), then science (SciKnowEval chemistry), then clinical reasoning (HuatuoGPT-o1).

With ordinary SFT, each new stage erases the one before. In the slide’s curves, tool-use performance falls sharply once training moves to science, and science falls when it moves to medicine. With self-distillation, all three skills stay high through the whole sequence. The slide’s headline for the SFT run is the same warning as Chapter 9: off-policy learning results in catastrophic forgetting. And for the other run: on-policy learning leads to better performance on both new and prior tasks.

Why does a demonstration work as a hint? In the paper’s setup the demonstration is placed in the context. The model that reads it is the teacher. The model without it is the student. The student is trained on its own attempts, graded by its own better-informed self. Nobody else’s text is forced into its weights.

The failure mode: the symptom is a student that copies the teacher’s surface and misses its insight. The measurement is accuracy without the hint, on problems where the hinted teacher is right. If it stays low, the hint did not transfer. The fix is a hint that carries real information, and more training rounds. A second risk is a hint that leaks the answer so directly that the teacher’s grades say nothing about reasoning.

In self-distillation, who is the teacher, and what makes it better than the student?

Chapter 11

Field Guide: The Whole Lecture on One Page

Pull the three kinds of feedback, the update algorithms and the risks into one map you can use

The lecture ends on one picture. It has three axes. The type of feedback a model gets: dense feedback, rewards or verifiers, self-generated targets, or human-given labels. The update algorithm: SFT, RL or distillation. And what is updated: the full weights, or a partial set such as an adapter. Every method in this session is a point in that space. Pick a point to name it.

Name the recipe

Choose the feedback you have, then the way you will update. The grid lights the cell, and the line below names the method and the chapter that teaches it.

A teaching map. The three axes are slide 45 of Lecture 6; the method named in each cell is this lesson’s own reading of where each technique sits, and several cells have more than one fair answer.

The numbers that matter

WhatNumberWhy it matters
Deployed AI tokensmore than 300 trillion per dayA web-scale corpus of experience, every day, mostly unused for learning
Return of rewards 0, 0, 1 at γ = 0.50.25Later reward counts for less
One REINFORCE step on a winP(up) 50% to 56.2%Win raises the chance of what you did
PPO clip, ε = 0.2, ratio 1.4, A = +1objective 1.2, gradient 0Updates stay small
Reward scores 8.0 vs 1.299.89% preferenceA gap of scores is a probability
GRPO, 3 right of 8advantage +1.29 and −0.775The group mean replaces the critic
R1-Zero on AIME 202415.6% to 71.0% pass@1; 86.7% with votingRule-based RL alone can teach reasoning
Toy pass@k, base vs RL19.1% vs 39.9% at k = 1; 99.9% vs 70.0% at k = 1,024 (illustrative)RL sharpens; it may not widen
Student on the teacher’s path35.8% after 20 tokens at 95% per token (illustrative)Copying never shows the student its own mistakes
Reverse-KL gaps, four tokens+0.1, −0.1, +2.3, +0.1; mean 0.6One bad token takes most of the push
Distance moved, RL vs SFT toy4.5 vs 9.0 natsKL from the base predicts forgetting
SDPO vs GRPO, LiveCodeBench v6about 0.49 vs about 0.41 (read off a chart)Dense self-feedback beats one score

The core as code

One update step of the method at the heart of the lecture, GRPO with a PPO-style clip, with every shape written out. The verifier is any program that returns a 0 or a 1.

pythonresp, logp_old = policy.sample(prompt, n=G)                    # [G, T] tokens, [G, T] log-probs (Ch 5)
r   = torch.tensor([verifier(prompt, y) for y in resp])        # [G] a rule-based 0 or 1 (Ch 5, 6)
adv = (r - r.mean()) / (r.std() + 1e-6)                        # [G] group baseline, no critic
logp_new = policy.log_prob(prompt, resp)                       # [G, T]
ratio = (logp_new - logp_old).exp()                            # [G, T] new / old (Ch 3)
a = adv[:, None]                                               # [G, 1] same advantage for every token
obj = torch.min(ratio * a, ratio.clamp(1 - eps, 1 + eps) * a)  # [G, T] clipped objective
loss = -obj.mean() + beta * kl_to_reference(policy, ref, resp)  # scalar, KL leash (Ch 4, 9)
loss.backward(); opt.step()

# the distillation variant (Ch 8, 10): swap the reward for a per-token grade from a teacher
roll = student.sample(prompt)                                  # [B, T] the student's own attempt
gap  = student.log_prob(prompt, roll) - teacher.log_prob(prompt_with_hint, roll)   # [B, T]
loss = (gap.detach() * student.log_prob(prompt, roll)).mean()  # scalar, reverse KL

Before you update the weights, check

Where it sits in the field

This is Model Evolution 1 of the course’s arc. The weeks before it evolved the context and the harness around a frozen model. This week the weights themselves change. The next lecture in the course returns to RL in practice.

The session’s eleven readings, all taught above:

Keep going with our own lessons: Policy Gradients, RL Algorithms, Reward and Alignment and Test-Time Compute.

The takeaway. A model learns from a signal, and the signal sets the limit. A copy shows the result but never your mistakes. A score says how you did, but not where. A teacher who grades every token, even a teacher that is just you with a hint, points at the cause. Whatever you choose, learn from your own attempts, keep the update close to the base model, and watch for a reward that rewards the wrong thing.
You want a model to learn a new skill from a handful of expert demonstrations without losing its other skills. Which choice follows the lecture?

Now press Present or Teach and explain the day from memory: how one score, one copy and one critic each teach a model, why a group replaces the critic in GRPO, what pass@k reveals, and why learning from your own attempts forgets less. Then go back to the instrument at the top, move the mistake to token 8, and say what each teacher can tell the student.

How to AI an AI, Lecture 6 and guest lecture: Model Evolution 1
Taught by Paul Liang (MIT Media Lab and EECS) with guest Idan Shenfeld, MIT MAS.S62 AI4AI, Fall 2026. The course site · Lecture slides · Back to Gleams