EyeTrans:融合人类注意力与机器注意力以实现神经代码摘要
EyeTrans: Merging Human and Machine Attention for Neural Code Summarization
AI总结:
本文提出EyeTrans,通过眼动追踪获取程序员注意力并将其融入Transformer的机器注意力,从而提升神经代码摘要的功能性与通用摘要性能。
摘要:
神经代码摘要利用深度学习模型自动生成代码片段的简短自然语言摘要。Transformer模型的发展促使注意力机制在模型设计中得到广泛应用。尽管现有工作主要且几乎完全聚焦于源代码的静态属性以及抽象语法树(AST)等相关结构表示,但很少有研究考虑人类注意力,即程序员在检查和理解代码时关注的位置。本文中,我们开发了一种将人类注意力纳入机器注意力以增强神经代码摘要的方法。为促进这种融合并证明该假设,我们提出了EyeTrans,它包括三个步骤:(1)开展大规模眼动追踪人类研究,收集并预分析用于模型训练的数据;(2)设计一种以数据为中心的方法,在Transformer架构中整合人类注意力与机器注意力;(3)在两个代码摘要任务上进行全面实验,以证明将人类注意力纳入Transformer的有效性。整合人类注意力使功能性摘要性能提升最高达29.91%,通用代码摘要性能提升最高达6.39%,表明这种结合具有显著收益。我们还通过构建具有挑战性的摘要场景,进一步探究鲁棒性和效率方面的性能,EyeTrans在这些场景中表现出有趣的特性。我们还对注意力图进行可视化,以描绘通过纳入人类注意力,Transformer中机器注意力产生的简化效应。这项工作通过引入更多以人为中心的方法和数据,有望推动软件工程中的AI研究。
英文摘要:
Neural code summarization leverages deep learning models to automatically generate brief natural language summaries of code snippets. The development of Transformer models has led to extensive use of attention during model design. While existing work has primarily and almost exclusively focused on static properties of source code and related structural representations like the Abstract Syntax Tree (AST), few studies have considered human attention, that is, where programmers focus while examining and comprehending code. In this paper, we develop a method for incorporating human attention into machine attention to enhance neural code summarization. To facilitate this incorporation and vindicate this hypothesis, we introduce EyeTrans, which consists of three steps: (1) we conduct an extensive eye-tracking human study to collect and pre-analyze data for model training, (2) we devise a data-centric approach to integrate human attention with machine attention in the Transformer architecture, and (3) we conduct comprehensive experiments on two code summarization tasks to demonstrate the effectiveness of incorporating human attention into Transformers. Integrating human attention leads to an improvement of up to 29.91% in Functional Summarization and up to 6.39% in General Code Summarization performance, demonstrating the substantial benefits of this combination. We further explore performance in terms of robustness and efficiency by creating challenging summarization scenarios in which EyeTrans exhibits interesting properties. We also visualize the attention map to depict the simplifying effect of machine attention in the Transformer by incorporating human attention. This work has the potential to propel AI research in software engineering by introducing more human-centered approaches and data.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。