Code Summarization with Structure-induced Transformer

34091

Authors

nan

Abstract

Code summarization (CS) is becoming a promising area in recent language understand- ing, which aims to generate sensible human language automatically for programming lan- guage in the format of source code, serving in the most convenience of programmer de- veloping. It is well known that program- ming languages are highly structured. Thus previous works attempt to apply structure- based traversal (SBT) or non-sequential mod- els like Tree-LSTM and graph neural net- work (GNN) to learn structural program se- mantics. However, it is surprising that incorpo- rating SBT into advanced encoder like Trans- former instead of LSTM has been shown no performance gain, which lets GNN become the only rest means modeling such necessary structural clue in source code. To release such inconvenience, we propose structure- induced Transformer, which encodes sequen- tial code inputs with multi-view structural clues in terms of a newly-proposed structure- induced self-attention mechanism. Extensive experiments show that our proposed structure- induced Transformer helps achieve new state- of-the-art results on benchmarks. 1

Keywords

nan

Full Content

Findings of the Association for Computational Linguistics: ACL-IJCNLP 2021, pages 1078–1090 August 1–6, 2021. ©2021 Association for Computational Linguistics 1078 Code Summarization with Structure-induced Transformer Hongqiu Wu1,2,3, Hai Zhao1,2,3, ∗, Min Zhang4 1 Department of Computer Science and Engineering, Shanghai Jiao Tong University 2 Key Laboratory of Shanghai Education Commission for Intelligent Interaction and Cognitive Engineering, Shanghai Jiao Tong University, Shanghai, China 3 MoE Key Lab of Artificial Intelligence, AI Institute, Shanghai Jiao Tong University, Shanghai, China 4 Institute of Artificial Intelligence, School of Computer Science and Technology, Soochow University, Suzhou, China wuhongqiu@sjtu.edu.cn, zhaohai@cs.sjtu.edu.cn, minzhang@suda.edu.cn Abstract Code summarization (CS) is becoming a promising area in recent language understand- ing, which aims to generate sensible human language automatically for programming lan- guage in the format of source code, serving in the most convenience of programmer de- veloping. It is well known that program- ming languages are highly structured. Thus previous works attempt to apply structure- based traversal (SBT) or non-sequential mod- els like Tree-LSTM and graph neural net- work (GNN) to learn structural program se- mantics. However, it is surprising that incorpo- rating SBT into advanced encoder like Trans- former instead of LSTM has been shown no performance gain, which lets GNN become the only rest means modeling such necessary structural clue in source code. To release such inconvenience, we propose structure- induced Transformer, which encodes sequen- tial code inputs with multi-view structural clues in terms of a newly-proposed structure- induced self-attention mechanism. Extensive experiments show that our proposed structure- induced Transformer helps achieve new state- of-the-art results on benchmarks. 1 Introduction By 2020, software development and maintenance become an indispensable part of human work and life. Various assistant technical measures have been taken to facilitate more enjoyable software devel- opment, among which it is especially welcomed by programmers when there is a code summarization task generating sensible human language annota- tions automatically. ∗Corresponding author. This paper was partially supported by National Key Research and Development Program of China (No. 2017YFB0304100), Key Projects of National Natu- ral Science Foundation of China (U1836222 and 61733011), Huawei-SJTU long term AI project, Cutting-edge Machine Reading Comprehension and Language Model. This work was supported by Huawei Noah’s Ark Lab. Code (Java) private void attachPlot (SVGPlot newplot) { this.plot = newplot; if (newplot == null) { super.setSVGDocument(null); return; } newplot.synchronizeWith(synchronizer); super.setSVGDocument( newplot.getDocument()); super.setDisableInteractions( newplot.getDisableInteractions()); } Summ. Attach to a new plot and display. Code (Python) def get change lines in file for tag(tag, change dict): cleaned lines = [] data list = change dict.get(’data’, []) for data dict in data list: block = data dict.get(’block’, ”) lines = block.split(’\\n’) for line in lines: index = line.find(tag) if (index >(-1)): line = line[index:] cleaned lines.append(line) return cleaned lines Summ. The received change dict is the jsonified version of the changes to a file in a changeset being pushed to the Tool Shed from the command line. This method cleans and returns appropriate lines for inspection. Table 1: Task samples of code summarization, where summ. refers to the …

Content truncated to 500 words

Labeled Text

Code summarization (CS) is becoming a promising area in recent language understanding, which aims to generate sensible human language automatically for programming language in the format of source code, serving in the most convenience of programmer developing. It is well known that programming languages are highly structured. Thus previous works attempt to apply structurebased traversal (SBT) or non-sequential models like Tree-LSTM and graph neural network (GNN) to learn structural program semantics. However, it is surprising that incorporating SBT into advanced encoder like Transformer instead of LSTM has been shown no performance gain, which lets GNN become the only rest means modeling such necessary structural clue in source code. To release such inconvenience, we propose structureinduced Transformer, which encodes sequential code inputs with multi-view structural clues in terms of a newly-proposed structureinduced self-attention mechanism. Extensive experiments show that our proposed structureinduced Transformer helps achieve new stateof-the-art results on benchmarks. 1

Publication Details

Paper ID:
34091
Year:
2021
Publication:
TIPSTER
Publication Type:
conf
DOI:
nan