Topic 47 of 62 · Post-training
GRPO: group-relative advantages
HardHow does GRPO estimate advantages without a critic, and what does it give up?
1 · Start with the intuition
Sample several completions for the same prompt and grade them against each other. Because every completion shares a prompt, the group’s average reward is a natural baseline. No value model is needed.
2 · How the mechanism works
Mechanism step 1 of 3 · no question to answer
Sample a group
Draw G completions o₁ … o_G for one prompt q.
Next, we will look at: Standardize rewards. Move on when this operation makes sense.
Visualizing the behavior
Where this sits: the RL-for-LLMs progression
GRPO: the group replaces the value model
Group-standardized advantages, G = 4
Derived3 · The governing equation
Âᵢ,ₜ = (rᵢ − mean(r₁…r_G)) / std(r₁…r_G) ρᵢ,ₜ = πθ(oᵢ,ₜ | q, oᵢ,<ₜ) / π_old(oᵢ,ₜ | q, oᵢ,<ₜ) J = E[ (1/G) Σᵢ (1/|oᵢ|) Σₜ min(ρᵢ,ₜÂᵢ,ₜ, clip(ρᵢ,ₜ, 1−ε, 1+ε)Âᵢ,ₜ) ] − β·KL(πθ ‖ π_ref)
Notation: rᵢ is the reward of completion i and ρ the per-token probability ratio. With outcome rewards, every token in a completion shares its advantage. DeepSeekMath adds the KL term to the loss rather than folding it into the reward.
Dropping the critic removes a model-sized network and its training, which suits verifiable rewards such as correct/incorrect maths answers. The costs move elsewhere. Each prompt needs G rollouts, and generation dominates wall-clock. There is no token-level credit. A group in which every completion earns the same reward has zero advantage and contributes no policy gradient. The std normalization and per-response 1/|oᵢ| average also introduce biases, which the variants address.
4 · Put concrete numbers on it
Worked numbers (from stated assumptions)5 · Common misconception to avoid
“GRPO is just REINFORCE with a group baseline.” It keeps PPO’s clipped importance ratio for sample reuse and adds a reference KL. What it removes is the critic, not the trust-region machinery.
In practice · implementation & engineering rule of thumb
Skip or resample prompt groups where all G completions receive the exact same reward (std == 0)—those groups have zero advantage and waste gradient compute.
# Group-relative advantage across G rollouts per prompt: # rewards shape: [num_prompts, G] mean_r = rewards.mean(dim=-1, keepdim=True) std_r = rewards.std(dim=-1, keepdim=True, correction=0) # population std, as in the worked example advantages = (rewards - mean_r) / (std_r + 1e-6) # Broadcasts to tokens of each rollout
6 · Self-check & interview synthesis
Explain it in your own words first
Before revealing the reference answer, try answering the opening question aloud in four beats: what it is → how the math works → what trade-off it makes → a concrete number or failure mode.
Follow-up question interviewers often ask next
MediumWhy does a prompt the model always solves contribute no policy gradient?
Show follow-up reasoning
All G rewards are equal, so every advantage is zero and the surrogate’s gradient vanishes; only the KL term acts. Those rollouts cost generation compute for no learning signal. DAPO’s dynamic sampling filters such groups out.