基于错误代码驱动的测试用例合成与密集奖励塑造的稳健代码强化学习
文章背景与核心概要
大语言模型(LLM)的代码生成能力在可验证奖励强化学习(RLVR)的推动下取得了显着提升。然而,由于测试用例覆盖率不足,这一方法的有效性常常受到限制,进而导致奖励作弊(Reward Hacking)和策略退化。为了克服这些局限性,本文推出了 RobustTests 这一新颖的框架。该框架利用错误代码驱动的测试用例合成技术以及密集奖励塑造,来提升训练的鲁棒性,减少假阴性,并全面增强 LLM 的代码生成水平。
本文提出的 RobustTests 框架通过引入“接近正确”的错误代码来捕捉潜在的逻辑偏差,并采用带有行为特征聚类的验证器智能体过滤无效或冗余的测试用例。此外,研究还引入了一种基于通过率的逐步密集奖励函数,以减轻假阴性并增强训练的稳定性。通过该流水线,研究团队构建了具有卓越诊断效用的增强版 CodeContests+ 数据集,实验证明,在 Qwen3-32B 模型上应用该框架进行强化学习微调,在 LiveCodeBench 上实现了 3% 的绝对性能提升。
论文元数据 (Paper Metadata)
- arXiv ID: 2608.24135
- 主要学科: 人工智能 (
cs.AI) - 次要学科: 软件工程 (
cs.SE) - 会议录用: 已被 EMNLP 2026 录用
- 提交日期: 2026年8月25日(修订于:2026年8月27日)
- 作者: Yiwen Zhang, Xiaodong Yan, Zhenyu Huang, Deng Zhao, Liang Jiang, Qing Cui, Zujie Wen, Zhiqiang Zhang, Jun Zhou
- 开源资源: Hugging Face 数据集 (RobustTests)
摘要 (Abstract)
可验证奖励强化学习(RLVR)对于增强 LLM 代码生成至关重要,但其效力往往因测试用例覆盖不足而受阻,从而导致奖励作弊和策略退化。为了解决这一问题,我们提出了 RobustTests,这是一个具有错误代码驱动的测试用例合成策略的框架。通过利用“接近正确”的错误代码,RobustTests 能够捕捉潜在的逻辑差异,并采用具备行为特征聚类的验证器智能体来过滤无效或冗余的测试用例。
此外,本文引入了一种基于通过率的逐步密集奖励函数,以减轻假阴性并增强训练鲁棒性。利用此流水线,我们构建了具有更优诊断效用的 CodeContests+ 数据集的增强版本。实验结果表明,通过 RobustTests 对 Qwen3-32B 进行 RL 微调,在 LiveCodeBench 上实现了 3% 的绝对提升,证明了其在推进 LLM 代码生成能力方面的有效性。
Reinforcement Learning from Verifiable Rewards (RLVR) is pivotal for enhancing LLM code generation, yet its efficacy is often hindered by insufficient test case coverage, leading to reward hacking and policy degradation. To address this, we propose RobustTests, a framework featuring a faulty-code-driven test case synthesis strategy. By leveraging "near-correct" faulty codes, RobustTests captures latent logical discrepancies and employs validator agents with behavioral feature clustering to filter invalid or redundant test cases.
Additionally, a stepwise dense reward function based on pass rates is introduced to mitigate false negatives and enhance training robustness. Using this pipeline, we construct an augmented version of the
CodeContests+dataset with superior diagnostic utility. Experimental results show that RL fine-tuning ofQwen3-32Bvia RobustTests achieves a 3% absolute gain on LiveCodeBench, demonstrating its effectiveness in advancing LLM code generation proficiency.
核心框架组件 (Key Framework Components)
- 错误代码驱动合成: 利用“接近正确”的错误代码来揭示隐藏的逻辑缺陷。
- 验证器智能体: 实施行为特征聚类,以过滤掉冗余或无效的测试用例。
- 密集奖励塑造: 采用基于通过率的逐步奖励函数,以最小化假阴性并稳定训练过程。
- Faulty-Code-Driven Synthesis: Uses "near-correct" faulty code to uncover hidden logical flaws.
- Validator Agents: Implements behavioral feature clustering to filter out redundant or invalid test cases.
- Dense Reward Shaping: Utilizes a stepwise reward function based on pass rates to minimize false negatives and stabilize the training process.