[论文解读] RAG-Enhanced Commit Message Generation
该论文提出 REACT,一种检索增强型框架,通过检索相关代码差异和提交消息对作为范例,来指导预训练语言模型(PLMs)和大语言模型(LLMs)进行提交消息生成。通过微调或少样本学习整合这些范例,REACT 在多个模型上均提升了性能,在 Llama 3 上实现了高达 102% 的 BLEU 提升,在 CodeT5 上实现了 55% 的提升,达到新的 SOTA 水平。
Commit message is one of the most important textual information in software development and maintenance. However, it is time-consuming to write commit messages manually. Commit Message Generation (CMG) has become a research hotspot. Recently, several pre-trained language models (PLMs) and large language models (LLMs) with code capabilities have been introduced, demonstrating impressive performance on code-related tasks. Meanwhile, prior studies have explored the utilization of retrieval techniques for CMG, but it is still unclear what effects would emerge from combining advanced retrieval techniques with various generation models. This paper proposed REACT, a REtrieval-Augmented framework for CommiT message generation. It integrates advanced retrieval techniques with different PLMs and LLMs, to enhance the performance of these models on the CMG task. Specifically, a hybrid retriever is designed and used to retrieve the most relevant code diff and commit message pair as an exemplar. Then, the retrieved pair is utilized to guide and enhance the CMG task by PLMs and LLMs through fine-tuning and in-context learning. The experimental results show that REACT significantly enhances these models' performance on the CMG task, improving the BLEU score of CodeT5 by up to 55%, boosting Llama 3's BLEU score by 102%, and substantially surpassing all baselines.
研究动机与目标
- 解决软件开发中手动编写提交消息耗时且质量不一致的问题。
- 探索检索增强生成(RAG)如何在现有方法之外提升提交消息生成(CMG)性能。
- 评估将先进检索技术与多种代码能力语言模型(PLMs 和 LLMs)结合的有效性。
- 建立一个可泛化的框架,在无需从头开始进行任务特定训练的情况下,提升多个模型的 CMG 性能。
- 探究检索相似代码-提交对是否能显著提升生成质量,超越标准提示工程或微调方法。
提出的方法
- 设计并实现一种混合检索器,从代码库中检索最相关的代码差异与提交消息对作为范例。
- 使用检索到的范例来增强预训练语言模型(PLMs)和大语言模型(LLMs)的输入上下文。
- 对 LLMs 使用包含上下文学习的范例,对 PLMs 使用检索到的范例作为额外训练信号进行微调。
- 将范例信息整合到生成过程中,以指导生成更准确且上下文相关的提交消息。
- 利用代码能力语言模型(CLMs)如 CodeT5、Llama 3 等的先验知识,在无需完整微调的情况下提升生成性能。
- 在广泛使用的基准数据集上评估该框架,以确保可复现性和泛化能力。

实验结果
研究问题
- RQ1检索增强生成是否能在多种预训练语言模型和大语言模型上显著提升提交消息生成性能?
- RQ2与标准提示工程或微调相比,整合检索到的范例对生成的提交消息质量有何影响?
- RQ3检索带来的性能提升在不同类型的语言模型(PLMs 与 LLMs)之间是否存在差异?
- RQ4一个统一的框架是否能有效提升多个模型,而无需进行模型特定的再训练?
- RQ5检索到的范例质量在多大程度上影响最终的生成结果?
主要发现
- REACT 在提交消息生成任务上实现了新的 SOTA 性能,超越了所有先前基线方法。
- 通过检索增强的微调,该框架将 CodeT5 的 BLEU 分数最高提升了 55%。
- 当使用 REACT 框架结合上下文学习时,Llama 3 的 BLEU 分数提升了 102%。
- 性能提升在多个模型上保持一致,证明了检索增强方法的广泛适用性。
- 结果证实,结合 CLMs 的先验知识与相关范例,能显著提升生成质量。
- 即使在默认超参数设置下,该框架也表现出强有效性,表明其对模型特定配置具有鲁棒性。

阅读本论文
在 Nubint 阅读器中打开原文,边读边就任意段落提问。
在 Nubint 中阅读本论文本解读由 AI 根据论文原文生成,引用前请核对原文。