arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2603.05863cs.CLcs.LGcs.SE
收藏

ReflexiCoder:通过强化学习教大语言模型自我反思和自我纠正生成的代码

ReflexiCoder: Teaching Large Language Models to Self-Reflect on Generated Code and Self-Correct It via Reinforcement Learning

The Hong Kong University of Science and Technology (Guangzhou)(香港科技大学(广州));The Hong Kong University of Science and Technology(香港科技大学);Amazon AGI(亚马逊人工智慧实验室);NAVER Cloud(NAVER云)

Juyong Jiang, Jiasi Shen, Sunghun Kim, Kang Min Yoo, Jeonghoon Kim, Sungju Kim

AI总结:

本文提出ReflexiCoder,一种基于强化学习的框架,使大语言模型在推理过程中自我反思和纠正代码,通过细粒度奖励函数优化整个反思-纠正过程,实现无需外部反馈的自我调试能力,实验表明其在多个基准测试中表现优异,且在推理效率上更高效。

摘要:

尽管大型语言模型(LLMs)已革新了代码生成,但标准的“系统1”方法在复杂算法任务上往往遇到性能瓶颈。现有的迭代改进策略在推理过程中试图弥合这一差距,但主要依赖外部或acles、执行反馈或计算成本高的提示-响应循环。在本文中,我们提出ReflexiCoder,一种新颖的强化学习(RL)框架,将结构化的推理轨迹,包括初始生成、具有错误和优化意识的反思以及自我纠正,直接内化到模型的权重中。与以往方法不同,ReflexiCoder从依赖外部的改进转向在推理过程中内在的、完全自主的自我反思和自我纠正能力。我们利用仅基于强化学习的训练范式,结合细粒度的奖励函数,优化整个反思-纠正轨迹,教会模型如何在推理过程中无需依赖真实反馈或执行引擎进行调试。在七个基准测试中的广泛实验表明,我们的ReflexiCoder-8B在1.5B到14B范围内的领先开源模型中建立了新的最先进(SOTA)水平,单次尝试下在HumanEval(Plus)上达到94.51%(87.20%),在MBPP(Plus)上达到81.80%(78.57%),在BigCodeBench上达到35.00%,在LiveCodeBench上达到52.21%,在CodeForces上达到37.34%。值得注意的是,我们的框架比基础模型显著更节省token,通过纪律性的、高效的推理和反思模式,将推理时的计算开销减少了约40%。源代码和数据可在https://github.com/juyongjiang/ReflexiCoder上获得。

英文摘要:

While Large Language Models (LLMs) have revolutionized code generation, standard ``System 1'' approaches that generate solutions in a single forward pass often hit a performance ceiling on complex algorithmic tasks. Existing iterative refinement strategies attempt to bridge this gap at inference time, yet they predominantly rely on external oracles, execution feedback, or computationally expensive prompt-response cycles. In this work, we propose ReflexiCoder, a novel reinforcement learning (RL) framework that internalizes the structured reasoning trajectory, encompassing initial generation, bug and optimization aware reflection, and self-correction, directly into the model's weights. Unlike prior methods, ReflexiCoder shifts the paradigm from external-dependent refinement to an intrinsic, fully autonomous self-reflection and self-correction capabilities at inference time. We utilize an RL-only training paradigm with granular reward functions to optimize the entire reflection-correction trajectory, teaching the model how to debug without reliance on ground-truth feedback or execution engines at inference time. Extensive experiments across seven benchmarks demonstrate that our ReflexiCoder-8B establishes a new state-of-the-art (SOTA) among leading open-source models in the 1.5B to 14B range, achieving 94.51% (87.20%) on HumanEval (Plus), 81.80% (78.57%) on MBPP (Plus), 35.00% on BigCodeBench, 52.21% on LiveCodeBench, and 37.34% on CodeForces in a single-attempt setting, rivaling or surpassing proprietary models like GPT-5.1. Notably, our framework is significantly more token-efficient than base models, reducing inference-time compute overhead by approximately 40% through disciplined, efficient reasoning and reflection patterns. The source code and data are available at https://github.com/juyongjiang/ReflexiCoder.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