Learning Program Representations with a Tree-Structured Transformer

Wenhan Wang, Kechi Zhang, Ge Li, Shangqing Liu, Anran Li +2 more
8/18/2022
cs.SEcs.LG
transformer-attention

Official code: jacobwwh/tree_transformer (3 stars, Python, last commit 2022-12-19).

Abstract

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).

Show full abstract

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.

View on arXivView PDF

Code Implementations(1)

Code for paper "Learning Program Representations with a Tree-Structured Transformer".

33PythonDec 9, 20213 years ago

Similar Papers

Cite this paper

@article{wang2022learning,
  title  = {Learning Program Representations with a Tree-Structured Transformer},
  author = {Wenhan Wang and Kechi Zhang and Ge Li and Shangqing Liu and Anran Li and Zhi Jin and Yang Liu},
  year   = {2022},
  eprint = {2208.08643},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2208.08643}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2208.08643.svg)](https://codeofpaper.com/paper/2208.08643)

Discussion