惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google Online Security Blog
Google Online Security Blog
博客园_首页
酷 壳 – CoolShell
酷 壳 – CoolShell
Jina AI
Jina AI
博客园 - Franky
大猫的无限游戏
大猫的无限游戏
Hugging Face - Blog
Hugging Face - Blog
博客园 - 司徒正美
V
V2EX
雷峰网
雷峰网
云风的 BLOG
云风的 BLOG
V
Visual Studio Blog
F
Full Disclosure
Y
Y Combinator Blog
V
V2EX - 技术
Attack and Defense Labs
Attack and Defense Labs
S
Security @ Cisco Blogs
Schneier on Security
Schneier on Security
Microsoft Azure Blog
Microsoft Azure Blog
SecWiki News
SecWiki News
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
The GitHub Blog
The GitHub Blog
量子位
PCI Perspectives
PCI Perspectives
S
Secure Thoughts
D
Darknet – Hacking Tools, Hacker News & Cyber Security
AWS News Blog
AWS News Blog
Blog — PlanetScale
Blog — PlanetScale
爱范儿
爱范儿
K
Kaspersky official blog
B
Blog
A
Arctic Wolf
Hacker News: Ask HN
Hacker News: Ask HN
L
LangChain Blog
T
Tor Project blog
P
Privacy & Cybersecurity Law Blog
Recent Announcements
Recent Announcements
宝玉的分享
宝玉的分享
The Register - Security
The Register - Security
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
L
Lohrmann on Cybersecurity
D
Docker
A
About on SuperTechFans
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Google DeepMind News
Google DeepMind News
The Last Watchdog
The Last Watchdog
S
Security Affairs
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Privacy International News Feed
Simon Willison's Weblog
Simon Willison's Weblog

博客园 - stardsd

智能体攻防 计算语言学(computational linguistics) 状态空间模型(State Space Model, SSM) 神经符号集成(Neuro-Symbolic Integration) 动态计算分配(Dynamic Compute Allocation)技术:MoD 从LLM到SLM:小型语言模型 Claud Code 源码设计哲学总结 Claud Code源代码主提示词(prompts)中文版 REPL的实现以及Agent的REPL-Plan模式 LLM 大语言模型研究进展与趋势报告 DeepSeek DualPath 论文解读 Test Time Scaling (TTS) Web 4.0:Agentic Web CL-bench:上下文学习的评测 梅宏院士:符号主义与连接主义的结合应该成为下一代AI的发展方向 训推误差(training-inference mismatch)与重要性采样(Importance Sampling,IS) GRPO(Group Relative Policy Optimization) 算法的演进脉络以及DAPO、VAPO、SRPO、GFPO的区别与联系 VLM评估体系指标对比:CIDEr vs CLIPScore vs GPT-based Eval CIDEr公式:多模态评价指标 TDM(Tree-based Deep Model,树模型) VLM的视觉词汇表扩充(Vary:扩展大型视觉语言模型的视觉词汇量) CLIP视觉词汇表与Q-Former Agent Skill 解析 斯科特·佩奇(Scott E. Page)多样性预测定理(Diversity Prediction Theorem) AI合成数据、模型坍缩与数据焦虑问题:合成数据的扩展定律(Scaling Law) - stardsd
如何设计GRPO系算法的reasoning reward + pair采样策略
stardsd · 2026-02-03 · via 博客园 - stardsd

下面进入 「能不能把 RL 真正用在 reasoning 上」的核心工程区
reward 设计 + pair 采样策略——为什么这是 GFPO 真正赢的地方

下面内容默认背景:

  • 任务是 reasoning / 数学 / 代码 / 多步推理
  • backbone 是 LLM(policy)
  • 用的是 GRPO 系(DAPO / VAPO / SRPO / GFPO)

一、Reasoning Reward 设计(不是“对/错”那么简单)

1️⃣ Reward 的三层结构(这是工业级做法)

结论先给:真正好用的 reasoning reward 一定是「分解式」的

\( R = \alpha R_{\text{final}} + \beta R_{\text{process}} + \gamma R_{\text{format}} \)

(1)Final Reward:最终是否正确(必要,但不够)

答案正确 → +1
答案错误 → 0 / -1

数学式:

\( R_{\text{final}} = \begin{cases} 1, & \text{Answer correct} \ 0, & \text{otherwise} \end{cases} \)

⚠️ 问题:

  • 太稀疏(sparse)
  • 对 reasoning 过程完全无感知

👉 只能当“锚点”,不能当主力


(2)Process Reward:推理过程质量(核心)

这是 reasoning RL 成败的分水岭。

