RepoCoder: Repository-Level Code Completion Through Iterative Retrieval and Generation
By Fengji Zhang, Bei Chen, Yue Zhang, Jin Liu, Daoguang Zan, Yi Mao, Jian-Guang Lou, Weizhu Chen. 2023
516 citations recorded by the source corpus.
The task of repository-level code completion is to continue writing the unfinished code based on a broader context of the repository. While for automated code completion tools, it is difficult to utilize the useful information scattered in different files. We propose RepoCoder, a simple, generic, and effective framework to address the challenge. It streamlines the repository-level code completion process by incorporating a similarity-based retriever and a pre-trained code language model in an iterative retrieval-generation pipeline. RepoCoder makes effective utilization of repository-level information for code completion and has the ability to generate code at various levels of granularity. Moreover, we propose a new benchmark RepoEval, which consists of the latest and high-quality real-world repositories covering line, API invocation, and function body completion scenarios. Experimental results indicate that RepoCoder significantly improves the In-File completion baseline by over 10% in all settings and consistently outperforms the vanilla retrieval-augmented code completion approach. Furthermore, we validate the effectiveness of RepoCoder through comprehensive analysis, providing valuable insights for future research. Our source code and benchmark are publicly available: https://github.com/microsoft/CodeT/tree/main/RepoCoder
Subfields: Computer Networks and Communications, Information Systems, Information Systems and Management, Retrieval-Augmented Generation, Code Generation & Program Synthesis
How researchers see this paper
The researchers whose trusted networks rank it highest, strongest advocate first. Every researcher gets a different order.
In Computer Networks and Communications
- Armando Solar-Lezama
- Chun Xia
- Koushik Sen
- Lingming Zhang
- Ion Stoica
- Scott Shenker
- Mosharaf Chowdhury
- Sylvia Ratnasamy
In Information Systems
- Yinlin Deng
- Chun Xia
- Lingming Zhang
- Ling-Ming Zhang
- Soren Dunn
- Armando Solar-Lezama
- Koushik Sen
- Naman Jain
In Information Systems and Management
In Code Generation & Program Synthesis
Citations in the corpus
- LiveCodeBench: Holistic and Contamination Free Evaluation of Large Language Models for Code (2024, methodology): “…engineering tasks, such as JuICe (Agashe et al., 2019), APIBench (Patil et al., 2023), RepoBench (Liu et al., 2023c), ODEX (Wang et al., 2022b), SWE-Bench (Jimenez et al., 2023), GoogleCodeRepo (Shrivastava et al., 2023), RepoEval (Zhang et al., 2023a), and Cocomic-Data (Ding et al., 2022).”
- Evaluating Large Language Models in Class-Level Code Generation (2024, background): “While some recent code completion efforts [31, 74] focus on handling longer code contexts with more dependencies, the generated output still remains at the function or statement level.”
- Agentless: Demystifying LLM-based Software Engineering Agents (2024, methodology): “After removing all files from these irrelevant folders, A GENTLESS divides each remaining file into chunks of code segments and computes the embedding for each chunk using an embedding model.”
- A Comprehensive Overview of Large Language Models (2023, unknown): “Many of the multimodal tool augmentation systems employ multimodal LLMs [271], [272], [270], [261], while others utilize single modality LLMs and generate a plan on using different modality tools to solve multimodal queries [273].”
- Native Sparse Attention: Hardware-Aligned and Natively Trainable Sparse Attention (2025, unknown): “…for next-generation large language models, driven by diverse real-world applications ranging from in-depth reasoning (DeepSeek-AI, 2025; Zelik-man et al., 2022), repository-level code generation (Zhang et al., 2023a; Zhang et al.) and multi-turn autonomous agent systems (Park et al., 2023).”
- Active Retrieval Augmented Generation (2023, unknown): “Iterative and adaptive retrieval Iterative retrieval and refinement has been studied in both text and code generation tasks (Peng et al., 2023; Zhang et al., 2023; Zemlyanskiy et al., 2022; Yu et al., 2023).”
- A Survey on Large Language Models for Code Generation (2024, unknown): “…sections demonstrate several aspects of the broader code generation topic and are categorized into three groups of tasks: (A) code generation and code completion (foundational tasks), (B) code generation and code search (advanced tasks), and (C) debugging and code translation (auxiliary tasks).”
- Retrieval-Augmented Generation for AI-Generated Content: A Survey (2024, unknown): “RepoCoder [218] employs an iterative retrieval-generation pipeline for code completion tasks, enhancing each retrieval query with code generated in prior iterations to more effectively leverage information dispersed across various files, thereby achieving superior results.”
- A Survey of Model Architectures in Information Retrieval (2025, unknown): “…(Khandelwal et al., 2020; Borgeaud et al., 2022) to applications in agents (Wu et al., 2023; Wang et al., 2024a), code generation (Wang et al., 2024c; Zhang et al., 2023a), robotics (Anwar et al., 2024), medicine (Jeong et al., 2024), and protein research (Jumper et al., 2021), inter alia .”
- FreshStack: Building Realistic Benchmarks for Evaluating Retrieval on Technical Documents (2025, unknown): “This drives the robustness of systems in answering questions in evolving public libraries or private code bases [92, 29], a company’s internal forum [60], or technical troubleshooting [69, 58, 8].”