CoRaCMG:基于上下文检索的提交信息生成框架
CoRaCMG: Contextual Retrieval-Augmented Framework for Commit Message Generation
AI总结:
本文提出CoRaCMG框架,通过检索相似diff-消息对增强LLM生成提交信息的精度和信息量,实验表明其在BLEU、ROUGE-L、METEOR和CIDEr四项指标上显著提升性能。
摘要:
提交信息在记录代码变更意图中起关键作用,但往往质量低、模糊或不完整,限制了其效用。提交信息生成(CMG)旨在从代码差异中自动生成描述性提交信息,以减少开发者的努力并提高信息质量。尽管最近的LLM进展在自动化CMG方面显示出潜力,但其性能仍有限。本文旨在通过检索相似的diff-消息对来增强CMG性能,引导LLM生成更精确和信息丰富的提交信息。我们提出了CoRaCMG,一种用于提交信息生成的上下文检索增强框架,分为三个阶段:(1)检索:检索相似的diff-消息对;(2)增强:将它们与查询diff结合成结构化提示;(3)生成:通过LLM生成对应的查询diff提交信息。CoRaCMG使LLM能够从检索到的diff-消息对中学习项目特定的术语和写作风格。我们评估了CoRaCMG在多个LLM(如GPT、DeepSeek和Qwen)上的表现,并将其性能与最先进的基线进行了比较。实验结果表明,CoRaCMG在四项指标(BLEU、ROUGE-L、METEOR和CIDEr)上显著提升了LLM的性能。具体而言,当使用单个检索到的例子对时,DeepSeek-R1在BLEU和CIDEr上的相对提升分别为76%和71%。在加入单个例子对后,GPT-4o实现了最高的提升率,BLEU提高了89%。此外,使用超过三个例子后,性能增益趋于平缓,表明边际效益递减。进一步分析显示,这些改进归因于模型能够从检索到的例子对中捕捉到人类编写提交信息的术语和写作风格。
英文摘要:
Commit messages play a key role in documenting the intent behind code changes. However, they are often low-quality, vague, or incomplete, limiting their usefulness. Commit Message Generation (CMG) aims to automatically generate descriptive commit messages from code diffs to reduce developers' effort and improve message quality. Although recent advances in LLMs have shown promise in automating CMG, their performance remains limited. This paper aims to enhance CMG performance by retrieving similar diff-message pairs to guide LLMs to generate commit messages that are more precise and informative. We proposed CoRaCMG, a Contextual Retrieval-augmented framework for Commit Message Generation, structured in three phases: (1) Retrieve: retrieving the similar diff-message pairs; (2) Augment: combining them with the query diff into a structured prompt; and (3) Generate: generating commit messages corresponding to the query diff via LLMs. CoRaCMG enables LLMs to learn project-specific terminologies and writing styles from the retrieved diff-message pairs. We evaluated CoRaCMG across multiple LLMs (e.g., GPT, DeepSeek, and Qwen) and compared its performance against SOTA baselines. Experimental results show that CoRaCMG significantly boosts LLM performance across four metrics (BLEU, Rouge-L, METEOR, and CIDEr). Specifically, DeepSeek-R1 achieves relative improvements of 76% in BLEU and 71% in CIDEr when augmented with a single retrieved example pair. After incorporating the single example pair, GPT-4o achieves the highest improvement rate, with BLEU increasing by 89%. Moreover, performance gains plateau after more than three examples are used, indicating diminishing returns. Further analysis shows that the improvements are attributed to the model's ability to capture the terminologies and writing styles of human-written commit messages from the retrieved example pairs.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。