Title
AST-Trans: Code Summarization with Efficient Tree-Structured Attention
Abstract
Code summarization aims to generate brief natural language descriptions for source codes. The state-of-the-art approaches follow a transformer-based encoder-decoder architecture. As the source code is highly structured and follows strict grammars, its Abstract Syntax Tree (AST) is widely used for encoding structural information. However, ASTs are much longer than the corresponding source code. Existing approaches ignore the size constraint and simply feed the whole linearized AST into the encoders. We argue that such a simple process makes it difficult to extract the truly useful dependency relations from the overlong input sequence. It also incurs significant computational overhead since each node needs to apply self-attention to all other nodes in the AST. To encode the AST more effectively and efficiently, we propose AST-Trans in this paper which exploits two types of node relationships in the AST: ancestor-descendant and sibling relationships. It applies the tree-structured attention to dynamically allocate weights for relevant nodes and exclude irrelevant nodes based on these two relationships. We further propose an efficient implementation to support fast parallel computation for tree-structure attention. On the two code summarization datasets, experimental results show that AST-Trans significantly outperforms the state-of-the-arts while being times more efficient than standard transformers <sup xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink">1</sup> <sup xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink">1</sup> All the codes and data are available at https://github.com/zetang94/ICSE2022_AST_Trans.git.
Year
DOI
Venue
2022
10.1145/3510003.3510224
2022 IEEE/ACM 44th International Conference on Software Engineering (ICSE)
Keywords
DocType
ISSN
tree-based neural network,source code summarization
Conference
0270-5257
ISBN
Citations 
PageRank 
978-1-6654-9589-9
0
0.34
References 
Authors
0
7
Name
Order
Citations
PageRank
Ze Tang100.34
Xiaoyu Shen200.34
Chuanyi Li32712.92
JiDong Ge411928.39
Liguo Huang500.34
Zhelin Zhu600.34
Bin Luo76621.04