[Paper Review] Automatically Generating Commit Messages from Diffs using Neural Machine Translation
This paper proposes using Neural Machine Translation (NMT) to automatically generate concise, high-level commit messages from code diffs by training on a filtered corpus of 2M commit-message pairs from top GitHub projects. The method achieves strong performance on common change patterns but generates low-quality outputs for novel changes; a quality-assurance filter mitigates this by warning users when predictions are unreliable, significantly improving output reliability.
Commit messages are a valuable resource in comprehension of software evolution, since they provide a record of changes such as feature additions and bug repairs. Unfortunately, programmers often neglect to write good commit messages. Different techniques have been proposed to help programmers by automatically writing these messages. These techniques are effective at describing what changed, but are often verbose and lack context for understanding the rationale behind a change. In contrast, humans write messages that are short and summarize the high level rationale. In this paper, we adapt Neural Machine Translation (NMT) to automatically "translate" diffs into commit messages. We trained an NMT algorithm using a corpus of diffs and human-written commit messages from the top 1k Github projects. We designed a filter to help ensure that we only trained the algorithm on higher-quality commit messages. Our evaluation uncovered a pattern in which the messages we generate tend to be either very high or very low quality. Therefore, we created a quality-assurance filter to detect cases in which we are unable to produce good messages, and return a warning instead.
Motivation & Objective
- To address the lack of automated tools that generate high-level, rationale-focused commit messages rather than low-level change descriptions.
- To improve software maintainability by automatically generating concise, human-like commit messages from code diffs.
- To reduce the burden on developers by automating commit message creation, especially for repetitive or patterned changes.
- To identify and filter out low-quality commit messages during training to improve model reliability.
- To develop a quality-assurance mechanism that detects when the model cannot generate a reliable message, issuing a warning instead.
Proposed method
- Train a neural machine translation (NMT) model on paired diffs and human-written commit messages from the top 1,000 GitHub projects.
- Apply a verb-direct-object (V-DO) pattern filter to select only high-quality, grammatically structured commit messages for training.
- Use sequence-to-sequence NMT architecture with attention mechanisms to map code diffs to natural language commit messages.
- Implement a quality-assurance filter that evaluates model confidence and flags low-confidence predictions for human review.
- Evaluate model performance using automated metrics (e.g., BLEU, METEOR) and human evaluation on a representative sample of generated messages.
- Release the full dataset and implementation to support reproducibility and future research.
Experimental results
Research questions
- RQ1Can neural machine translation effectively generate high-level, rationale-focused commit messages from code diffs?
- RQ2How does the quality of training data affect the model’s ability to generate accurate and concise commit messages?
- RQ3To what extent does the model generalize across different types of code changes, especially novel or non-repetitive ones?
- RQ4Can a quality-assurance filter effectively detect and flag low-confidence predictions, reducing the risk of misleading outputs?
- RQ5How do automated metrics correlate with human judgments of message quality and relevance?
Key findings
- The NMT model performs well on common, repetitive change patterns, generating messages that are highly similar to reference human-written messages, as confirmed by human evaluation.
- A significant portion of generated messages were of low quality, particularly for novel or non-repetitive changes, indicating limitations in generalization beyond learned patterns.
- The quality-assurance filter successfully reduced the number of low-quality predictions, decreasing the proportion of very poor messages (score 0) in evaluation.
- Human evaluators rated a large number of generated messages as very close matches to reference messages (high similarity), indicating strong performance on typical cases.
- The model struggles to generate messages for changes that require new insights, as these are beyond the scope of pattern-based learning from historical data.
- The dataset of 2 million filtered commit-message pairs and the full implementation are publicly released to support reproducibility and further research.
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.