Manuscript Offprint

arXiv:2609.30953

CoCoRerank: Towards Conventional Commit Message Generation by Component and Candidate Consistency Reranking

Shaopeng Jia, Yali Du, Ming Li

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Commit messages are essential for understanding software changes, yet automatic commit message generation typically treats a message as an unstructured text sequence. This limits its ability to support standardized development workflows, where commit messages are often expected to follow the Conventional Commits Specification (CCS) in the form type (scope): subject. In this paper, we study conventional commit message generation under the complete CCS format. We construct a new benchmark of 86,688 high-quality commits collected from open-source GitHub repositories, with each message normalized into type, scope, and subject through structural normalization and semantic quality filtering. Based on this benchmark, we propose a two-dimensional consistency-based reranking framework named CoCoRERANK for LLM-based generation. CoCoRERANK exploits horizontal consistency among the code change, type, scope, and subject, as well as vertical consensus across multiple generated candidates. Experiments with representative CMG baselines, LLM generators, reranking strategies, and ablation variants show that CoCoRERANK improves both structural component prediction and subject generation quality. The results demonstrate that complete CCS supervision and multidimensional consistency modeling provide an effective foundation for accurate and standardized commit message generation. The artifact is publicly released at https://github.com/bluewhalebug/CoCoRerank.

Introduction

A commit message records the intent and effect of a software change in natural language. It is routinely used in code review, debugging, maintenance, release management, and collaboration, where developers need to understand not only what code was changed but also why the change matters (Barnett et al. 2016; Li and Ahmed 2023). However, writing an informative commit message is a manual and often neglected activity. This tension has motivated commit message generation (CMG), which aims to generate a message directly from a code diff. Recently, both task-specific learning methods and large language models (LLMs) have been widely applied to software engineering tasks, such as code summarization (Crupi et al. 2025; Virk, Devanbu, and Ahmed 2025), code generation (Sun et al. 2026; Liu et al. 2026a; Du et al. 2026b,a), bug localization (Du and Yu 2023; Ma, Du, and Li 2023), and code translation (Du et al. 2023; Du, Sun, and Li 2024, 2025). In CMG, these models typically operate on code diffs, which provide a compact representation of the changes introduced by a commit rather than the complete source code. Early neural approaches formulated CMG as a seq-to-seq translation problem (Jiang, Armaly, and McMillan 2017), and later methods improved generation by incorporating code structure, edit representations, retrieval signals, pretraining, and hybrid generation–retrieval designs (Xu et al. 2019; Nie et al. 2021; Dong et al. 2022; Liu et al. 2018, 2020; Shi et al. 2022; He et al. 2023). These advances have improved the fluency and informativeness of generated messages, but they mostly treat a commit message as a single unstructured text sequence.

Unstructured generation is insufficient for practical development workflows as real projects often rely on standardized commit formats. The Conventional Commits Specification (CCS) represents a commit message as type (scope): subject, where type indicates the category of a change, scope identifies the affected component, and subject summarizes the concrete modification. This decomposition makes commit messages both human readable and machine interpretable, enabling downstream automation such as changelog generation and semantic versioning. It also exposes a more fine-grained generation objective: a conventional message is correct only when its category, affected component, and textual description are mutually compatible with the same code change. Existing CMG methods do not explicitly model this three-part structure. A generated message may be fluent while still assigning an inconsistent type, an irrelevant scope, or a subject that does not match the predicted metadata.

Progress on conventional commit message generation is further limited by the lack of suitable datasets (Zeng et al. 2025). Existing CMG datasets have supported important progress in neural generation, project-specific modeling, and large-scale evaluation (Jiang, Armaly, and McMillan 2017; Liu et al. 2019; Xu et al. 2019; Tao et al. 2021; Schall, Czinczoll, and De Melo 2024). Nevertheless, they generally provide unstructured messages or retain only partial structured information, which prevents models from being trained and evaluated on the complete CCS format. As a result, current evaluation cannot separately measure whether a model predicts the right change type, identifies the right scope,

∗^{*}These authors contributed equally.

†^{\dagger}Corresponding author.

and writes a subject that is consistent with both. This gap makes it difficult to study the central question: how to generate conventional commit messages whose components are individually accurate and jointly coherent.

To address this gap, we construct a new dataset for conventional commit message generation. The dataset contains 86,688 high-quality commits collected from open-source GitHub repositories, and each message is normalized into the complete type, scope, and subject structure. We apply systematic structural normalization to remove malformed or ambiguous CCS fields and semantic quality filtering to discard vague, automatically generated, or diff-inconsistent messages. By preserving the complete structure, the dataset provides supervision for conventional generation and enables fine-grained evaluation of each component.

