TL;DR
RepoBench is a new benchmark designed to evaluate how well AI systems handle "repository-level" code completion—the real-world scenario where code depends on multiple interconnected files. It breaks down the problem into three distinct tasks: retrieving the right context from other files, completing the code using that context, and managing the entire end-to-end pipeline.
What Problem Does This Paper Address?
Most current AI code assistants are evaluated on "single-file" tasks. In these benchmarks, the model is given a snippet of a single file and asked to fill in the rest. However, professional software development rarely happens in a vacuum. Real-world code is a complex web of dependencies: a function in main.py might rely on a class defined in utils.py and a constant in config.py.
Existing benchmarks fail to measure a system's ability to navigate these cross-file relationships. This creates a gap between high benchmark scores and actual utility for developers working on complex, multi-file projects. RepoBench closes this gap by forcing models to look outside their current file to find the information they need to generate accurate code.
Methods
The researchers introduced three interconnected sub-tasks to evaluate different "muscles" of an auto-completion system:
- RepoBench-R (Retrieval): Tests the system's ability to search the entire repository and find the specific "gold snippet" (the relevant code from another file) needed to complete the current line.
- RepoBench-C (Code Completion): Assuming the system already has the right context, how well can it predict the next line? This focuses heavily on the model's reasoning and generation capabilities.
- RepoBench-P (Pipeline): The most realistic and challenging task. The system must first retrieve the relevant snippets on its own and then use them to generate the code.
They also defined three difficulty settings to test varying levels of context dependence:
- Cross-File-First (XF-F): The hardest setting; the model must predict a line using a module it hasn't seen yet in the current file.
- Cross-File-Random (XF-R): The model has seen the module before, but must still use cross-file context to succeed.
- In-File (IF): A baseline where no cross-file information is needed.
Datasets
To ensure robust evaluation, the benchmark relies on carefully curated datasets:
- Training Data: Sourced from the
github-codedataset, consisting of over 10,000 Python and 14,000 Java repositories. - Test Data: To prevent "data leakage" (where a model has already memorized the test data during its training phase), the authors newly crawled GitHub for repositories created between February and August 2023. This ensures the benchmarks test true generalization.
- RepoBench v1.1: The authors maintain a "live" version of the benchmark that includes even longer context windows (up to 128k tokens) to keep pace with the rapidly expanding memory of modern Large Language Models (LLMs).
Key Insights and Ideas
- "Random is better than nothing": One of the most surprising findings was that including any cross-file context—even randomly selected snippets—improved completion performance compared to having no cross-file context at all. This suggests that LLMs are remarkably good at fostering contextual understanding when given a broader view of the project.
- The Python vs. Java Gap: Retrieval is generally more accurate in Python than in Java. The authors hypothesize this is because Python developers often define function arguments close to where they are called, providing better "scents" for the retrieval models to follow. Java’s heavy use of class structures adds a layer of complexity.
- Lexical vs. Semantic: Simple "lexical" retrieval (like Jaccard similarity, which just looks at overlapping words) is surprisingly competitive against complex "semantic" models (which use deep learning embeddings). For code, the specific names of variables and functions are often enough to find the right file.
- Placement Matters: In the end-to-end pipeline, the order of retrieved snippets matters. Placing the most relevant snippets closer to the point where the code needs to be completed (the "tail-end" of the prompt) yields significantly better results.
Key Results
The benchmark revealed clear leaders in both retrieval and generation tasks across different languages.
- Top Performers: InstructOR (a 1.5B parameter model) emerged as the strongest retrieval model, even beating much larger competitors. For code generation, CodeLlama-34B dominated Python tasks, while OpenAI’s Codex remained the leader for Java.
- Retrieval Accuracy: On the "Easy" Python subset, the best models achieved over 28% accuracy at finding the exact gold snippet on the first try (acc@1) and over 62% within the top three results (acc@3).
- Pipeline Synergy: The experiments proved that a "retrieval-augmented" approach significantly outperforms models that only look at the current file, highlighting the absolute necessity of repository-level awareness for modern coding assistants.
Limitations and Future Work
- Next-Line Focus: The benchmark currently focuses on predicting the next single line of code. While this is a standard metric, real developers often need multi-line blocks or entire functions generated at once.
- Computational Cost: Evaluating models on repository-level tasks with thousands of tokens is computationally expensive, which may limit how frequently researchers can run the full suite.
- Language Scope: While Python and Java cover a huge portion of the industry, expanding to other languages like C++ or Rust would provide a more holistic view of AI coding capabilities.
Summary updated