[Paper Review] CoTexT: Multi-task Learning with Code-Text Transformer
CoTexT is a pre-trained encoder-decoder transformer model fine-tuned on large-scale bimodal (code-text) and unimodal (code-only) programming language corpora to enable multi-task learning for natural language and code understanding. It achieves state-of-the-art performance across four CodeXGLUE tasks: code summarization, code generation, code refinement, and defect detection, outperforming models like CodeBERT and PLBART with consistent gains, especially in defect detection (+3.44%) and code generation across BLEU, CodeBLEU, and EM metrics.
We present CoTexT, a pre-trained, transformer-based encoder-decoder model that learns the representative context between natural language (NL) and programming language (PL). Using self-supervision, CoTexT is pre-trained on large programming language corpora to learn a general understanding of language and code. CoTexT supports downstream NL-PL tasks such as code summarizing/documentation, code generation, defect detection, and code debugging. We train CoTexT on different combinations of available PL corpus including both "bimodal" and "unimodal" data. Here, bimodal data is the combination of text and corresponding code snippets, whereas unimodal data is merely code snippets. We first evaluate CoTexT with multi-task learning: we perform Code Summarization on 6 different programming languages and Code Refinement on both small and medium size featured in the CodeXGLUE dataset. We further conduct extensive experiments to investigate CoTexT on other tasks within the CodeXGlue dataset, including Code Generation and Defect Detection. We consistently achieve SOTA results in these tasks, demonstrating the versatility of our models.
Motivation & Objective
- To develop a unified pre-trained model that learns joint representations between natural language and programming language for improved code intelligence tasks.
- To investigate the effectiveness of combining bimodal (code-text pairs) and unimodal (code-only) data in pre-training for downstream code-related NLP tasks.
- To achieve state-of-the-art performance across multiple CodeXGLUE benchmark tasks, including code summarization, code generation, code refinement, and defect detection.
- To demonstrate the generalization capability of the model on programming languages not included in its training data, such as C for defect detection.
- To release pre-trained checkpoints and source code to support future research and model improvements.
Proposed method
- CoTexT is based on the T5 encoder-decoder transformer architecture with multi-head attention mechanisms and is pre-trained using self-supervised objectives, including masked language modeling and denoising autoencoding.
- The model uses SentencePiece for subword tokenization, with special handling of out-of-vocabulary code-specific symbols (e.g., {, [, $) by encoding them into meaningful natural language representations.
- Pre-training is performed on large-scale corpora: CodeSearchNet and GitHub repositories, using both bimodal (code + natural language) and unimodal (code-only) data combinations.
- Fine-tuning is conducted using the T5 framework on four CodeXGLUE tasks: code summarization (6 languages), code refinement (small/medium), code generation, and defect detection.
- Multiple versions of CoTexT are trained with different data combinations (e.g., 1-CCG, 2-CC) to evaluate the impact of data modality on performance.
- The model is initialized from the original T5 base model pre-trained on the C4 corpus to accelerate convergence and improve performance.
Experimental results
Research questions
- RQ1Can a unified pre-trained encoder-decoder transformer model effectively learn joint representations between natural language and programming language?
- RQ2How does combining bimodal and unimodal training data affect performance across diverse code intelligence tasks?
- RQ3To what extent can a model pre-trained on multiple programming languages generalize to low-resource languages or unseen languages like C?
- RQ4Does multi-task learning with CoTexT lead to consistent improvements across code summarization, code generation, code refinement, and defect detection?
- RQ5Can CoTexT outperform existing SOTA models such as CodeBERT and PLBART across multiple benchmarks?
Key findings
- CoTexT achieves state-of-the-art performance on the CodeXGLUE benchmark for code summarization, outperforming previous models on overall, Python-specific, Java-specific, and Go-specific BLEU-4 scores.
- For code refinement, CoTexT achieves SOTA results on all metrics for the small test set and on accuracy for the medium test set, significantly outperforming base T5.
- In code generation, CoTexT achieves SOTA results across all three metrics: Exact Match (20.10), BLEU (66.62), and CodeBLEU (65.99), outperforming both CodeGPT-adapted and PLBART.
- For defect detection on C code, CoTexT achieves a 3.44% improvement over the previous SOTA model (PLBART), demonstrating strong zero-shot generalization to unseen languages.
- The model shows robust performance across multiple programming languages, with notable gains on high-resource languages like Python and Java, suggesting scalability with increased training data.
- CoTexT's performance is consistently superior across all evaluated tasks, indicating the effectiveness of its multi-task learning and pre-training strategy on diverse code and text data.
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.