如何选择可复用的预训练代码模型?一种学习视角
How to Select Pre-Trained Code Models for Reuse? A Learning Perspective
AI总结:
本文研究面向代码智能任务的预训练代码模型复用选择问题,提出基于代理模型与特征-标签分布偏差的免微调选择方法,在100个模型上以100秒实现低于6%的性能损失。
摘要:
先预训练语言模型再进行微调,已被证明是适用于代码生成、代码摘要和漏洞检测等广泛代码智能任务的高效且有效技术。然而,在大规模代码语料库上预训练语言模型在计算上非常昂贵。幸运的是,许多现成的预训练代码模型(Pre-trained Code Models,PCM),如 CodeBERT、CodeT5、CodeGen 和 Code Llama,已公开发布。这些模型在预训练期间获得了通用的代码理解与生成能力,从而提升了其在下游代码智能任务上的性能。随着此类公开预训练模型数量不断增加,为特定任务选择最合适的模型进行复用至关重要。本文系统研究了 PCM 的可复用性。我们首先探索三种直观的模型选择方法,即按模型规模、训练数据或暴力微调进行选择。实验结果表明,这些直接技术要么性能较差,要么成本高昂。受这些发现启发,我们探索基于学习的模型选择策略,在不改变预训练模型参数的情况下利用这些模型。具体而言,我们训练代理模型来评估预训练模型的性能,并测量模型潜在特征与任务标签之间的分布偏差,将二者的接近程度作为模型可迁移性的指标。我们针对代码智能任务,在 100 个广泛使用的开源 PCM 上开展实验,这些模型的规模从 4250 万到 30 亿参数不等。结果表明,基于学习的选择方法将选择时间缩短至 100 秒,而暴力微调需要 2700 小时,并且相关任务中的性能下降不到 6%。
英文摘要:
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.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。