Context-aware code summarization with multi-relational graph neural network

被引:0
|
作者
Wang, Yanlin [1 ]
Shi, Ensheng [2 ]
Du, Lun [3 ]
Yang, Xiaodi [4 ]
Hu, Yuxuan [5 ]
Wang, Yanli [1 ]
Guo, Daya [1 ]
Han, Shi [3 ]
Zhang, Hongyu [6 ]
Zhang, Dongmei [3 ]
机构
[1] Sun Yat Sen Univ, Guangzhou, Peoples R China
[2] Xi An Jiao Tong Univ, Xian, Peoples R China
[3] Microsoft Res Asia, Beijing, Peoples R China
[4] Univ Hong Kong, Hong Kong, Peoples R China
[5] Beijing Univ Technol, Beijing, Peoples R China
[6] Chongqing Univ, Chongqing, Peoples R China
关键词
Source code summarization; Unified modeling language; Graph neural network; Transformer;
D O I
10.1007/s10515-025-00490-z
中图分类号
TP31 [计算机软件];
学科分类号
081202 ; 0835 ;
摘要
Source code summaries are short natural language descriptions of code snippets that help developers better understand and maintain source code. There has been a surge of work on automatic code summarization to reduce the burden of writing summaries manually. However, contemporary approaches only leverage the information within the boundary of the method being summarized (i.e., local context), and ignore the broader context that could assist with code summarization. This paper explores two global contexts, namely intra-class and inter-class contexts, and proposes CoCoSUM: Context-Aware Code Summarization with Multi-Relational Graph Neural Network. CoCoSUM first incorporates class names as the intra-class context to generate the class semantic embeddings. Then, relevant Unified Modeling Language (UML) class diagrams are extracted as inter-class context and are encoded into the class relational embeddings using a novel Multi-Relational Graph Neural Network (MRGNN). Class semantic embeddings and class relational embeddings, together with the outputs from code token encoder and AST encoder, are passed to a decoder armed with a two-level attention mechanism to generate high-quality, context-aware code summaries. Experimental results show that CoCoSUM outperforms state-of-the-art methods and the global contexts adopted in CoCoSUM can also strengthen existing code summarization models. Our replication package is anonymously available at https://github.com/DeepSoftwareAnalytics/cocosum.
引用
收藏
页数:26
相关论文
共 50 条
  • [31] Multi-relational Poincare Graph Embeddings
    Balazevic, Ivana
    Allen, Carl
    Hospedales, Timothy
    ADVANCES IN NEURAL INFORMATION PROCESSING SYSTEMS 32 (NIPS 2019), 2019, 32
  • [32] TBNet: a context-aware graph network for tuberculosis diagnosis
    Lu, Si-Yuan
    Wang, Shui-Hua
    Zhang, Xin
    Zhang, Yu-Dong
    COMPUTER METHODS AND PROGRAMS IN BIOMEDICINE, 2022, 214
  • [33] Graph Attention Network for Context-Aware Visual Tracking
    Shao, Yanyan
    Guo, Dongyan
    Cui, Ying
    Wang, Zhenhua
    Zhang, Liyan
    Zhang, Jianhua
    IEEE TRANSACTIONS ON NEURAL NETWORKS AND LEARNING SYSTEMS, 2024,
  • [34] Reinforced Neighborhood Selection Guided Multi-Relational Graph Neural Networks
    Peng, Hao
    Zhang, Ruitong
    Dou, Yingtong
    Yang, Renyu
    Zhang, Jingyi
    Philip, S. Yu
    ACM TRANSACTIONS ON INFORMATION SYSTEMS, 2022, 40 (04)
  • [35] Meta-Path Learning for Multi-relational Graph Neural Networks
    Ferrini, Francesco
    Longa, Antonio
    Passerini, Andrea
    Jaeger, Manfred
    LEARNING ON GRAPHS CONFERENCE, VOL 231, 2023, 231
  • [36] Cognitive name-face association through context-aware Graph Neural Network
    Fenza, Giuseppe
    Gallo, Mariacristina
    Loia, Vincenzo
    Volpe, Alberto
    NEURAL COMPUTING & APPLICATIONS, 2022, 34 (13): : 10279 - 10293
  • [37] Cognitive name-face association through context-aware Graph Neural Network
    Giuseppe Fenza
    Mariacristina Gallo
    Vincenzo Loia
    Alberto Volpe
    Neural Computing and Applications, 2022, 34 : 10279 - 10293
  • [38] Context-aware code certification
    Eusterbrock, J
    19TH INTERNATIONAL CONFERENCE ON AUTOMATED SOFTWARE ENGINEERING, PROCEEDINGS, 2004, : 358 - 361
  • [39] Recursive Multi-Relational Graph Convolutional Network for Automatic Photo Selection
    Xu, Wujiang
    Xu, Yifei
    Sang, Genan
    Li, Li
    Wang, Aichen
    Wei, Pingping
    Zhu, Li
    IEEE TRANSACTIONS ON MULTIMEDIA, 2023, 25 : 3825 - 3840
  • [40] Semantic and relation aware neural network model for bi-class multi-relational heterogeneous graphs
    Zhao, Yufei
    Liu, Hua
    Duan, Hua
    ISCIENCE, 2025, 28 (04)