mlsanityData to 14 Oct 2026

RAG or Fine-tuning? A Comparative Study on LCMs-based Code Completion in Industry

arXiv 2505.15179 ↗First posted 21 May 2025cs.SEcited by 5

On the map: Retrieval-augmented generation → RAG for code

Abstract (arXiv)

Code completion, a crucial practice in industrial settings, helps developers improve programming efficiency by automatically suggesting code snippets during development. With the emergence of Large Code Models (LCMs), this field has witnessed significant advancements. Due to the natural differences between open-source and industrial codebases, such as coding patterns and unique internal dependencies, it is a common practice for developers to conduct domain adaptation when adopting LCMs in industry. There exist multiple adaptation approaches, among which retrieval-augmented generation (RAG) and fine-tuning are the two most popular paradigms. However, no prior research has explored the trade-off of the two approaches in industrial scenarios. To mitigate the gap, we comprehensively compare the two paradigms including Retrieval-Augmented Generation (RAG) and Fine-tuning (FT), for industrial code completion in this paper. In collaboration with Tencent's WXG department, we collect over 160,000 internal C++ files as our codebase. We then compare the two types of adaptation approaches from three dimensions that are concerned by industrial practitioners, including effectiveness, efficiency, and parameter sensitivity, using six LCMs. Our findings reveal that RAG, when implemented with appropriate embedding models that map code snippets into dense vector representations, can achieve higher accuracy than fine-tuning alone. Specifically, BM25 presents superior retrieval effectiveness and efficiency among studied RAG methods. Moreover, RAG and fine-tuning are orthogonal and their combination leads to further improvement. We also observe that RAG demonstrates better scalability than FT, showing more sustained performance gains with larger scales of codebase.

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 41 of its 76 references that are in the map. First posted on arXiv 21 May 2025.

Builds on

41 of 76 references.

Closest ancestors · 2

Same direction, newest first

  1. 2023RAP-Gen: Retrieval-Augmented Patch Generation with CodeT5 for Automatic Program Repair12 Sep
  2. 2022ReACC: A Retrieval-Augmented Code Completion Framework15 Mar

Other references · 39

  1. 2015Distilling the Knowledge in a Neural Networkcited by 10,324
  2. 2023Efficient Memory Management for Large Language Model Serving with PagedAttentioncited by 5,944
  3. 2016SGDR: Stochastic Gradient Descent with Warm Restartscited by 5,045
  4. 2024Qwen2.5 Technical Reportcited by 4,942
  5. 2016Overcoming catastrophic forgetting in neural networkscited by 4,787
  6. 2022FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awarenesscited by 3,673
  7. 2023Code Llama: Open Foundation Models for Codecited by 2,139
  8. 2020CodeBERT: A Pre-Trained Model for Programming and Natural Languagescited by 1,310
  9. 2024Qwen2.5-Coder Technical Reportcited by 1,203
  10. 2024DeepSeek-Coder: When the Large Language Model Meets Programming -- The Rise of Code Intelligencecited by 1,181
  11. 2021CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generationcited by 906
  12. 2016Training Deep Nets with Sublinear Memory Costcited by 848
27 more
  1. 2019Generalization through Memorization: Nearest Neighbor Language Modelscited by 800
  2. 2021CodeXGLUE: A Machine Learning Benchmark Dataset for Code Understanding and Generationcited by 744
  3. 2023WizardCoder: Empowering Code Large Language Models with Evol-Instructcited by 733
  4. 2020CodeBLEU: a Method for Automatic Evaluation of Code Synthesiscited by 479
  5. 2023RepoCoder: Repository-Level Code Completion Through Iterative Retrieval and Generationcited by 367
  6. 2022UniXcoder: Unified Cross-Modal Pre-training for Code Representationcited by 361
  7. 2023RepoBench: Benchmarking Repository-Level Code Auto-Completion Systemscited by 353
  8. 2024CRUXEval: A Benchmark for Code Reasoning, Understanding and Executioncited by 300
  9. 2023Magicoder: Empowering Code Generation with OSS-Instructcited by 256
  10. 2024BM25S: Orders of magnitude faster lexical search via eager sparse scoringcited by 88
  11. 2024ChatQA 2: Bridging the Gap to Proprietary LLMs in Long Context and RAG Capabilitiescited by 53
  12. 2017Code Completion with Neural Attention and Pointer Networkscited by 49
  13. 2023What Makes Good In-context Demonstrations for Code Intelligence Tasks with LLMs?cited by 47
  14. 2022No More Fine-Tuning? An Experimental Evaluation of Prompt Tuning in Code Intelligencecited by 41
  15. 2022CCTEST: Testing and Repairing Code Completion Systemscited by 35
  16. 2021Code Structure Guided Transformer for Source Code Summarizationcited by 30
  17. 2024Search-Based LLMs for Code Optimizationcited by 28
  18. 2023Domain Knowledge Matters: Improving Prompts with Fix Templates for Repairing Python Type Errorscited by 22
  19. 2024Testing and Understanding Erroneous Planning in LLM Agents through Synthesized User Inputscited by 22
  20. 2023Domain Adaptive Code Completion via Language Models and Decoupled Domain Databasescited by 19
  21. 2024SCALE: Constructing Structured Natural Language Comment Trees for Software Vulnerability Detectioncited by 17
  22. 2024Exploring Multi-Lingual Bias of Large Code Models in Code Generationcited by 17
  23. 2023Benchmarking and Explaining Large Language Model-based Code Generation: A Causality-Centric Approachcited by 15
  24. 2022Unleashing the Power of Compiler Intermediate Representation to Enhance Neural Program Embeddingscited by 10
  25. 2023REEF: A Framework for Collecting Real-World Vulnerabilities and Fixescited by 8
  26. 2024A Systematic Evaluation of Large Code Models in API Suggestion: When, Which, and Howcited by 7
  27. 2024Contextual API Completion for Unseen Repositories Using LLMscited by 6

Built on by

Cited by year (2026 to 14 Oct)

Citing papers per year: 2025: 2; 2026: 3.

5 papers.

Similar, not cited

Close in wording, no citation either way

  1. 2025A Deep Dive into Retrieval-Augmented Generation for Code Completion: Experience on WeChat
  2. 2025Evaluating Large Language Models for Functional and Maintainable Code in Industrial Settings: A Case Study at ASML
  3. 2024Retrieval-augmented code completion for local projects using large language models
  4. 2024A Lightweight Framework for Adaptive Retrieval In Code Completion With Critique Model
  5. 2024Prompt-based Code Completion via Multi-Retrieval Augmented Generation
  6. 2026Not All RAGs Are Created Equal: A Component-Wise Empirical Study for Software Engineering Tasks
  7. 2024Repoformer: Selective Retrieval for Repository-Level Code Completion
  8. 2024CodeRAG-Bench: Can Retrieval Augment Code Generation?