Source Code Summarization with Structural Relative Position Guided
Transformer
- URL: http://arxiv.org/abs/2202.06521v1
- Date: Mon, 14 Feb 2022 07:34:33 GMT
- Title: Source Code Summarization with Structural Relative Position Guided
Transformer
- Authors: Zi Gong, Cuiyun Gao, Yasheng Wang, Wenchao Gu, Yun Peng, Zenglin Xu
- Abstract summary: Source code summarization aims at generating concise and clear natural language descriptions for programming languages.
Recent efforts focus on incorporating the syntax structure of code into neural networks such as Transformer.
We propose a Structural Relative Position guided Transformer, named SCRIPT.
- Score: 19.828300746504148
- License: http://arxiv.org/licenses/nonexclusive-distrib/1.0/
- Abstract: 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.
Related papers
- Transformers are Efficient Compilers, Provably [11.459397066286822]
Transformer-based large language models (LLMs) have demonstrated surprisingly robust performance across a wide range of language-related tasks.
In this paper, we take the first steps towards a formal investigation of using transformers as compilers from an expressive power perspective.
We introduce a representative programming language, Mini-Husky, which encapsulates key features of modern C-like languages.
arXiv Detail & Related papers (2024-10-07T20:31:13Z) - Structural Biases for Improving Transformers on Translation into
Morphologically Rich Languages [120.74406230847904]
TP-Transformer augments the traditional Transformer architecture to include an additional component to represent structure.
The second method imbues structure at the data level by segmenting the data with morphological tokenization.
We find that each of these two approaches allows the network to achieve better performance, but this improvement is dependent on the size of the dataset.
arXiv Detail & Related papers (2022-08-11T22:42:24Z) - Transformer with Tree-order Encoding for Neural Program Generation [8.173517923612426]
We introduce a tree-based positional encoding and a shared natural-language subword vocabulary for Transformers.
Our findings suggest that employing a tree-based positional encoding in combination with a shared natural-language subword vocabulary improves generation performance over sequential positional encodings.
arXiv Detail & Related papers (2022-05-30T12:27:48Z) - An Exploratory Study on Code Attention in BERT [8.488193857572211]
We investigate the attention behavior of PLM on code and compare it with natural language.
We show that BERT pays more attention to syntactic entities, specifically identifiers and separators, in contrast to the most attended token in NLP.
The findings can benefit the research community by using code-specific representations instead of applying the common embeddings used in NLP.
arXiv Detail & Related papers (2022-04-05T21:23:10Z) - Enriching Transformers with Structured Tensor-Product Representations
for Abstractive Summarization [131.23966358405767]
We adapt TP-TRANSFORMER with the explicitly compositional Product Representation (TPR) for the task of abstractive summarization.
Key feature of our model is a structural bias that we introduce by encoding two separate representations for each token.
We show that our TP-TRANSFORMER outperforms the Transformer and the original TP-TRANSFORMER significantly on several abstractive summarization datasets.
arXiv Detail & Related papers (2021-06-02T17:32:33Z) - Code Structure Guided Transformer for Source Code Summarization [17.512699897227055]
Transformer-based approaches do not explicitly incorporate the code structure information which is important for capturing code semantics.
We propose a novel approach named SG-Trans to incorporate code structural properties into Transformer.
arXiv Detail & Related papers (2021-04-19T14:26:56Z) - SIT3: Code Summarization with Structure-Induced Transformer [48.000063280183376]
We propose a novel model based on structure-induced self-attention, which encodes sequential inputs with highly-effective structure modeling.
Our newly-proposed model achieves new state-of-the-art results on popular benchmarks.
arXiv Detail & Related papers (2020-12-29T11:37:43Z) - GraphCodeBERT: Pre-training Code Representations with Data Flow [97.00641522327699]
We present GraphCodeBERT, a pre-trained model for programming language that considers the inherent structure of code.
We use data flow in the pre-training stage, which is a semantic-level structure of code that encodes the relation of "where-the-value-comes-from" between variables.
We evaluate our model on four tasks, including code search, clone detection, code translation, and code refinement.
arXiv Detail & Related papers (2020-09-17T15:25:56Z) - Improved Code Summarization via a Graph Neural Network [96.03715569092523]
In general, source code summarization techniques use the source code as input and outputs a natural language description.
We present an approach that uses a graph-based neural architecture that better matches the default structure of the AST to generate these summaries.
arXiv Detail & Related papers (2020-04-06T17:36:42Z) - Bi-Decoder Augmented Network for Neural Machine Translation [108.3931242633331]
We propose a novel Bi-Decoder Augmented Network (BiDAN) for the neural machine translation task.
Since each decoder transforms the representations of the input text into its corresponding language, jointly training with two target ends can make the shared encoder has the potential to produce a language-independent semantic space.
arXiv Detail & Related papers (2020-01-14T02:05:14Z)
This list is automatically generated from the titles and abstracts of the papers in this site.
This site does not guarantee the quality of this site (including all information) and is not responsible for any consequences.