AI State of the Art
SOTA/Alignement : instruction, RLHF, DPO et apprentissage par renforcement/34 min
Section 114

GRPO and Online DPO: Beyond PPO for Alignment

Listen as a podcast →

Why Look for Alternatives to PPO?

PPO works. It ran the final RLHF stage of the first large aligned models, InstructGPT foremost among them. But it has a considerable operational cost.

Recall what PPO (Proximal Policy Optimization) requires. The full count, including which parts learn and which stay frozen, is in RLHF in practice; PPO's own machinery is explained in PPO, value functions and actor-critic. In short:

ModelRoleStatus
The policythe model you want to improvetrained
The critic (also called the value model)estimates "how much total reward will this beginning of a response earn"trained
The reference modelfrozen copy of the starting point, used to measure driftfrozen
The reward modelscores the responsesfrozen

Two trained models, two frozen ones: four sets of weights to host, and for the two trained ones you also have to store gradients and optimizer states. On top of that: clipping (cutting off whatever goes past a bound), Kullback-Leibler coefficients and hyperparameters everywhere, PPO is notoriously difficult to stabilize.

The natural question: can you keep RL's power (the model generates its responses and learns from its mistakes) while eliminating the complexity?

Two algorithms answer yes: GRPO and oDPO.


The Flaw in PPO That GRPO Fixes

In one sentence: PPO needs a whole critic network, which has to be trained and whose errors pollute the learning signal; GRPO deletes it and uses the average of a group of answers to the same question as its baseline.

GRPO stands for Group Relative Policy Optimization. The algorithm was introduced in the DeepSeekMath paper.

DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models (the paper that introduces GRPO)

The Central Idea

GRPO starts from a simple observation: why train a critic to estimate a response's quality, when you can directly compare responses against each other?

Instead of asking the critic "how much is this response worth?", GRPO generates a group of responses to the same prompt and compares them. The best are reinforced, the worst are penalized. No need for a separate model to estimate an "absolute value", relative comparison is enough.

It's like grading exams: instead of a complex absolute grading rubric, you rank the papers against each other.

How It Works, Step by Step

For each training prompt:

Step 1 (Generate a group of responses. The current model produces GG different responses to the same prompt) in practice a handful to a few dozen. The sampling temperature is set high enough to get diversity: temperature is the dial that decides whether the model always takes the most likely next word (low temperature, identical answers) or allows itself less likely ones (high temperature, varied answers).

Step 2, Evaluate each response. A score rir_i is assigned to each response. This score can come from a classic reward model or, even better, from an automatic verifier, that is the principle of RLVR (Reinforcement Learning with Verifiable Rewards), covered in Reward modeling and RLVR. In math for example: ri=1r_i = 1 if the answer is correct, ri=0r_i = 0 otherwise.

Step 3, Normalize within the group. Compute the mean μ\mu and standard deviation σ\sigma of the scores in the group, then each response's advantage:

Ai=ri−μσA_i = \frac{r_i - \mu}{\sigma}

The symbols: rir_i is the score of the ii-th response in the group; μ\mu (Greek mu) is the mean of those scores; σ\sigma (sigma) is their standard deviation, the usual measure of how spread out they are (see expectation and variance); AiA_i is that response's advantage. In plain words: by how much does this answer beat the group average, counted in standard deviations?

One symbol, two meanings

Careful: on this page σ\sigma means the standard deviation of a group of scores here, while further down, in the DPO loss, the same σ\sigma means the sigmoid function. That is a notation clash inherited from the papers, not a subtlety: the two objects have nothing to do with each other.

If Ai>0A_i > 0, the response is better than the group average, reinforce it. If Ai<0A_i < 0, it's worse, penalize it. This is the group baseline: each response is judged relative to the others, not in absolute terms.

Step 4, Update the model. Apply a policy gradient update weighted by these normalized advantages.

Four-quadrant diagram around four coloured petals labelled Sample, Rewards, Loss and Back propagate. Quadrant 1, Given a query sample G responses: the equation 5x plus 3 equals 18 with three worked solutions, two correct ones ticked in green giving x equals 3, one wrong one marked with a red cross giving x equals 4.2. Quadrant 2, Calculate Rewards and Advantages: rewards r1 equals 1, r2 equals 1, r3 equals 0; mean reward two thirds, about 0.6667; standard deviation about 0.4714; advantages A1 and A2 about 0.7071 and A3 about minus 1.4142. Quadrant 3, Compute the Loss: the GRPO loss formula with the probability ratio, the clipping and the KL term. Quadrant 4, Backpropagate: gradient computation and parameter update by an optimizer.
The four steps worked through on a tiny numerical example. The model produces three solutions to 5x plus 3 equals 18: two correct (reward 1) and one wrong (reward 0). The group mean is 0.6667 and the standard deviation 0.4714, which gives an advantage of plus 0.7071 to the two correct answers and minus 1.4142 to the wrong one. You can see exactly where the numbers that weight the update come from: the group scores alone, with no value network anywhere.Source : The Illustrated GRPO, Abderrahman Skiredj

