[Paper Review] CommitBART: A Large Pre-trained Model for GitHub Commits
CommitBART is a large pre-trained encoder-decoder Transformer model fine-tuned on a benchmark of 7.99 million GitHub commits across seven programming languages. It uses denoising, cross-modal generation, and contrastive learning objectives across six pre-training tasks, achieving state-of-the-art performance on commit understanding and generation tasks, including commit message generation and updated code snippet generation.
GitHub commits, which record the code changes with natural language messages for description, play a critical role for software developers to comprehend the software evolution. To promote the development of the open-source software community, we collect a commit benchmark including over 7.99 million commits across 7 programming languages. Based on this benchmark, we present CommitBART, a large pre-trained encoder-decoder Transformer model for GitHub commits. The model is pre-trained by three categories (i.e., denoising objectives, cross-modal generation and contrastive learning) for six pre-training tasks to learn commit fragment representations. Furthermore, we unify a ``commit intelligence'' framework with one understanding task and three generation tasks for commits. The comprehensive experiments on these tasks demonstrate that CommitBARTsignificantly outperforms previous pre-trained works for code. Further analysis also reveals each pre-training task enhances the model performance.
Motivation & Objective
- To address the lack of large-scale, publicly available commit data for training specialized models in software engineering.
- To develop a pre-trained model specifically tailored for GitHub commits, capturing both code and natural language semantics.
- To unify a 'commit intelligence' framework supporting both understanding and generation tasks for commits.
- To improve performance on commit-related NLP tasks through multi-objective pre-training.
- To release a large-scale commit benchmark and model to accelerate research in code intelligence.
Proposed method
- Collect a benchmark of 7.99 million commits from the top 500 GitHub projects across seven programming languages (C, CSharp, Java, JavaScript, PHP, Python, TypeScript).
- Design and pre-train CommitBART using three categories of objectives: denoising (text infilling and graph-guided token masking), cross-modal generation (PL2NL and PLNL2PL), and contrastive learning (NLPL alignment and SimCSE).
- Use graph-guided token masking to enhance semantic alignment between commit messages and code changes by predicting tokens common to both.
- Implement PL2NL generation to predict commit messages from code changes and PLNL2PL generation to predict updated code from previous code and commit messages.
- Apply contrastive learning via NLPL alignment to align code and message embeddings and SimCSE to learn robust, semantically equivalent representations through dropout-augmented encoding.
- Fine-tune CommitBART on downstream tasks including security patch identification (understanding) and commit message generation, positive code statement generation, and updated code snippet generation.
Experimental results
Research questions
- RQ1Can a large-scale, commit-specific pre-trained model significantly improve performance on commit-related NLP tasks compared to general-purpose code models?
- RQ2How effective are different pre-training objectives—denoising, cross-modal generation, and contrastive learning—in enhancing commit representation learning?
- RQ3To what extent does graph-guided token masking improve semantic alignment between commit messages and code changes?
- RQ4Can the unified 'commit intelligence' framework support diverse downstream tasks with strong generalization?
- RQ5How does CommitBART perform on generation tasks requiring functional correctness and semantic accuracy?
Key findings
- CommitBART achieves state-of-the-art performance on all evaluated tasks, including security patch identification and commit message generation, outperforming prior models such as UniXcoder and Incr-PLBART.
- The ablation study shows that removing the PLNL2PL generation task reduces the BLEU-4 score for updated code snippet generation from 57.63 to 53.70 across seven languages.
- Graph-guided token masking significantly improves performance on generation tasks, indicating its effectiveness in reducing the semantic gap between code and natural language.
- Both contrastive learning objectives (NLPL alignment and SimCSE) contribute meaningfully to model performance, enhancing embedding quality.
- Case studies confirm that CommitBART generates accurate package names (e.g., 'xray.backends') in commit messages, while baselines fail, demonstrating superior semantic capture.
- Segment embeddings are found to be beneficial, likely due to the complex structure of commits involving multiple components like messages and code changes.
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.