Built upon the dataset, we present CoCoRERANK, a dual-consistency reranking framework for LLM-driven conventional commit message generation. Its name derives from the Conventional Commits Specification (CCS) and the two core consistency constraints: component and candidate consistency. Modern LLMs readily generate multiple candidate commits from a single code diff, yet optimal candidate selection remains difficult (Li et al. 2022; Chen et al. 2023; Liu et al. 2026b). This problem becomes more severe for conventional CMG, as candidates differ widely in structural compliance and semantic alignment with code edits. Our core insight is that high-quality CCS commits must satisfy two complementary consistency requirements: 1) Horizontal component consistency: The type, scope, and subject segments act as mutually complementary semantic views and must coherently describe the same code change; prior work confirms cross-view consensus boosts output reliability (Huang et al. 2024; Sun and Li 2023). 2) Vertical candidate consistency: Valid change interpretations recur across multiple generated candidates, a self-consistency property proven effective for filtering trustworthy model outputs (Wang et al. 2023; Chen et al. 2024). In CoCoRERANK, we extract consensus type and scope from all candidates, score each subject's compatibility with the code diff and consensus metadata, and aggregate scores over semantically clustered subjects. This pipeline picks commits that are both structurally coherent and statistically representative of the full candidate pool.

We evaluate the proposed dataset and CoCoRERANK against representative retrieval-based, learning-based, hybrid, and advanced LLM-based baselines. Experiments show that our method improves direct LLM generation across the conventional components and outperforms alternative candidate selection strategies such as majority voting and minimum-Bayes-risk reranking. Ablation and cross-model analyses further show that both component consistency and candidate consensus contribute to the final performance. Our main contributions are summarized as follows:

• We introduce a new dataset containing 86,688 high-quality commits that strictly follow the CCS format. Unlike existing CMG datasets, it preserves the complete type, scope, and subject structure, constructed through rigorous structural and semantic quality control.

• We propose a two-dimensional consistency-based reranking method named CoCoRERANK for LLM-based commit message generation. The method jointly exploits consistency among the three CCS components and consistency across multiple generated candidates, leading to more accurate and structurally coherent commit messages.

• We conduct extensive experiments with representative CMG baselines, LLM generators, and reranking strategies. The results demonstrate the effectiveness of CCS modeling and show that the proposed consistency signals are complementary to conventional CMG.

References (47)

  • METEOR: An Automatic Metric for MT Evaluation with Improved Correlation with Human Judgments
  • The Relationship between Commit Message Detail and Defect Proneness in Java Projects on GitHub
  • Automatically documenting program changes
  • CodeT: Code Generation with Generated Tests
  • Universal Self-Consistency for Large Language Models
  • On automatically generating commit messages via summarization of source code changes
  • On the effectiveness of llm-as-a-judge for code generation and summarization
  • DeepSeek-Coder-V2: Breaking the Barrier of Closed-Source Models in Code Intelligence (opens arXiv in a new tab)
  • Fira: fine-grained graph-based code change representation for automated commit message generation
  • Capturing the context-aware code change via dynamic control flow graph for commit message generation
  • Beyond lexical consistency: Preserving semantic consistency for program translation
  • A joint learning model with variational interaction for multilingual program translation
  • Post-incorporating code structural knowledge into pretrained models via icl for code translation
  • CIT-CAD: Constraint Intent Tree-based CAD Code Generation and Verification
  • Design-Specification Tiling for ICL-based CAD Code Generation (opens arXiv in a new tab)
  • Pre-training code representation with semantic flow graph for effective bug localization
  • The Llama 3 Herd of Models
  • Come: Commit message generation with modification embedding
  • Cc2vec: Distributed representations of code changes
  • Enhancing large language models in coding through multi-perspective self-consistency
  • Qwen2.5-Coder Technical Report
  • Automatically generating commit messages from diffs using neural machine translation
  • Hard negative mixing for contrastive learning
  • Supervised contrastive learning
  • Semantic Uncertainty: Linguistic Invariances for Uncertainty Estimation in Natural Language Generation
  • Minimum bayes-risk decoding for statistical machine translation
  • Commit Message Matters: Investigating Impact and Evolution of Commit Message Quality
  • Competition-level code generation with alphacode
  • Uncertainty-aware contrastive learning with hard negative sampling for code search tasks
  • Generating commit messages from diffs using pointer-generator network
  • Random Selection Reveals Implicit Knowledge Consensus in Code Generation
  • Dynamic-static synergistic selection method for candidate code solutions with generated test cases
  • Atom: Commit message generation based on abstract syntax tree and hybrid ranking
  • Neural-machine-translation-based commit message generation: how far are we? In Proceedings of the 33rd ACM/IEEE international conference on automated software engineering, 373–384
  • Capturing the Long-Distance Dependency in the Control Flow Graph via Structural-Guided Attention for Bug Localization
  • Coregen: Contextualized code representation learning for commit message generation
  • Commit-bench: A benchmark for commit message generation
  • On automatic summarization of what and why information in source code changes
  • Race: Retrieval-augmented commit message generation
  • Enhancing unsupervised domain adaptation by exploiting the conceptual consistency of multiple self-supervised tasks
  • ACES: Who Tests the Tests? Leave-One-Out AUC Consistency for Code Generation (opens arXiv in a new tab)
  • On the evaluation of commit message generation models: An experimental study
  • Calibration of large language models on code summarization
  • CommitSuite: A Comprehensive Benchmark for Commit Classification and Message Generation (opens arXiv in a new tab)
  • Self-Consistency Improves Chain of Thought Reasoning in Language Models
  • Commit Message Generation for Source Code Changes
  • A First Look at Conventional Commits Classification