Skip to main content
QUICK REVIEW

[论文解读] ATOM: Commit Message Generation Based on Abstract Syntax Tree and Hybrid Ranking

Shangqing Liu, Cuiyun Gao|arXiv (Cornell University)|Dec 6, 2019
Software Engineering Research参考文献 71被引用 14
一句话总结

该论文提出 ATOM,一种利用抽象语法树(ASTs)捕捉代码语义并结合检索与生成消息的混合排序模块的提交消息生成模型。在来自56个热门Java仓库的数据集上,ATOM在BLEU-4指标上相比最先进模型性能提升30.72%。

ABSTRACT

Commit messages record code changes (e.g., feature modifications and bug repairs) in natural language, and are useful for program comprehension. Due to the frequent updates of software and time cost, developers are generally unmotivated to write commit messages for code changes. Therefore, automating the message writing process is necessitated. Previous studies on commit message generation have been benefited from generation models or retrieval models, but the code structure of changed code, i.e., AST, which can be important for capturing code semantics, has not been explicitly involved. Moreover, although generation models have the advantages of synthesizing commit messages for new code changes, they are not easy to bridge the semantic gap between code and natural languages which could be mitigated by retrieval models. In this paper, we propose a novel commit message generation model, named ATOM, which explicitly incorporates the abstract syntax tree for representing code changes and integrates both retrieved and generated messages through hybrid ranking. Specifically, the hybrid ranking module can prioritize the most accurate message from both retrieved and generated messages regarding one code change. We evaluate the proposed model ATOM on our dataset crawled from 56 popular Java repositories. Experimental results demonstrate that ATOM increases the state-of-the-art models by 30.72% in terms of BLEU-4 (an accuracy measure that is widely used to evaluate text generation systems). Qualitative analysis also demonstrates the effectiveness of ATOM in generating accurate code commit messages.

研究动机与目标

  • 为解决因开发者时间限制和缺乏标准化而导致的提交消息质量低下或缺失的问题。
  • 通过显式建模代码结构(即抽象语法树,ASTs)来改进提交消息生成。
  • 通过结合基于检索和基于生成的方法,弥合代码变更与自然语言之间的语义鸿沟。
  • 开发一种混合排序机制,从检索和生成的候选消息中选择最准确的一条。

提出的方法

  • ATOM将代码变更编码为AST路径,以捕捉语法和语义结构,从而在表示上超越简单的标记序列。
  • 它采用神经机器翻译(NMT)模型,从AST编码的代码变更中生成提交消息。
  • 它使用信息检索方法,基于diff向量相似度从大规模数据集中检索相似的提交消息。
  • 混合排序模块结合检索模型和生成模型的得分,为每段代码变更选择最准确的消息。
  • 该模型在56个热门Java仓库的自定义数据集上进行训练和评估,聚焦于真实世界的代码变更。
  • 使用BLEU-4作为主要评估指标,用于与最先进模型进行性能对比。

实验结果

研究问题

  • RQ1与扁平标记序列相比,基于AST的代码表示是否能提升提交消息生成的准确性?
  • RQ2结合基于检索和基于生成的方法,在缩小代码与自然语言之间语义鸿沟方面有多高效?
  • RQ3混合排序机制是否能优于独立的检索或生成模型,在提交消息选择中表现更优?
  • RQ4引入AST结构在多大程度上提升了模型对未见代码变更的泛化能力?

主要发现

  • ATOM在BLEU-4上相比最先进模型实现30.72%的性能提升,证明了显著的性能增益。
  • 使用AST路径进行代码表示能更有效地捕捉代码变更中的语法和语义信息。
  • 混合排序模块有效结合了检索和生成的消息,所选输出的准确性高于任一方法单独使用。
  • 定性分析表明,与基线模型相比,ATOM生成的提交消息更具精确性和上下文相关性。
  • 该模型在性能上优于基于检索的(NNGen)和基于生成的(NMT)模型,表明混合方法的有效性。
  • 该方法在生产级Java仓库的真实代码变更上表现稳健,验证了其实际适用性。

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。