HELoC: Hierarchical Contrastive Learning of Source Code Representation
Abstract syntax trees (ASTs) play a crucial role in source code representation. In addition to the syntactic structure of ASTs, the hierarchical relationships/structures among the nodes in ASTs are also essential to enhance the code representation. However, due to the large number of nodes in an AST and the typically deep AST hierarchy, it is still challenging to learn the hierarchical structures within an AST effectively. In this paper, we propose HELoC, a hierarchical contrastive learning model for source code representation. To effectively learn the AST hierarchy, we use contrastive learning to allow the network to autonomously predict the AST node level and learn the hierarchical relationships between nodes, which makes the representation vectors of nodes with greater differences in AST levels farther apart in the embedding space. By using such vectors, the structural similarities between code snippets can be measured more precisely. In the learning process, a novel GNN (called Residual Self-attention Graph Neural Network, RSGNN) is used, which enables HELoC to focus on embedding the local structure of an AST while capturing its overall structure. HELoC also learns the representation of AST paths and combines them with the AST hierarchy representation to obtain a comprehensive representation of source code. HELoC is self-supervised and can be applied to many source code related downstream tasks after pre-training. Our experimental results demonstrate that HELoC outperforms the state-of-the-art models when applied to code classification and code clone detection.
Mon 16 MayDisplayed time zone: Eastern Time (US & Canada) change
21:00 - 21:50 | Session 9: Program Representation 2Research at ICPC room Chair(s): Lingxiao Jiang Singapore Management University | ||
21:00 7mTalk | HELoC: Hierarchical Contrastive Learning of Source Code Representation Research Xiao Wang Shandong Normal University, Qiong Wu Shandong Normal University, Hongyu Zhang University of Newcastle, Chen Lyu Shandong Normal University, Xue Jiang Shandong Normal University, Zhuoran Zheng Nanjing University of Science and Technology, Lei Lyu Shandong Normal University, Songlin Hu Institute of Information Engineering, Chinese Academy of Sciences Media Attached | ||
21:07 7mTalk | Exploring GNN Based Program Embedding Technologies for Binary related Tasks Research YixinGuo Peking University, Pengcheng Li Google, Inc, Yingwei Luo Peking University, Xiaolin Wang Peking University, Zhenlin Wang Michigan Technological University Media Attached | ||
21:14 7mTalk | Learning Heterogeneous Type Information in Program Graphs Research Kechi Zhang Peking University, Wenhan Wang Nanyang Technological University, Huangzhao Zhang Peking University, Ge Li Peking University, Zhi Jin Peking University DOI Pre-print Media Attached | ||
21:21 7mTalk | Unified Abstract Syntax Tree Representation Learning for Cross-language Program Classification Research Kesu Wang Nanjing University, Meng Yan Chongqing University, He Zhang Nanjing University, Haibo Hu Chongqing University Media Attached | ||
21:28 7mTalk | On the Transferability of Pre-trained Language Models for Low-Resource Programming Languages Research Fuxiang Chen University of British Columbia, Fatemeh Hendijani Fard University of British Columbia, David Lo Singapore Management University, Timofey Bryksin JetBrains Research; HSE University Pre-print Media Attached | ||
21:35 15mLive Q&A | Q&A-Paper Session 9 Research |