A Novel Source Code Representation Approach Based on Multi-Head Attention

被引:0
|
作者
Xiao, Lei [1 ]
Zhong, Hao [1 ]
Liu, Jianjian [1 ]
Zhang, Kaiyu [1 ]
Xu, Qizhen [1 ]
Chang, Le [2 ]
机构
[1] Xiamen Univ Technol, Coll Comp & Informat Engn, Xiamen 361024, Peoples R China
[2] Software Secur Co, Chengdu 610041, Peoples R China
关键词
multi-head attention; code clone; code classification; source code representation; CLONE DETECTION;
D O I
10.3390/electronics13112111
中图分类号
TP [自动化技术、计算机技术];
学科分类号
0812 ;
摘要
Code classification and code clone detection are crucial for understanding and maintaining large software systems. Although deep learning surpasses traditional techniques in capturing the features of source code, existing models suffer from low processing power and high complexity. We propose a novel source code representation method based on the multi-head attention mechanism (SCRMHA). SCRMHA captures the vector representation of entire code segments, enabling it to focus on different positions of the input sequence, capture richer semantic information, and simultaneously process different aspects and relationships of the sequence. Moreover, it can calculate multiple attention heads in parallel, speeding up the computational process. We evaluate SCRMHA on both the standard dataset and an actual industrial dataset, and analyze the differences between these two datasets. Experiment results in code classification and clone detection tasks show that SCRMHA consumes less time and reduces complexity by about one-third compared with traditional source code feature representation methods. The results demonstrate that SCRMHA reduces the computational complexity and time consumption of the model while maintaining accuracy.
引用
收藏
页数:22
相关论文
共 50 条
  • [1] Combining Multi-Head Attention and Sparse Multi-Head Attention Networks for Session-Based Recommendation
    Zhao, Zhiwei
    Wang, Xiaoye
    Xiao, Yingyuan
    2023 INTERNATIONAL JOINT CONFERENCE ON NEURAL NETWORKS, IJCNN, 2023,
  • [2] On the diversity of multi-head attention
    Li, Jian
    Wang, Xing
    Tu, Zhaopeng
    Lyu, Michael R.
    NEUROCOMPUTING, 2021, 454 : 14 - 24
  • [3] DCT based multi-head attention-BiGRU model for EEG source location
    Zhang, Boyuan
    Li, Donghao
    Wang, Dongqing
    BIOMEDICAL SIGNAL PROCESSING AND CONTROL, 2024, 93
  • [4] Word embedding factor based multi-head attention
    Li, Zhengren
    Zhao, Yumeng
    Zhang, Xiaohang
    Han, Huawei
    Huang, Cui
    ARTIFICIAL INTELLIGENCE REVIEW, 2025, 58 (04)
  • [5] Entity and relation collaborative extraction approach based on multi-head attention and gated mechanism
    Zhao, Wei
    Zhao, Shan
    Chen, Shuhui
    Weng, Tien-Hsiung
    Kang, WenJie
    CONNECTION SCIENCE, 2022, 34 (01) : 670 - 686
  • [6] Multi-Head Attention-Based Spectrum Sensing for Radio
    Devarakonda, B. V. Ravisankar
    Nandanavam, Venkateswararao
    INTERNATIONAL JOURNAL OF ELECTRICAL AND COMPUTER ENGINEERING SYSTEMS, 2023, 14 (02) : 135 - 143
  • [7] Predicting disease genes based on multi-head attention fusion
    Linlin Zhang
    Dianrong Lu
    Xuehua Bi
    Kai Zhao
    Guanglei Yu
    Na Quan
    BMC Bioinformatics, 24
  • [8] Predicting disease genes based on multi-head attention fusion
    Zhang, Linlin
    Lu, Dianrong
    Bi, Xuehua
    Zhao, Kai
    Yu, Guanglei
    Quan, Na
    BMC BIOINFORMATICS, 2023, 24 (01)
  • [9] MAFD: A Federated Distillation Approach with Multi-head Attention for Recommendation Tasks
    Wu, Aming
    Kwon, Young-Woo
    38TH ANNUAL ACM SYMPOSIUM ON APPLIED COMPUTING, SAC 2023, 2023, : 1221 - 1224
  • [10] EXPLOITING MULTI-HEAD ATTENTION MAPS INTO A DEEP RIEMANNIAN REPRESENTATION TO QUANTIFY PULMONARY NODULES
    Moreno, Alejandra
    Olmos, Juan
    Guayacan, Luis
    Martinez, Fabio
    2023 IEEE 20TH INTERNATIONAL SYMPOSIUM ON BIOMEDICAL IMAGING, ISBI, 2023,