The Formula Decoded

The complete GRPO loss:

LGRPO=−1G∑i=1G[min⁡(πθ(yi∣x)πold(yi∣x)Ai,  clip(πθ(yi∣x)πold(yi∣x),1−ε,1+ε)Ai)−β⋅DKL(πθ∥πref)]\mathcal{L}_{\text{GRPO}} = -\frac{1}{G} \sum_{i=1}^{G} \left[ \min\left( \frac{\pi_\theta(y_i|x)}{\pi_{\text{old}}(y_i|x)} A_i, \; \text{clip}\left(\frac{\pi_\theta(y_i|x)}{\pi_{\text{old}}(y_i|x)}, 1-\varepsilon, 1+\varepsilon \right) A_i \right) - \beta \cdot D_{KL}(\pi_\theta \| \pi_{\text{ref}}) \right]

Let's decode each piece:

  • LGRPO\mathcal{L}_{\text{GRPO}}, the loss to be minimized. GG is the number of responses in the group, and 1G∑i=1G\frac{1}{G}\sum_{i=1}^{G} simply means "average over the GG responses". xx is the prompt, yiy_i the ii-th generated response.

  • πθ\pi_\theta, the policy being trained, that is, the model itself, whose learned parameters are collectively called θ\theta (theta). πold\pi_{\text{old}} is a copy of that same model as it stood when the GG responses were generated, and πref\pi_{\text{ref}} is the frozen copy of the starting point.

  • πθ(yi∣x)πold(yi∣x)\frac{\pi_\theta(y_i|x)}{\pi_{\text{old}}(y_i|x)}, the importance ratio: how much has the probability of this response changed since the last update. If the ratio is very different from 1, the model has moved a lot.

  • clip(⋅,1−ε,1+ε)\text{clip}(\cdot, 1-\varepsilon, 1+\varepsilon), the clipping (identical to PPO): we prevent the ratio from straying too far from 1. ε\varepsilon (epsilon) is the half-width of the allowed band; with the default inherited from the PPO paper, ε=0.2\varepsilon = 0.2, the ratio is bounded between 0.8 and 1.2. This prevents overly brutal updates that would destabilize the model.

  • min⁡(⋅,⋅)\min(\cdot, \cdot), we take the minimum of both terms (clipped and unclipped). This is PPO's conservative mechanism: we never take the most optimistic update, always the most cautious.

  • AiA_i, the normalized advantage computed in step 3. This is where GRPO differs from PPO: this advantage comes from the group, not from a critic.

  • β⋅DKL(πθ∥πref)\beta \cdot D_{KL}(\pi_\theta \| \pi_{\text{ref}}), the Kullback-Leibler penalty. The Kullback-Leibler divergence, abbreviated KL after its two authors, measures how far apart two probability distributions are: it is zero when they are identical and grows as they separate. Here it measures the gap between the trained model and the frozen copy of the starting point, which stops the former from drifting away from the latter. β\beta (beta) is the coefficient that sets the strength of that constraint.

In plain words: for each of the GG responses, push its probability in the direction of its advantage, never counting more than a 20% change at once, and subtract a penalty proportional to how far the model has drifted from where it started.

Hand-drawn diagram of how GRPO works. On the left, an observation s corresponding to question q enters an Actor (LLM) that produces a policy. Below, the old policy pi theta old, repeated, generates a group of G token sequences a sub i comma 1 to a sub i comma N, each with a sequence of per-token rewards r sub i comma 1 to r sub i comma N. A brace groups these G rows and leads to the advantage estimate A hat equals r sub i minus the mean of r, divided by the standard deviation of r. Top right, the full J GRPO objective with the group average, the sequence average, the minimum between the probability ratio and its clipped version, and the minus beta times KL divergence term. Bottom right, the formula for the unbiased estimator of that KL divergence.
The same formula, laid out on the circuit that produces it. Follow the lower branch: a single question, G responses sampled with the old policy, one reward per token, and the brace that gathers the whole group to compute A hat. That value then feeds the objective at the top right, where you find the probability ratio, the clipping and the KL penalty described just above.Source : Group Relative Policy Optimization (GRPO) Illustrated Breakdown, Ebrahim Pichka
What Really Changes Compared to PPO

The formula is nearly identical to PPO. The only difference is how AiA_i is computed: PPO uses a separately trained critic to estimate the advantage, GRPO uses the group mean. By eliminating the critic, you remove an entire model from the training loop, less memory, less code, fewer things to get wrong.

