跳转至

DiDPO:面向编程智能体训练的差分双重策略优化

文章背景与核心概要

DiDPO(Diff-in-Diff Policy Optimization,差分双重策略优化)是一种创新的无评论员(critic-free)强化学习框架,旨在解决训练编程智能体时特有的信用分配难题。传统的基于可验证奖励的强化学习(RLVR)方法在处理大型代码差异(diff)时,往往难以区分单个代码变更的具体影响,而 DiDPO 则直接作用于代码差异的结构本身。

该方法通过将多轮编程交互分解为“思维-行动”步骤,并将相似的子差异聚合为“锚点(anchors)”,有效地将差异层面的优势投影回单个 Token。在 Qwen2.5-7B-Coder 上的实验结果表明,DiDPO 的表现超过了现有的智能体强化学习基线 10% 以上,显著缩小了小型模型与大型模型之间的性能差距。


核心创新点

1. 细粒度信用分配

与依赖全局结果奖励或粗粒度步骤奖励的标准强化学习方法不同,DiDPO 将代码差异视为信用分配的主要单元。它认识到编程动作涉及复杂的跨区域变更,使得传统的奖励信号不足以支持细粒度的学习。

Unlike standard RL methods that rely on global outcome rewards or coarse step-level rewards, DiDPO treats code diffs as the primary unit of credit. It recognizes that coding actions involve complex, multi-region changes, making traditional reward signals insufficient for granular learning.

2. “可分组性得分”(Groupability Score)

DiDPO 引入了一种专门的评分机制,将完整的差异拆分为有意义的子差异。该得分平衡了以下两个方面: * 语义范围: 确保锚点代表连贯的编程逻辑。 * 分组质量: 确保产生的优势组在统计学上对训练具有显著意义。

DiDPO introduces a specialized scoring mechanism to split whole diffs into meaningful sub-diffs. This score balances: * Semantic Scope: Ensuring the anchors represent coherent coding logic. * Group Mass: Ensuring the resulting advantage groups are statistically significant for training.

3. 基于锚点的优势投影

通过将高度相似的子差异聚合为“锚点”,模型创建了优势组。这些组允许系统将代码变更的整体成功或失败投影回生成该变更的具体 Token,从而为策略优化提供更精确的信号。

By aggregating highly similar sub-diffs into "anchors," the model creates advantage groups. These groups allow the system to project the overall success or failure of a code change back to the specific tokens that generated that change, providing a more precise signal for policy optimization.


性能亮点

  • 基准测试优势: 在长程编程和推理任务中,相比强大的智能体强化学习基线,性能有显著提升。
  • 效率: 使小型模型(如 Qwen2.5-7B-Coder)能够达到通常仅大型架构才具备的性能水平。
  • 开源: 作者发布了 verl-code,这是一个专为支持各种强化学习方法和标准化编程基准测试而设计的智能体强化学习代码库。
  • Benchmark Superiority: Significant improvements in long-horizon coding and reasoning tasks compared to strong agentic RL baselines.
  • Efficiency: Enables smaller models (e.g., Qwen2.5-7B-Coder) to achieve performance levels typically reserved for much larger architectures.
  • Open Source: The authors have released verl-code, an agentic RL codebase designed to support various RL methods and standardized coding benchmarks.

访问与资源