Skip to main navigation Skip to search Skip to main content

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

  • Chaozheng Wang
  • , Zezhou Yang
  • , Shuzheng Gao
  • , Cuiyun Gao*
  • , Ting Peng
  • , Hailiang Huang
  • , Yuetang Deng
  • , Michael Lyu
  • *Corresponding author for this work
  • Chinese University of Hong Kong
  • Tencent

Research output: Chapter in Book/Report/Conference proceedingConference contributionpeer-review

Abstract

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. Our findings provide actionable guidance for choosing and implementing appropriate methods to adopt LCMs based on specific industrial scenarios and requirements.

Original languageEnglish
Title of host publicationFSE Companion 2025 - Companion Proceedings of the 33rd ACM International Conference on the Foundations of Software Engineering
EditorsJingyue Li
PublisherAssociation for Computing Machinery
Pages93-104
Number of pages12
ISBN (Electronic)9798400712760
DOIs
StatePublished - 28 Jul 2025
Externally publishedYes
Event33rd ACM International Conference on the Foundations of Software Engineering, FSE Companion 2025 - Trondheim, Norway
Duration: 23 Jun 202527 Jun 2025

Publication series

NameProceedings of the ACM SIGSOFT Symposium on the Foundations of Software Engineering
ISSN (Print)1539-7521

Conference

Conference33rd ACM International Conference on the Foundations of Software Engineering, FSE Companion 2025
Country/TerritoryNorway
CityTrondheim
Period23/06/2527/06/25

Keywords

  • Fine-Tuning
  • Large Code Models
  • Retrieval Augmented Generation

Fingerprint

Dive into the research topics of 'RAG or Fine-tuning? A Comparative Study on LCMs-based Code Completion in Industry'. Together they form a unique fingerprint.

Cite this