LLM + RoboticsModule 12 · Video 06

From REINFORCE to PPO to GRPO: the RL behind reasoning models

Reasoning models are trained by letting them attempt problems and reinforcing the attempts that work. The algorithms behind that step form a family tree: REINFORCE, then baselines and value functions, actor-critic and GAE, TRPO and PPO, and finally GRPO, which drops the value network and compares each answer with the others in its group. This guide follows the video's chapters, points to the course's in-depth PPO material, and spends its own space on GRPO and the Dr. GRPO correction.

Video length23:31
Published16 May 2025
LevelIntermediate: expectations, log-probabilities and gradients; some RL vocabulary helps
Builds onModule 02 · RL ladder, 30u30 Day 29 · PPO, Module 07 · RLVR

Video by Jia-Bin Huang · Watch on YouTube

Start here (no maths needed)

To teach an AI to solve maths problems, you can let it try a problem many times, check which answers are right, and nudge it towards the kind of thinking that produced the right ones. GRPO does this by comparing each answer with the others in the same batch: better than average gets pushed up, worse than average gets pushed down.

Think of it like this

A coach wants to know whether a runner had a good day. One way is to keep a notebook predicting how fast the runner "should" be on each track, and compare against that. Keeping that notebook accurate is a lot of work. Another way: have eight runners race the same track at once, and just compare each with the group's average. Faster than the group is good, slower is bad. No notebook needed. That second way is GRPO; the notebook is PPO's critic.

How it works

  1. Give the model one question and let it write several answers (a "group"), say 8.
  2. A checker scores each answer, for example 1 if the final answer is right and 0 if it's wrong.
  3. Work out the group's average score. Answers above it get a positive "advantage", answers below it a negative one.
  4. Make every word in a good answer a bit more likely, and every word in a bad answer a bit less likely.
  5. Don't change too much in one step (a "clip"), and stay close to the original model (a "KL" leash), so training stays stable.

Why robots care

Robots learn many skills by trial and error in simulation, and the algorithms used there are the same family: policy gradients and PPO. GRPO's trick of comparing several attempts from the same starting point works whenever you can reset to the same situation and try again, which simulators make easy.

Try it

Words to know

Policy
The model's way of choosing what to do (for a language model, which token to write next).
Reward
A score for how well an attempt went.
Advantage
How much better an attempt was than expected.
Critic (value function)
A second model that predicts how well things will go from here, used as the "expected" score.
Clipping
A rule that stops one update from changing the policy too much.

Going deeper: everything below is the full version, with some maths. On a first read, skim the headings and the "Why it matters for robotics" box, and come back for the rest later.

1. Watch

Chapter guide

TimeChapterWhat to look for
0:00IntroductionWhy RL is the step that turns a pretrained model into a reasoning model.
0:43NotationStates, actions, policy πθ, trajectories τ and returns. For an LLM: the state is the prompt plus tokens so far, the action is the next token.
2:41Policy gradientThe log-derivative trick that turns "maximise expected reward" into a gradient you can estimate from samples.
5:11Decomposing trajectory into states and actionsWhy the environment's dynamics drop out of the gradient, leaving only the policy's log-probabilities.
7:05Baseline subtractionSubtracting a baseline leaves the gradient unbiased but cuts its variance.
7:58Value function estimationLearning V(s) as the baseline, by regression on observed returns.
8:31Advantage estimationThe advantage A = Q − V, TD residuals and Generalized Advantage Estimation's λ knob between bias and variance.
11:11Actor-critic methodsTraining the policy (actor) and value function (critic) together.
12:16Trust region policy optimizationOptimising a surrogate objective under a KL constraint, so one update can't wreck the policy.
16:48Proximal Policy OptimizationReplacing TRPO's constraint with a clipped probability ratio that ordinary SGD can optimise.
19:55Group Relative Policy OptimizationDropping the critic: the baseline becomes the mean reward of a group of answers to the same prompt.
21:58Dr. GRPOThe two normalisations in GRPO that introduce bias, and what removing them changes.

The video's description also recommends three longer resources: Pieter Abbeel's Foundations of Deep RL lectures, David Silver's UCL course and Sutton and Barto's book. They're listed in the references.

2. The ideas, explained

Policy gradient (REINFORCE)

Williams (1992) showed how to follow the gradient of expected reward using only samples. Because the environment's transition probabilities don't depend on θ, they vanish from the gradient of the log-probability of a trajectory, and only the policy's own terms remain:

