一句话:比较全参数、轻量与前缀微调三种个性化策略,在 Java 单元测试生成上权衡性能与计算成本。
大型 Transformer 模型在代码建模中已成为主流,但预训练后微调仍面临泛化挑战。本文探索面向代码生成的模型个性化,在 Java 方法生成单元测试的任务上评估三种个性化微调技术:(i) 全参数自定义微调;(ii) 轻量微调,冻结大部分参数,仅调整 token 嵌入与 softmax 层或仅最后一层;(iii) 前缀微调,保持模型参数冻结,仅优化项目特定的小前缀向量。作者用代码与任务特定指标、训练时间和总计算量比较各策略,分析其在性能与计算成本间的权衡,并讨论不同部署场景下各自的泛化与成本收益。
Large Transformer models achieved the state-of-the-art status for Natural Language Understanding tasks and are increasingly becoming the baseline model architecture for modeling source code. Transformers are usually pre-trained on large unsupervised corpora, learning token representations and transformations relevant to modeling generally available text, and are then fine-tuned on a particular downstream task of interest. While fine-tuning is a tried-and-true method for adapting a model to a new domain -- for example, question-answering on a given topic -- generalization remains an on-going challenge. In this paper, we explore and evaluate transformer model fine-tuning for personalization. In the context of generating unit tests for Java methods, we evaluate learning to personalize to a specific software project using several personalization techniques. We consider three key approaches: (i) custom fine-tuning, which allows all the model parameters to be tuned; (ii) lightweight fine-tuning, which freezes most of the model's parameters, allowing tuning of the token embeddings and softmax layer only or the final layer alone; (iii) prefix tuning, which keeps model parameters frozen, but optimizes a small project-specific prefix vector. Each of these techniques offers a trade-off in total compute cost and predictive performance, which we evaluate by code and task-specific metrics, training time, and total computational operations. We compare these fine-tuning strategies for code generation and discuss the potential generalization and cost benefits of each in various deployment scenarios.
@inproceedings{paperbot7039,
title = {Exploring and evaluating personalized models for code generation},
author = {Andrei Zlotchevski and Dawn Drain and Alexey Svyatkovskiy and Colin B. Clement and Neel Sundaresan and Michele Tufano},
booktitle = {FSE},
year = {2022},
doi = {10.1145/3540250.3558959}
}