[Paper Review] Using Transfer Learning for Code-Related Tasks
This paper investigates transfer learning using the T5 model for four code-related tasks—automatic bug-fixing, mutant injection, assert statement generation, and code summarization—demonstrating that pre-training significantly boosts performance, though multi-task fine-tuning does not consistently improve results across all tasks.
Deep learning (DL) techniques have been used to support several code-related tasks such as code summarization and bug-fixing. In particular, pre-trained transformer models are on the rise, also thanks to the excellent results they achieved in Natural Language Processing (NLP) tasks. The basic idea behind these models is to first pre-train them on a generic dataset using a self-supervised task (e.g, filling masked words in sentences). Then, these models are fine-tuned to support specific tasks of interest (e.g, language translation). A single model can be fine-tuned to support multiple tasks, possibly exploiting the benefits of transfer learning. This means that knowledge acquired to solve a specific task (e.g, language translation) can be useful to boost performance on another task (e.g, sentiment classification). While the benefits of transfer learning have been widely studied in NLP, limited empirical evidence is available when it comes to code-related tasks. In this paper, we assess the performance of the Text-To-Text Transfer Transformer (T5) model in supporting four different code-related tasks: (i) automatic bug-fixing, (ii) injection of code mutants, (iii) generation of assert statements, and (iv) code summarization. We pay particular attention in studying the role played by pre-training and multi-task fine-tuning on the model's performance. We show that (i) the T5 can achieve better performance as compared to state-of-the-art baselines; and (ii) while pre-training helps the model, not all tasks benefit from a multi-task fine-tuning.
Motivation & Objective
- To evaluate the effectiveness of transfer learning via the T5 model for diverse code-related tasks.
- To assess whether pre-training on a large code and text dataset improves performance on downstream code tasks.
- To investigate whether multi-task fine-tuning across different code tasks enhances model generalization and performance.
- To analyze data leakage risks between training and test sets through Levenshtein distance correlation.
- To compare T5 performance against state-of-the-art baselines across four distinct code-related NLP tasks.
Proposed method
- Pre-trained a T5 model on a combined dataset of 499,618 English sentences and 1,569,889 Java methods using a self-supervised masked language modeling objective.
- Fine-tuned the pre-trained T5 model on four distinct code-related tasks: bug-fixing, mutant injection, assert generation, and code summarization.
- Applied multi-task fine-tuning by jointly training the model on all four datasets to assess transferability across heterogeneous data types.
- Computed pairwise Levenshtein distances between training and test sets to detect data snooping and assess model generalizability.
- Used Point Biserial Correlation (PBC) and Pearson Correlation to analyze the relationship between training-test similarity and model performance.
- Evaluated model performance using BLEU score and perfect prediction accuracy, comparing results against existing state-of-the-art baselines.
Experimental results
Research questions
- RQ1Does pre-training the T5 model on a large code and natural language dataset improve performance on downstream code-related tasks?
- RQ2To what extent does multi-task fine-tuning across diverse code tasks (e.g., raw code vs. abstracted code vs. natural language) enhance model performance?
- RQ3How does data overlap between training and test sets affect model performance, and is the model’s success due to data leakage or generalization?
- RQ4How does the T5 model’s performance compare to existing state-of-the-art deep learning models across four distinct code-related tasks?
- RQ5Are there specific task types where multi-task learning provides measurable benefits, or is the performance gain inconsistent across tasks?
Key findings
- Pre-training significantly improves model performance across all four code-related tasks, confirming the value of pre-training for code representation learning.
- Multi-task fine-tuning does not consistently improve performance, suggesting that the differing data types (e.g., raw code, abstracted code, natural language) may hinder knowledge transfer.
- The T5 model outperforms existing state-of-the-art baselines across all four tasks, even though those baselines do not use pre-training or require ~22 hours of additional pre-training computation.
- Correlation analysis shows low to moderate negative correlations between training-test Levenshtein distance and performance, indicating minimal data leakage and strong generalization capability.
- The model performs worse as the minimum and median distances between training and test examples increase, suggesting sensitivity to distributional shift.
- For perfect prediction, a positive correlation between maximum distance and performance was observed, possibly due to outliers or rare test cases, but overall correlations remained low, supporting model robustness.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.