A Deep Dive into Retrieval-Augmented Generation for Code Completion: Experience on WeChat
On the map: Retrieval-augmented generation → RAG for code
Abstract (arXiv)
Code completion, a crucial task in software engineering that enhances developer productivity, has seen substantial improvements with the rapid advancement of large language models (LLMs). In recent years, retrieval-augmented generation (RAG) has emerged as a promising method to enhance the code completion capabilities of LLMs, which leverages relevant context from codebases without requiring model retraining. While existing studies have demonstrated the effectiveness of RAG on public repositories and benchmarks, the potential distribution shift between open-source and closed-source codebases presents unique challenges that remain unexplored. To mitigate the gap, we conduct an empirical study to investigate the performance of widely-used RAG methods for code completion in the industrial-scale codebase of WeChat, one of the largest proprietary software systems. Specifically, we extensively explore two main types of RAG methods, namely identifier-based RAG and similarity-based RAG, across 26 open-source LLMs ranging from 0.5B to 671B parameters. For a more comprehensive analysis, we employ different retrieval techniques for similarity-based RAG, including lexical and semantic retrieval. Based on 1,669 internal repositories, we achieve several key findings: (1) both RAG methods demonstrate effectiveness in closed-source repositories, with similarity-based RAG showing superior performance, (2) the effectiveness of similarity-based RAG improves with more advanced retrieval techniques, where BM25 (lexical retrieval) and GTE-Qwen (semantic retrieval) achieve superior performance, and (3) the combination of lexical and semantic retrieval techniques yields optimal results, demonstrating complementary strengths. Furthermore, we conduct a developer survey to validate the practical utility of RAG methods in real-world development environments.
Key facts. Cited by 5 papers in the map (data through 14 Oct 2026). Placed in RAG for code, one of 15 directions in Retrieval-augmented generation. Builds on 35 of its 53 references that are in the map. First posted on arXiv 24 Jul 2025.
Builds on
35 of 53 references.
Closest ancestors · 4
Same direction, newest first
- 2024GraphCoder: Enhancing Repository-Level Code Completion via Code Context Graph-based Retrieval and Language Model11 Jun
- 2024FT2Ra: A Fine-Tuning-Inspired Approach to Retrieval-Augmented Code Completion2 Apr
- 2024Repoformer: Selective Retrieval for Repository-Level Code Completion15 Mar
- 2022ReACC: A Retrieval-Augmented Code Completion Framework15 Mar
Other references · 31
- 2023Retrieval-Augmented Generation for Large Language Models: A Surveycited by 2,212
- 2023Code Llama: Open Foundation Models for Codecited by 2,139
- 2024Qwen2 Technical Reportcited by 2,120
- 2020CodeBERT: A Pre-Trained Model for Programming and Natural Languagescited by 1,310
- 2024Qwen2.5-Coder Technical Reportcited by 1,203
- 2023Towards General Text Embeddings with Multi-stage Contrastive Learningcited by 723
- 2024Yi: Open Foundation Models by 01.AIcited by 719
- 2024DeepSeek LLM: Scaling Open-Source Language Models with Longtermismcited by 642
- 2020CodeBLEU: a Method for Automatic Evaluation of Code Synthesiscited by 479
- 2022UniXcoder: Unified Cross-Modal Pre-training for Code Representationcited by 361
- 2023RepoBench: Benchmarking Repository-Level Code Auto-Completion Systemscited by 353
- 2024DeepSeek-Coder-V2: Breaking the Barrier of Closed-Source Models in Code Intelligencecited by 331
19 more
- 2024OpenCoder: The Open Cookbook for Top-Tier Code Large Language Modelscited by 130
- 2023Retrieval meets Long Context Large Language Modelscited by 115
- 2022Re2G: Retrieve, Rerank, Generatecited by 102
- 2024BM25S: Orders of magnitude faster lexical search via eager sparse scoringcited by 88
- 2024Don't Forget to Connect! Improving RAG with Graph-based Rerankingcited by 49
- 2023What Makes Good In-context Demonstrations for Code Intelligence Tasks with LLMs?cited by 47
- 2024Dataflow-Guided Retrieval Augmentation for Repository-Level Code Completioncited by 40
- 2024Language Models for Code Completion: A Practical Evaluationcited by 39
- 2024The Chronicles of RAG: The Retriever, the Chunk and the Generatorcited by 34
- 2024REPOFUSE: Repository-Level Code Completion with Fused Dual Contextcited by 32
- 2024Teaching Code LLMs to Use Autocompletion Tools in Repository-Level Code Generationcited by 30
- 2024Generalization-Enhanced Code Vulnerability Detection via Multi-Task Instruction Fine-Tuningcited by 30
- 2022CoCoSoDa: Effective Contrastive Learning for Code Searchcited by 22
- 2024STALL+: Boosting LLM-based Repository-level Code Completion with Static Analysiscited by 21
- 2024Studying LLM Performance on Closed- and Open-source Datacited by 11
- 2024When Neural Code Completion Models Size up the Situation: Attaining Cheaper and Faster Completion through Dynamic Model Inferencecited by 10
- 2024VulScribeR: Exploring RAG-based Vulnerability Augmentation with LLMscited by 7
- 2023Generative Type Inference for Pythoncited by 6
- 2024RAG-Enhanced Commit Message Generationcited by 6
Built on by
Citing papers per year: 2025: 1; 2026: 4.
5 papers.
- 2025DocLens : A Tool-Augmented Multi-Agent Framework for Long Visual Document Understandingcited by 15
- 2026RepoShapley: Shapley-Enhanced Context Filtering for Repository-Level Code Completioncited by 3
- 2026Engineering Reliable Coding Agents: Evaluating and Operating the System Around the Modelcited by 3
- 2026Fine-grained Fragment Retrieval in Multi-modal Long-form Dialoguescited by 0
- 2026An Exploration of Agentic Information Fusion for Test Maintenance Predictioncited by 0
- 2026Engineering Reliable Coding Agents: Evaluating and Operating the System Around the Model14 Aug 2026
- 2026An Exploration of Agentic Information Fusion for Test Maintenance Prediction6 Jul 2026
- 2026Fine-grained Fragment Retrieval in Multi-modal Long-form Dialogues3 Jun 2026
- 2026RepoShapley: Shapley-Enhanced Context Filtering for Repository-Level Code Completion6 Jan 2026
- 2025DocLens : A Tool-Augmented Multi-Agent Framework for Long Visual Document Understanding14 Nov 2025
Similar, not cited
Close in wording, no citation either way
- 2024CodeRAG-Bench: Can Retrieval Augment Code Generation?
- 2024Retrieval-augmented code completion for local projects using large language models
- 2025Retrieval-Augmented Code Generation: A Survey with Focus on Repository-Level Approaches
- 2024A Lightweight Framework for Adaptive Retrieval In Code Completion With Critique Model
- 2024Evaluating the Effectiveness and Efficiency of Demonstration Retrievers in RAG for Coding Tasks
- 2026Not All RAGs Are Created Equal: A Component-Wise Empirical Study for Software Engineering Tasks
- 2025What to Retrieve for Effective Retrieval-Augmented Code Generation? An Empirical Study and Beyond
- 2025Impact-driven Context Filtering For Cross-file Code Completion