paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Sifting through the Chaff: On Utilizing Execution Feedback for Ranking the Generated Code Candidates

去芜存菁:利用执行反馈对生成的代码候选进行排序
ASE Proceedings of the 39th IEEE/ACM International Conference on Automated Software Engineering2024匹配度 3/10 · 论文属于LLM生成代码的候选排序,使用执行反馈与多任务学习,虽与代码/程序语言及LLM应用相关,但并未涉及用户核心关注的静态分析、形式化验证、浮点程序分析或贝叶斯程序分析,也不是将LLM/Agent用于改进静态分析。引用 9 inbox
Zhihong Sun, Yao Wan, Jia Li, Hongyu Zhang, Zhi Jin, Ge Li, Chen Lyu
crossref: 2026-09-12

AI 速览

一句话:提出 RankEF,用多任务学习将代码分类与执行反馈生成结合,无需执行代码即可对 LLM 生成的代码候选排序。

大语言模型虽能自动生成代码,但在复杂任务上仍难以保证语法与语义正确。常见做法是用 LLM 生成多个候选解再从中挑选,而「代码排序」问题依然困难:基于执行的方法受制于高质量单元测试稀缺与安全风险,非执行方法(如仅用分类标签训练的 CodeRanker)又难以捕捉细微错误、缺乏错误解释。本文提出 RankEF,其核心洞见是有效的排序器必须真正理解错误代码的成因,仅靠分类标签不足。方法上采用多任务学习,将代码分类与执行反馈生成联合训练,使模型在排序阶段无需真正执行代码即可区分正确与错误解。在 APPS、MBPP、HumanEval 三个代码生成基准上,RankEF 显著优于当时最优的 CodeRanker,在 APPS 测试集上 Pass@1、Pass@2、Pass@5 分别取得 +30.97%、+31.43%、+19.51% 的相对提升。

问题
LLM 为一道题生成多个代码候选后,如何挑出真正正确的解仍很困难:基于执行的排序依赖单元测试且存在安全风险,非执行排序仅靠分类标签难以刻画细微错误。
方法
提出 RankEF,用多任务学习把代码分类与执行反馈生成统一到一个模型中,让排序器学会理解错误代码的成因;排序阶段不再需要执行代码即可对候选打分排序。
评估
在 APPS、MBPP、HumanEval 三个代码生成基准上与 SOTA 的 CodeRanker 对比,APPS 测试集上 Pass@1、Pass@2、Pass@5 分别相对提升 30.97%、31.43%、19.51%。
原文摘要(Abstract)

Large Language Models (LLMs), such as GPT-4, StarCoder, and Code Llama, are transforming the way developers approach programming by automatically generating code based on given contexts, such as natural language descriptions or incomplete surrounding code. Despite advancements, generating syntactically and semantically correct code remains challenging, especially for complex programming tasks. Existing approaches typically generate multiple candidate solutions using LLMs to increase the likelihood of producing correct code. However, selecting the correct code from these candidates --- a process known as code ranking --- remains a major challenge. Current research on code ranking can be categorized into execution-based and non-execution-based methods. Execution-based methods, although effective, encounter notable limitations, such as scarcity of quality unit tests and security risks. Non-execution-based methods like CodeRanker, which rely solely on classification labels to train a code ranker, struggle to capture subtle errors and provide detailed error insights. Recognizing the strengths and limitations of both approaches, we propose a new method that integrates the advantages of execution-based and non-execution-based techniques. The key insight of our work is that an effective code ranker is expected to truly comprehend the underlying causes of erroneous code, as relying solely on classification labels is insufficient. Inspired by this, this paper puts forward RankEF, an innovative approach for code ranking that leverages execution feedback. RankEF employs multi-task learning to integrate code classification with execution feedback generation. This approach enables the model to understand the reasons behind incorrect code, distinguishing between correct and incorrect solutions without the need to execute the code during the ranking phase. Experiments on three code generation benchmarks---APPS, MBPP, and HumanEval---demonstrate that RankEF significantly outperforms the state-of-the-art CodeRanker, achieving relative improvements of +30.97%, +31.43%, and +19.51% in Pass@1, Pass@2, and Pass@5 on APPS test, respectively.

链接与引用

DOI 原文 ·

BibTeX
@inproceedings{paperbot8323,
  title = {Sifting through the Chaff: On Utilizing Execution Feedback for Ranking the Generated Code Candidates},
  author = {Zhihong Sun and Yao Wan and Jia Li and Hongyu Zhang and Zhi Jin and Ge Li and Chen Lyu},
  booktitle = {ASE},
  year = {2024},
  doi = {10.1145/3691620.3695000}
}