How to Select Pre-Trained Code Models for Reuse? A Learning Perspective
Pre-training a language model and then fine-tuning it has shown to be an efficient and effective technique for a wide range of code intelligence tasks, such as code generation, code summarization, and vulnerability detection. However, pre-training language models on a large-scale code corpus is compu-tationally expensive. Fortunately, many off-the-shelf Pre-trained Code Models (PCMs), such as CodeBERT, CodeT5, CodeGen, and Code Llama, have been released publicly. These models acquire general code understanding and generation capability during pre-training, which enhances their performance on downstream code intelligence tasks. With an increasing number of these public pre-trained models, selecting the most suitable one to reuse for a specific task is essential. In this paper, we systematically investigate the reusability of PCMs. We first explore three intuitive model selection methods that select by size, training data, or brute-force fine-tuning. Experimental results show that these straightforward techniques either perform poorly or suffer high costs. Motivated by these findings, we explore learning-based model selection strategies that utilize pre-trained models without altering their parameters. Specifically, we train proxy models to gauge the performance of pre-trained models, and measure the distribution deviation between a model's latent features and the task's labels, using their closeness as an indicator of model transferability. We conduct experiments on 100 widely-used open-source PCMs for code intelligence tasks, with sizes ranging from 42.5 million to 3 billion parameters. The results demonstrate that learning-based selection methods reduce selection time to 100 seconds, compared to 2,700 hours with brute-force fine-tuning, with less than 6% performance degradation across related tasks.
Authors
- Zhangqian Bi (ORCID: https://orcid.org/0000-0003-2257-9052)
- Hai Jin (ORCID: https://orcid.org/0000-0002-3934-7605)
- Guandong Xu (ORCID: https://orcid.org/0000-0003-4493-6663)
- Junyi Zhang (ORCID: https://orcid.org/0000-0001-8986-6588)
- Hongyu Zhang (ORCID: https://orcid.org/0000-0002-3063-9425)
- Yao Wan (ORCID: https://orcid.org/0000-0001-6937-4180)
- Zhaoyang Chu (ORCID: https://orcid.org/0000-0003-4333-8063)
- You Hu (ORCID: https://orcid.org/0009-0006-9823-1465)
Institutions
- University of Technology Sydney (AU)
- Chongqing University (CN)
- Cloud Computing Center (CN)
- Huazhong University of Science and Technology (CN)
Publication Details
- Published
- 2025-03-04
- DOI
- https://doi.org/10.1109/saner64311.2025.00065
- Citations
- 1
- Primary Topic
- Natural Language Processing Techniques
- Type
- article
- Field-Weighted Citation Impact
- 2.48