A Multi-Modal Transformer-based Code Summarization Approach for Smart Contracts

被引:49
|
作者
Yang, Zhen [1 ]
Keung, Jacky [1 ]
Yu, Xiao [2 ]
Gu, Xiaodong [3 ]
Wei, Zhengyuan [1 ]
Ma, Xiaoxue [1 ]
Zhang, Miao [1 ]
机构
[1] City Univ Hong Kong, Dept Comp Sci, Hong Kong, Peoples R China
[2] Wuhan Univ Technol, Sch Comp Sci & Technol, Wuhan, Peoples R China
[3] Shanghai Jiao Tong Univ, Sch Software, Shanghai, Peoples R China
来源
2021 IEEE/ACM 29TH INTERNATIONAL CONFERENCE ON PROGRAM COMPREHENSION (ICPC 2021) | 2021年
关键词
Smart Contracts; Code Summarization; Transformer; Graph Convolution; Structure-based Traversal;
D O I
10.1109/ICPC52881.2021.00010
中图分类号
TP31 [计算机软件];
学科分类号
081202 ; 0835 ;
摘要
Code comment has been an important part of computer programs, greatly facilitating the understanding and maintenance of source code. However, high-quality code comments are often unavailable in smart contracts, the increasingly popular programs that run on the blockchain. In this paper, we propose a Multi-Modal Transformer-based (MMTrans) code summarization approach for smart contracts. Specifically, the MMTrans learns the representation of source code from the two heterogeneous modalities of the Abstract Syntax Tree (AST), i.e., Structure-based Traversal (SBT) sequences and graphs. The SBT sequence provides the global semantic information of AST, while the graph convolution focuses on the local details. The MMTrans uses two encoders to extract both global and local semantic information from the two modalities respectively, and then uses a joint decoder to generate code comments. Both the encoders and the decoder employ the multi-head attention structure of the Transformer to enhance the ability to capture the long-range dependencies between code tokens. We build a dataset with over 300K <method, comment > pairs of smart contracts, and evaluate the MMTrans on it. The experimental results demonstrate that the MMTrans outperforms the state-of-the-art baselines in terms of four evaluation metrics by a substantial margin, and can generate higher quality comments.
引用
收藏
页码:1 / 12
页数:12
相关论文
共 50 条
  • [1] M2TS: Multi-Scale Multi-Modal Approach Based on Transformer for Source Code Summarization
    Gao, Yuexiu
    Lyu, Chen
    30TH IEEE/ACM INTERNATIONAL CONFERENCE ON PROGRAM COMPREHENSION (ICPC 2022), 2022, : 24 - 35
  • [2] M2TS: Multi-Scale Multi-Modal Approach Based on Transformer for Source Code Summarization
    Gao, Yuexiu
    Lyu, Chen
    IEEE International Conference on Program Comprehension, 2022, 2022-March : 24 - 35
  • [3] FMCF: A fusing multiple code features approach based on Transformer for Solidity smart contracts source code summarization
    Lei, Gang
    Zhang, Donghua
    Xiao, Jianmao
    Fan, Guodong
    Cao, Yuanlong
    Feng, Zhiyong
    APPLIED SOFT COMPUTING, 2024, 166
  • [4] Multi-Modal Code Summarization with Retrieved Summary
    Lin, Lile
    Huang, Zhiqiu
    Yu, Yaoshen
    Liu, Yapeng
    2022 IEEE 22ND INTERNATIONAL WORKING CONFERENCE ON SOURCE CODE ANALYSIS AND MANIPULATION (SCAM 2022), 2022, : 132 - 142
  • [5] Swin transformer-based GAN for multi-modal medical image translation
    Yan, Shouang
    Wang, Chengyan
    Chen, Weibo
    Lyu, Jun
    FRONTIERS IN ONCOLOGY, 2022, 12
  • [6] Multi-Modal Pedestrian Crossing Intention Prediction with Transformer-Based Model
    Wang, Ting-Wei
    Lai, Shang-Hong
    APSIPA TRANSACTIONS ON SIGNAL AND INFORMATION PROCESSING, 2024, 13 (05)
  • [7] FNR: a similarity and transformer-based approach to detect multi-modal fake news in social media
    Ghorbanpour, Faeze
    Ramezani, Maryam
    Fazli, Mohammad Amin
    Rabiee, Hamid R.
    SOCIAL NETWORK ANALYSIS AND MINING, 2023, 13 (01)
  • [8] FNR: a similarity and transformer-based approach to detect multi-modal fake news in social media
    Faeze Ghorbanpour
    Maryam Ramezani
    Mohammad Amin Fazli
    Hamid R. Rabiee
    Social Network Analysis and Mining, 13
  • [9] Pedestrian Crossing Intention Prediction with Multi-Modal Transformer-Based Model
    Wang, Ting Wei
    Lai, Shang-Hong
    2023 ASIA PACIFIC SIGNAL AND INFORMATION PROCESSING ASSOCIATION ANNUAL SUMMIT AND CONFERENCE, APSIPA ASC, 2023, : 1349 - 1356
  • [10] A Transformer-Based Approach for Smart Invocation of Automatic Code Completion
    de Moor, Aral
    van Deursen, Arie
    Izadi, Maliheh
    PROCEEDINGS OF THE 1ST ACM INTERNATIONAL CONFERENCE ON AI-POWERED SOFTWARE, AIWARE 2024, 2024, : 28 - 37