arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2412.12447cs.SEcs.AIcs.CL
收藏

PERC:面向代表性不足代码生成的计划即查询示例检索

PERC: Plan-As-Query Example Retrieval for Underrepresented Code Generation

Seoul National University(首尔大学);Interdisciplinary Program in Artificial Intelligence, Seoul National University(首尔大学人工智能跨学科项目)

Jaeseok Yoo, Hojae Han, Youngwon Lee, Jaejin Kim, Seung-won Hwang

AI总结:

针对代表性不足编程语言的代码生成问题,提出PERC框架,利用伪代码提取算法计划作为查询检索少样本示例,在多个基准上显著提升生成准确率并优于现有RAG方法。

摘要:

使用大型语言模型进行代码生成已展现出显著的潜力,特别是采用带有少样本示例的检索增强生成(RAG)时。然而,选择能够提升生成质量的有效示例仍是一项艰巨的任务,尤其是当目标编程语言(PL)代表性不足时。在本研究中,我们提出两个关键发现:(1)检索其呈现的算法计划可被参考用于生成目标行为的示例,能显著提高生成准确率;(2)将代码转换为伪代码能有效捕捉此类算法计划,即使源和目标PL不同,也能提升检索质量。基于这些发现,我们提出了用于代码生成中少样本提示的计划即查询示例检索(PERC),这是一个利用算法计划来识别和检索有效示例的新颖框架。我们通过在CodeContests、HumanEval和MultiPL-E基准上进行的大量实验验证了PERC的有效性:无论源和目标编程语言匹配还是不同,PERC在代码生成中始终优于最先进的RAG方法,突显了其在多样编码环境中的适应性和鲁棒性。

英文摘要:

Code generation with large language models has shown significant promise, especially when employing retrieval-augmented generation (RAG) with few-shot examples. However, selecting effective examples that enhance generation quality remains a challenging task, particularly when the target programming language (PL) is underrepresented. In this study, we present two key findings: (1) retrieving examples whose presented algorithmic plans can be referenced for generating the desired behavior significantly improves generation accuracy, and (2) converting code into pseudocode effectively captures such algorithmic plans, enhancing retrieval quality even when the source and the target PLs are different. Based on these findings, we propose Plan-as-query Example Retrieval for few-shot prompting in Code generation (PERC), a novel framework that utilizes algorithmic plans to identify and retrieve effective examples. We validate the effectiveness of PERC through extensive experiments on the CodeContests, HumanEval and MultiPL-E benchmarks: PERC consistently outperforms the state-of-the-art RAG methods in code generation, both when the source and target programming languages match or differ, highlighting its adaptability and robustness in diverse coding environments.

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

↑