Repoformer: Selective Retrieval for Repository-Level Code Completion

Fuente: arXiv
Gespeichert in:
Bibliographische Detailangaben
Hauptverfasser: Wu, Di, Ahmad, Wasi Uddin, Zhang, Dejiao, Ramanathan, Murali Krishna, Ma, Xiaofei
Format: Preprint
Veröffentlicht: 2024
Schlagworte:
Online-Zugang:
Tags: Tag hinzufügen
Keine Tags, Fügen Sie den ersten Tag hinzu!
_version_ 1866910471544635392
author Wu, Di
Ahmad, Wasi Uddin
Zhang, Dejiao
Ramanathan, Murali Krishna
Ma, Xiaofei
author_facet Wu, Di
Ahmad, Wasi Uddin
Zhang, Dejiao
Ramanathan, Murali Krishna
Ma, Xiaofei
contents 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.
format Preprint
id arxiv_https___arxiv_org_abs_2403_10059
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle Repoformer: Selective Retrieval for Repository-Level Code Completion
Wu, Di
Ahmad, Wasi Uddin
Zhang, Dejiao
Ramanathan, Murali Krishna
Ma, Xiaofei
Software Engineering
Computation and Language
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.
title Repoformer: Selective Retrieval for Repository-Level Code Completion
topic Software Engineering
Computation and Language
url https://arxiv.org/abs/2403.10059