mlsanityData to 14 Oct 2026

A Deep Dive into Retrieval-Augmented Generation for Code Completion: Experience on WeChat

arXiv 2507.18515 ↗First posted 24 Jul 2025cs.SEcited by 5

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

  1. 2024GraphCoder: Enhancing Repository-Level Code Completion via Code Context Graph-based Retrieval and Language Model11 Jun
  2. 2024FT2Ra: A Fine-Tuning-Inspired Approach to Retrieval-Augmented Code Completion2 Apr
  3. 2024Repoformer: Selective Retrieval for Repository-Level Code Completion15 Mar
  4. 2022ReACC: A Retrieval-Augmented Code Completion Framework15 Mar

Other references · 31

  1. 2023Retrieval-Augmented Generation for Large Language Models: A Surveycited by 2,212
  2. 2023Code Llama: Open Foundation Models for Codecited by 2,139
  3. 2024Qwen2 Technical Reportcited by 2,120
  4. 2020CodeBERT: A Pre-Trained Model for Programming and Natural Languagescited by 1,310
  5. 2024Qwen2.5-Coder Technical Reportcited by 1,203
  6. 2023Towards General Text Embeddings with Multi-stage Contrastive Learningcited by 723
  7. 2024Yi: Open Foundation Models by 01.AIcited by 719
  8. 2024DeepSeek LLM: Scaling Open-Source Language Models with Longtermismcited by 642
  9. 2020CodeBLEU: a Method for Automatic Evaluation of Code Synthesiscited by 479
  10. 2022UniXcoder: Unified Cross-Modal Pre-training for Code Representationcited by 361
  11. 2023RepoBench: Benchmarking Repository-Level Code Auto-Completion Systemscited by 353
  12. 2024DeepSeek-Coder-V2: Breaking the Barrier of Closed-Source Models in Code Intelligencecited by 331
19 more
  1. 2024OpenCoder: The Open Cookbook for Top-Tier Code Large Language Modelscited by 130
  2. 2023Retrieval meets Long Context Large Language Modelscited by 115
  3. 2022Re2G: Retrieve, Rerank, Generatecited by 102
  4. 2024BM25S: Orders of magnitude faster lexical search via eager sparse scoringcited by 88
  5. 2024Don't Forget to Connect! Improving RAG with Graph-based Rerankingcited by 49
  6. 2023What Makes Good In-context Demonstrations for Code Intelligence Tasks with LLMs?cited by 47
  7. 2024Dataflow-Guided Retrieval Augmentation for Repository-Level Code Completioncited by 40
  8. 2024Language Models for Code Completion: A Practical Evaluationcited by 39
  9. 2024The Chronicles of RAG: The Retriever, the Chunk and the Generatorcited by 34
  10. 2024REPOFUSE: Repository-Level Code Completion with Fused Dual Contextcited by 32
  11. 2024Teaching Code LLMs to Use Autocompletion Tools in Repository-Level Code Generationcited by 30
  12. 2024Generalization-Enhanced Code Vulnerability Detection via Multi-Task Instruction Fine-Tuningcited by 30
  13. 2022CoCoSoDa: Effective Contrastive Learning for Code Searchcited by 22
  14. 2024STALL+: Boosting LLM-based Repository-level Code Completion with Static Analysiscited by 21
  15. 2024Studying LLM Performance on Closed- and Open-source Datacited by 11
  16. 2024When Neural Code Completion Models Size up the Situation: Attaining Cheaper and Faster Completion through Dynamic Model Inferencecited by 10
  17. 2024VulScribeR: Exploring RAG-based Vulnerability Augmentation with LLMscited by 7
  18. 2023Generative Type Inference for Pythoncited by 6
  19. 2024RAG-Enhanced Commit Message Generationcited by 6

Built on by

Cited by year (2026 to 14 Oct)

Citing papers per year: 2025: 1; 2026: 4.

5 papers.

Similar, not cited

Close in wording, no citation either way

  1. 2024CodeRAG-Bench: Can Retrieval Augment Code Generation?
  2. 2024Retrieval-augmented code completion for local projects using large language models
  3. 2025Retrieval-Augmented Code Generation: A Survey with Focus on Repository-Level Approaches
  4. 2024A Lightweight Framework for Adaptive Retrieval In Code Completion With Critique Model
  5. 2024Evaluating the Effectiveness and Efficiency of Demonstration Retrievers in RAG for Coding Tasks
  6. 2026Not All RAGs Are Created Equal: A Component-Wise Empirical Study for Software Engineering Tasks
  7. 2025What to Retrieve for Effective Retrieval-Augmented Code Generation? An Empirical Study and Beyond
  8. 2025Impact-driven Context Filtering For Cross-file Code Completion