论文标题

用树结构变压器学习程序表示

Learning Program Representations with a Tree-Structured Transformer

论文作者

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

论文摘要

学习程序的学习向量表示是应用深度学习技术来理解任务的关键步骤。提出了各种神经网络模型,以从树结构化的程序表示中学习,例如抽象语法树(AST)和混凝土语法树(CST)。但是,大多数神经体系结构要么无法捕获无处不在的远程依赖性,要么无法学习语法树节点的有效表示形式,从而使它们无法执行节点级别的预测任务,例如BUG本地化。在本文中,我们提出了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.

扫码加入交流群

加入微信交流群

微信交流群二维码

扫码加入学术交流群,获取更多资源