NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

CommitBART: A Large Pre-trained Model for GitHub Commits

Shangqing Liu, Yanzhou Li, Yang LiuarXiv 2022 · DOI

Abstract

CommitBART is the first large-scale pre-trained model specifically designed to understand and generate GitHub commits. By training on a massive new benchmark of nearly 8 million commits across seven programming languages, it significantly outperforms general-purpose code models on tasks like security patch identification and automated commit message generation.

Introduction: The Challenge of Commit Intelligence

In software engineering, a "commit" is a multi-modal record of evolution. It encapsulates the "before" and "after" states of code, specific file paths, and a natural language message explaining the rationale behind the change. While powerful pre-trained models for code (e.g., CodeBERT, CodeT5) exist, they are typically trained on isolated functions or snippets. These models often lack "commit intelligence"—the ability to link structural code changes to descriptive intent.

Example of a GitHub commit showing code changes and the associated message.

Previous efforts, such as CommitBERT, were hampered by small datasets and a lack of commit-specific pre-training objectives. CommitBART addresses this gap by treating the commit as a first-class citizen in the pre-training pipeline.

Methodology: Making Models Commit-Aware

CommitBART is an encoder-decoder Transformer based on the BART architecture. To handle the unique structure of commits, the authors introduced specialized segment identifiers: [MSG] for the commit message, [FILE] for the file path, [CODE] for context, and [NEG] / [POS] to mark deleted and added code statements.

The model's pre-training involves six tasks across three distinct categories:

  1. Denoising: Includes standard text infilling and a novel Graph-guided Token Masking (GTM). GTM utilizes a "commit-graph" to link shared tokens (e.g., variable names) between the message and the code, forcing the model to learn semantic mappings.
  2. Cross-modal Generation: Focuses on generating messages from code changes (PL2NL) and updated code from a message and prior code (PLNL2PL).
  3. Contrastive Learning: Employs techniques like SimCSE to ensure robust representations by comparing similar and dissimilar commit fragments.
Overview of CommitBART's pre-training tasks, including Text Infilling, Graph-guided Token Masking, and cross-modal generation.

The Commit Benchmark

A major contribution of this work is the Commit Benchmark, an unprecedented dataset of over 7.99 million commits. These were extracted from the top 500 starred projects on GitHub across seven languages: C, C#, Java, JavaScript, PHP, Python, and TypeScript. This represents a massive scale-up from previous benchmarks (e.g., 345,000 commits for CommitBERT), providing the data density required for large-scale pre-training.

Key Insights

  • Multi-Modality is Essential: Commits are inherently relational. The GTM task successfully bridges the "semantic gap" between developer descriptions and actual code changes by masking tokens present in both modalities.
  • Structural Embeddings: Unlike standard NLP, commit data is highly structured. The use of segment embeddings to distinguish between context, deletions, and additions was found to be vital for performance.
  • Domain Specificity: General code models trained on static snippets fall short on commit-related tasks. Pre-training specifically on the diff (the change) and the intent (the message) is necessary for true commit intelligence.

Evaluation Results

CommitBART achieved state-of-the-art results across several benchmarks:

  • Security Patch Identification: Achieved an F1-score of 95.49, surpassing UniXcoder (94.95).
  • Commit Message Generation: Scored a BLEU-4 of 20.60 across 7 languages, significantly outperforming CodeT5-base (18.04).
  • Code Generation: In the "Updated Code Snippet Generation" task, CommitBART reached a BLEU-4 of 57.63, outperforming Incr-PLBART (56.36).

Ablation studies confirmed that every pre-training task, particularly GTM, contributed significantly to the model's success in generation tasks.

Limitations and Future Work

The authors identify two primary areas for improvement. First, the reliance on match-based metrics like BLEU-4 may not fully capture functional correctness; future work could incorporate execution-based metrics (e.g., pass@k). Second, the current model targets only the first sentence of commit messages for efficiency, potentially ignoring deeper context found in multi-sentence commit bodies.

Summary updated

BibTeX
@misc{liu2022commitbart,
  author = {Shangqing Liu and Yanzhou Li and Yang Liu},
  title = {{CommitBART: A Large Pre-trained Model for GitHub Commits}},
  year = {2022},
  eprint = {2208.08100},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2208.08100},
}
Figure