Custom AI models for the enterprise · New York · LondonSecurityResearchContact sales
Finetune the World
Explainer

GRPO explained: group-relative policy optimization, with the math

GRPO removes PPO’s value network by comparing each sampled answer with its siblings. That one change makes RL cheaper and introduces behaviours you need to know before using it on an enterprise task.

The idea in one paragraph#

For each prompt, sample a group of responses from the current policy, score each with a reward (often a programmatic verifier), and push the policy toward responses that scored above the group’s average and away from those below. The group average replaces the learned value function PPO uses as a baseline, saving the memory and compute of a second large network. GRPO was introduced in the DeepSeekMath paper and later popularized by reasoning-model training.

Group-relative advantages#

Given rewards for the responses to one prompt, each response’s advantage is its standardized reward:

In the outcome-reward setting, every token of response receives the same advantage .

A worked example#

Four SQL queries are sampled for one question; a verifier runs them and returns 1 if the result matches the reference, else 0. Rewards : mean 0.5, standard deviation 0.5, advantages . The two correct queries are reinforced and the two wrong ones suppressed with equal weight.

Now suppose the question is easy and all four are correct: rewards , every advantage is zero (implementations add a small to the denominator), and the prompt contributes no learning signal. The same happens when all four fail. Only prompts the model sometimes gets right teach it anything.

import torch
def group_advantages(rewards: torch.Tensor, eps: float = 1e-6) -> torch.Tensor:
    # rewards: [num_prompts, G]
    mean = rewards.mean(dim=1, keepdim=True)
    std = rewards.std(dim=1, keepdim=True, unbiased=False)
    return (rewards - mean) / (std + eps)

r = torch.tensor([[1., 0., 0., 1.], [1., 1., 1., 1.]])
print(group_advantages(r))   # [[ 1, -1, -1,  1], [0, 0, 0, 0]]

The objective#

GRPO keeps PPO’s clipped importance ratio and adds a KL penalty to a reference model directly in the loss (rather than in the reward). With :

where the per-token KL is estimated with the non-negative, unbiased estimator

The clipping (typically ) stops any single update from moving the policy too far from the one that generated the samples.

Known biases and fixes#

Two normalizations in the objective have side effects that Liu et al. analyse in detail:

  • Length normalization : for a negative advantage, spreading the penalty over more tokens makes each token’s penalty smaller, so long wrong answers are punished less than short wrong ones. Over training this can inflate response length, especially on incorrect outputs.
  • Standard-deviation normalization: prompts where the group’s rewards barely vary (nearly all right or nearly all wrong) get their small differences amplified, weighting very easy and very hard questions more heavily.

Their proposed variant, Dr. GRPO, removes both normalizations. For enterprise tasks where response length matters (tool calls, structured outputs, support replies), we monitor length on held-out prompts and prefer the unbiased form.

GRPO vs PPO vs DPO#

PPO (RLHF)GRPODPO
Learns fromreward model scores on fresh samplesrewards on groups of fresh samplesfixed preference pairs
Extra networks in memoryreward model + value modelreward model or verifier onlyreference model only
Generation during trainingyesyes, G per promptno
Relative costhighesthighlow
Best fornuanced learned rewardsverifiable outcomesexpert comparisons

On compute: a GRPO step with generates eight completions per prompt, and generation runs at low hardware utilisation, which is why RL stages dominate project compute (compute model).

Using GRPO on enterprise tasks#

The quality of a GRPO run is bounded by its verifier. Verifiers we build most often:

TaskVerifierExploit to guard against
Text-to-SQLexecute against a snapshot, compare result setsqueries that return the right rows by accident (e.g. LIMIT tricks)
Tool-calling agentschema validation + simulated tool executionvalid calls that skip a required step
Structured extractionfield-level match to labelled targetscopying spans that look right without normalizing
Classification with rationalelabel match + rationale consistency judgerationales that contradict the label

Two operational rules follow from the zero-advantage property. Curate a prompt set the SFT model solves sometimes but not always — filter out prompts with group accuracy 0 or 1 after a few epochs. And size to the pass rate: if a prompt succeeds 10% of the time, a group of 4 has a 66% chance of containing no success at all (); a group of 16 brings that to 19%.

References#

  1. Shao, Z. et al. (2024). DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models. arXiv:2402.03300.
  2. Schulman, J. et al. (2017). Proximal Policy Optimization Algorithms. arXiv:1707.06347.
  3. Liu, Z. et al. (2025). Understanding R1-Zero-Like Training: A Critical Perspective. arXiv:2503.20783.
  4. Ouyang, L. et al. (2022). Training language models to follow instructions with human feedback. arXiv:2203.02155.

Frequently asked

Can’t find your question? Ask a senior engineer.

What is GRPO in machine learning?

Group Relative Policy Optimization is a reinforcement-learning algorithm for language models that samples several responses per prompt, standardizes their rewards within the group to get advantages, and updates the policy with a PPO-style clipped objective plus a KL penalty, without a learned value function.

Is GRPO better than DPO?

They suit different data. GRPO needs a reward or verifier and generates samples during training; it can exceed the quality of demonstrations on verifiable tasks. DPO needs only fixed preference pairs and is far cheaper. Many pipelines use DPO first and GRPO where outcomes are checkable.

Why do some GRPO prompts give zero gradient?

If every response in a group gets the same reward, all standardized advantages are zero. Prompts the model always solves, or never solves, therefore contribute no learning signal.

Bring us one task. We’ll show you what a specialist model can do.

A 45-minute briefing with a senior research engineer. You leave with a feasibility read, a data plan and a fixed quote, whether or not you hire us.

Book a briefing →