Code Structure Guided Transformer for Source Code Summarization
- URL: http://arxiv.org/abs/2104.09340v1
- Date: Mon, 19 Apr 2021 14:26:56 GMT
- Title: Code Structure Guided Transformer for Source Code Summarization
- Authors: Shuzheng Gao, Cuiyun Gao, Yulan He, Jichuan Zeng, Lun Yiu Nie, Xin Xia
- Abstract summary: 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.
- Score: 17.512699897227055
- License: http://arxiv.org/licenses/nonexclusive-distrib/1.0/
- Abstract: Source code summarization aims at generating concise descriptions of given
programs' functionalities. While Transformer-based approaches achieve promising
performance, they do not explicitly incorporate the code structure information
which is important for capturing code semantics. Besides, without explicit
constraints, multi-head attentions in Transformer may suffer from attention
collapse, leading to poor code representations for summarization. Effectively
integrating the code structure information into Transformer is under-explored
in this task domain. In this paper, we propose a novel approach named SG-Trans
to incorporate code structural properties into Transformer. Specifically, to
capture the hierarchical characteristics of code, we inject the local symbolic
information (e.g., code tokens) and global syntactic structure (e.g., data
flow) into the self-attention module as inductive bias. Extensive evaluation
shows the superior performance of SG-Trans over the state-of-the-art
approaches.
Related papers
- CodeSAM: Source Code Representation Learning by Infusing Self-Attention with Multi-Code-View Graphs [8.850533100643547]
We propose CodeSAM, a novel framework to infuse multiple code-views into transformer-based models by creating self-attention masks.
We use CodeSAM to fine-tune a small language model (SLM) like CodeBERT on the downstream SE tasks of semantic code search, code clone detection, and program classification.
arXiv Detail & Related papers (2024-11-21T22:24:47Z) - SparseCoder: Identifier-Aware Sparse Transformer for File-Level Code
Summarization [51.67317895094664]
This paper studies file-level code summarization, which can assist programmers in understanding and maintaining large source code projects.
We propose SparseCoder, an identifier-aware sparse transformer for effectively handling long code sequences.
arXiv Detail & Related papers (2024-01-26T09:23:27Z) - SIM-Trans: Structure Information Modeling Transformer for Fine-grained
Visual Categorization [59.732036564862796]
We propose the Structure Information Modeling Transformer (SIM-Trans) to incorporate object structure information into transformer for enhancing discriminative representation learning.
The proposed two modules are light-weighted and can be plugged into any transformer network and trained end-to-end easily.
Experiments and analyses demonstrate that the proposed SIM-Trans achieves state-of-the-art performance on fine-grained visual categorization benchmarks.
arXiv Detail & Related papers (2022-08-31T03:00:07Z) - 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) - Source Code Summarization with Structural Relative Position Guided
Transformer [19.828300746504148]
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.
arXiv Detail & Related papers (2022-02-14T07:34:33Z) - Text Compression-aided Transformer Encoding [77.16960983003271]
We propose explicit and implicit text compression approaches to enhance the Transformer encoding.
backbone information, meaning the gist of the input text, is not specifically focused on.
Our evaluation on benchmark datasets shows that the proposed explicit and implicit text compression approaches improve results in comparison to strong baselines.
arXiv Detail & Related papers (2021-02-11T11:28:39Z) - 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) - Relevance Transformer: Generating Concise Code Snippets with Relevance
Feedback [6.230751621285322]
We introduce and study modern Transformer architectures for explicit code generation.
We propose a new model called the Relevance Transformer that incorporates external knowledge using pseudo-relevance feedback.
The results show improvements over state-of-the-art methods based on BLEU evaluation.
arXiv Detail & Related papers (2020-07-06T09:54:17Z) - A Transformer-based Approach for Source Code Summarization [86.08359401867577]
We learn code representation for summarization by modeling the pairwise relationship between code tokens.
We show that despite the approach is simple, it outperforms the state-of-the-art techniques by a significant margin.
arXiv Detail & Related papers (2020-05-01T23:29:36Z)
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.