J(θ) = E_{τ~π_θ}[ R(τ) ]
∇J(θ) = E_τ[ Σ_t ∇_θ log π_θ(a_t | s_t) · G_t ]      G_t = Σ_{k≥t} γ^{k−t} r_k  (reward-to-go)
with a baseline:  replace G_t by G_t − b(s_t)          (still unbiased, lower variance)

The estimate is unbiased but very noisy. The rest of the family tree is mostly about reducing that noise and keeping updates safe. The course derives and codes these steps on Module 02's RL ladder.

Value functions, advantages and GAE

The best simple baseline is the state value V(s), the expected return from s. Then Gt − V(st) estimates the advantage A(s, a) = Q(s, a) − V(s): how much better this action was than the policy's average. Actor-critic methods learn V with a second network and use it in the update; Mnih et al.'s A3C (2016) is the reference the video cites. Generalized Advantage Estimation (Schulman, Moritz, Levine, Jordan and Abbeel, 2015) blends short and long look-aheads:

δ_t = r_t + γ V(s_{t+1}) − V(s_t)                  (TD residual)
Â_t^GAE(γ,λ) = Σ_{l≥0} (γλ)^l δ_{t+l}
λ = 0: one-step TD (low variance, biased by V)   λ = 1: Monte Carlo return − V (unbiased, noisy)

TRPO and PPO

Policy gradients can take a step that's too large and collapse the policy. TRPO (Schulman et al., 2015) maximises an importance-weighted surrogate subject to a limit on the average KL divergence from the old policy, solved with conjugate gradients and a line search. PPO (Schulman et al., 2017) gets most of the benefit with a first-order trick: clip the probability ratio so there's no incentive to move it outside [1 − ε, 1 + ε].

ρ_t(θ) = π_θ(a_t | s_t) / π_θ_old(a_t | s_t)
TRPO:  max E[ ρ_t Â_t ]   s.t.  E[ KL(π_θ_old ‖ π_θ) ] ≤ δ
PPO:   L^CLIP = E[ min( ρ_t Â_t, clip(ρ_t, 1−ε, 1+ε) Â_t ) ]

In LLM fine-tuning (RLHF), PPO usually runs with four models in memory: the policy, a critic of similar size, a frozen reference model for the KL penalty, and a reward model. The PPO mechanics, ε ablations and a full implementation are on 30u30 Day 29; this page doesn't repeat them.

Group Relative Policy Optimization (GRPO)

GRPO was introduced by Shao et al. in the DeepSeekMath paper (2024) as a PPO variant that improves maths reasoning while reducing PPO's memory use. Its key move is to remove the critic. For each question q, sample a group of G outputs o1…oG from the old policy, score them, and use the group's statistics as the baseline:

Â_{i,t} = ( r_i − mean(r_1..r_G) ) / std(r_1..r_G)       (outcome reward: same for every token of o_i)

J_GRPO(θ) = E[ (1/G) Σ_i (1/|o_i|) Σ_t {
              min( ρ_{i,t} Â_{i,t}, clip(ρ_{i,t}, 1−ε, 1+ε) Â_{i,t} )
              − β · D_KL[ π_θ ‖ π_ref ] } ]

D_KL estimate per token:  π_ref/π_θ − log(π_ref/π_θ) − 1      (non-negative, unbiased)

Three differences from PPO as used in RLHF:

DeepSeek-R1 (DeepSeek-AI, 2025) made GRPO famous: its R1-Zero model was trained with large-scale RL using GRPO and rule-based rewards directly on a base model, without supervised fine-tuning first, and long reasoning behaviour emerged. Module 07 covers this RL-with-verifiable-rewards recipe in context (RLVR section).

Interactive: GRPO group advantages vs a critic baseline

One prompt, G sampled answers, each scored 1 (correct) or 0 (wrong). For each answer, three bars show its advantage: GRPO (r − mean) / std, Dr. GRPO r − mean, and a PPO-style baseline r − V, where V is a critic's guess of the success rate. Dots above the axis mark correct answers.

Group mean, std
–
Correct answer: GRPO / Dr. GRPO / Critic
–
Chance the group has no signal
–
Group
–

