arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2104.09340cs.CL
收藏

用于Source Code摘要的代码结构引导的Transformer

Code Structure Guided Transformer for Source Code Summarization

Harbin Institute of Technology, Shenzhen(哈尔滨工业大学(深圳));University of Warwick(华威大学);The Chinese University of Hong Kong(香港中文大学);Tsinghua University(清华大学);Huawei(华为)

Shuzheng Gao, Cuiyun Gao, Yulan He, Jichuan Zeng, Lun Yiu Nie, Xin Xia, Michael R. Lyu

摘要:

代码摘要帮助开发人员理解程序,并减少他们在软件维护期间推断程序功能的时间。最近的努力诉诸于深度学习技术,例如用于生成准确代码摘要的序列到序列模型,其中基于transformer的方法已经取得了有希望的性能。然而,有效地将代码结构信息集成到Transformer中,在这个任务领域中还没有得到充分的探索。在本文中,我们提出了一种新的方法命名为SG-transans纳入代码的结构特性到Transformer。具体来说,我们注入本地符号信息(例如,代码令牌和语句)和全局语法结构(例如,数据流图)输入到Transformer的自注意模块中作为感应偏置。为了进一步捕捉代码的层次特性,将局部信息和全局结构分别分布在Transformer的低层和高层的注意头中。广泛的评估表明,SG-Trans的性能优于最先进的方法。与表现最好的基线相比,SG-Trans在METEOR得分方面仍然提高了1.4%和2.0%,METEOR得分是一种广泛用于衡量生成质量的指标,分别在两个基准数据集上。

英文摘要:

Code summaries help developers comprehend programs and reduce their time to infer the program functionalities during software maintenance. Recent efforts resort to deep learning techniques such as sequence-to-sequence models for generating accurate code summaries, among which Transformer-based approaches have achieved promising performance. However, effectively integrating the code structure information into the Transformer is under-explored in this task domain. In this paper, we propose a novel approach named SG-Trans to incorporate code structural properties into Transformer. Specifically, we inject the local symbolic information (e.g., code tokens and statements) and global syntactic structure (e.g., data flow graph) into the self-attention module of Transformer as inductive bias. To further capture the hierarchical characteristics of code, the local information and global structure are designed to distribute in the attention heads of lower layers and high layers of Transformer. Extensive evaluation shows the superior performance of SG-Trans over the state-of-the-art approaches. Compared with the best-performing baseline, SG-Trans still improves 1.4% and 2.0% in terms of METEOR score, a metric widely used for measuring generation quality, respectively on two benchmark datasets.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