ZeroShotMind

Paper

DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models

GRPO eliminates the value network from PPO by estimating advantage from group-relative reward normalization, halving memory cost while matching quality on outcome-reward tasks.

Zhihong Shao, Peiyi Wang, Qihao Zhu, Runxin Xu, Junxian He, Yongsheng Wan, et al. — DeepSeek2024arXiv ↗Views:

rlpolicy-gradientllm-trainingreasoning

The critic is the bottleneck

PPO needs a baseline to turn raw returns into advantages, and that baseline comes from a learned value function Vϕ(s)V_\phi(s). In RLHF the value network is a second transformer, typically the same size as the policy, trained alongside it. So a 70B policy implies a 70B critic, and both must hold parameters, gradients, and optimizer state in GPU memory at once. The value network is pure training overhead — it is discarded at inference — yet it roughly doubles the memory footprint of the run and adds its own forward and backward pass to every step. At the scale where reasoning models become interesting, that second copy is often what you cannot afford.

Estimating advantage from a group

GRPO removes the critic by replacing the learned baseline with an empirical one. For a prompt qq, sample a group of GG completions {o1,,oG}\{o_1, \dots, o_G\} from the current policy and score each with the reward model to get {r1,,rG}\{r_1, \dots, r_G\}. The advantage of a completion is just its reward standardized within the group:

A^i=rimean(r1,,rG)std(r1,,rG)\hat{A}_i = \frac{r_i - \operatorname{mean}(r_1, \dots, r_G)}{\operatorname{std}(r_1, \dots, r_G)}

Every token in completion oio_i inherits this same scalar A^i\hat{A}_i, so a completion that beats its siblings gets a positive signal across all of its tokens and one that trails them gets a negative one — with no value network anywhere in the computation.

The objective

GRPO keeps PPO's clipped surrogate verbatim; only the source of A^\hat{A} changes. Writing ri,t(θ)=πθ(oi,tq,oi,<t)/πθold(oi,tq,oi,<t)r_{i,t}(\theta) = \pi_\theta(o_{i,t} \mid q, o_{i,<t}) / \pi_{\theta_\text{old}}(o_{i,t} \mid q, o_{i,<t}) for the per-token probability ratio, the loss averages the clipped objective over the tokens of each completion and the completions of each group, with an explicit KL penalty pulling the policy toward a reference:

LGRPO(θ)=E ⁣[1Gi=1G1oit=1oimin ⁣(ri,t(θ)A^i,  clip(ri,t(θ),1ϵ,1+ϵ)A^i)]+βDKL ⁣(πθπref)\mathcal{L}^{\text{GRPO}}(\theta) = -\,\mathbb{E}\!\left[\frac{1}{G}\sum_{i=1}^{G}\frac{1}{|o_i|}\sum_{t=1}^{|o_i|} \min\!\Big(r_{i,t}(\theta)\,\hat{A}_i,\; \operatorname{clip}\big(r_{i,t}(\theta),\, 1-\epsilon,\, 1+\epsilon\big)\,\hat{A}_i\Big)\right] + \beta\, D_{\text{KL}}\!\big(\pi_\theta \,\|\, \pi_\text{ref}\big)

The clip term plays exactly the role it does in PPO — it caps how far each update can move the ratio from 1 — while the β\beta term keeps the policy from drifting away from the reference model and degenerating, a job PPO usually folds into the reward instead.

Why the group mean is a valid baseline

A baseline reduces the variance of a policy gradient without biasing it, as long as it does not depend on the action being scored. The value function V(s)V(s) is the optimal such baseline: it is the expected reward over actions from state ss. The group mean mean(r1,,rG)\operatorname{mean}(r_1, \dots, r_G) is a Monte Carlo estimate of exactly that expectation — average reward over GG completions drawn from the policy at prompt qq — so subtracting it answers "was this completion better or worse than what this policy typically produces here?" Dividing by the group standard deviation rescales that comparison to unit variance, which keeps the gradient magnitude stable across prompts of wildly different difficulty.

What you give up

The group baseline buys its memory savings with resolution. Because every token of oio_i shares one scalar A^i\hat{A}_i, GRPO supplies an outcome-level advantage: it can say a whole completion was good but not which step inside it earned the credit. A PPO critic, or a process reward model that scores intermediate steps, can hand back a different A^t\hat{A}_t at each token and assign blame to the specific line where a derivation went wrong. That finer signal matters when the reward is dense. But for the tasks GRPO targets — a math answer is right or wrong, a program passes its tests or fails them — the reward is a single bit delivered at the end, and there is no intermediate truth for a token-level estimator to recover. When the reward itself is outcome-level, an outcome-level advantage loses nothing.

Choosing G

The group size GG trades estimator quality against inference cost. The group mean and standard deviation are sample statistics over GG draws, so their error shrinks like 1/G1/\sqrt{G} — a larger group gives a more accurate baseline and a less noisy advantage — but it also multiplies the number of completions you must generate per prompt, and generation, not the gradient step, dominates the wall-clock of RL on language models. In practice G=8G = 8 or G=16G = 16 sits at the knee of that curve: enough samples for the within-group statistics to be meaningful, few enough that sampling stays affordable.