[Paper Review] RepoBench: Benchmarking Repository-Level Code Auto-Completion Systems
RepoBench introduces a repository-level benchmark for code auto-completion with three tasks—Retrieval, Code Completion, and Pipeline—evaluated on Python and Java across multiple models and retrieval strategies.
Large Language Models (LLMs) have greatly advanced code auto-completion systems, with a potential for substantial productivity enhancements for developers. However, current benchmarks mainly focus on single-file tasks, leaving an assessment gap for more complex, real-world, multi-file programming scenarios. To fill this gap, we introduce RepoBench, a new benchmark specifically designed for evaluating repository-level code auto-completion systems. RepoBench supports both Python and Java and consists of three interconnected evaluation tasks: RepoBench-R (Retrieval), RepoBench-C (Code Completion), and RepoBench-P (Pipeline). Each task respectively measures the system's ability to retrieve the most relevant code snippets from other files as cross-file context, predict the next line of code with cross-file and in-file context, and handle complex tasks that require a combination of both retrieval and next-line prediction. RepoBench aims to facilitate a more complete comparison of performance and encouraging continuous improvement in auto-completion systems. RepoBench is publicly available at https://github.com/Leolty/repobench.
Motivation & Objective
- Address the gap in evaluating multi-file, repository-scale code completion systems beyond single-file benchmarks.
- Provide a benchmark with three interconnected tasks (Retrieval, Code Completion, Pipeline) to assess end-to-end workflow.
- Offer insights into how models handle cross-file and long-context code in real-world repositories.
- Facilitate fair comparison and drive improvements in repository-level code intelligence.
Proposed method
- Construct a dataset from GitHub code (training) and newly crawled GitHub repositories (test) focusing on Python and Java.
- Parse cross-file dependencies via tree-sitter to identify cross-file lines and corresponding definitions.
- Define three tasks: RepoBench-R (Retrieval), RepoBench-C (Code Completion), RepoBench-P (Pipeline).
- Create prompts by combining cross-file context (from imports) and in-file context (preceding lines) with a 30-line cap for RepoBench-C.
- Evaluate using acc@k for retrieval, Exact Match (EM) and Edit Similarity (ES) for completion and pipeline.
- Test a range of baselines including lexical, semantic retrieval (CodeBERT, UniXcoder), and large language models (Codex, CodeGen, StarCoder) with Python/Java variants.
Experimental results
Research questions
- RQ1How well do retrieval strategies identify relevant cross-file snippets to support next-line prediction?
- RQ2How effectively can models predict the next code line using cross-file and in-file context, under different context lengths (XF-F, XF-R, IF)?
- RQ3What is the end-to-end performance when combining retrieval and completion in a pipeline, and how does cross-file context placement affect results?
- RQ4Do repository-level benchmarks reveal language-specific differences (Python vs Java) in retrieval and completion performance?
Key findings
- UniXcoder consistently outperforms other retrieval methods in RepoBench-R, indicating strong semantic understanding of cross-file snippets.
- Lexical (Jaccard) retrieval generally beats Edit Similarity for cross-file snippet relevance.
- Python retrieval tasks tend to yield higher accuracy than Java across methods.
- In RepoBench-P, incorporating cross-file context improves performance across settings, and effective retrieval (e.g., UniXcoder) enhances both retrieval and completion results.
- The order/placement of retrieved snippets affects code completion effectiveness, with closer proximity to the target line offering gains.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.