M2TS: Multi-Scale Multi-Modal Approach Based on Transformer for Source Code Summarization

Yuexiu Gao, Chen Lyu
3/18/2022
cs.SEcs.AI
transformer-attention

Official code: TranSMS/M2TS (24 stars, NewLisp, last commit 2023-10-15).

Abstract

Source code summarization aims to generate natural language descriptions of code snippets. Many existing studies learn the syntactic and semantic knowledge of code snippets from their token sequences and Abstract Syntax Trees (ASTs).

Show full abstract

They use the learned code representations as input to code summarization models, which can accordingly generate summaries describing source code. Traditional models traverse ASTs as sequences or split ASTs into paths as input. However, the former loses the structural properties of ASTs, and the latter destroys the overall structure of ASTs. Therefore, comprehensively capturing the structural features of ASTs in learning code representations for source code summarization remains a challenging problem to be solved. In this paper, we propose M2TS, a Multi-scale Multi-modal approach based on Transformer for source code Summarization. M2TS uses a multi-scale AST feature extraction method, which can extract the structures of ASTs more completely and accurately at multiple local and global levels. To complement missing semantic information in ASTs, we also obtain code token features, and further combine them with the extracted AST features using a cross modality fusion method that not only fuses the syntactic and contextual semantic information of source code, but also highlights the key features of each modality. We conduct experiments on two Java and one Python datasets, and the experimental results demonstrate that M2TS outperforms current state-of-the-art methods. We release our code at https://github.com/TranSMS/M2TS.

View on arXivView PDF

Code Implementations(1)

TranSMS/M2TSOfficial100%
243NewLisp, PythonAug 27, 20213 years ago

Similar Papers

Cite this paper

@article{gao2022mts,
  title  = {M2TS: Multi-Scale Multi-Modal Approach Based on Transformer for Source Code Summarization},
  author = {Yuexiu Gao and Chen Lyu},
  year   = {2022},
  eprint = {2203.09707},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2203.09707}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2203.09707.svg)](https://codeofpaper.com/paper/2203.09707)

Discussion