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

需要多少次尝试?跨模型规模和基准的LLM代码生成中的迭代自修复

How Many Tries Does It Take? Iterative Self-Repair in LLM Code Generation Across Model Scales and Benchmarks

Independent Researcher(独立研究员)

Johin Johny Arimbur

AI总结:

研究探讨了在不同模型规模和基准测试中,通过迭代自修复提高代码生成正确率的方法,发现自修复显著提升了通过率,且现代模型无需微调即可实现有效自修复。

摘要:

大型语言模型在首次尝试中经常无法生成正确的代码,但大多数基准测试均采用单次尝试设置。我们研究了在七个模型上进行迭代自修复(将执行错误反馈给模型以进行修正)的情况,这些模型涵盖三种家族和开源及专有提供商。在HumanEval(164个问题)和MBPP Sanitized(257个问题)上,最多五次尝试,自修复普遍提高了通过率:在HumanEval上提高+4.9至+17.1个百分点,在MBPP上提高+16.0至+30.0个百分点。Gemini 2.5 Flash在HumanEval上达到96.3%的通过率,在MBPP上达到93.8%。大多数增益集中在前两次尝试中。错误类型分析显示,断言错误(逻辑错误)修复难度最大,约为45%,而语法和名称错误修复率显著更高,与LLM自修正的局限性相关。先前研究发现较弱的模型在自修复中失败或需要微调;我们显示现代指令微调模型仅需提示即可实现有效自修复,即使在8B规模上。我们还提供了密集和MoE架构在自修复中的首次比较,并将修复与重采样权衡分析扩展到现代模型。提示消融揭示链式思维修复在有能力模型中可产生额外+5.5个百分点的自修复增益(以修复delta的改善衡量)。

英文摘要:

Large language models frequently fail to produce correct code on their first attempt, yet most benchmarks evaluate them in a single-shot setting. We investigate iterative self-repair (feeding execution errors back to the model for correction) across seven models spanning three families and both open-weight and proprietary providers: Llama 3.1 8B, Llama 3.3 70B, Llama 4 Scout (MoE, 16 experts), Llama 4 Maverick (MoE, 128 experts), Qwen3 32B, Gemini 2.5 Flash, and Gemini 2.5 Pro. On HumanEval (164 problems) and MBPP Sanitized (257 problems) with up to five attempts, self-repair universally improves pass rates: +4.9 to +17.1 pp on HumanEval and +16.0 to +30.0 pp on MBPP. Gemini 2.5 Flash achieves the highest final pass rates (96.3% HumanEval, 93.8% MBPP). Most gains concentrate in the first two rounds.Error-type analysis shows assertion errors (logical mistakes) are the hardest to repair at ~45%, while syntax and name errors are repaired at substantially higher rates, connecting to broader findings on the limits of LLM self-correction. Prior work found that weaker models fail at self-repair or require fine-tuning; we show that modern instruction-tuned models succeed with prompting alone, even at 8B scale. We also provide the first comparison of dense and MoE architectures for self-repair, and extend the repair-vs-resampling tradeoff analysis to modern models. A prompt ablation reveals chain-of-thought repair yields up to +5.5 pp additional self-repair gain (measured as improvement in repair delta) over minimal prompting for capable models.

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

↑