arXivDaily arXiv每日学术速递 周一至周五更新
​通知:联邦节假日调休:哥伦布日 / 原住民日(Columbus Day / Indigenous Peoples' Day),今日(13日)无更新。
arXiv 2601.19697cs.SEcs.AI

AlignCoder: 为目标意图对齐检索以实现仓库级代码补全

AlignCoder: Aligning Retrieval with Target Intent for Repository-Level Code Completion

School of Software, Sun Yat-sen University(中山大学软件学院);Sun Yat-sen University(中山大学)

Tianyue Jiang, Yanli Wang, Yanlin Wang, Daya Guo, Ensheng Shi, Yuchi Ma, Jiachi Chen, Zibin Zheng

AI总结:

针对仓库级代码补全中检索与目标代码不匹配及无法利用推理信息的问题,提出AlignCoder框架,通过查询增强和基于强化学习的检索器训练,在CrossCodeEval上EM分数提升18.1%。

摘要:

由于现有代码大语言模型(code LLMs)对仓库特定上下文和领域知识的理解有限,仓库级代码补全仍然是一项具有挑战性的任务。虽然检索增强生成(RAG)方法通过检索相关代码片段作为跨文件上下文显示出前景,但它们存在两个基本问题:检索过程中查询与目标代码之间的不对齐,以及现有检索方法无法有效利用推理信息。为了解决这些挑战,我们提出了AlignCoder,一个仓库级代码补全框架,引入了查询增强机制和基于强化学习的检索器训练方法。我们的方法生成多个候选补全以构建增强查询,从而弥合初始查询与目标代码之间的语义差距。此外,我们采用强化学习训练AlignRetriever,使其学会利用增强查询中的推理信息进行更准确的检索。我们在两个广泛使用的基准测试(CrossCodeEval和RepoEval)上,使用五个骨干代码LLM评估了AlignCoder,在CrossCodeEval基准测试上,与基线相比,EM分数提高了18.1%。结果表明,我们的框架实现了优越的性能,并在各种代码LLM和编程语言中表现出高度的泛化能力。

英文摘要:

Repository-level code completion remains a challenging task for existing code large language models (code LLMs) due to their limited understanding of repository-specific context and domain knowledge. While retrieval-augmented generation (RAG) approaches have shown promise by retrieving relevant code snippets as cross-file context, they suffer from two fundamental problems: misalignment between the query and the target code in the retrieval process, and the inability of existing retrieval methods to effectively utilize the inference information. To address these challenges, we propose AlignCoder, a repository-level code completion framework that introduces a query enhancement mechanism and a reinforcement learning based retriever training method. Our approach generates multiple candidate completions to construct an enhanced query that bridges the semantic gap between the initial query and the target code. Additionally, we employ reinforcement learning to train an AlignRetriever that learns to leverage inference information in the enhanced query for more accurate retrieval. We evaluate AlignCoder on two widely-used benchmarks (CrossCodeEval and RepoEval) across five backbone code LLMs, demonstrating an 18.1% improvement in EM score compared to baselines on the CrossCodeEval benchmark. The results show that our framework achieves superior performance and exhibits high generalizability across various code LLMs and programming languages.

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

↑