A Novel Neural Source Code Representation Based on Abstract Syntax Tree

By Jian Zhang, Xu Wang, Hongyu Zhang, Hailong Sun, Kaixuan Wang, Xudong Liu. 2019

715 citations recorded by the source corpus.

Exploiting machine learning techniques for analyzing programs has attracted much attention. One key problem is how to represent code fragments well for follow-up analysis. Traditional information retrieval based methods often treat programs as natural language texts, which could miss important semantic information of source code. Recently, state-of-the-art studies demonstrate that abstract syntax tree (AST) based neural models can better represent source code. However, the sizes of ASTs are usually large and the existing models are prone to the long-term dependency problem. In this paper, we propose a novel AST-based Neural Network (ASTNN) for source code representation. Unlike existing models that work on entire ASTs, ASTNN splits each large AST into a sequence of small statement trees, and encodes the statement trees to vectors by capturing the lexical and syntactical knowledge of statements. Based on the sequence of statement vectors, a bidirectional RNN model is used to leverage the naturalness of statements and finally produce the vector representation of a code fragment. We have applied our neural network based source code representation method to two common program comprehension tasks: source code classification and code clone detection. Experimental results on the two tasks indicate that our model is superior to state-of-the-art approaches.

Subfields: Information Systems, Software, Code Generation & Program Synthesis, Program Analysis & Verification, Signal Processing

How researchers see this paper

The researchers whose trusted networks rank it highest, strongest advocate first. Every researcher gets a different order.

In Information Systems

  1. Prem Devanbu
  2. Baishakhi Ray
  3. Daya Guo
  4. Nan Duan
  5. Ge Li
  6. Michael Pradel
  7. Saikat Chakraborty
  8. Georgios Gousios

In Software

  1. Prem Devanbu
  2. Neel Sundaresan
  3. Michael Pradel
  4. Daya Guo
  5. Vincent J. Hellendoorn
  6. Nan Duan
  7. Alexey Svyatkovskiy
  8. Georgios Gousios

In Code Generation & Program Synthesis

  1. Prem Devanbu
  2. Baishakhi Ray
  3. Ge Li
  4. Saikat Chakraborty
  5. Wasi Uddin Ahmad
  6. Zhi Jin
  7. Yunfei Zhao
  8. Yangruibo Ding

In Program Analysis & Verification

  1. Michael Pradel
  2. Prem Devanbu
  3. Georgios Gousios
  4. Petros Maniatis
  5. Ge Li
  6. Satish Chandra
  7. Vincent J. Hellendoorn
  8. Aditya Kanade

In Signal Processing

  1. Baishakhi Ray
  2. Saikat Chakraborty
  3. Ge Li
  4. Georgios Gousios
  5. Michael Pradel
  6. Prem Devanbu
  7. Vincent J. Hellendoorn
  8. Satish Chandra

Citations in the corpus