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

CoRaCMG: Contextual Retrieval-Augmented Framework for Commit Message Generation

Bo Xiong, Linghao Zhang, Chong Wang, Peng LiangarXiv 2025 · DOI

TL;DR

CoRaCMG is a novel framework that significantly improves automated commit message generation by providing Large Language Models (LLMs) with similar historical examples. By using a hybrid retrieval system to find relevant "diff-message" pairs, the framework allows models like GPT-4o and DeepSeek-R1 to adopt project-specific terminology and styles, outperforming both human-written messages and previous state-of-the-art tools.

Introduction

Writing high-quality git commit messages is a cornerstone of software maintenance, yet it is a task developers famously find tedious. Consequently, many manual commit messages are vague (e.g., "fix bug") or incomplete.

While automated Commit Message Generation (CMG) tools have existed for years, they face a "context gap." Rule-based systems are too rigid, and standard LLMs—while linguistically capable—often produce generic messages that ignore a project's specific jargon or preferred writing style. The authors identify that a key missing ingredient is historical context: the best way to write a message for a current code change is often to look at how similar changes were described in the past.

The Search-and-Imitate intuition: using historical context to guide commit message generation.

Methods: The CoRaCMG Framework

The authors propose CoRaCMG (Contextual Retrieval-Augmented Framework for Commit Message Generation), which operates in three distinct phases as shown in the architecture diagram below:

The CoRaCMG architecture: a three-stage pipeline consisting of Retrieval, Augmentation, and Generation.
  1. Retrieve: When a developer makes a code change (a "query diff"), the system searches a database of historical commits. It uses a Hybrid Retriever that combines two methods:
  2. BM25: A classic lexical search that matches specific keywords and variable names.
  3. Semantic Embeddings (Jina AI): A deep-learning approach that understands the "intent" of the code change, even if the variable names differ.
  4. Augment: The system takes the most relevant historical "diff-message" pairs and inserts them into a structured prompt. This effectively gives the LLM a "few-shot" learning opportunity, showing it exactly how this specific project describes similar changes.
  5. Generate: The augmented prompt is fed into an LLM (the authors tested GPT-4o, DeepSeek-V3/R1, and Qwen-2.5). The model then generates a new message, imitating the style and terminology of the retrieved examples.

Crucially, this approach is training-free. It doesn't require expensive fine-tuning; it simply leverages the "In-Context Learning" capabilities of modern LLMs.

Datasets: Introducing ApacheCM

The researchers introduced ApacheCM, a high-quality dataset designed to fix the "noise" found in older benchmarks. They applied strict filters to remove bot-generated messages, "revert" commits, and messages that were too short (under 5 words) or too long (over 50 words).

Key characteristics of ApacheCM include:

  • Source: 234,799 commit records from the top 50 Apache Software Foundation projects.
  • Diversity: Unlike many previous datasets that were Java-only, ApacheCM covers nine programming languages, including Python, C++, and Rust.

Key Insights and Results

  • The "Search-and-Imitate" Intuition: The authors realized that human developers often look at previous commits to figure out how to phrase a new one. CoRaCMG formalizes this "manual" process for AI.
  • Reasoning Models Shine: The study found that DeepSeek-R1 (a reasoning-focused model) was particularly effective. Its internal chain-of-thought allows it to better identify why a specific terminology was used in an example and apply it correctly to the new diff.
  • LLMs vs. Humans: In a surprising twist, human evaluators often rated the LLM-generated messages higher than the original developer-written ones. This is because LLMs are more disciplined at fully describing the "what" and "how" of a change, whereas developers often provide "low-quality, vague, or incomplete" summaries.
  • Performance Boost: The framework showed massive improvements across standard NLP metrics (BLEU, METEOR, Rouge-L, and CIDEr). For GPT-4o, adding just one retrieved example increased its BLEU score by 89% and its CIDEr score by 72%.
  • Human Evaluation: On a 1–5 scale for "Completeness," the enhanced DeepSeek-R1 scored 3.22, while the original human-written reference messages scored only 1.55.

Limitations and Future Work

While CoRaCMG represents a significant step forward, it faces a few challenges. First is the "Cold Start" Problem: RAG relies on history. If a project is brand new and has no previous commits, the retrieval phase will fail to find relevant examples. Second, Tangled Commits containing multiple unrelated changes can confuse the retriever, leading to incomplete messages.

Finally, the authors note that some commits are driven by External Context (like Jira tickets). Future versions should incorporate issue descriptions and pull request discussions to capture the "why" behind a change more accurately.

Summary updated

BibTeX
@misc{xiong2025coracmg,
  author = {Bo Xiong and Linghao Zhang and Chong Wang and Peng Liang},
  title = {{CoRaCMG: Contextual Retrieval-Augmented Framework for Commit Message Generation}},
  year = {2025},
  eprint = {2509.18337},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2509.18337},
}
Figure