Recent advancements in large language models (LLMs) have substantially improved automated code generation. While function-level and file-level generation have achieved promising results, real-world software development typically requires reasoning across entire repositories. This gives rise to the challenging task of Repository-Level Code Generation (RLCG), where models must capture long-range dependencies, ensure global semantic consistency, and generate coherent code spanning multiple files or modules. To address these challenges, Retrieval-Augmented Generation (RAG) has emerged as a powerful paradigm that integrates external retrieval mechanisms with LLMs, enhancing context-awareness and scalability. In this survey, we provide a comprehensive review of research on Retrieval-Augmented Code Generation (RACG), with an emphasis on repository-level approaches. We categorize existing work along several dimensions, including generation strategies, retrieval modalities, model architectures, training paradigms, and evaluation protocols. Furthermore, we summarize widely used datasets and benchmarks, analyze current limitations, and outline key challenges and opportunities for future research. Our goal is to establish a unified analytical framework for understanding this rapidly evolving field and to inspire continued progress in AI-powered software engineering.
翻译:近年来,大型语言模型(LLMs)的进步显著提升了自动化代码生成的性能。尽管函数级和文件级代码生成已取得可喜成果,但现实世界的软件开发通常需要对整个代码仓库进行推理。这催生了具有挑战性的仓库级代码生成(RLCG)任务,该任务要求模型必须捕获长距离依赖关系、确保全局语义一致性,并生成跨多个文件或模块的连贯代码。为应对这些挑战,检索增强生成(RAG)已成为一种强大的范式,它将外部检索机制与LLMs相结合,从而增强了上下文感知能力和可扩展性。本综述对检索增强代码生成(RACG)的研究进行了全面回顾,并着重关注仓库级方法。我们从多个维度对现有工作进行了分类,包括生成策略、检索模态、模型架构、训练范式和评估协议。此外,我们总结了广泛使用的数据集与基准,分析了当前存在的局限性,并概述了未来研究的关键挑战与机遇。我们的目标是建立一个统一的分析框架,以理解这一快速发展的领域,并启发人工智能驱动的软件工程领域持续取得进展。