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.
翻译:方案学习矢量的表达方式是应用深层次学习技术以了解方案任务的关键步骤。 各种神经网络模型建议从树结构化的方案表达方式中学习, 例如抽象的合成树(AST)和混凝土的合成树(CST ) 。 然而, 大多数神经结构或者未能捕捉到在程序上普遍存在的长距离依赖性, 或者无法学习通制树节点的有效表达方式, 从而使它们无法执行节点级预测任务, 例如错误本地化。 在本文中, 我们提议了树- 变异, 一个新的循环型树结构神经网络, 学习源码的矢量表达方式。 我们提议了一个多头关注机制, 来模拟兄弟姐妹和亲子节点之间的依赖性。 此外, 我们提议了一个双向传播战略, 让节点信息沿着两个方向传递, 即自下向上和上向下传递。 这样, 树- 变形可以学习节点特征的信息以及全球背景信息。 广泛的实验结果显示, 我们的树- 透明的树图层预测方法没有在树图层和树图层层次上大幅超越了方向。