arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2408.05715cs.AIcs.SE
收藏

Top Pass:通过Pass@k最大化代码排序提升代码生成效果

Top Pass: Improve Code Generation by Pass@k-Maximized Code Ranking

Nanjing University(南京大学);School of Artificial Intelligence, Nanjing University(南京大学人工智能学院)

Zhi-Cun Lyu, Xin-Ye Li, Zheng Xie, Ming Li

AI总结:

针对大语言模型代码生成在复杂问题下少量尝试难获正确代码的问题,提出直接优化pass@k损失的Top Pass代码排序方法,在四个基准上提升了代码生成可用性,CodeContests的pass@1相对提升32.9%。

摘要:

近年来,大语言模型(LLMs)的深度发展极大提升了代码生成能力。然而,这类基于LLM的代码生成方法在面对复杂问题时,仍难以在少数几次尝试中生成无错误的代码。为解决这一问题,主流策略是采样大量候选程序,寄希望于其中任意一个能够正常运行。但代码生成系统的用户通常期望仅通过审查或测试少量候选代码就能找到正确程序,否则系统便毫无用处。本文提出Top Pass,一种从大量候选代码中识别潜在正确解的代码排序方法。Top Pass直接优化pass@k损失函数,提升候选列表顶部的代码质量,使用户能以尽可能少的尝试次数找到正确解。在四个基准上的实验结果表明,我们的Top Pass方法通过生成更优的排序结果提升了代码生成模型的可用性,尤其在CodeContests数据集上,与当前最优排序方法相比,pass@1实现了32.9%的相对提升。

英文摘要:

Code generation has been greatly enhanced by the profound advancements in Large Language Models (LLMs) recently. Nevertheless, such LLM-based code generation approaches still struggle to generate error-free code in a few tries when faced with complex problems. To address this, the prevailing strategy is to sample a huge number of candidate programs, with the hope of any one in them could work. However, users of code generation systems usually expect to find a correct program by reviewing or testing only a small number of code candidates. Otherwise, the system would be unhelpful. In this paper, we propose Top Pass, a code ranking approach that identifies potential correct solutions from a large number of candidates. Top Pass directly optimizes the pass@k loss function, enhancing the quality at the top of the candidate list. This enables the user to find the correct solution within as few tries as possible. Experimental results on four benchmarks indicate that our Top Pass method enhances the usability of code generation models by producing better ranking results, particularly achieving a 32.9\% relative improvement in pass@1 on CodeContests when compared to the state-of-the-art ranking method.

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

↑