arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2508.20124cs.SEcs.AI
收藏

迈向代码生成中更好的正确性与效率

Towards Better Correctness and Efficiency in Code Generation

Yunlong Feng, Yang Xu, Xiao Xu, Binyuan Hui, Junyang Lin

AI总结:

针对代码大模型生成代码运行效率低的问题,提出性能奖励引导的效率导向强化学习框架及两阶段调优方法,在7B模型上同时提升正确性与效率。

摘要:

尽管代码大型语言模型在代码生成方面已展现出显著进展,但生成的代码往往运行效率较差,限制了其在性能敏感场景中的实际应用。为解决这一局限,我们提出了一种以效率为导向的强化学习框架,该框架由一种新颖的性能奖励引导。基于该框架,我们更深入地研究代码效率问题,识别并提出克服关键瓶颈的方法:(1)动态探索克服了离线微调的静态数据约束,能够发现更高效的代码实现。(2)错误不敏感的强化学习方法和高对比度效率信号,对于缓解系统性错误并实现有效优化至关重要。(3)在线探索从高正确性基线开始时最为有效,因为这可以在不牺牲准确性的情况下提升效率。基于这些发现,我们最终提出一种两阶段调优方法,在正确性和效率之间实现了高而均衡的性能。实验结果表明了该方法的有效性:在7B模型上,它将代码正确性提高了10.18%,运行效率提高了7.75%,达到了可与大得多的模型相媲美的性能。

英文摘要:

While code large language models have demonstrated remarkable progress in code generation, the generated code often exhibits poor runtime efficiency, limiting its practical application in performance-sensitive scenarios. To address this limitation, we propose an efficiency-oriented reinforcement learning framework guided by a novel performance reward. Based on this framework, we take a deeper dive into the code efficiency problem, identifying then proposing methods to overcome key bottlenecks: (1) Dynamic exploration overcomes the static data constraints of offline fine-tuning, enabling the discovery of more efficient code implementations. (2) The error-insensitive reinforcement learning method and high-contrast efficiency signals are crucial for mitigating systematic errors and achieving effective optimization. (3) Online exploration is most effective when starting from a high-correctness baseline, as this allows for efficiency improvements without sacrificing accuracy. With these discoveries, we finally propose a two-stage tuning method, which achieves high and balanced performance across correctness and efficiency. The results of experiments show the effectiveness of the method, which improves code correctness by 10.18\% and runtime efficiency by 7.75\% on a 7B model, achieving performance comparable to much larger model.

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

↑