Source Code Summarization with Structural Relative Position Guided Transformer
Source code summarization aims at generating concise and clear natural language descriptions for programming languages. Well-written code summaries are beneficial for programmers to participate in the software development and maintenance process. To learn the semantic representations of source code, recent efforts focus on incorporating the syntax structure of code into neural networks such as Transformer. Such Transformer-based approaches can better capture the long-range dependencies than other neural networks including Recurrent Neural Networks (RNNs), however, most of them do not consider the structural relative correlations between tokens, e.g., relative positions in Abstract Syntax Trees (ASTs), which is beneficial for code semantics learning. To model the structural dependency, we propose a Structural Relative Position guided Transformer, named SCRIPT. SCRIPT first obtains the structural relative positions between tokens via parsing the ASTs of source code, and then passes them into two types of Transformer encoders. One Transformer directly adjusts the input according to the structural relative distance; and the other Transformer encodes the structural relative positions during computing the self-attention scores. Finally, we stack these two types of Transformer encoders to learn representations of source code. Experimental results show that the proposed SCRIPT outperforms the state-of-the-art methods by at least 1.6%, 1.4% and 2.8% with respect to BLEU, ROUGE-L and METEOR on benchmark datasets, respectively. We further show that how the proposed SCRIPT captures the structural relative dependencies.
Code (1)
Tasks
Code SummarizationPositionSource Code SummarizationMethods 이 논문이 사용한 방법론
Similar Papers 제목 키워드 기반
A Structural Transformer with Relative Positions in Trees for Code-to-Sequence Tasks
We suggest two approaches to incorporate syntactic information into transformer models encoding trees (e.g. abstract syntax trees) and generating sequences. First, we use self-attention with relative position representat…
Code SummarizationMachine TranslationPositionSource Code Summarization+1A Transformer-based Approach for Source Code Summarization
Generating a readable summary that describes the functionality of a program is known as source code summarization. In this task, learning code representation by modeling the pairwise relationship between code tokens to c…
Code SummarizationPositionSource Code SummarizationRetrieval-based Layer-wise Adaptive Transformer for Source Code Summarization
We propose a model that learns both the sequential and the structural features of code for source code summarization. We adopt the Abstract Syntax Tree (AST) and graph convolution to model the structural information and …
Code SummarizationRetrievalSource Code SummarizationModeling Hierarchical Syntax Structure with Triplet Position for Source Code Summarization
Automatic code summarization, which aims to describe the source code in natural language, has become an essential task in software maintenance. Our fellow researchers have attempted to achieve such a purpose through vari…
Code SummarizationGraph Neural NetworkPositionSource Code Summarization+1Modeling Hierarchical Syntax Structure with Triplet Position for Source Code Summarization
Automatic code summarization, which aims to describe the source code in natural language, has become an essential task in software maintenance. Our fellow researchers have attempted to achieve such a purpose through vari…
Code SummarizationGraph Neural NetworkPositionSource Code Summarization+1