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

Repoformer:面向仓库级代码补全的选择性检索

Repoformer: Selective Retrieval for Repository-Level Code Completion

University of California Los Angeles(加州大学洛杉矶分校);AWS AI Labs(亚马逊云科技人工智能实验室)

Di Wu, Wasi Uddin Ahmad, Dejiao Zhang, Murali Krishna Ramanathan, Xiaofei Ma

AI总结:

本文提出选择性RAG框架Repoformer,通过自监督学习使代码语言模型自我评估检索必要性并利用噪声上下文,在多基准上达到SOTA性能且实现高达70%推理加速。

摘要:

检索增强生成(RAG)的最新进展开启了仓库级代码补全的新纪元。然而,现有方法对检索的固定使用暴露了效率和鲁棒性方面的问题,很大一部分检索到的上下文被证明对代码语言模型(code LMs)无益甚至有害。在本文中,我们提出了一种选择性RAG框架,以在不需要时避免检索。为了支持该框架,我们设计了一种自监督学习方法,使代码LM能够准确自我评估检索是否能提升其输出质量,并稳健地利用潜在有噪声的检索上下文。使用该LM同时作为选择性RAG策略和生成模型,我们的框架在包括RepoEval、CrossCodeEval和CrossCodeLongEval(一个新的长篇代码补全基准)在内的多种基准上实现了最先进的仓库级代码补全性能。同时,我们的分析表明,在在线服务环境中,选择性检索带来了高达70%的推理加速,且不损害性能。我们进一步证明,我们的框架能够适应不同的生成模型、检索器和编程语言。这些进步使我们的框架成为迈向更准确和高效的仓库级代码补全的重要一步。

英文摘要:

Recent advances in retrieval-augmented generation (RAG) have initiated a new era in repository-level code completion. However, the invariable use of retrieval in existing methods exposes issues in both efficiency and robustness, with a large proportion of the retrieved contexts proving unhelpful or harmful to code language models (code LMs). In this paper, we propose a selective RAG framework to avoid retrieval when unnecessary. To power this framework, we design a self-supervised learning approach to enable a code LM to accurately self-evaluate whether retrieval can improve its output quality and robustly leverage the potentially noisy retrieved contexts. Using this LM as both the selective RAG policy and the generation model, our framework achieves state-of-the-art repository-level code completion performance on diverse benchmarks including RepoEval, CrossCodeEval, and CrossCodeLongEval, a new long-form code completion benchmark. Meanwhile, our analyses show that selectively retrieving brings as much as 70% inference speedup in the online serving setting without harming the performance. We further demonstrate that our framework is able to accommodate different generation models, retrievers, and programming languages. These advancements position our framework as an important step towards more accurate and efficient repository-level code completion.

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

↑