Group Relative Policy Optimization (GRPO)
Group Relative Policy Optimization
Section titled “Group Relative Policy Optimization”: frozen model at the end of SFT : RL model at the start of each iteration : currently updating RL model
Step 1: Group Sampling
Section titled “Step 1: Group Sampling”First, we sample a batch of prompts
Step 2: Reward Calculation
Section titled “Step 2: Reward Calculation”For each sequence, we compute the reward with a reward model or a rule-based
heuristic, obtaining
From these rewards, we compute their mean and standard deviation, obtaining
Step 3: Credit Assignment
Section titled “Step 3: Credit Assignment”Outcome supervision: The naive way would be to assume each token’s advantage
to be the same as the sequence’s, i.e.
Process supervision:
-
Group the tokens in a sequence into reasoning steps:
, where each is a contiguous span of tokens. -
For each reasoning step
, compute its cumulative reward up to and including that step: . -
Compute mean and standard deviation across all steps and sequences:
-
Normalize each step reward:
-
Assign each token
an advantage equal to the sum of normalized rewards from its step onward (letting denote the step index containing token ): . The intuition is the same as a return in RL: a token gets credit for all the reward that follows from its step, not just the reward of its immediate step. -
Calculate the token-level importance sampling ratio:
It measures how much the currently updating policy
This feeds directly into the clipped PPO objective, which is the next natural step:
where:
- The min-clip prevents the policy from updating too aggressively in a single step
- The KL penalty against
(the SFT model) keeps the RL model from drifting too far from the base A few natural additions that would make the exposition complete:
The
This is non-negative and an unbiased estimator of the true KL.
The outer training loop
Section titled “The outer training loop”After each iteration, set