The present application relates to a multi-view contrast learning cross-language
source code representation method, and belongs to the technical field of
computer software information. Firstly, the present application initializes the learnable parameters of the
Transformer according to the
programming language type using a meta-learning method; secondly, the present application constructs a code feature heterogeneous graph depending on the
syntax, structure and other information of the
source code segment, aggregates the heterogeneous graph using a GCN to obtain
graph node embedding; then, the present application aggregates the same-hop neighborhood information of the nodes according to the meta-path to obtain the serialized representation of the graph nodes, generates the
graph node embedding using a
Transformer and a hierarchical attention mechanism; finally, the present application establishes a contrast
loss function according to the node embedding under two perspectives, and trains a cross-language
source code representation model. The present application extracts
programming language specific information and constructs a model using multi-view
graph node embedding to improve the cross-
language code representation effect and improve the accuracy of code summarization, source code
vulnerability detection and the like, in view of the fact that the existing method applies general code features of
programming languages to affect the representation effect and the model appears to be over-smoothed.