arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2208.08643cs.SEcs.LG
收藏

用树结构的Transformer学习程序表示

Learning Program Representations with a Tree-Structured Transformer

Peking University(北京大学);Nanyang Technological University(南洋理工大学)

Wenhan Wang, Kechi Zhang, Ge Li, Shangqing Liu, Anran Li, Zhi Jin, Yang Liu

摘要:

学习程序的向量表示是将深度学习技术应用于程序理解任务的关键步骤。提出了各种神经网络模型来从树结构的程序表示学习,例如,抽象语法树(AST)和具体语法树(CST)。然而,大多数神经架构要么无法捕获程序中普遍存在的长程依赖关系,要么无法学习语法树节点的有效表示,使它们无法执行节点级预测任务,例如,缺陷定位在本文中,我们提出了Tree-Transformer,一种新的递归树结构的神经网络学习的矢量表示的源代码。我们提出了一个多头注意力机制来模拟兄弟节点和父子节点对之间的依赖关系。此外,我们提出了一个双向传播策略,让节点的信息传递在两个方向,自下而上和自上而下沿树。通过这种方式,Tree-Transformer可以学习节点特征的信息以及全局上下文信息。大量的实验结果表明,我们的Tree-Transformer显着优于现有的基于树和基于图的程序表示学习方法在树级和节点级的预测任务。

英文摘要:

Learning vector representations for programs is a critical step in applying deep learning techniques for program understanding tasks. Various neural network models are proposed to learn from tree-structured program representations, e.g., abstract syntax tree (AST) and concrete syntax tree (CST). However, most neural architectures either fail to capture long-range dependencies which are ubiquitous in programs, or cannot learn effective representations for syntax tree nodes, making them incapable of performing the node-level prediction tasks, e.g., bug localization. In this paper, we propose Tree-Transformer, a novel recursive tree-structured neural network to learn the vector representations for source codes. We propose a multi-head attention mechanism to model the dependency between siblings and parent-children node pairs. Moreover, we propose a bi-directional propagation strategy to allow node information passing in two directions, bottom-up and top-down along trees. In this way, Tree-Transformer can learn the information of the node features as well as the global contextual information. The extensive experimental results show that our Tree-Transformer significantly outperforms the existing tree-based and graph-based program representation learning approaches in both the tree-level and node-level prediction tasks.

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

↑