Tuesday Weekly AI Post, part two. This morning I covered DPO vs RLHF and ended on "a well-tuned PPO can still win." This afternoon is the algorithm that made online RL cheap enough that many open reasoning models use it: GRPO (Group Relative Policy Optimization).
Short version: GRPO is PPO with the value model (the critic) deleted. Instead of learning a baseline, it samples a group of answers to the same prompt and uses the group's own average as the baseline. That one change is why it fits on less hardware, why it pairs so well with checkable rewards like "is the math answer right", and also where its two known biases come from.
Quick recap: what PPO needs
In the InstructGPT-style RLHF loop, PPO maximizes reward from a reward model while a KL penalty keeps the policy close to a reference model. To compute advantages (how much better this token was than expected), PPO trains a value function alongside the policy.
The DeepSeekMath paper (Shao et al., 2024), which introduced GRPO, points out two problems with that critic for LLMs:
- The value function is "typically another model of comparable size as the policy model", so it is a substantial memory and compute burden.
- Usually only the last token gets a reward score, which makes it hard to train a value function that is accurate at every token.
The GRPO idea: let the group be the baseline
For each question q, GRPO samples a group of G outputs o_1 ... o_G from the current (old) policy, scores each one, then normalizes inside the group:
A_i = (r_i - mean(r_1..r_G)) / std(r_1..r_G)
With outcome supervision, every token of output o_i gets that same advantage A_i. Then it applies the familiar PPO clipped objective with those advantages, averaged per token and per output, and subtracts a KL term to the reference model:
J_GRPO = mean over i of (1/|o_i|) * sum over t of
min( ratio_t * A_i , clip(ratio_t, 1-eps, 1+eps) * A_i ) - beta * KL(pi_theta || pi_ref)
A few details from the paper worth knowing:
- The KL is added directly to the loss, not folded into the reward as in InstructGPT-style PPO, so it doesn't complicate the advantage calculation. They use an unbiased KL estimator that is always positive.
- The group-relative advantage "aligns well with the comparative nature of reward models", because reward models are usually trained on comparisons between outputs for the same question.
- They also describe a process supervision variant, where a process reward model scores each reasoning step and a token's advantage is the sum of normalized step rewards that follow it.
What you drop: the value model. What you add: G samples per prompt. You are trading critic memory for generation compute.
The numbers from the original paper
DeepSeekMath-RL 7B setup (from the paper): policy learning rate 1e-6, KL coefficient 0.04, 64 samples per question, max length 1024, training batch size 1024, one policy update per exploration stage.
Using only a subset of English instruction-tuning data, GRPO improved the already-strong DeepSeekMath-Instruct 7B:
| Benchmark | Instruct | + GRPO |
|---|---|---|
| GSM8K | 82.9% | 88.2% |
| MATH | 46.8% | 51.7% |
| CMATH (out-of-domain) | 84.6% | 88.8% |
Why it took off: GRPO + verifiable rewards
GRPO only needs a scalar score per output. That score doesn't have to come from a neural reward model.
DeepSeek-R1 (Guo et al., 2025) trained DeepSeek-R1-Zero with RL directly on the DeepSeek-V3 base model using rule-based rewards: an accuracy reward (is the boxed math answer correct, do the test cases pass) and a format reward. They deliberately avoided neural reward models for reasoning tasks because those "are susceptible to reward hacking during large-scale reinforcement learning", and retraining them adds cost and complexity. Even in the later R1 stages, they report that more steps with a model-based preference reward "may lead to reward hacking", so those rewards were only used in the final 400 steps.
Result they report: R1-Zero's average pass@1 on AIME 2024 went from 15.6% to 77.9% during RL, and 86.7% with self-consistency decoding.
The pattern to take away: group sampling + a reward you can check in code is a much easier RL setup than a learned critic + a learned reward model.
The two biases (and the fixes you can toggle)
"Understanding R1-Zero-Like Training: A Critical Perspective" (Liu et al., 2025, the Dr. GRPO paper) found two optimization biases in the original GRPO objective:
-
Response-level length bias. Dividing each output's loss by its own length
|o_i|means correct short answers get bigger updates, and wrong long answers are penalized less. The policy drifts toward longer and longer incorrect responses. - Question-level difficulty bias. Dividing by the group's std gives more weight to questions where almost all answers are right or almost all are wrong (low std), which is a strange thing to upweight.
Their fix, Dr. GRPO, removes both normalizations. They report it improves token efficiency while keeping reasoning performance, and their minimalist R1-Zero recipe reached 43.3% on AIME 2024 with a 7B base model.
They also caution that base-model choice matters: DeepSeek-V3-Base already showed "aha moment" behavior and Qwen2.5 base models reason well even without prompt templates, so not every gain you see is caused by RL.
Running it: TRL GRPOTrainer
Hugging Face TRL's quickstart is genuinely this short (the docs say it takes about a day on 8 GPUs):
# train_grpo.py
from datasets import load_dataset
from trl import GRPOTrainer
from trl.rewards import accuracy_reward # pip install trl[math_verify]
dataset = load_dataset("trl-lib/DeepMath-103K", split="train")
trainer = GRPOTrainer(
model="Qwen/Qwen2.5-0.5B-Instruct",
reward_funcs=accuracy_reward,
train_dataset=dataset,
)
trainer.train()
A custom reward is a plain Python function that returns one float per completion. This is the TRL docs' format reward, inspired by DeepSeek-R1:
import re
def format_reward_func(completions, **kwargs):
pattern = r"^<think>.*?</think><answer>.*?</answer>$"
contents = [c[0]["content"] for c in completions]
return [1.0 if re.match(pattern, s) else 0.0 for s in contents]
Things in TRL that differ from the 2024 paper, so read your config:
-
KL is off by default (
beta = 0.0). TRL cites work showing the KL term is not essential for GRPO; setbetainGRPOConfigif you want it. -
Length normalization: TRL doesn't scale by
1/|o_i|because of the length bias above. You can pickloss_type="dapo"(normalize by total tokens in the batch) orloss_type="dr_grpo"(divide by a constant, recommended to be the max completion length). -
Std scaling:
scale_rewards=Falseturns off the per-group std division (the difficulty bias). Note that this also removes variance normalization, so update size then depends on your raw reward scale.scale_rewards="batch"uses group mean with batch-level std.
What I'd watch in a GRPO run
-
frac_reward_zero_std(TRL logs it): the fraction of prompts where every sample got the same reward. If all G answers are right or all are wrong, the advantage is zero and that prompt teaches nothing. If this is high, your prompts are too easy or too hard for the current model. -
completions/mean_lengthover time, split by correct vs incorrect if you can. Growing wrong answers is the length bias showing up. -
Reward hacking: read samples. A format reward that only checks tags can be satisfied by an empty
<think></think>. - Held-out evals outside your reward. The reward going up is not the same as the model getting better.
When to use GRPO vs DPO
- You have preference pairs and no way to check answers: start with DPO (this morning's post). It's offline, cheap, and stable.
- You can score answers in code (math, unit tests, schema validation, exact match): GRPO with a verifiable reward is the natural fit, and the group-relative baseline removes the critic.
- Budget: GRPO saves critic memory but spends it on G generations per prompt, so generation throughput (often vLLM) becomes your bottleneck.
References
- Shao et al., 2024, DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models (introduces GRPO): https://arxiv.org/abs/2402.03300
- DeepSeek-AI (Guo et al.), 2025, DeepSeek-R1: Incentivizing Reasoning Capability in LLMs via Reinforcement Learning: https://arxiv.org/abs/2501.12948
- Liu et al., 2025, Understanding R1-Zero-Like Training: A Critical Perspective (Dr. GRPO): https://arxiv.org/abs/2503.20783
- Hugging Face TRL, GRPO Trainer docs: https://huggingface.co/docs/trl/main/en/grpo_trainer
- This morning's companion post, DPO vs RLHF: https://dev.to/m_t_ramkrushna/dpo-vs-rlhf-explained-the-same-objective-without-the-reward-model-and-when-ppo-still-wins-3ee5
Question for you: if you've run GRPO, what reward did you use, and did you keep the KL term?
Top comments (0)