How to Select Pre-Trained Code Models for Reuse? A Learning Perspective

Zhangqian Bi, Yao Wan, Zhaoyang Chu, Yufei Hu, Junyi Zhang +3 more
1/7/2025
cs.SEcs.CL

No official code found. Best implementation: CGCL-codes/naturalcc (320 stars, MIT, last commit 2026-04-28).

Abstract

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, pretraining language models on a large-scale code corpus is computationally 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 pretraining, 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 opensource 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.

View on arXivView PDF

Code Implementations(1)

MIT

NaturalCC: An Open-Source Toolkit for Code Intelligence

32061Shell, PythonDec 4, 20205 months agoMIT
deep-learningnatural-language-processingprogramming-languagetoolkit

Similar Papers

Cite this paper

@article{bi2025select,
  title  = {How to Select Pre-Trained Code Models for Reuse? A Learning Perspective},
  author = {Zhangqian Bi and Yao Wan and Zhaoyang Chu and Yufei Hu and Junyi Zhang and Hongyu Zhang and Guandong Xu and Hai Jin},
  year   = {2025},
  eprint = {2501.03783},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2501.03783v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2501.03783.svg)](https://codeofpaper.com/paper/2501.03783)

Discussion