HELoC:Source Code表示的层次对比学习
HELoC: Hierarchical Contrastive Learning of Source Code Representation
摘要:
摘要抽象语法树在源代码表示中起着至关重要的作用。然而,由于AST中的大量节点和通常深的AST层次结构,有效地学习AST的层次结构是具有挑战性的。在本文中,我们提出了HELoC,一个分层的对比学习模型的源代码表示。为了有效地学习AST层次结构,我们使用对比学习来让网络预测AST节点级别,并以自监督的方式学习节点之间的层次关系,这使得AST级别差异较大的节点的表示向量在嵌入空间中相距更远。通过使用这些向量,可以更精确地测量代码片段之间的结构相似性。在学习过程中,设计了一种新的GNN(称为残差自注意图神经网络,RSGNN),使HELoC能够专注于嵌入AST的局部结构,同时捕获其整体结构。HELoC是自监督的,可以应用于许多与源代码相关的下游任务,例如代码分类、代码克隆检测和预训练后的代码聚类。我们广泛的实验表明,HELoC优于最先进的源代码表示模型。
英文摘要:
Abstract syntax trees (ASTs) play a crucial role in source code representation. However, due to the large number of nodes in an AST and the typically deep AST hierarchy, it is challenging to learn the hierarchical structure of 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 predict the AST node level and learn the hierarchical relationships between nodes in a self-supervised manner, 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 designed, which enables HELoC to focus on embedding the local structure of an AST while capturing its overall structure. HELoC is self-supervised and can be applied to many source code related downstream tasks such as code classification, code clone detection, and code clustering after pre-training. Our extensive experiments demonstrate that HELoC outperforms the state-of-the-art source code representation models.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。