LLM RL 核心算法:PPO、DPO、GRPO
这篇只聚焦三件事:PPO 是经典 online RLHF(模型边采样边用奖励更新),DPO 是 offline preference optimization(只用 chosen / rejected 偏好对),GRPO 是 critic-free reasoning RL(用同题多答案的组内相对奖励替代 value model)。其他变体可以之后单开一篇,这里先梳理主干。
0. 先背这张表
| 算法 | 最短定位 | 数据从哪来 | 是否 online rollout | 是否需要 critic | 适合场景 |
|---|---|---|---|---|---|
| PPO | 经典 RLHF | reward model / rule reward / judge | 是 | 通常需要 | 通用对齐、reward model 已经有了 |
| DPO | 偏好对齐 | chosen / rejected pair | 否 | 不需要 | 指令风格、偏好数据、稳定省事 |
| GRPO | 推理 RL | 同题多采样后的 reward group | 是 | 不需要 | 数学、代码、可验证 reward 的 reasoning |
记忆法:
PPO = 在线采样 + reward model/function + critic baseline + KL/clip
DPO = 离线偏好对 + reference model + 分类式 loss
GRPO = 在线同题多采样 + 组内相对 reward + no critic
1. 共同底层:Policy Gradient
LLM 可以看成策略:
pi_theta(y | x)
给定 prompt x,模型生成答案 y。RL 的目标是最大化期望奖励:
maximize_theta E_{x ~ D, y ~ pi_theta(. | x)}[R(x, y)]
最朴素的更新方向:
grad J(theta) ~= A(x, y) * grad log pi_theta(y | x)
直觉:
- 比 baseline 更好的回答,增加生成概率。
- 比 baseline 更差的回答,降低生成概率。
- 真正训练时要减方差、控 KL、处理长序列,所以才会演化出 PPO / GRPO 这类更稳定的目标。
2. PPO:经典 RLHF
PPO 的标准 RLHF pipeline:
SFT model
-> train reward model from preference data
-> online rollout with current policy
-> PPO update policy under KL constraint
LLM 版 PPO 常见奖励:
reward = reward_model_score - beta * KL(pi_theta || pi_ref)
PPO 训练时通常有四个角色:
| 角色 | 作用 |
|---|---|
| policy model | 正在被训练的 LLM |
| reference model | 通常是 SFT checkpoint,用来计算 KL,限制别跑飞 |
| reward model / reward function | 给完整回答或过程打分 |
| value model / critic | 估计 baseline / value,帮助算 advantage、降方差 |
PPO 的核心目标可以这样理解:
ratio = pi_theta(token) / pi_old(token)
objective = min(ratio * advantage, clip(ratio, 1-eps, 1+eps) * advantage)
这里的 pi_old 是采样 rollout 时的旧策略;PPO 更新时用 importance ratio 比较“现在的 policy”和“采样时的 policy”。为什么要 clip:如果新 policy 相对旧 policy 变化过大,就截断更新,避免一次梯度更新导致训练不稳定。
PPO 的具体流程
假设 prompt 是:
写一个 Python 函数,判断括号字符串是否合法。
当前 policy 采样出一个回答:
用栈扫描字符串;遇到左括号入栈,遇到右括号检查栈顶是否匹配。
训练时会发生这几步:
| 步骤 | 发生了什么 | 这个量用来干嘛 |
|---|---|---|
| 1. rollout | 当前 policy 真正生成一条答案 | 得到一条 token trajectory |
| 2. reward | reward model / unit test / judge 给答案打分,比如 0.86 |
告诉模型这条答案好不好 |
| 3. KL penalty | 如果新模型离 reference 太远,扣掉一点分,比如 0.06 |
防止为了 reward 把语言能力训坏 |
| 4. critic | value model 预测每个 prefix 未来大概能拿多少分 | 提供 baseline,降低方差 |
| 5. advantage | actual return - critic prediction |
判断这段生成比预期好还是差 |
| 6. PPO update | 用 clipped ratio 更新 token 概率 | 好的 token trajectory 概率上升,坏的下降 |
一个数字例子:
reward_model_score = 0.86
kl_penalty = 0.06
actual_return = 0.80
critic prediction at this prefix = 0.55
advantage = 0.80 - 0.55 = +0.25
这说明这段生成比 critic 预期更好,PPO 会提高这条回答里相关 token 的概率。但如果某个 token 的概率变化太猛:
ratio = pi_theta(token) / pi_old(token) = 1.35
clip range = [0.8, 1.2]
那这个样本的 surrogate objective 会被截到 1.2 * advantage,不再鼓励 ratio 继续变大。直觉就是:
可以朝高 reward 方向走,但一步不能迈太大。
如果另一个回答 reward 很低:
actual_return = 0.20
critic prediction = 0.55
advantage = -0.35
对应 token 的概率就会被压低。PPO 的重点不是只看 reward,而是看:
这个生成结果是否比 critic 原本预期更好?
新 policy 相对 old policy 改得是否过猛?
新 policy 是否离 reference model 太远?
PPO 的优点:
- online RL,能直接优化 reward。
- 适合 reward model 已经比较可靠的通用 RLHF。
- 有 critic 和 clipping,训练信号比裸 REINFORCE 稳。
PPO 的缺点:
- 工程重:policy / ref / reward / critic 多模型协同。
- critic 训练不稳会直接影响 advantage。
- 对超参、KL 系数、reward scale 比较敏感。
3. DPO:偏好优化,不是传统 online RL
DPO 直接使用偏好对:
prompt x
chosen answer y_w > rejected answer y_l
它不需要先训练一个显式 reward model,也不需要在线采样 rollout。核心是让模型相对 reference 更偏向 chosen、更远离 rejected:
log pi_theta(y_w | x) - log pi_ref(y_w | x)
should be larger than
log pi_theta(y_l | x) - log pi_ref(y_l | x)
DPO loss 的直觉版:
loss = -log sigmoid(
beta * [
log_ratio(chosen) - log_ratio(rejected)
]
)
其中 log_ratio(y)=log pi_theta(y|x)-log pi_ref(y|x),beta 控制偏好强度和相对 reference 的保守程度。这里的 reference model 仍然很关键:它不是 critic,而是用来限制模型偏离原始行为的基准。
从技术上说,DPO 更准确地说是从 KL 正则化 RLHF 推导出的离线偏好优化方法。它利用最优 KL 正则化策略与隐式 reward 之间的闭式关系,避免训练单独的 reward model 和运行在线 RL。
DPO 的具体流程
DPO 不让模型在线试错,而是直接吃偏好数据。比如一条训练样本是:
Prompt:
解释 reward model 和 critic 的区别。
Chosen:
reward model 是裁判,给完整答案打分;critic 是预测器,估计当前状态未来能拿多少 reward。
Rejected:
reward model 和 critic 都是给模型打分的东西,差别不大。
DPO 看的是:当前模型相对 reference model,有没有更偏向 chosen。
假设当前 policy 的 log probability 是:
log pi_theta(chosen | x) = -120
log pi_theta(rejected | x) = -115
这说明当前模型反而更容易生成 rejected,因为 -115 比 -120 概率更高。
再看 reference model:
log pi_ref(chosen | x) = -118
log pi_ref(rejected | x) = -116
于是 DPO 比较的是两个 reference-relative ratio:
chosen_log_ratio = -120 - (-118) = -2
rejected_log_ratio = -115 - (-116) = +1
gap = chosen_log_ratio - rejected_log_ratio = -3
gap 是负的,说明当前模型相对 reference 更偏向 rejected。DPO loss 会推动:
increase log pi_theta(chosen | x)
decrease log pi_theta(rejected | x)
所以 DPO 的训练信号不是:
这个答案 reward = 0.8
而是:
同一个 prompt 下,chosen 相对 reference 的 log-prob improvement 应该高于 rejected。
注意:实际实现里通常用整段回答的 token log-probability 求和或平均;回答长度、截断方式和 tokenizer 都会影响数值,所以 DPO 样本最好保证 chosen / rejected 在同一 prompt 下可比。
它的关键优点是工程简单:不需要 rollout、不需要显式 / 单独的 reward model 在线打分,也不需要 critic。缺点也来自这里:模型只能从已有偏好对中学习,不会主动探索全新的更优答案。
DPO 的优点:
- 简单稳定,不用在线 RL 环境。
- 不需要单独 reward model 和 critic。
- 对现成 preference pair 数据非常友好。
DPO 的缺点:
- 不会主动探索新答案,只能从离线偏好数据里学。
- 对数学、代码这类可验证任务,常常不如 online RLVR 直接。
- 如果偏好数据覆盖不够,模型容易学到风格而不是能力。
4. GRPO:推理模型常用的 critic-free RL
GRPO 的核心是同一个 prompt 采样多个答案,然后组内比较。
Prompt x
├── answer A -> reward 0.9
├── answer B -> reward 0.7
├── answer C -> reward 0.2
└── answer D -> reward 0.0
用组内均值做 baseline、组内标准差做 normalization:
mean = 0.45
std = 0.36
A_adv = (0.9 - 0.45) / 0.36 = +1.25
B_adv = (0.7 - 0.45) / 0.36 = +0.69
C_adv = (0.2 - 0.45) / 0.36 = -0.69
D_adv = (0.0 - 0.45) / 0.36 = -1.25
所以它可以省掉 value model / critic:
PPO: reward function + critic baseline
GRPO: reward function + group-relative baseline
GRPO 的具体流程
假设 prompt 是一道数学题:
如果 3x + 5 = 20,求 x。
GRPO 不只采样一个答案,而是同一个 prompt 采样一组答案:
| 样本 | 模型回答 | reward |
|---|---|---|
| A | 3x=15,所以 x=5 |
1.0 |
| B | 3x=25,所以 x=8.33 |
0.0 |
| C | x=(20-5)/3=5 |
1.0 |
| D | x=15 |
0.0 |
组内平均 reward 是 baseline,组内标准差负责归一化:
mean_reward = (1.0 + 0.0 + 1.0 + 0.0) / 4 = 0.5
std_reward = 0.5
于是每个回答的 advantage 可以近似理解成:
A_adv = (1.0 - 0.5) / 0.5 = +1.0
B_adv = (0.0 - 0.5) / 0.5 = -1.0
C_adv = (1.0 - 0.5) / 0.5 = +1.0
D_adv = (0.0 - 0.5) / 0.5 = -1.0
训练更新就很直观:
A / C 的 token 概率上升
B / D 的 token 概率下降
这里没有单独的 value model,因为 baseline 来自同一个 prompt 的 group mean,std 只负责把尺度拉齐。也就是说:
PPO 问 critic: 这个 prefix 未来大概值多少分?
GRPO 问同组样本: 这个答案比同题其他答案强还是弱?
GRPO 还会保留 PPO 类似的 ratio / KL 控制,避免模型为了拿 reward 过度偏离 reference。它最适合数学、代码、选择题、格式可验证任务,因为 reward 可以自动算:
数学: 最终答案是否正确
代码: unit tests 是否通过
工具调用: 任务是否完成、证据是否满足
GRPO 特别适合 RLVR(reinforcement learning with verifiable rewards):
- 数学题:最终答案可校验。
- 代码题:unit test 可校验。
- STEM / reasoning:可以用 rule-based verifier 或 judge;如果用 LLM-as-judge,要额外防 judge bias 和 reward hacking。
GRPO 的优点:
- 不训练 critic,显存和工程复杂度更低。
- 同题多样本天然产生相对比较信号。
- DeepSeekMath 引入了 GRPO;DeepSeek-R1-Zero 使用 GRPO 风格的大规模 RL;DeepSeek-R1 又加入 cold-start SFT、rejection sampling / SFT 和额外 RL 阶段,所以 R1 不能简化成“只用了 GRPO”。
GRPO 的缺点:
- 需要 online rollout,采样成本高。
- reward 最好可验证;纯主观偏好任务不一定适合。
- group size、reward normalization、KL 控制都会影响稳定性。
5. Reward Model 和 Critic 不要混淆
| 项目 | Reward model / reward function | Critic / value model |
|---|---|---|
| 一句话 | 裁判 | 预测器 |
| 输出 | 这个回答得几分 | 当前状态未来大概能得几分 |
| 是否直接作为 policy reward signal | 是,policy 要提高 reward | 不直接作为 reward;critic 自身要拟合 value / return,并用来算 advantage |
| PPO 需要吗 | 需要 reward 信号 | 通常需要 |
| GRPO 需要吗 | 需要 reward 信号 | 不需要 |
| DPO 需要吗 | 不显式需要 | 不需要 |
最容易被问的点:
reward model: answer -> score
critic: partial trajectory/state -> expected return
advantage: per-token/step return estimate (often GAE / KL-shaped) - critic prediction
6. 怎么选算法
| 条件 | 优先选 |
|---|---|
| 只有 chosen/rejected 偏好对,想快速稳定对齐 | DPO |
| 有可靠 reward model,要做经典 RLHF | PPO |
| 数学/代码/推理,reward 可自动验证 | GRPO |
| 训练资源有限,不想维护 critic | DPO 或 GRPO |
| 想让模型在在线 rollout 里探索更优 reasoning,且 reward 能可靠自动验证 | GRPO |
| 想最大化通用 reward,同时 reward model 已成熟 | PPO |
最实用的面试回答:
PPO 是传统 RLHF 主力,完整但重;DPO 是偏好对齐主力,离线、简单、稳定;GRPO 是 reasoning RL 主力,用组内相对 reward 替代 critic,适合数学/代码这类可验证任务。
7. 高频问答
DPO 算不算 RL?
广义上它来自 RLHF 目标的推导,狭义上不是传统 online RL。它没有 rollout、没有环境交互、没有 critic,更准确叫 offline preference optimization。
GRPO 为什么不需要 critic?
因为它对同一个 prompt 采样多个答案,用组内 reward 的均值构造 baseline,再用组内标准差归一化 advantage。critic 的作用是提供 baseline,GRPO 用 group baseline 替代了它。
PPO 和 GRPO 最大区别?
PPO 通常训练 value model / critic 来估计 advantage;GRPO 用同题多样本的相对 reward 估计 advantage。PPO 更通用,GRPO 在可验证 reasoning 任务上更省、更直接。
三者共同点是什么?
都在控制“新模型相对旧模型/reference model 的概率变化”。PPO 用 ratio clipping 和 KL,DPO 用 reference-relative preference loss,GRPO 通常也会保留 KL 或 ratio clipping。
8. 最终速记
PPO:
在线 RLHF;reward model/function + critic + KL/clip
通用 RLHF 最强基线之一,但成本高、对超参敏感
DPO:
离线偏好优化;chosen/rejected 偏好对
无 rollout、无显式 reward model、无 critic
简单稳定,适合 instruction / preference alignment
GRPO:
在线 critic-free RL;group-relative advantage
无 value model,适合可验证 reasoning reward
常见于现代可验证推理 RL
Core LLM RL Algorithms: PPO, DPO, GRPO
This note focuses on three central algorithms: PPO as the classic online RLHF workhorse, DPO as a common offline preference optimization method, and GRPO as a critic-free RL method often used in reasoning-model training. Many variants deserve their own post; this page focuses on the core ideas.
0. Memorize This Table First
| Algorithm | Short description | Where the data comes from | Online rollout? | Needs a critic? | Best fit |
|---|---|---|---|---|---|
| PPO | Classic RLHF | reward model / rule reward / judge | Yes | Usually yes | General alignment when a reward model already exists |
| DPO | Preference alignment | chosen / rejected pair | No | No | Instruction style, preference data, stable and simple tuning |
| GRPO | Reasoning RL | reward group from multiple samples for the same prompt | Yes | No | Math, code, and reasoning with verifiable rewards |
Mnemonic:
PPO = online sampling + reward model/function + critic baseline + KL/clip
DPO = offline preference pairs + reference model + classification-style loss
GRPO = online multi-sampling per prompt + group-relative reward + no critic
1. Shared Foundation: Policy Gradient
An LLM can be viewed as a policy:
pi_theta(y | x)
Given a prompt x, the model generates an answer y. The RL objective is to maximize expected reward:
maximize_theta E_{x ~ D, y ~ pi_theta(. | x)}[R(x, y)]
The simplest update direction is:
grad J(theta) ~= A(x, y) * grad log pi_theta(y | x)
Intuition:
- If an answer is better than the baseline, increase its generation probability.
- If an answer is worse than the baseline, decrease its generation probability.
- Real training must reduce variance, control KL drift, and handle long sequences, which is why more stable objectives such as PPO and GRPO are used.
2. PPO: Classic RLHF
The standard PPO-based RLHF pipeline is:
SFT model
-> train reward model from preference data
-> online rollout with current policy
-> PPO update policy under KL constraint
A common LLM PPO reward is:
reward = reward_model_score - beta * KL(pi_theta || pi_ref)
PPO training usually has four roles:
| Role | What it does |
|---|---|
| policy model | The LLM being trained |
| reference model | Usually the SFT checkpoint; used to compute KL and keep the policy from drifting too far |
| reward model / reward function | Scores the full answer or the process |
| value model / critic | Estimates the baseline / value, helps compute advantage, and reduces variance |
The core PPO objective can be understood as:
ratio = pi_theta(token) / pi_old(token)
objective = min(ratio * advantage, clip(ratio, 1-eps, 1+eps) * advantage)
Here pi_old is the old policy that produced the rollout samples. During the PPO update, the importance ratio compares the current policy with the policy used at sampling time. The reason for clip is simple: if the new policy changes too much relative to the old policy, PPO truncates the update to avoid destabilizing training in a single gradient step.
The PPO Workflow
Suppose the prompt is:
Write a Python function that checks whether a bracket string is valid.
The current policy samples this answer:
Scan the string with a stack; push left brackets, and when a right bracket appears, check whether it matches the stack top.
Training then goes through these steps:
| Step | What happens | What the quantity is used for |
|---|---|---|
| 1. rollout | The current policy actually generates an answer | Produces a token trajectory |
| 2. reward | The reward model / unit test / judge scores the answer, for example 0.86 |
Tells the model whether this answer is good |
| 3. KL penalty | If the new model is too far from the reference, subtract a penalty, for example 0.06 |
Prevents reward optimization from damaging language ability |
| 4. critic | The value model predicts the expected future score for each prefix | Provides a baseline and reduces variance |
| 5. advantage | actual return - critic prediction |
Decides whether this generation was better or worse than expected |
| 6. PPO update | Update token probabilities with the clipped ratio | Good token trajectories go up; bad ones go down |
A numeric example:
reward_model_score = 0.86
kl_penalty = 0.06
actual_return = 0.80
critic prediction at this prefix = 0.55
advantage = 0.80 - 0.55 = +0.25
This means the generation was better than the critic expected, so PPO increases the probability of the relevant tokens in that answer. But if a token probability changes too aggressively:
ratio = pi_theta(token) / pi_old(token) = 1.35
clip range = [0.8, 1.2]
the surrogate objective for that sample is clipped to 1.2 * advantage, so it no longer encourages the ratio to grow further. The intuition is:
Move toward higher reward, but do not take too large a step at once.
If another answer has low reward:
actual_return = 0.20
critic prediction = 0.55
advantage = -0.35
the corresponding token probabilities are pushed down. PPO is not just asking “what is the reward?” It is asking:
Was this generation better than the critic expected?
Did the new policy change too much relative to the old policy?
Is the new policy too far from the reference model?
PPO strengths:
- It is online RL and can directly optimize a reward signal.
- It is suitable for general RLHF when the reward model is reasonably reliable.
- With a critic and clipping, it is more stable than raw REINFORCE.
PPO weaknesses:
- It is engineering-heavy: policy / reference / reward / critic models must work together.
- Unstable critic training directly corrupts the advantage estimates.
- It is sensitive to hyperparameters, KL coefficients, and reward scale.
3. DPO: Preference Optimization, Not Traditional Online RL
DPO directly consumes preference pairs:
prompt x
chosen answer y_w > rejected answer y_l
It does not require training an explicit reward model first, and it does not need online rollout. The core idea is to make the model prefer the chosen answer over the rejected answer relative to a reference model:
log pi_theta(y_w | x) - log pi_ref(y_w | x)
should be larger than
log pi_theta(y_l | x) - log pi_ref(y_l | x)
An intuitive DPO loss:
loss = -log sigmoid(
beta * [
log_ratio(chosen) - log_ratio(rejected)
]
)
where log_ratio(y)=log pi_theta(y|x)-log pi_ref(y|x), and beta controls preference strength and conservatism relative to the reference. The reference model is still crucial: it is not a critic; it is the behavioral anchor that limits how far the model moves away from the original policy.
Technically, DPO is best described as an offline preference optimization method derived from KL-regularized RLHF. It uses the closed-form relationship between an optimal KL-regularized policy and its implicit reward to avoid training a separate reward model and running online RL.
How DPO Works
DPO does not let the model learn by online trial and error. It trains directly on preference data. For example:
Prompt:
Explain the difference between a reward model and a critic.
Chosen:
A reward model is a judge that scores a complete answer; a critic is a predictor that estimates how much future reward the current state can obtain.
Rejected:
A reward model and a critic both score the model; there is not much difference.
DPO asks whether the current model, relative to the reference model, prefers the chosen answer.
Suppose the current policy log probabilities are:
log pi_theta(chosen | x) = -120
log pi_theta(rejected | x) = -115
This means the current model is actually more likely to generate the rejected answer, because -115 is a higher log probability than -120.
Now look at the reference model:
log pi_ref(chosen | x) = -118
log pi_ref(rejected | x) = -116
DPO compares the two reference-relative ratios:
chosen_log_ratio = -120 - (-118) = -2
rejected_log_ratio = -115 - (-116) = +1
gap = chosen_log_ratio - rejected_log_ratio = -3
The gap is negative, so the current model is more tilted toward the rejected answer than the reference is. The DPO loss pushes it to:
increase log pi_theta(chosen | x)
decrease log pi_theta(rejected | x)
So the training signal is not:
this answer has reward = 0.8
It is:
for the same prompt, the chosen answer should improve relative to the reference more than the rejected answer
In practice, implementations usually sum or average token log probabilities across the whole answer. Answer length, truncation, and tokenizer behavior all affect the values, so chosen / rejected samples should be comparable under the same prompt.
DPO’s main advantage is engineering simplicity: no rollout, no explicit / separate online reward-model scoring, and no critic. Its limitation comes from the same place: the model learns only from existing preference pairs and does not actively explore new, better answers.
DPO strengths:
- Simple and stable; no online RL environment is required.
- No separate reward model or critic is needed.
- Very convenient when chosen / rejected preference pairs already exist.
DPO weaknesses:
- It does not actively explore new answers; it learns from offline preference data.
- For math and code tasks with verifiable outcomes, direct online RLVR is often stronger.
- If preference coverage is poor, the model may learn style more than capability.
4. GRPO: Critic-Free RL Often Used for Reasoning Models
The core idea of GRPO is to sample multiple answers for the same prompt and compare them within the group.
Prompt x
├── answer A -> reward 0.9
├── answer B -> reward 0.7
├── answer C -> reward 0.2
└── answer D -> reward 0.0
Use the group mean as the baseline and the group standard deviation for normalization:
mean = 0.45
std = 0.36
A_adv = (0.9 - 0.45) / 0.36 = +1.25
B_adv = (0.7 - 0.45) / 0.36 = +0.69
C_adv = (0.2 - 0.45) / 0.36 = -0.69
D_adv = (0.0 - 0.45) / 0.36 = -1.25
This lets GRPO remove the value model / critic:
PPO: reward function + critic baseline
GRPO: reward function + group-relative baseline
How GRPO Works
Suppose the prompt is a math problem:
If 3x + 5 = 20, what is x?
GRPO does not sample only one answer. It samples a group of answers for the same prompt:
| Sample | Model answer | reward |
|---|---|---|
| A | 3x=15, so x=5 |
1.0 |
| B | 3x=25, so x=8.33 |
0.0 |
| C | x=(20-5)/3=5 |
1.0 |
| D | x=15 |
0.0 |
The group mean reward is the baseline, and the group standard deviation normalizes scale:
mean_reward = (1.0 + 0.0 + 1.0 + 0.0) / 4 = 0.5
std_reward = 0.5
Each answer’s advantage can be understood as:
A_adv = (1.0 - 0.5) / 0.5 = +1.0
B_adv = (0.0 - 0.5) / 0.5 = -1.0
C_adv = (1.0 - 0.5) / 0.5 = +1.0
D_adv = (0.0 - 0.5) / 0.5 = -1.0
The update is intuitive:
increase the token probabilities for A / C
decrease the token probabilities for B / D
There is no separate value model. The baseline comes from the group mean for the same prompt; the standard deviation only rescales the advantage. In other words:
PPO asks the critic: roughly how much future reward is this prefix worth?
GRPO asks the group: is this answer better or worse than the other answers for the same problem?
GRPO still usually keeps PPO-like ratio / KL control so the model does not over-optimize reward and drift too far from the reference policy. It is especially suitable for math, code, multiple-choice, and format-verifiable tasks because rewards can be computed automatically:
math: whether the final answer is correct
code: whether unit tests pass
tool use: whether the task is completed and the evidence satisfies the requirement
GRPO is especially natural for RLVR, or reinforcement learning with verifiable rewards:
- Math: the final answer can be checked.
- Code: unit tests can verify behavior.
- STEM / reasoning: a rule-based verifier or judge can be used; if using an LLM-as-judge, watch for judge bias and reward hacking.
GRPO strengths:
- No critic training, so memory and engineering complexity are lower.
- Multiple samples for the same prompt naturally provide relative comparison signals.
- DeepSeekMath introduced GRPO; DeepSeek-R1-Zero used GRPO-style large-scale RL; DeepSeek-R1 then added cold-start SFT, rejection sampling / SFT, and additional RL stages, so R1 should not be simplified to “only GRPO.”
GRPO weaknesses:
- It still requires online rollout, so sampling cost is high.
- Rewards should preferably be verifiable; purely subjective preference tasks are not always a good fit.
- Group size, reward normalization, and KL control all affect stability.
5. Do Not Confuse Reward Model and Critic
| Item | Reward model / reward function | Critic / value model |
|---|---|---|
| One-liner | Judge | Predictor |
| Output | How good this answer is | How much future reward this state is expected to get |
| Direct policy reward signal? | Yes, the policy tries to increase reward | Not directly a reward; the critic fits value / return and is used to compute advantage |
| Needed by PPO? | Needs a reward signal | Usually yes |
| Needed by GRPO? | Needs a reward signal | No |
| Needed by DPO? | Not explicitly | No |
The most interview-relevant distinction:
reward model: answer -> score
critic: partial trajectory/state -> expected return
advantage: per-token/step return estimate (often GAE / KL-shaped) - critic prediction
6. How to Choose
| Condition | Prefer |
|---|---|
| You only have chosen/rejected preference pairs and want fast, stable alignment | DPO |
| You have a reliable reward model and want classic RLHF | PPO |
| Math / code / reasoning, and rewards can be automatically verified | GRPO |
| Training resources are limited and you do not want to maintain a critic | DPO or GRPO |
| You want the model to explore better reasoning through online rollout, and reward can be reliably verified | GRPO |
| You want to maximize a general reward, and the reward model is mature | PPO |
The most practical interview answer:
PPO is the traditional RLHF workhorse: complete but heavy. DPO is the preference-alignment workhorse: offline, simple, and stable. GRPO is a reasoning-RL workhorse: it replaces the critic with group-relative reward and is well suited to verifiable math/code-style tasks.
7. Common Questions
Is DPO RL?
In a broad sense, it is derived from an RLHF objective. In the narrower, traditional sense, it is not online RL: there is no rollout, no environment interaction, and no critic. It is more accurate to call it offline preference optimization.
Why Does GRPO Not Need a Critic?
Because it samples multiple answers for the same prompt, uses the group reward mean as the baseline, and uses the group standard deviation to normalize advantage. The critic’s role is to provide a baseline; GRPO replaces it with a group baseline.
What Is the Biggest Difference Between PPO and GRPO?
PPO usually trains a value model / critic to estimate advantage. GRPO estimates advantage from relative rewards among multiple samples for the same prompt. PPO is more general; GRPO is cheaper and more direct for verifiable reasoning tasks.
What Do All Three Share?
All three control how much the new model’s probabilities change relative to an old policy or reference model. PPO uses ratio clipping and KL, DPO uses a reference-relative preference loss, and GRPO usually keeps KL or ratio clipping as well.
8. Final Cheat Sheet
PPO:
online RLHF, reward model/function + critic + KL/clip
strongest general RLHF baseline, but expensive and sensitive
DPO:
offline preference optimization, chosen/rejected pair
no rollout, no explicit reward model, no critic
simple, stable, good for alignment
GRPO:
online critic-free RL, group-relative advantage
no value model, good for verifiable reasoning rewards
common in modern verifiable reasoning RL