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.


翻译:仓库级代码补全对于现有代码大语言模型(code LLM)而言仍是一项具有挑战性的任务,这主要源于其对仓库特定上下文和领域知识的理解有限。尽管检索增强生成(RAG)方法通过检索相关代码片段作为跨文件上下文已展现出潜力,但其存在两个根本性问题:检索过程中查询与目标代码之间的错位,以及现有检索方法无法有效利用推理信息。为应对这些挑战,本文提出AlignCoder——一个仓库级代码补全框架,该框架引入了查询增强机制与基于强化学习的检索器训练方法。我们的方法通过生成多个候选补全结果来构建增强查询,从而弥合初始查询与目标代码之间的语义鸿沟。此外,我们采用强化学习训练AlignRetriever,使其学习利用增强查询中的推理信息以实现更精准的检索。我们在两个广泛使用的基准数据集(CrossCodeEval与RepoEval)上对AlignCoder进行了评估,覆盖五种骨干代码LLM。实验结果表明,在CrossCodeEval基准上,我们的方法相比基线在EM分数上实现了18.1%的提升。这些结果证明,我们的框架不仅取得了优越的性能,而且在不同的代码LLM与编程语言间展现出高度的泛化能力。

0
下载
关闭预览

相关内容

代码(Code)是专知网的一个重要知识资料文档板块,旨在整理收录论文源代码、复现代码,经典工程代码等,便于用户查阅下载使用。
检索增强生成(RAG)技术,261页slides
专知会员服务
42+阅读 · 2025年10月16日
【SIGIR2025教程】动态与参数化检索增强生成
专知会员服务
17+阅读 · 2025年7月14日
定制化大型语言模型的图检索增强生成综述
专知会员服务
38+阅读 · 2025年1月28日
图增强生成(GraphRAG)
专知会员服务
35+阅读 · 2025年1月4日
检索增强生成系统中的可信度:综述
专知会员服务
44+阅读 · 2024年9月18日
《大型语言模型中基于检索的文本生成》综述
专知会员服务
60+阅读 · 2024年4月18日
【Code】GraphSAGE 源码解析
AINLP
31+阅读 · 2020年6月22日
NLP-Progress记录NLP最新数据集、论文和代码: 助你紧跟NLP前沿
中国人工智能学会
12+阅读 · 2018年11月15日
深度学习文本分类方法综述(代码)
中国人工智能学会
28+阅读 · 2018年6月16日
OCR开源库(文本区域定位和文本识别):github
数据挖掘入门与实战
28+阅读 · 2017年11月26日
TextInfoExp:自然语言处理相关实验(基于sougou数据集)
全球人工智能
12+阅读 · 2017年11月12日
国家自然科学基金
18+阅读 · 2017年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
13+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
5+阅读 · 2014年12月31日
VIP会员
最新内容
《系统簇式多域作战规划范畴论框架》
专知会员服务
3+阅读 · 4月20日
高效视频扩散模型:进展与挑战
专知会员服务
1+阅读 · 4月20日
乌克兰前线的五项创新
专知会员服务
7+阅读 · 4月20日
 军事通信系统与设备的技术演进综述
专知会员服务
5+阅读 · 4月20日
《北约标准:医疗评估手册》174页
专知会员服务
4+阅读 · 4月20日
《提升生成模型的安全性与保障》博士论文
专知会员服务
4+阅读 · 4月20日
美国当前高超音速导弹发展概述
专知会员服务
4+阅读 · 4月19日
无人机蜂群建模与仿真方法
专知会员服务
14+阅读 · 4月19日
相关VIP内容
检索增强生成(RAG)技术,261页slides
专知会员服务
42+阅读 · 2025年10月16日
【SIGIR2025教程】动态与参数化检索增强生成
专知会员服务
17+阅读 · 2025年7月14日
定制化大型语言模型的图检索增强生成综述
专知会员服务
38+阅读 · 2025年1月28日
图增强生成(GraphRAG)
专知会员服务
35+阅读 · 2025年1月4日
检索增强生成系统中的可信度:综述
专知会员服务
44+阅读 · 2024年9月18日
《大型语言模型中基于检索的文本生成》综述
专知会员服务
60+阅读 · 2024年4月18日
相关基金
国家自然科学基金
18+阅读 · 2017年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
13+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
5+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员