What GRPO is
For a maths problem with a known answer, the reward can be computed: the final answer is right or it is not. GRPO (group relative policy optimisation) is a version of PPO for such rewards that needs no value model. For each prompt it samples a group of answers and scores each with rules. Each answer's advantage is its reward relative to the rest of its group, and every token of the answer gets that advantage. Shao et al. introduced it for DeepSeekMath, and DeepSeek-R1 used it at scale to train long reasoning.
This page runs GRPO on Qwen2.5-0.5B-Instruct (494 M parameters) with two GSM8K test problems: row 1 (a robe's bolts of fibre, answer 3) and row 3 (James's sprints, answer 540). Each round samples a group of 8 answers per problem at temperature 1, up to 320 tokens each. The policy is then updated twice on them (), for 4 rounds and 8 updates in all, following TRL's GRPOTrainer as a plain loop on the CPU.
Rule-based rewards
The system prompt asks the model to "reason step by step, and put your final answer within \boxed{}". Two rules score each answer: correct (the boxed number equals GSM8K's answer) and boxed (the answer used the box at all), combined as . A group of 8 answers lists the group with its reward chips; open an answer to read it. Rule-based rewards cannot be fooled the way a learned reward model can (see the RLHF tab), but they only exist for tasks with checkable answers.
Group-relative advantage
PPO learns a value model to tell good answers from lucky ones. GRPO uses the group as the baseline instead:
Here std is Bessel-corrected and guards against division by zero. Group-relative advantage shows the group's mean and standard deviation and each answer's . In round 1, row 1's group has mean reward 0.5625 and row 3's 0.625. Correct answers get positive advantages and are pushed up; the others get negative ones and are pushed down. A group whose answers all get the same reward has all and teaches nothing, the case the DAPO tab filters out.
Clipped objective with KL
Each token of answer gets PPO's clipped term with the ratio , minus a KL penalty to the reference model, averaged over the answer's tokens and then over the group:
with and . Unlike RLHF's PPO, the KL penalty sits in the loss, not in the reward. It uses an estimator that is never negative: with for the token, . The Clipped objective with KL strip shades the selected answer's tokens by ratio, KL or loss. On the first update of a round , so every ratio is 1 and nothing is clipped. Since the advantages sum to zero within each group, the clipped part of the loss then averages to 0, leaving only the small KL term, as Loss at each update shows; the gradient is not zero.
The estimator grows exponentially in . At update 2 the mean KL jumps to 4.46. One token that the first update made about 10,000 times less likely (its log-probability went from −0.125 to −9.389) has a KL term near 10,546. It dominates that update's loss and gradient, with a gradient norm of 486 before clipping to 1. AdamW's first steps move every weight by about the learning rate, , and that alone can shift a single token this far.
Did the policy move?
Did the policy move? re-scores round 1's answers with the policy after 0, 2, 4, 6 and 8 updates. For row 1, both answers with became more likely and all 6 with became less likely. For row 3, 1 of 2 rose and all 6 fell.
Fresh groups each round samples new answers every round. Correct answers out of 8 go 2, 7, 4, 6 and, after training, 6 for row 1, and 2, 3, 7, 4 and 3 for row 3. By the end every answer of both problems uses the box, and the mean reward of a fresh group goes from 0.594 to 1.063. The counts mix the policy's change with sampling luck: with 8 answers a group's share moves in steps of 1/8. Answers also grew longer, from 206 to 238 tokens on average.
Where GRPO came from
GRPO keeps PPO's clipped ratio (Schulman et al., 2017) and replaces the learned value baseline with the group mean, saving a second model as large as the policy. Shao et al. (2024) introduced it to train DeepSeekMath 7B, which reached 51.7 % on the competition-level MATH benchmark without tools or voting. DeepSeek-R1-Zero (2025) ran it on a base model with only accuracy and format rewards, and long chains of reasoning emerged. Liu et al. then showed two biases in the objective above. Dividing by penalises each token of a long wrong answer less than a short one's, and dividing by the group's standard deviation weights questions by difficulty. DAPO (the DAPO tab) changes the token averaging, the clip range and the sampling.
Papers
- DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models Introduces GRPO: PPO with group-relative advantages instead of a value model and a KL penalty in the loss.
- Proximal Policy Optimization Algorithms PPO’s clipped probability ratio, which GRPO keeps.
- DeepSeek-R1: Incentivizing Reasoning Capability in LLMs via Reinforcement Learning GRPO with rule-based accuracy and format rewards at scale, from a base model (R1-Zero) and after SFT (R1).
- Training Verifiers to Solve Math Word Problems GSM8K, the grade-school maths problems this page samples answers to.
- Qwen2.5 Technical Report The Qwen2.5 family, including Qwen2.5-0.5B-Instruct, the policy on this page.
- Understanding R1-Zero-Like Training: A Critical Perspective Shows the length and standard-deviation biases of GRPO’s objective and proposes Dr. GRPO without them.
See also
- ReasoningThinking Thinking mode · a budget for reasoning tokens
- ReasoningSelf-consistency Self-consistency · a majority vote over sampled answers
- Evalspass@k pass@k · sampled programs run against HumanEval tests
- Post-trainingRLOO RLOO · REINFORCE with a leave-one-out baseline
- ReasoningRepeated sampling Repeated sampling compared · the vote and the reward model on the same answers
- RLPPO PPO · GAE advantages along a trajectory and the clipped update