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

· ICPC· · transformer, code-summarization

Paper: A Multi-Modal Transformer-based Code Summarization Approach for Smart Contract

Data: https://zenodo.org/record/4587089#.YEog9-gzYuV

Code: https://github.com/yz1019117968/ICPC-21-MMTrans

MMTrans: SBT, graph, and joint decoder for smart contract comment generation

Abstract

The work applies code summarization to smart contracts—the programs executed on blockchains. An SBT sequence encodes global AST structure, graph convolution captures local structure, and a joint decoder generates comments. Both the encoder and decoder rely on Transformer multi-head attention to model long-range dependencies.

Introduction

Automatic code summarization for smart contracts has received relatively little attention, largely for two reasons: (1) many in-code comments are unusable, which hampers developers’ understanding and learning; and (2) code cloning and duplication are more prevalent than in conventional software. Producing high-quality comments therefore raises two core challenges:

  • How to extract semantic information from source code: an AST can be represented in multiple modalities—e.g., SBT sequences and graphs—each emphasizing a different facet of semantics.
  • How to capture long-range dependencies among code tokens: SBT sequences supply global AST context, graph convolution supplies local context, and Transformer multi-head attention models dependencies across tokens.

The authors collect 40,932 smart contracts from Etherscan.io, yielding 347,410 method–comment pairs.

Approach

avatar

Experiment

avatar
avatar

<HR align=left color=#987cb9 SIZE=1>