Why It Works Better Than PPO in Practice

Less memory. PPO: 4 models. GRPO: 3 models (policy + reference + reward model), or just 2 if an automatic verifier replaces the reward model. Do the arithmetic in the open: a critic the same size as the policy, say 70 billion parameters, takes 70×109×2=14070 \times 10^9 \times 2 = 140 GB in BF16 (2 bytes per parameter) for its weights alone, and since it is trained, add its gradients and optimizer states, which cost at least as much again. Removing the critic removes that whole block.

More stable. PPO's critic is itself a neural network that must be trained, and its estimation errors propagate into the policy's updates. GRPO computes its baseline directly from the actual scores, no approximation error.

Simpler to implement. The reference implementation of GRPO in TRL (Transformer Reinforcement Learning, Hugging Face's post-training library) is markedly shorter than a full PPO implementation, which additionally has to host the critic, the GAE advantage estimator and all their settings.

It scales. The larger GG (the group size), the more accurate the baseline. It's a very simple compute-versus-quality trade-off to adjust.

GRPO + RLVR: The Winning Combination

GRPO shines particularly when combined with RLVR, that is, when a machine rather than a learned model decides whether the answer is right:

  1. You pose a math problem to the model
  2. GRPO generates a group of different responses
  3. An automatic verifier gives ri=1r_i = 1 (correct) or ri=0r_i = 0 (incorrect)
  4. Correct responses are reinforced, incorrect ones are penalized

No reward model, no critic, no human annotators. Just a model, a verifier, and GRPO. That simplicity is what let the open-source community launch its own DeepSeek-R1 reproductions so quickly.

Who Uses GRPO?
  • DeepSeek: GRPO is introduced in the DeepSeekMath paper; it was the use for DeepSeek-R1, on mathematical reasoning and code, that made it famous.
  • The Qwen team (Alibaba): they started from GRPO and then published their own variant, GSPO, whose abstract credits it with part of the improvements in the Qwen3 models. See GRPO variants.
  • Open-source community: thanks to libraries such as TRL and OpenRLHF, GRPO became the most common RL algorithm for R1 reproduction projects.
  • Trend: GRPO, and above all its corrected variants, have largely replaced PPO as the starting point for training reasoning.

The Flaw in DPO That oDPO Fixes

In one sentence: DPO learns from a frozen set of pairs that quickly becomes too easy for the model; oDPO builds the pairs on the fly from what the model produces right now.

A note on the name: the literature usually says online DPO; "oDPO" is a convenient shorthand, not the name of a founding paper.

The Problem with Classic DPO

DPO (Direct Preference Optimization) was a revolution: it eliminates RL entirely, training directly on preference pairs (preferred response versus rejected response). The mechanism is covered in DPO and DPO in practice.

Direct Preference Optimization: Your Language Model is Secretly a Reward Model

But DPO has a structural flaw. It is offline: you collect a dataset of preference pairs before training, then train the model on this fixed dataset. The problem?

The model evolves, but its training data stays frozen.

At the start of training, the dataset pairs are informative: they show errors the model actually makes. But as the model improves, these pairs become trivial, the model already knows the preferred response is better. It's not learning much anymore.

It's like a student who keeps solving beginner-level exercises when they've already become an expert: they get 100% but no longer progress.

The oDPO Solution: Fresh Pairs at Every Step

oDPO (online DPO) solves this problem by generating preference pairs on the fly, from the current model's responses.

The oDPO Loop, Step by Step

Step 1, Sample prompts. Draw a batch of prompts from the training dataset.

Step 2, Generate responses. For each prompt, the current model (the one being trained) generates NN different responses. This is the crucial difference from offline DPO: the responses come from the model in its current state, not from a pre-collected dataset.

Step 3, Score the responses. A reward model (or automatic verifier) assigns a score to each response.

Step 4, Form the pairs. For each prompt, take the response with the best score, chosen (preferred response), and the one with the worst score, rejected (rejected response). You now have a fresh preference pair that reflects the errors the model is making right now.

Step 5, Apply the DPO loss. Use exactly the same loss as classic DPO on these fresh pairs:

LDPO=−log⁡σ(β[log⁡πθ(yw∣x)πref(yw∣x)−log⁡πθ(yl∣x)πref(yl∣x)])\mathcal{L}_{\text{DPO}} = -\log \sigma\left(\beta \left[\log \frac{\pi_\theta(y_w|x)}{\pi_{\text{ref}}(y_w|x)} - \log \frac{\pi_\theta(y_l|x)}{\pi_{\text{ref}}(y_l|x)}\right]\right)

The symbols: ywy_w is the preferred response (ww for winner) and yly_l the rejected one (ll for loser); xx is the prompt; πθ\pi_\theta is the model being trained and πref\pi_{\text{ref}} its frozen starting copy; β\beta (beta) sets how firmly the model is held near that reference. As for σ\sigma, here it is the sigmoid function, the S-shaped curve that squashes any number into the range 0 to 1, used to turn a gap into a probability. Nothing to do with the standard deviation written σ\sigma above.

In plain words: raise the probability of the good answer and lower the probability of the bad one, but always relative to what the starting model gave them.

The formula is identical to standard DPO. What changes is that ywy_w and yly_l are generated by the current model instead of coming from a fixed dataset.

Step 6, Update the weights and repeat.

Why Fresh Pairs Make the Difference

With oDPO, preference pairs are always at the model's current level. The model never re-encounters errors it has already corrected, it's always confronted with its current mistakes. It's a training curriculum that automatically adapts to the student's level.

oDPO vs Offline DPO: When to Choose What?

Offline DPO remains relevant when:

  • You have an excellent human preference dataset (e.g., Anthropic HH, UltraFeedback)
  • Your compute resources are limited, offline DPO doesn't need to generate responses at every step
  • Human annotation quality is superior to what an automatic reward model could provide

oDPO is preferable when:

  • You have a good reward model or automatic verifier
  • Your existing preference dataset is small or of average quality
  • You are willing to pay for generation at every step in order to train on the model's current mistakes rather than on mistakes it has already fixed
What we cannot put a number on here

You will often read that online methods end up ahead of offline ones. The underlying argument is sound (learning from your current mistakes beats learning from stale ones) but the measured gap depends entirely on the dataset, the reward model and the benchmark chosen. No general figure is given here, for want of a neutral comparison to cite.


GRPO vs oDPO: What's the Difference?

Both algorithms generate responses on the fly (they're both "online"), but they differ in how they use those responses:

GRPOoDPO
Loss typePolicy gradient (RL)DPO loss (contrastive)
How are responses used?Each response individually, weighted by its advantage AiA_iAs pairs (preferred versus rejected)
Number of responses usedAll GG responses contributeOnly the 2 extremes (best and worst)
Information exploitedThe complete ranking of the groupOnly "which is better, which is worse"
Kullback-Leibler termExplicit in the lossImplicit, via the reference model
Intuition: GRPO Uses More Information

If you generate sixteen responses, GRPO uses all sixteen scores to compute advantages, every response contributes to the update. oDPO keeps only two (the best and the worst) and ignores the other fourteen. In theory GRPO is therefore more sample-efficient: it extracts more learning from the same amount of generated text, which is the expensive part. That said, the argument is theoretical, and no comparison figure is offered here.


Summary Table: PPO vs GRPO vs DPO vs oDPO

PPOGRPOOffline DPOoDPO
Models in memory4 (policy, reference, reward, critic)2-3 (policy, reference, reward or verifier)2 (policy, reference)3 (policy, reference, reward)
Generation during trainingYesYesNo (fixed dataset)Yes
Required dataPrompts + reward modelPrompts + reward model or verifierPre-collected (preferred, rejected) pairsPrompts + reward model or verifier
Implementation complexityVery highModerateLowModerate
StabilityHard to stabilizeStableVery stableStable
Who uses itOpenAI, historically (InstructGPT)DeepSeek, the Qwen teamSeveral open-weight families whose technical reports describe a DPO stageResearch, open-source projects

In Practice: When to Choose What?

  • GRPO, when you have an automatic verifier (math, code) or a good reward model, and you want to train reasoning. It's the usual starting point for reproducing DeepSeek-R1 type results, in practice in one of its corrected variants, described in GRPO variants.

  • oDPO, when you want the simplicity of DPO while working on fresh data. A good compromise if you have a reward model but no exact verifier.

  • Offline DPO, when you have an excellent human preference dataset and limited resources. Remains the simplest to implement.

  • PPO, in practice, increasingly less used for LLMs. Its complexity is no longer justified now that simpler alternatives exist.

The Underlying Trend

The ecosystem is converging toward simpler algorithms that drop PPO's most expensive components while keeping its power. GRPO and its variants dominate for reasoning (math, code); DPO and its online versions for general alignment. PPO, with its four models and dozens of hyperparameters, remains important to understand (the importance ratio and the clipping you meet everywhere come from it) but it is rarely the first choice today.

Check your understanding0 / 4

1. PPO needs a critic, an entire trained network that estimates how much a partial answer is worth. What does GRPO replace it with?

2. A preference-pair dataset was carefully collected before training. Why does it become a problem for classic DPO as training goes on?

3. You generate sixteen answers per prompt. What is the real difference between GRPO and online DPO in how those sixteen answers are used?

4. The Greek letter sigma appears both in GRPO's advantage formula and in DPO's loss function. What does it stand for?