Skip to main content
QUICK REVIEW

[Paper Review] RACE: Retrieval-Augmented Commit Message Generation

Ensheng Shia, Yanlin Wang|arXiv (Cornell University)|Mar 5, 2022
Software Engineering ResearchComputer Science5 citations
TL;DR

This paper proposes RACE, a retrieval-augmented neural model for commit message generation that retrieves semantically similar commit messages as exemplars and uses an exemplar guider to align them with the current code diff, significantly improving generation quality. RACE outperforms state-of-the-art models across five programming languages, boosting performance by up to 43% in BLEU scores and showing strong human evaluation results in informativeness, conciseness, and expressiveness.

ABSTRACT

Commit messages are important for software development and maintenance. Many neural network-based approaches have been proposed and shown promising results on automatic commit message generation. However, the generated commit messages could be repetitive or redundant. In this paper, we propose RACE, a new retrieval-augmented neural commit message generation method, which treats the retrieved similar commit as an exemplar and leverages it to generate an accurate commit message. As the retrieved commit message may not always accurately describe the content/intent of the current code diff, we also propose an exemplar guider, which learns the semantic similarity between the retrieved and current code diff and then guides the generation of commit message based on the similarity. We conduct extensive experiments on a large public dataset with five programming languages. Experimental results show that RACE can outperform all baselines. Furthermore, RACE can boost the performance of existing Seq2Seq models in commit message generation.

Motivation & Objective

  • To address the issue of repetitive, redundant, or low-information commit messages generated by existing neural models.
  • To improve the accuracy and informativeness of commit message generation by leveraging semantically similar past commits as exemplars.
  • To mitigate the risk of retrieved exemplars introducing incorrect or irrelevant information by learning semantic similarity between the current diff and the retrieved commit.
  • To design a framework that enhances existing Seq2Seq models through retrieval-augmented generation without requiring retraining from scratch.
  • To validate the effectiveness of the approach through automatic metrics and human evaluation across diverse programming languages.

Proposed method

  • Train a code diff encoder to embed code changes into a high-dimensional semantic space for similarity computation.
  • Retrieve the most similar code diff and its associated commit message from a large parallel corpus using vector similarity (e.g., cosine distance).
  • Treat the retrieved commit message as an exemplar to guide the generation process.
  • Introduce an exemplar guider module that learns the semantic similarity between the current code diff and the retrieved exemplar.
  • Use the similarity score to dynamically attend to or condition the generation model on the exemplar, ensuring relevant and accurate message synthesis.
  • Integrate the retrieval-augmented mechanism into existing Seq2Seq models (e.g., NMTGen, CodeT5, CommitBERT) to boost their performance without retraining.

Experimental results

Research questions

  • RQ1Can retrieval-augmented generation improve the quality and informativeness of automatically generated commit messages compared to pure neural or retrieval-based baselines?
  • RQ2How effective is the exemplar guider in aligning retrieved exemplars with the current code diff to prevent the introduction of irrelevant or incorrect information?
  • RQ3To what extent can RACE enhance the performance of existing state-of-the-art Seq2Seq models in commit message generation?
  • RQ4Does the retrieval-augmented approach generalize across multiple programming languages, including Java, C#, C++, Python, and JavaScript?
  • RQ5How do human evaluators rate the informativeness, conciseness, and expressiveness of commit messages generated by RACE compared to baselines?

Key findings

  • RACE significantly outperforms all 11 state-of-the-art baselines across four automatic metrics—BLEU, Meteor, Rouge-L, and Cider—on a large-scale dataset with five programming languages.
  • RACE improves the performance of NMTGen by 43%, CommitBERT by 11%, CodeT5-small by 15%, and CodeT5-base by 16% in terms of BLEU score on average.
  • Human evaluation shows RACE achieves the highest average scores in informativeness (2.49), conciseness (3.08), and expressiveness (2.85), with all improvements being statistically significant (p < 0.05).
  • The exemplar guider effectively reduces the risk of incorporating irrelevant or incorrect information from retrieved exemplars by learning semantic similarity between the current diff and the retrieved commit.
  • The framework is effective as a plug-in enhancement, boosting existing models without requiring retraining from scratch.
  • The approach demonstrates strong generalization across five diverse programming languages, indicating broad applicability.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.