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 LLMs)而言仍是一项具有挑战性的任务,原因在于模型对仓库特定上下文和领域知识的理解有限。尽管基于检索增强生成(RAG)的方法通过检索相关代码片段作为跨文件上下文展现出潜力,但其存在两个根本问题:检索过程中查询与目标代码之间的语义对齐偏差,以及现有检索方法无法有效利用推理信息。针对这些挑战,我们提出AlignCoder——一种仓库级代码补全框架,该框架引入了查询增强机制和基于强化学习的检索器训练方法。我们的方法生成多个候选补全结果以构建增强查询,从而弥合初始查询与目标代码之间的语义鸿沟。此外,我们采用强化学习训练AlignRetriever,使其能够学习利用增强查询中的推理信息以实现更精准的检索。我们在两个广泛使用的基准(CrossCodeEval和RepoEval)上,基于五种骨干代码LLM对AlignCoder进行评估,结果显示在CrossCodeEval基准上EM分数相较基线方法提升18.1%。实验结果表明,该框架能够取得卓越性能,并在多种代码LLM及编程语言上展现出高泛化能力。

0
下载
关闭预览

相关内容

代码(Code)是专知网的一个重要知识资料文档板块,旨在整理收录论文源代码、复现代码,经典工程代码等,便于用户查阅下载使用。
【SIGIR2025教程】动态与参数化检索增强生成
专知会员服务
17+阅读 · 2025年7月14日
定制化大型语言模型的图检索增强生成综述
专知会员服务
38+阅读 · 2025年1月28日
大型语言模型对齐技术综述:RLHF、RLAIF、PPO、DPO 等
专知会员服务
55+阅读 · 2024年7月24日
《大型语言模型中基于检索的文本生成》综述
专知会员服务
60+阅读 · 2024年4月18日
【Code】GraphSAGE 源码解析
AINLP
31+阅读 · 2020年6月22日
高效的文本生成方法 — LaserTagger 现已开源
TensorFlow
30+阅读 · 2020年2月27日
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日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
5+阅读 · 2014年12月31日
VIP会员
最新内容
ICML 2026 | 面向视觉语言模型的语义鲁棒性认证
专知会员服务
0+阅读 · 10分钟前
学习数据的几何:形状空间分析数学综述
专知会员服务
8+阅读 · 6月17日
定向能反无人机系统最新发展动态
专知会员服务
10+阅读 · 6月17日
从燃煤战舰到算法战争:水面指挥的永恒要求
专知会员服务
6+阅读 · 6月17日
相关基金
国家自然科学基金
18+阅读 · 2017年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
13+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
5+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员