常见做法 A:Step-level heuristic

  • 每一步是否 逻辑自洽
  • 是否 引用了前一步结果
  • 是否出现明显 hallucination / 跳步

例子(工程里常用):

\( R_{\text{process}} = \frac{1}{T} \sum_{t=1}^{T} r_t \)

其中:

\( r_t \in {-1, 0, +1} \)

  • +1:合法推理步骤
  • 0:无信息/废话
  • -1:明显错误(数算错、逻辑断裂)

👉 可以:

  • 规则 + parser
  • 小 verifier model
  • 或 GPT-judge(弱监督)

常见做法 B:Self-consistency / Majority agreement

同一个 prompt 采样 K 条 reasoning:

\( R_{\text{process}} = \mathbb{I}(\text{path} \in \text{majority cluster}) \)

  • 多数 reasoning 路径一致 → 奖励高
  • 离群路径 → 奖励低

这是 GFPO 非常爱用的一类信号


(3)Format Reward:让模型“好好想”

不是形式主义,这在 RL 里非常重要。

- 是否使用 <thinking> / step-by-step
- 是否输出结构化 reasoning
- 是否在 answer 前完成 reasoning

例子:

\( R_{\text{format}} =\begin{cases} 1, & \text{Valid reasoning format} 0, & \text{otherwise}\end{cases} \)

👉 防止模型走捷径、直接猜答案


✅ 一个典型配置(真实项目常见)

α = 1.0   (最终正确性)
β = 0.5   (推理质量)
γ = 0.2   (格式约束)

二、Pair 采样策略(GFPO 真正拉开差距的地方)

你如果只记一句话:

GFPO 赢,不是 reward 更聪明,而是 pair 选得更毒


1️⃣ 为什么 pair sampling 比 reward 更重要?

GRPO 本质:

\( L = - \mathbb{E}_{(x^+, x^-)} \left[ \log \sigma \bigl( A(x^+) - A(x^-) \bigr) \right] \)

👉 如果 pair 选得不好

  • reward 再准也没梯度
  • learning signal 接近 0

2️⃣ 四类 Pair Sampling(从弱到强)

❌ 随机 Pair(baseline,别用)

任意两条 reasoning

问题:

  • 大多数 pair reward 接近
  • 梯度噪声大

⚠️ SRPO:Success vs Failure Pair

正确答案 vs 错误答案

形式:

\( (x^+, x^-) = (\text{correct path}, \text{wrong path}) \)

优点:

  • 简单有效

缺点:

  • 对 reasoning 中间质量无感知
  • 太 coarse

✅ VAPO / DAPO:Variance-aware Pair

高 reward path vs 低 reward path

\( (x^+, x^-) = \arg\max R - \arg\min R \)

优点:

  • 利用 reward 分布

问题:

  • 仍然可能是“明显好 vs 明显烂”
  • 对 reasoning 精修不足

🚀 GFPO:Fine-grained Reasoning Pair(关键)

GFPO 的核心思想:

只比较“几乎一样,但关键一步不同”的 reasoning

具体 Pair 构造方式

(1)Prefix-sharing Pair(最重要)

Step 1 ✔
Step 2 ✔
Step 3 ❌   ← 分歧点

构造:

\( (x^+, x^-) = (\text{correct continuation}, \text{wrong continuation}) \)

👉 梯度 直接打在那一步


(2)Near-miss Pair(差一点对)

算式只错一位 / 推导只漏一步

Reward 差距小,但 信息密度极高


(3)Self-contrast Pair(同一模型自己打自己)

同 prompt
Top-1 reasoning vs Top-2 reasoning

这是 reasoning 场景下最稳定的信号


3️⃣ GFPO Pair Sampling 伪代码(核心逻辑)

paths = sample_reasoning(policy, prompt, K)

scored = [(path, reward(path)) for path in paths]

pairs = []
for p_i, p_j in combinations(scored, 2):
    if share_long_prefix(p_i, p_j) and abs(r_i - r_j) > eps:
        pairs.append((better(p_i, p_j), worse(p_i, p_j)))

三、为什么 GFPO 在 reasoning task 上会赢?

一句话总结:

GFPO 把“我哪里想错了”变成了可学习信号

对比:

方法 学到的是什么
SRPO 对 vs 错
VAPO 高分 vs 低分
GFPO 这一步为什么错

这在:

  • 数学
  • 代码
  • 逻辑推理
  • Chain-of-Thought

上是 质变级提升


四、真实项目中该怎么选?

工程建议(非常实际)

场景 推荐
小模型 / 算力紧 SRPO
reward 噪声大 VAPO
reasoning / 数学 / 代码 GFPO(强烈)
前期冷启动 SRPO → GFPO
SFT + RL 混合 DAPO → GFPO