TL;DR
Group Relative Policy Optimization (GRPO) fine-tunes a language model with reinforcement learning. For each question it samples a group of answers, scores each one with a reward, and uses the group's own average as the baseline. An answer is reinforced if it beat the group and discouraged if it did not. This drops the value model that PPO needs, which is usually a second network as large as the policy.
Where you'll see it: training the reasoning behaviour of open math and code models, where answers can be checked automatically and a critic network would double the memory bill.
Intuition
Grade on a curve
Imagine a class sitting an exam, where you can only say whether each answer was good or bad, not how good. A common way to grade on a curve is to compare each student to the class average. Someone above average gets credit, someone below gets a mark against them, and the absolute score does not matter so much as the ranking inside the group.
GRPO does exactly that for a language model. Pick one question, let the current model write answers to it, score every answer, and compare each score to the mean of its own group. The reward model or checker does not need to be calibrated across questions. It only needs to rank answers that answer the same question.
Why not a critic
Policy gradient methods need a baseline to reduce variance. The baseline is an estimate of how well the model usually does from a given state, and Actor-Critic Methods methods learn it with a Value Function network. PPO does this, and for language models the critic is typically another model about the size of the policy. A critic also has to produce a value at every token, but the reward model usually scores only the finished answer, so the critic has very little signal to learn from at most positions.
GRPO replaces the learned baseline with a statistic of the group. The mean of several sampled rewards is a fair baseline for the question, and it costs nothing to train. The authors of DeepSeekMath describe it as obviating the value model and using the average reward of multiple sampled outputs as the baseline.
flowchart LR
subgraph PPO
P1[Sample one answer] --> P2[Reward model scores it]
P2 --> P3[Value network estimates baseline]
P3 --> P4[Advantage per token]
end
subgraph GRPO
G1[Sample G answers] --> G2[Reward each answer]
G2 --> G3[Subtract group mean, divide by group std]
G3 --> G4[Advantage per answer, shared by its tokens]
end
The math
For a question , sample answers from the old policy and give each a scalar reward . The group-relative advantage of answer is
Every token of answer receives this same advantage, , in the outcome-supervised setting.
Here and are taken over the group only. Dividing by the standard deviation puts advantages on a comparable scale across questions where the rewards spread differently.
The objective
GRPO maximises the following objective, which is PPO's clipped surrogate applied per answer and averaged over the group, with a KL penalty against a reference model:
Here is the probability ratio for token of answer , is the clipping range, and is the KL coefficient. The inner average over divides each answer's contribution by its length, so long answers do not dominate the update.
Three pieces are worth separating:
- The ratio is the importance weight that lets the update reuse samples from the old policy (see Importance Sampling). The clip stops any single token from moving the policy too far in one step, exactly as in PPO.
- The advantage comes from the group, not from a critic.
- The KL term is added to the loss directly rather than folded into the reward. The paper argues this keeps the advantage calculation simple.
The KL estimator
The KL divergence from the policy to the reference is estimated per token with a non-negative estimator. Writing , the estimator is
This is the form in Kullback–Leibler Divergence that is guaranteed positive, and it is zero exactly when , that is, when the two models agree on that token. It is an unbiased estimator of the KL when the tokens are sampled from , which is why it is preferred to the simpler penalty that appears in the PPO reward.
Process supervision
The same machinery accepts step-level rewards. Each reasoning step gets a score, the scores are normalised across all steps of all answers in the group, and each token's advantage is the sum of normalised scores from the steps that follow it. Credit flows back from later steps to earlier tokens, which gives denser supervision than a single end-of-answer reward.
Worked examples
A question has group size . The checker gives reward 1 for a correct final answer and 0 otherwise. Suppose the sampled answers are correct, wrong, wrong, correct.
- Rewards: .
- Mean: .
- Standard deviation (population form): .
- Advantages: , , , .
Interpretation: the two correct answers each receive +1 on every token and are reinforced. The two wrong answers receive −1 and are pushed down. The baseline needed no critic, only the four rewards. A sample standard deviation would give and slightly smaller advantages, so implementations differ on this convention.
Same setup, but now all four answers are correct, so .
- Mean: .
- Standard deviation: .
- The advantage is undefined as written.
Interpretation: when a question is too easy, or too hard, every answer in the group gets the same reward and the group carries no comparative signal. Implementations add a small constant to the denominator, which makes every advantage zero, so the question contributes nothing to the update. This is a real cost of the method: a large share of questions can sit at 0 or 1 pass rate and waste compute. Filtering or re-weighting such questions is a common response.
Take one token where the reference model gives probability 0.4 and the current policy gives 0.5, so .
- Estimator: .
- , so .
- Sum: .
- Repeat with the policy moved the other way: policy probability 0.32 gives and estimator .
Interpretation: both drifts from the reference produce a small positive penalty, and the penalty grows as the ratio moves away from 1. A policy that has drifted far on many tokens pays a large total KL cost, which holds it near the model it started from. The coefficient sets how much that matters against the reward.
In the DeepSeekMath experiments, GRPO started from a supervised instruction-tuned 7B model. The RL data was about 144K chain-of-thought questions drawn from GSM8K and MATH training sets. For each question the model sampled 64 answers. The policy learning rate was , the KL coefficient was 0.04, the training batch size was 1024, the maximum length was 1024 tokens, and each batch of samples received a single gradient update before new samples were drawn. Each question therefore contributed a group of 64 advantages computed in the same way as the four-answer example above, only with a larger group.
Tradeoffs and failure modes
| Situation | Problem | Better choice |
|---|---|---|
| Reward is a learned model trained on comparisons | Group-relative ranking matches how such models are trained, which is a strength | GRPO fits well |
| Reward is sparse and binary, and most questions are too easy or too hard | Groups with identical rewards produce zero advantage, wasting compute | Filter or re-weight questions, or use a larger group |
| Long reasoning chains where credit is hard to assign | End-of-answer reward gives one scalar per answer | Process supervision, or a value model that gives per-token estimates |
| Small group size, such as 2 or 4 | The mean and standard deviation are noisy, so advantages are noisy | Larger groups, at the cost of more sampling |
| Memory is tight and a critic would not fit | GRPO needs no critic, only the policy and reference models | GRPO |
| Rewards come from a changing reward model | The group baseline shifts with the reward scale | Normalise rewards per batch, or retrain the reward model iteratively |
The failure modes follow from the design. Because the baseline is an average over only samples, it is biased toward the samples the old policy happened to produce, so the method can favour answers the current model already finds easy. Length normalisation by changes the effective weight of each token. The reward is also the only supervision: a poorly designed checker or a reward model that can be gamed will be optimised faithfully, and the KL term limits but does not prevent this.
History
Policy gradient methods that reinforce sampled actions in proportion to their returns date to the late 1980s and early 1990s, and Williams's REINFORCE is the standard reference. Proximal Policy Optimization, introduced by Schulman and colleagues in 2017, made the method stable enough for large-scale use by clipping the probability ratio. It became the default for fine-tuning language models with human feedback, as in the InstructGPT line of work, and its value network was a standard part of that recipe.
GRPO appeared in February 2024 in DeepSeekMath, from a team at DeepSeek. The paper's goal was a 7B open model that was strong at competition mathematics, and RL was one stage of that effort. The authors motivated GRPO by the cost of the value model in PPO and by the match between group comparisons and how reward models are trained on pairwise preferences. The method was used again in 2025 in DeepSeek-R1, where RL with rule-based rewards on verifiable tasks was a central part of training the reasoning behaviour.
Check yourself
QuestionRecall: what does GRPO use as the baseline for the advantage, in place of PPO's learned value function?Show answer
It uses the mean reward of the group of answers sampled for the same question, normalised by the group standard deviation. No separate network is trained to predict value. The baseline is recomputed from scratch for each question at each step.
QuestionCompute: a group of answers has rewards . What are the advantages of the four answers? Use the population standard deviation.Show answer
Mean is . Deviations are , , , . Population variance is , so the standard deviation is . Advantages are , , , and . The single correct answer receives a large positive advantage, and the three wrong ones share a small negative one. This is the normalisation doing its job: a rare success is weighted strongly.
QuestionWhy does GRPO compute the KL penalty directly in the loss rather than subtracting it from the reward, as PPO does?Show answer
Subtracting a per-token KL term from the reward would change the reward at every token, and the advantage would then be computed from the modified rewards. Because GRPO's advantage is a single group-relative number per answer, adding per-token KL to the reward would complicate the calculation of that advantage. Placing the KL term in the loss keeps the advantage defined only by the task reward, while still penalising drift from the reference model.
QuestionWhy does a question where every answer is correct contribute nothing to the update, and what would you do about it in a training run?Show answer
When all rewards are equal, the mean equals each reward and every deviation is zero, so the advantage is zero or undefined. The gradient from that group is therefore zero. In a training run, a large fraction of such questions wastes samples. Common responses are to drop questions whose pass rate is 0 or 1 for several rounds, to resample them with a harder variant, or to increase the group size so that occasional failures appear among the answers.
QuestionApplied: you are training a code model with unit tests as the reward, which is binary and cheap to compute. Your group size is 8 and most generated programs either pass all tests or fail. What do you monitor, and what would make you switch to a critic-based method?Show answer
Monitor the fraction of groups with mixed rewards, since only those carry signal, and the KL divergence and reward trajectory together. If mixed groups become rare, the run has stalled, and you would lengthen the training problems or raise the group size. You would consider a critic-based method, such as PPO with a value network, if the answers were long enough that the single end-of-answer reward gave too little credit assignment, or if per-token value estimates were needed for a dense signal that group comparisons cannot provide.
Sources
- Shao et al. (2024), DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models, where GRPO is introduced: https://arxiv.org/abs/2402.03300
- Schulman et al. (2017), Proximal Policy Optimization Algorithms: https://arxiv.org/abs/1707.06347
- DeepSeek-AI (2025), DeepSeek-R1: Incentivizing Reasoning Capability in LLMs via Reinforcement Learning: https://arxiv.org/abs/2501.12948