arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2604.05560cs.SE
收藏

面向竞争性代码生成的迭代测试与修复框架

An Iterative Test-and-Repair Framework for Competitive Code Generation

Zhejiang University(浙江大学);University College London(伦敦大学学院)

Lingxiao Tang, Muyang Ye, Zhaoyang Chu, Xiaoxue Ren, Zhongxin Liu, Lingfeng Bao, He Ye

AI总结:

FixAudit通过迭代测试与修复循环改进代码生成,通过共享模型和专门角色联合训练,提升代码质量与测试覆盖率。

摘要:

大型语言模型(LLMs)在代码生成方面取得了显著进展,但竞争性编程仍具挑战性。最近基于训练的方法通过强化学习(RL)和执行反馈改进了代码生成。最近的框架CURE进一步将测试生成纳入训练过程,联合训练一个Coder和一个Tester。在推理时,Coder生成多个候选程序,Tester根据问题描述生成测试用例。通过最多测试用例通过的候选程序作为最终答案。然而,CURE有两个关键限制:首先,Tester从不阅读任何候选代码,因此其测试往往无法暴露实现特定的bug;其次,Coder每次从头生成候选程序,从不基于失败测试学习修复bug。为解决这些限制,我们提出FixAudit,从新视角出发:从单个初始候选程序开始,通过针对性的测试与修复调试循环迭代改进候选程序。该框架通过四个阶段训练一个共享模型,包含两个专门角色:Fixer根据失败测试修复当前候选程序,Auditor阅读候选代码生成新测试用例以暴露其剩余bug。我们评估FixAudit在三个基准测试上:APPS、CodeContests和xCodeEval。应用于7B模型,在零样本设置下,该框架在相同模型家族中超越了更大的32B基线的平均性能。与基于相同7B基础模型的强大基线相比,FixAudit将平均Pass@1提高了35.1%到36.8%,平均AvgPassRatio提高了7.1%到24.5%。

英文摘要:

Large language models (LLMs) have made remarkable progress in code generation, but competitive programming remains a challenge. Recent training-based methods have improved code generation by using reinforcement learning (RL) with execution feedback. The more recent framework CURE further incorporates test generation into the training process, jointly training a Coder and a Tester within a single model. At inference time, the Coder generates many candidate programs, and the Tester generates tests from the problem description. The candidate who passes the most of the generated tests is selected as the final answer. However, CURE has two critical limitations. First, the Tester never reads any candidate code, so its tests often fail to expose implementation-specific bugs. Second, the Coder generates every candidate from scratch and never learns to fix a buggy program based on a failed test. To address these limitations, we propose FixAudit, which approaches competitive code generation from a new perspective: starting from a single initial candidate, it iteratively improves the candidate through a targeted test-and-repair debugging cycle. The framework trains one shared model with two specialized roles through four stages: the Fixer, which repairs the current candidate based on a failing test, and the Auditor, which reads the candidate code to generate new tests that expose its remaining bugs. We evaluate FixAudit on three benchmarks: APPS, CodeContests, and xCodeEval. Applied to a 7B model, the framework surpasses the average performance of the larger 32B baseline within the same model family under the zero-shot setting. Compared to strong baselines built on the same 7B base model, FixAudit improves average Pass@1 by 35.1% to 36.8% and average AvgPassRatio by 7.1% to 24.5%.

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

↑