Try this: the defaults (success rate 0.3, G = 8, V = 0.5, group #1) draw 2 correct answers out of 8. Mean 0.25, std 0.43, so a correct answer gets +1.73 under GRPO, +0.75 under Dr. GRPO and +0.50 against the critic. Groups where every answer is right or every answer is wrong give zero advantage to everyone, so they teach nothing. That happens with probability pG + (1 − p)G: 5.8% at the defaults, but 66.3% at success rate 0.05. Press "Sample new group" until you get exactly 1 correct out of 8: GRPO gives it +2.65 while Dr. GRPO gives +0.88. That large boost for rare successes on very hard (or very easy) prompts is the std normalisation that Dr. GRPO removes. Std here is the population standard deviation; implementations differ.

Dr. GRPO

Liu et al. (2025), in "Understanding R1-Zero-Like Training: A Critical Perspective", identify an optimisation bias in GRPO that artificially increases response length, especially for incorrect outputs, and propose Dr. GRPO ("GRPO Done Right") as an unbiased fix. It removes two normalisations:

Dr. GRPO:  Â_{i,t} = r_i − mean(r_1..r_G)
           J = E[ (1/G) Σ_i Σ_t min( ρ_{i,t} Â_{i,t}, clip(ρ_{i,t}, 1−ε, 1+ε) Â_{i,t} ) ] / C   (C constant)

The paper reports better token efficiency with similar reasoning performance, and a minimal R1-Zero-style recipe reaching 43.3% on AIME 2024 with a 7B base model. With r − mean as the advantage, the group mean is an ordinary REINFORCE baseline again (close to the leave-one-out style), which is a nice way to see that GRPO is still a policy gradient method underneath.

The family tree in one table

MethodBaseline / advantageStep-size controlExtra models
REINFORCE (1992)Return, optional baselineLearning rate onlyNone
Actor-critic, A3C (2016)Learned V(s)Learning rateCritic
GAE (2015)λ-weighted TD residuals(used inside TRPO/PPO)Critic
TRPO (2015)GAEHard KL constraintCritic
PPO (2017)GAEClipped ratioCritic (+ reference and reward models in RLHF)
GRPO (2024)Group mean, divided by group stdClipped ratio + KL to referenceReference (+ reward model or verifier)
Dr. GRPO (2025)Group mean onlyClipped ratioAs GRPO

3. Where the course goes deeper

TopicCourse page
Bellman → REINFORCE → A2C → GAE → PPO, as practice problemsModule 02 · RL ladder
PPO in depth: clipping, ε, GAE, a full implementation and robot locomotion30u30 Day 29 · PPO
RLHF and the reward model that PPO originally optimised30u30 Day 30 · RLHF
RL with verifiable rewards, the KL leash and where GRPO fits in post-trainingModule 07 · RLVR, Module 07 · KL
DPO and preference optimisation, the RL-free alternativeModule 08 · Stage 05
Book-length treatments of RL for LLMsModule 11 · Raschka, Module 11 · RLHF book
Dense teacher feedback instead of one reward per answerVideo 05 · On-policy distillation

Why it matters for robotics

Self-check

Why does subtracting a baseline b(s) from the return not bias the policy gradient?

Because Ea~π[∇ log π(a|s) · b(s)] = b(s) · ∇ Σa π(a|s) = b(s) · ∇1 = 0. The baseline doesn't depend on the action, so its contribution averages to zero, while it can greatly reduce variance.

What does GAE's λ trade off?

Bias against variance. λ = 0 uses one-step TD residuals, low variance but biased by errors in V. λ = 1 uses the full Monte Carlo return minus V, unbiased but noisy. Values in between weight longer look-aheads geometrically.

What does PPO's clip do for a positive-advantage action whose ratio is already 1.3 with ε = 0.2?

The clipped term is capped at 1.2 · Â, and the min picks it, so the gradient with respect to that sample is zero: there's no incentive to push its probability higher in this update.

Rewards in a group of 4 are (1, 0, 0, 0). What are the GRPO and Dr. GRPO advantages?

Mean 0.25. Population std = √(0.25 · 0.75) ≈ 0.433. GRPO: correct +0.75 / 0.433 ≈ +1.73, wrong −0.25 / 0.433 ≈ −0.58. Dr. GRPO: +0.75 and −0.25.

Why does the 1/|oi| term encourage long wrong answers?

A wrong answer's negative advantage is spread over its tokens and averaged by its length, so a longer wrong answer receives a smaller penalty per token. The model learns that rambling softens the punishment for being wrong.

Why is GRPO attractive for LLMs but less obviously so for a real robot?

For an LLM, sampling many answers to the same prompt is cheap and removes the need for a large critic. A real robot can't easily restart from exactly the same state many times, and long-horizon control with dense rewards benefits from a learned value function.

References

From the video's description (resources):

From the video's description (references):