Optimization method, device and computer equipment for graph representation learning model

By constructing enhanced graphs and community detection and integrating loss functions to optimize the graph representation learning model, the problem of difficulty in obtaining node labels is solved, representation learning at the node and community levels is realized, and the effect of graph representation learning is improved.

CN116227535BActive Publication Date: 2025-09-30ZHAOLIAN CONSUMER FINANCE CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202211668532.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-24
Publication Date
2025-09-30
Estimated Expiration
2042-12-24

AI Technical Summary

Technical Problem

In the existing graph representation learning model, when it is difficult to obtain node labels, only node relationships are considered, resulting in poor graph representation learning results.

Method used

By constructing the first enhanced graph and the second enhanced graph, building the first loss function and community detection based on the node vector to obtain the community center vector, determining the positive samples and negative samples, and fusing the loss function for iterative optimization to achieve comparative learning at the node level and the community level.

Benefits of technology

It improves the effect of graph representation learning, can learn representations at the node level and community level, and improves the quality of graph representation learning.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116227535B_ABST
    Figure CN116227535B_ABST
Patent Text Reader

Abstract

The present application relates to an optimization method, device and computer equipment for a graph representation learning model. The method includes: inputting a first enhanced graph and a second enhanced graph into the graph representation learning model to obtain node vectors of multiple first nodes in the first enhanced graph and node vectors of multiple second nodes in the second enhanced graph; constructing a first loss function for each first node based on each node vector; performing community detection on the node vector of each first node to obtain multiple community center vectors to determine the community positive samples and community negative samples of each first node; for each first node, constructing a second loss function for each first node based on the node vector, community positive samples and community negative samples of the first node; fusing the first loss function and the second loss function to construct a target loss function to iteratively optimize the graph representation learning model to obtain an optimized graph representation learning model. The use of this method can improve the graph representation learning effect.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to an optimization method, apparatus, and computer device for a graph representation learning model. Background Art

[0002] With the development of neural network technology, graph convolutional neural networks (GCNNs) have been widely used for graph representation learning. GCNNs can encode each node in a graph, converting each node into a node vector to obtain a node representation for each node. This representation is then used to learn graph representations. However, this process of learning graph representations based on node representations presents the difficulty of obtaining node labels.

[0003] In the existing technology, when node labels are difficult to obtain, contrastive learning that is independent of node labels can be introduced into the field of graph representation learning, so that different node representations are far away from each other, that is, different node representations are as dissimilar as possible, to achieve graph representation learning.

[0004] However, the contrastive learning introduced in the existing technology only considers the relationship between nodes, resulting in poor results in graph representation learning. Summary of the Invention

[0005] Based on this, it is necessary to provide a graph representation learning model optimization method, device, computer equipment, computer-readable storage medium and computer program product that can improve the graph representation learning effect in response to the above technical problems.

[0006] In a first aspect, the present application provides a method for optimizing a graph representation learning model. The method comprises:

[0007] Inputting the first enhanced graph and the second enhanced graph into the graph representation learning model respectively to obtain node vectors of the plurality of first nodes in the first enhanced graph and node vectors of the plurality of second nodes in the second enhanced graph, wherein the first enhanced graph and the second enhanced graph are obtained by performing data augmentation on the initial graph;

[0008] Based on each node vector, construct a first loss function corresponding to each first node;

[0009] Performing community detection on the node vectors of each first node to obtain multiple community center vectors, and determining community positive samples and community negative samples corresponding to each first node based on the community center vectors;

[0010] For each first node, construct a second loss function corresponding to each first node according to the node vector of the first node, the community positive sample, and the community negative sample;

[0011] The first loss function and the second loss function are integrated to construct a target loss function, and the graph representation learning model is iteratively optimized based on the target loss function to obtain an optimized graph representation learning model.

[0012] In one embodiment, constructing a first loss function corresponding to each first node based on each node vector includes:

[0013] For each first node, matching the first node with each second node respectively to obtain a second node that successfully matches the first node;

[0014] The node vector of the successfully matched second node is used as the node positive sample of the first node, and the node vectors of each second node, except the node positive sample, are used as the node negative samples of the first node;

[0015] Through node comparative learning, based on the node vector, node positive sample and node negative sample of each first node, a first loss function corresponding to each first node is constructed.

[0016] In one embodiment, constructing a first loss function corresponding to each first node based on the node vector, node positive sample, and node negative sample of each first node through node comparative learning includes:

[0017] For each first node, obtain a node positive similarity measurement value between the node vector of the first node and the node positive sample, and a node negative similarity measurement value between the node vector of the first node and the node negative sample;

[0018] Through node comparison learning, based on the node positive similarity measurement value and the node negative similarity measurement value, a first loss function corresponding to each first node is constructed.

[0019] In one embodiment, performing community detection on the node vectors of each first node to obtain a plurality of community center vectors, and determining the community positive samples and community negative samples corresponding to each first node based on the community center vectors includes:

[0020] Based on the clustering algorithm, community detection is performed on the node vector of each first node to obtain multiple node communities and the community center vectors corresponding to each node community. Each first node has its own corresponding node community.

[0021] For each first node, the community center vector of the node community corresponding to the first node is used as the community positive sample of the first node, and the other community center vectors except the community positive sample are used as the community negative samples of the first node.

[0022] In one embodiment, for each first node, constructing a second loss function corresponding to each first node according to the node vector of the first node, the community positive sample, and the community negative sample includes:

[0023] For each first node, obtain a community positive similarity measurement value between the node vector of the first node and the community positive sample, and a community negative similarity measurement value between the node vector of the first node and the community negative sample;

[0024] Through community comparative learning, a second loss function corresponding to each first node is constructed based on the community positive similarity measurement value and the community negative similarity measurement value.

[0025] In one embodiment, fusing the first loss function and the second loss function to construct a target loss function, iteratively optimizing the graph representation learning model based on the target loss function, and obtaining the optimized graph representation learning model includes:

[0026] Adding the loss term of the first loss function and the loss term of the second loss function corresponding to the same first node to construct a target loss function corresponding to each first node;

[0027] Based on each objective loss function, the model parameters in the graph representation learning model are iteratively updated to iteratively optimize the graph representation learning model;

[0028] When all objective loss functions meet the convergence conditions, an optimized graph representation learning model is obtained.

[0029] In a second aspect, the present application also provides an optimization device for a graph representation learning model. The device includes:

[0030] A node vector acquisition module is configured to input the first enhanced graph and the second enhanced graph into a graph representation learning model, respectively, to obtain node vectors for each of the plurality of first nodes in the first enhanced graph and node vectors for each of the plurality of second nodes in the second enhanced graph; the first enhanced graph and the second enhanced graph are obtained by performing data augmentation on the initial graph;

[0031] A first loss function construction module is used to construct a first loss function corresponding to each first node based on each node vector;

[0032] A community sample determination module is used to perform community detection on the node vectors of each first node to obtain multiple community center vectors, and determine the community positive sample and community negative sample corresponding to each first node based on the community center vectors;

[0033] A second loss function construction module is used to construct, for each first node, a second loss function corresponding to each first node according to the node vector of the first node, the community positive sample, and the community negative sample;

[0034] The model iterative optimization module is used to fuse the first loss function and the second loss function to construct a target loss function, and iteratively optimize the graph representation learning model based on the target loss function to obtain an optimized graph representation learning model.

[0035] In a third aspect, the present application further provides a computer device. The computer device includes a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are performed:

[0036] Inputting the first enhanced graph and the second enhanced graph into the graph representation learning model respectively to obtain node vectors of the plurality of first nodes in the first enhanced graph and node vectors of the plurality of second nodes in the second enhanced graph; the first enhanced graph and the second enhanced graph are obtained by performing data augmentation on the initial graph;

[0037] Based on each node vector, construct a first loss function corresponding to each first node;

[0038] Performing community detection on the node vectors of each first node to obtain multiple community center vectors, and determining community positive samples and community negative samples corresponding to each first node based on the community center vectors;

[0039] For each first node, construct a second loss function corresponding to each first node according to the node vector of the first node, the community positive sample, and the community negative sample;

[0040] The first loss function and the second loss function are integrated to construct a target loss function, and the graph representation learning model is iteratively optimized based on the target loss function to obtain an optimized graph representation learning model.

[0041] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the following steps:

[0042] Inputting the first enhanced graph and the second enhanced graph into the graph representation learning model respectively to obtain node vectors of the plurality of first nodes in the first enhanced graph and node vectors of the plurality of second nodes in the second enhanced graph; the first enhanced graph and the second enhanced graph are obtained by performing data augmentation on the initial graph;

[0043] Based on each node vector, construct a first loss function corresponding to each first node;

[0044] Performing community detection on the node vectors of each first node to obtain multiple community center vectors, and determining community positive samples and community negative samples corresponding to each first node based on the community center vectors;

[0045] For each first node, construct a second loss function corresponding to each first node according to the node vector of the first node, the community positive sample, and the community negative sample;

[0046] The first loss function and the second loss function are integrated to construct a target loss function, and the graph representation learning model is iteratively optimized based on the target loss function to obtain an optimized graph representation learning model.

[0047] In a fifth aspect, the present application further provides a computer program product. The computer program product includes a computer program that, when executed by a processor, implements the following steps:

[0048] Inputting the first enhanced graph and the second enhanced graph into the graph representation learning model respectively to obtain node vectors of the plurality of first nodes in the first enhanced graph and node vectors of the plurality of second nodes in the second enhanced graph; the first enhanced graph and the second enhanced graph are obtained by performing data augmentation on the initial graph;

[0049] Based on each node vector, construct a first loss function corresponding to each first node;

[0050] Performing community detection on the node vectors of each first node to obtain multiple community center vectors, and determining community positive samples and community negative samples corresponding to each first node based on the community center vectors;

[0051] For each first node, construct a second loss function corresponding to each first node according to the node vector of the first node, the community positive sample, and the community negative sample;

[0052] The first loss function and the second loss function are integrated to construct a target loss function, and the graph representation learning model is iteratively optimized based on the target loss function to obtain an optimized graph representation learning model.

[0053] The optimization method, apparatus, computer equipment, storage medium and computer program product of the above-mentioned graph representation learning model first obtain the node vector of each first node in the first enhanced graph and the node vector of each second node in the second enhanced graph based on the graph representation learning model, and construct a first loss function for each first node based on each node vector to perform comparative learning on the node representations of each node in the first enhanced graph and the second enhanced graph at the node level, and then perform community detection on the node vectors of each first node to obtain multiple community center vectors, and determine the community positive samples and community negative samples of each first node from the community center vectors, so as to construct a second loss function for each first node, and perform comparative learning on the node representations of each first node at the community level constructed by multiple first nodes, and then fuse the first loss function and the second loss function to obtain the target loss function, so as to iteratively optimize the graph representation learning model and obtain an optimized graph representation learning model. During the entire process, based on the node level, comparative learning is first performed on the nodes in the two enhanced graphs, so that the node representations of different nodes are far away from each other. Then, based on the community level, the node representations of the same community are close to each other, while the node representations of different communities are further away from each other. In the process of graph representation learning based on the optimized graph representation learning model, in addition to learning the node-level representation, the community-level representation can also be learned based on the community composed of multiple nodes, that is, a higher-level graph representation learning is performed, thereby improving the graph representation learning effect. BRIEF DESCRIPTION OF THE DRAWINGS

[0054] Figure 1 A schematic diagram of a flow chart of an optimization method for a graph representation learning model according to an embodiment;

[0055] Figure 2 1 is a schematic diagram of a process for performing edge perturbation during data enhancement in one embodiment;

[0056] Figure 3 is a schematic diagram of matching a first node with a second node in one embodiment;

[0057] Figure 4 A schematic flow chart of an optimization method for a graph representation learning model according to another embodiment;

[0058] Figure 5 1. It is an optimization flow chart of a graphical representation learning model in one embodiment;

[0059] Figure 6 Schematic diagram of a process for clustering a graph dataset using the above-mentioned optimized graph representation learning model in one embodiment;

[0060] Figure 7 It is a structural block diagram of an optimization device for a graph representation learning model in one embodiment;

[0061] Figure 8 FIG. 1 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0062] In order to make the purpose, technical solutions and advantages of this application more clear, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.

[0063] In one embodiment, Figure 1 As shown, a method for optimizing a graph representation learning model is provided. This embodiment uses the method applied to a terminal as an example. It is understandable that the method can also be applied to a server, or to a system including a terminal and a server, and implemented through interaction between the terminal and the server. In this embodiment, the method includes the following steps:

[0064] Step 102: Input the first enhanced graph and the second enhanced graph into the graph representation learning model respectively to obtain node vectors of the first nodes in the first enhanced graph and node vectors of the second nodes in the second enhanced graph. The first enhanced graph and the second enhanced graph are obtained by performing data enhancement on the initial graph.

[0065] in, Figure 1 A special data format consisting of multiple nodes and edges connecting them. A graph representation learning model is a model applied to graph machine learning. Specifically, it can be a model built on graph neural networks. It can extract node representations from each node in the graph and convert the nodes into vector form (mathematically easier to analyze), namely node vectors, so that each node in the graph can be processed based on the node vectors. Data augmentation can be used to expand limited data to obtain more equally valid data.

[0066] Optionally, the server can perform data enhancement on the initial graph according to a preconfigured data enhancement method to obtain a first enhanced graph and a second enhanced graph, and then input the first enhanced graph and the second enhanced graph into the graph representation learning model respectively, and extract the node representation of each node in the first enhanced graph and the second enhanced graph through the graph representation learning model to obtain the node vectors of each of the multiple first nodes in the first enhanced graph and the node vectors of each of the multiple second nodes in the second enhanced graph.

[0067] Exemplarily, in the process of performing data enhancement on the initial graph according to a preconfigured data enhancement method, the server can perform data enhancement on the initial graph based on edge perturbation (Node dropping) and attribute masking (Attribute masking). Among them, edge perturbation can perturb the connection relationship between the nodes in the graph by randomly adding or deleting a certain proportion of edges in the graph, and the probability of each edge being added or deleted can be configured according to the actual application scenario. Attribute masking can randomly remove the attribute information of some nodes in the graph, and then reconstruct the attribute information of the masked nodes based on the connection relationship between the nodes. The probability of each node being attribute masked can be configured according to the actual application scenario.

[0068] For example, Figure 2 As shown, a schematic diagram of edge perturbation in the data enhancement process is provided. Figure 2 The dashed lines in represent the edges that are randomly deleted. Figure 2 The data enhancement of the graph A in the example is used to obtain the enhanced graph B and enhanced graph C. The server can obtain the enhanced graph B by randomly deleting an edge and randomly adding another edge, and can also obtain the enhanced graph C by randomly deleting an edge. In this embodiment, the initial graph and the obtained enhanced graph are not limited to Figure 2 Several types are shown.

[0069] Optionally, graph neural networks that can be used to construct graph representation learning models include but are not limited to GCN (Graph Convolutional Network), GAT (Graph Attention Networks), GraphSAGE (Graph SAmpleand aggreGatE), etc.

[0070] Step 104: construct a first loss function corresponding to each first node based on each node vector.

[0071] The first loss function can be constructed based on the concept of the infoNCE loss function in contrastive learning. Contrastive learning is a self-supervised learning method that does not require labels (data categories) to train neural networks. Instead, it uses the data itself as supervisory information to learn the data's characteristic representations. The core idea of ​​contrastive learning is to bring similar samples closer together and dissimilar samples farther apart.

[0072] Optionally, for each first node, the server can first obtain the node positive sample and the node negative sample of the first node from the second node, and then obtain the similarity between the node vector of the first node and the node positive sample, and the similarity between the node vector of the first node and the node negative sample, so as to construct the first loss function corresponding to each first node in the first enhanced graph.

[0073] Step 106 : Perform community detection on the node vectors of each first node to obtain a plurality of community center vectors. Based on each community center vector, determine the community positive sample and community negative sample corresponding to each first node.

[0074] Specifically, community detection involves detecting clusters (node ​​communities) in a graph. Clusters represent collections of similar nodes (node ​​communities) in the graph. Graph clusters can provide a wealth of information about node similarity. Using well-defined clusters for graph representation learning allows for the learning of higher-level (community-level) information. The community center vector is the vector corresponding to the community center of each node community.

[0075] Optionally, the server can detect the node communities (clusters) in the first enhanced graph, that is, perform community detection on the node vectors of each first node, determine the community center vector corresponding to the community center of each node community, and then determine the community positive samples and community negative samples corresponding to each first node from each community center vector.

[0076] Step 108 : For each first node, construct a second loss function corresponding to each first node according to the node vector of the first node, the community positive sample, and the community negative sample.

[0077] Among them, the second loss function can also be constructed based on the concept of infoNCE loss function in contrastive learning.

[0078] Optionally, for each first node, the server can obtain the similarity between the node vector of the first node and the community positive sample, and the similarity between the node vector of the first node and the community negative sample based on the node vector of the first node, the community positive sample, and the community negative sample, so as to construct the second loss function corresponding to each first node.

[0079] Step 110: The first loss function and the second loss function are integrated to construct a target loss function, and the graph representation learning model is iteratively optimized based on the target loss function to obtain an optimized graph representation learning model.

[0080] Optionally, the server may construct a target loss function by fusing the first loss function and the second loss function, and then iteratively update the model parameters in the graph representation learning model based on the target loss function and a backpropagation algorithm to iteratively optimize the graph representation learning model and obtain an optimized graph representation learning model. Specifically, the backpropagation algorithm may iteratively update the parameters of each layer of the graph neural network model from the output layer to the input layer based on a gradient descent method until the loss function converges.

[0081] In the above-mentioned optimization method of the graph representation learning model, first, based on the graph representation learning model, the node vector of each first node in the first enhanced graph and the node vector of each second node in the second enhanced graph are obtained. Based on each node vector, a first loss function of each first node is constructed to perform comparative learning on the node representations of each node in the first enhanced graph and the second enhanced graph at the node level. Community detection is then performed on the node vector of each first node to obtain multiple community center vectors. From the community center vectors, the community positive samples and community negative samples of each first node are determined, thereby constructing a second loss function for each first node. Comparative learning is performed on the node representations of each first node at the community level constructed by multiple first nodes. The first loss function and the second loss function are then fused to obtain the target loss function, so as to iteratively optimize the graph representation learning model and obtain an optimized graph representation learning model. During the entire process, based on the node level, comparative learning is first performed on the nodes in the two enhanced graphs, so that the node representations of different nodes are far away from each other. Then, based on the community level, the node representations of the same community are close to each other, while the node representations of different communities are further away from each other. In the process of graph representation learning based on the optimized graph representation learning model, in addition to learning the node-level representation, the community-level representation can also be learned based on the community composed of multiple nodes, that is, a higher-level graph representation learning is performed, thereby improving the graph representation learning effect.

[0082] In one embodiment, constructing a first loss function corresponding to each first node based on each node vector includes:

[0083] For each first node, matching the first node with each second node respectively to obtain a second node that successfully matches the first node;

[0084] The node vector of the successfully matched second node is used as the node positive sample of the first node, and the node vectors of each second node, except the node positive sample, are used as the node negative samples of the first node;

[0085] Through node comparative learning, based on the node vector, node positive sample and node negative sample of each first node, a first loss function corresponding to each first node is constructed.

[0086] Optionally, for each first node, the server may match the first node with each second node respectively to obtain a second node that successfully matches the first node, wherein the number of second nodes that successfully match the first node is one, and then use the node vector of the successfully matched second node as the node positive sample of the first node, so that each first node corresponds to one node positive sample. Then, in the node vector of each second node, the node vectors other than the node positive sample are used as the node negative samples of the first node, so that each first node corresponds to multiple node negative samples. Finally, through node comparative learning, based on the node vector, node positive sample, and node negative sample of each first node, a first loss function corresponding to each first node is constructed.

[0087] For example, for the first enhanced graph g1 and the second enhanced graph g2, assuming that v i is the first node of i in g1 u i is the second node (u i ∈g2), specifically, it can be determined by formula (1) and formula (2) with v i Node positive sample v i + The corresponding second node and v i Node negative sample v i - The corresponding second node:

[0088] v i + = u i (1)

[0089] v i - = {u j ∈g2|j≠i} (2)

[0090] Among them, formula (1) represents: with v i Node positive sample v i + The corresponding second node is the i-th second node u in g2 i Formula (2) represents: with v i Node negative sample v i - The corresponding second node is g2, except u i Other nodes other than the jth second node u in g2 j (j≠i).

[0091] For example, Figure 2Assume that the enhanced graph B and enhanced graph C shown in FIG1 correspond to the first enhanced graph and all nodes in the enhanced graph B are first nodes, and the enhanced graph C corresponds to the second enhanced graph and all nodes in the enhanced graph C are second nodes. The server can match the first node in the enhanced graph B with the second node in the enhanced graph C, as shown in FIG1 . Figure 3 The figure shows a schematic diagram for matching B1, the first node in enhanced graph B, with C1, the second node in enhanced graph C. Because C1 and B1 are located in the same position, the server can determine that C1 and B1 are successfully matched and use the node vector corresponding to C1 as the node positive sample for B1. The node vectors corresponding to the second nodes in enhanced graph C other than C1 are used as node negative samples for B1. Similarly, the server can obtain node positive and node negative samples for each first node in enhanced graph B.

[0092] Optionally, based on the same method, the server may obtain node positive samples and node negative samples of each second node in the second enhanced graph.

[0093] In this embodiment, by matching each node in the first enhancement graph and the second enhancement graph respectively, the node positive samples and node negative samples of each first node can be obtained, so that the first loss function of each first node can be constructed based on the contrastive learning algorithm.

[0094] In one embodiment, constructing a first loss function corresponding to each first node based on the node vector, node positive sample, and node negative sample of each first node through node comparative learning includes:

[0095] For each first node, obtain a node positive similarity measurement value between the node vector of the first node and the node positive sample, and a node negative similarity measurement value between the node vector of the first node and the node negative sample;

[0096] Through node comparison learning, based on the node positive similarity measurement value and the node negative similarity measurement value, a first loss function corresponding to each first node is constructed.

[0097] Specifically, node comparative learning can be: based on the concept of comparative learning, comparative learning is performed on each node at the node level to make the node representations of different nodes distant from each other. The similarity metric can be used to measure the similarity between nodes.

[0098] Optionally, for each first node, the server can obtain the node positive similarity measurement value between the node vector of the first node and the node positive sample, and the node negative similarity measurement value between the node vector of the first node and the node negative sample based on a preconfigured similarity measurement function, and then through node comparative learning, according to the infoNCE loss function, based on the node positive similarity measurement value and the node negative similarity measurement value, construct the first loss function corresponding to each first node.

[0099] For example, the server can obtain the node positive similarity measurement value between the node vector of the first node and the node positive sample, and the node negative similarity measurement value between the node vector of the first node and the node negative sample based on the preconfigured similarity measurement function θ(·), and then construct the first loss function corresponding to each first node. i Taking θ as an example, the constructed first loss function can be specifically shown as formula (3):

[0100]

[0101] Among them, θ(v i ,u i ) Characterization: Calculate v i The corresponding node vector and u i The corresponding node vector (v i θ(v i ,u j ) Characterization: Calculate v i The corresponding node vector and u j The corresponding node vector (v i The node negative similarity metric between the node negative samples (negative samples of nodes). τ is a hyperparameter that can be configured according to the actual application scenario.

[0102] Optionally, based on the same method, the server may obtain the first loss function of each second node in the second enhanced graph.

[0103] In this embodiment, the first loss function corresponding to each first node is constructed by the similarity measurement value between the node vector of the first node and the node positive sample and the node negative sample, which can achieve comparative learning at the node level, thereby realizing graph representation learning at the node level.

[0104] In one embodiment, performing community detection on the node vectors of each first node to obtain a plurality of community center vectors, and determining the community positive samples and community negative samples corresponding to each first node based on the community center vectors includes:

[0105] Based on the clustering algorithm, community detection is performed on the node vector of each first node to obtain multiple node communities and the community center vectors corresponding to each node community. Each first node has its own corresponding node community.

[0106] For each first node, the community center vector of the node community corresponding to the first node is used as the community positive sample of the first node, and the other community center vectors except the community positive sample are used as the community negative samples of the first node.

[0107] The clustering algorithm includes but is not limited to K-means and other algorithms that can be used to implement clustering.

[0108] Optionally, the server can perform community detection on the node vectors of each first node in the first enhanced graph based on a clustering algorithm to obtain multiple node communities, each of which is composed of multiple first nodes that have a certain degree of similarity with each other, and each first node has its own corresponding node community. At the same time, the server can also obtain the community center vector corresponding to each node community. Furthermore, for each first node, the server can use the community center vector of the node community corresponding to the first node as the community positive sample of the first node, and use the other community center vectors other than the community positive sample as the community negative sample of the first node.

[0109] For example, after obtaining multiple node communities, the server can use the first nodes preliminarily determined to be in the same node community as each other's initial community positive samples, and the first nodes in different node communities as each other's initial community negative samples. Considering that each first node corresponds to multiple initial community positive samples, in order to simplify the process of constructing the second loss function, for each first node, the server can further use the community center vector of the node community corresponding to the first node as the final community positive sample of the first node, that is, use the community center vector of the node community to replace each first node in the node community. Similarly, the initial community negative samples can be further simplified, and all community center vectors except the community center vector of the node community corresponding to the first node can be used as community negative samples of the first node.

[0110] Optionally, based on the same method, the server may obtain the community positive samples and community negative samples of each second node in the second enhanced graph.

[0111] In this embodiment, by determining the community positive samples and community negative samples of each first node from the community center vector of each node community, it is possible to achieve comparative learning of the representation of each node at the community level. Furthermore, by using the community center vector of the node community to replace the first nodes in the node community, the efficiency of constructing the second loss function can also be improved.

[0112] In one embodiment, for each first node, constructing a second loss function corresponding to each first node according to the node vector of the first node, the community positive sample, and the community negative sample includes:

[0113] For each first node, obtain a community positive similarity measurement value between the node vector of the first node and the community positive sample, and a community negative similarity measurement value between the node vector of the first node and the community negative sample;

[0114] Through community comparative learning, a second loss function corresponding to each first node is constructed based on the community positive similarity measurement value and the community negative similarity measurement value.

[0115] Optionally, for each first node, the server can obtain the community positive similarity measurement value between the node vector of the first node and the community positive sample, and the community negative similarity measurement value between the node vector of the first node and the community negative sample based on a preconfigured similarity measurement function, and then through community comparative learning, according to the infoNCE loss function, based on the community positive similarity measurement value and the community negative similarity measurement value, construct a second loss function corresponding to each first node.

[0116] For example, for each first node, the server can obtain the community positive similarity measurement value between the node vector of the first node and the community positive sample, and the community negative similarity measurement value between the node vector of the first node and the community negative sample based on the preconfigured similarity measurement function θ(·), thereby constructing the second loss function corresponding to each first node. i As an example, assume that the matrix composed of all community center vectors is C1, each row of C1 corresponds to a community center vector, and v i The community center vector of the corresponding node community is located in the mth row, and the constructed second loss function can be specifically shown as formula (4):

[0117]

[0118] Among them, C1[m,:] represents: v i The community center vector of the corresponding node community, that is, v i θ(v i ,C1[m,:]) characterization: calculate v i The corresponding node vector and v i The community positive similarity metric between the corresponding community positive samples. C1[n,:] represents: except v i Other community center vectors other than the community center vector of the corresponding node community, that is, v i Community negative samples. θ(v i,C1[n,:]) characterization: calculate v i The corresponding node vector and v i The community negative similarity metric between the corresponding community negative samples. τ is a hyperparameter that can be configured according to the actual application scenario.

[0119] Optionally, based on the same method, the server may obtain the second loss function of each second node in the second enhanced graph.

[0120] In this embodiment, by constructing a second loss function corresponding to each first node through the similarity measurement value between the node vector of the first node and the community positive sample and the community negative sample, comparative learning at the community level can be achieved, thereby realizing graph representation learning at the community level.

[0121] In one embodiment, fusing the first loss function and the second loss function to construct a target loss function, iteratively optimizing the graph representation learning model based on the target loss function, and obtaining the optimized graph representation learning model includes:

[0122] Adding the loss term of the first loss function and the loss term of the second loss function corresponding to the same first node to construct a target loss function corresponding to each first node;

[0123] Based on each objective loss function, the model parameters in the graph representation learning model are iteratively updated to iteratively optimize the graph representation learning model;

[0124] When all objective loss functions meet the convergence conditions, an optimized graph representation learning model is obtained.

[0125] Optionally, the server can add the loss term of the first loss function corresponding to the same first node to the loss term of the second loss function to construct a target loss function corresponding to each first node, so that the target function corresponding to each node includes comparative learning at the node level and the community level, and then based on each target loss function and the back propagation algorithm, the gradient descent method is used to iteratively update the model parameters in the graph representation learning model to iteratively optimize the graph representation learning model. When each target loss function satisfies the convergence condition, an optimized graph representation learning model is obtained. Wherein, each target loss function satisfies the convergence condition, indicating that each target loss function gradually converges and converges to a minimum value.

[0126] Optionally, based on the same method, the server can obtain the target loss function of each second node in the second enhanced graph, so that the graph representation learning model can be further iteratively optimized based on the target loss function of each first node and each second node. When the target loss function of each first node and each second node meets the convergence conditions, the optimized graph representation learning model is obtained.

[0127] In this embodiment, the graph representation learning model is iteratively optimized based on the target loss function that includes comparative learning of the node level and the community level, so that the obtained optimized graph representation learning model can not only learn the representation of the node level, but also learn the representation of the community level, and can learn the similarity between the node representations corresponding to each node belonging to the same node community, thereby improving the graph representation learning effect of the optimized graph representation learning model.

[0128] In one embodiment, Figure 4 As shown, a flowchart of another optimization method for a graph representation learning model is provided, which specifically includes the following steps:

[0129] Step 402: Input the first enhanced graph and the second enhanced graph into a graph representation learning model to obtain node vectors for each of the plurality of first nodes in the first enhanced graph and node vectors for each of the plurality of second nodes in the second enhanced graph. The first enhanced graph and the second enhanced graph are obtained by performing data augmentation on the initial graph.

[0130] Step 404: For each first node, match the first node with each second node to obtain a second node that successfully matches the first node. The node vector of the successfully matched second node is used as a node positive sample of the first node, and the node vectors of each second node, excluding the node positive sample, are used as node negative samples of the first node.

[0131] Step 406: For each first node, obtain a node positive similarity measure between the node vector of the first node and the node positive sample, and a node negative similarity measure between the node vector of the first node and the node negative sample, and then construct a first loss function corresponding to each first node based on the node positive similarity measure and the node negative similarity measure through node comparative learning;

[0132] Step 408: Based on the clustering algorithm, perform community detection on the node vector of each first node to obtain multiple node communities and the community center vectors corresponding to each node community. Each first node has its own corresponding node community. For each first node, the community center vector of the node community corresponding to the first node is used as the community positive sample of the first node, and the other community center vectors except the community positive sample are used as the community negative samples of the first node.

[0133] Step 410: For each first node, obtain a community positive similarity measure between the node vector of the first node and a community positive sample, and a community negative similarity measure between the node vector of the first node and a community negative sample. Then, through community comparative learning, construct a second loss function corresponding to each first node based on the community positive similarity measure and the community negative similarity measure.

[0134] In step 412, the loss term of the first loss function corresponding to the same first node is added to the loss term of the second loss function to construct a target loss function corresponding to each first node. Then, based on each target loss function, the model parameters in the graph representation learning model are iteratively updated to iteratively optimize the graph representation learning model. When each target loss function meets the convergence conditions, an optimized graph representation learning model is obtained.

[0135] In another embodiment, Figure 2 The data enhancement process shown in is illustrated as an example. Figure 5 As shown in the figure, another optimization flow chart of the graph representation learning model is provided, which mainly includes the following processes: performing data enhancement on the initial graph A to obtain enhanced graph B and enhanced graph C, and then inputting the enhanced graph B and enhanced graph C into the graph representation learning model constructed based on GCN respectively to obtain the node representation (node ​​vector) of each node in the enhanced graph B and enhanced graph C, and then completing the node-level comparative learning and community-level comparative learning based on each node vector, and finally obtaining an optimized graph representation learning model that can learn node-level representation and community-level representation.

[0136] In one embodiment, Figure 6 As shown, a schematic diagram of the process of clustering a graph dataset by applying the above-mentioned optimized graph representation learning model is provided. The main process includes: inputting the graph dataset into the above-mentioned optimized graph representation learning model, outputting the contrast loss based on backpropagation, and then outputting the cross entropy loss by the multi-layer perceptron (MLP) composed of the linear layer (Linear) and the activation function (softmax). Furthermore, based on the true label of the required clustering, the clustering prediction result of the graph dataset is output.

[0137] It should be understood that, although the various steps in the flowcharts involved in the various embodiments described above are displayed in sequence according to the instructions of the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the flowcharts involved in the various embodiments described above can include multiple steps or multiple stages, and these steps or stages are not necessarily executed and completed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of steps or stages in other steps.

[0138] Based on the same inventive concept, the embodiments of the present application also provide a graph representation learning model optimization device for implementing the above-mentioned graph representation learning model optimization method. The implementation solution provided by the device is similar to the implementation solution described in the above-mentioned method. Therefore, the specific limitations of the embodiments of one or more graph representation learning model optimization devices provided below can be found in the above-mentioned limitations of the graph representation learning model optimization method, and will not be repeated here.

[0139] In one embodiment, Figure 7 As shown, an optimization device for a graph representation learning model is provided, comprising: a node vector acquisition module 702, a first loss function construction module 704, a community sample determination module 706, a second loss function construction module 708, and a model iterative optimization module 710, wherein:

[0140] A node vector obtaining module 702 is configured to input the first enhanced graph and the second enhanced graph into a graph representation learning model, respectively, to obtain node vectors for each of the first nodes in the first enhanced graph and node vectors for each of the second nodes in the second enhanced graph; the first enhanced graph and the second enhanced graph are obtained by performing data augmentation on the initial graph;

[0141] A first loss function construction module 704 is configured to construct a first loss function corresponding to each first node based on each node vector;

[0142] The community sample determination module 706 is configured to perform community detection on the node vectors of each first node to obtain multiple community center vectors, and determine the community positive sample and community negative sample corresponding to each first node based on the community center vectors;

[0143] A second loss function construction module 708 is configured to construct, for each first node, a second loss function corresponding to each first node according to the node vector of the first node, the community positive sample, and the community negative sample;

[0144] The model iterative optimization module 710 is used to fuse the first loss function and the second loss function to construct a target loss function, and iteratively optimize the graph representation learning model based on the target loss function to obtain an optimized graph representation learning model.

[0145] In one embodiment, the first loss function construction module is also used to match the first node with each second node for each first node, obtain the second node that successfully matches the first node, use the node vector of the successfully matched second node as the node positive sample of the first node, and use the node vectors of each second node except the node positive sample as the node negative sample of the first node, and then construct the first loss function corresponding to each first node based on the node vector, node positive sample and node negative sample of each first node through node comparative learning.

[0146] In one embodiment, the optimization device of the graph representation learning model also includes a first processing module, which is used to obtain, for each first node, a node positive similarity measurement value between the node vector of the first node and the node positive sample, and a node negative similarity measurement value between the node vector of the first node and the node negative sample, and then construct a first loss function corresponding to each first node based on the node positive similarity measurement value and the node negative similarity measurement value through node comparative learning.

[0147] In one embodiment, the community sample determination module is also used to perform community detection on the node vector of each first node based on a clustering algorithm to obtain multiple node communities and the community center vectors corresponding to each node community, wherein each first node has its own corresponding node community. Then, for each first node, the community center vector of the node community corresponding to the first node is used as the community positive sample of the first node, and the other community center vectors except the community positive sample are used as the community negative samples of the first node.

[0148] In one embodiment, the second loss function construction module is also used to obtain, for each first node, a community positive similarity measurement value between the node vector of the first node and the community positive sample, and a community negative similarity measurement value between the node vector of the first node and the community negative sample, and then through community comparative learning, construct a second loss function corresponding to each first node based on the community positive similarity measurement value and the community negative similarity measurement value.

[0149] In one embodiment, the model iteration optimization module is also used to add the loss term of the first loss function corresponding to the same first node and the loss term of the second loss function to construct a target loss function corresponding to each first node, and then iteratively update the model parameters in the graph representation learning model based on each target loss function to iteratively optimize the graph representation learning model. When each target loss function meets the convergence conditions, an optimized graph representation learning model is obtained.

[0150] Each module in the above-mentioned device for optimizing a graph representation learning model may be implemented in whole or in part through software, hardware, or a combination thereof. Each module may be embedded in or independent of a processor in a computer device in the form of hardware, or may be stored in a memory in the computer device in the form of software, so that the processor can call and execute the corresponding operations of each module.

[0151] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 8 As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, abbreviated as I / O) and a communication interface. The processor, memory and input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store optimization data of the graph representation learning model. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a method for optimizing a graph representation learning model is implemented.

[0152] Those skilled in the art will understand that Figure 8 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.

[0153] In one embodiment, a computer device is provided, including a memory and a processor. The memory stores a computer program, and the processor implements the steps in the above method embodiments when executing the computer program.

[0154] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.

[0155] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.

[0156] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions.

[0157] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, database or other media used in the embodiments provided in this application may include at least one of non-volatile and volatile memory. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory may include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in the various embodiments provided herein may include at least one of a relational database and a non-relational database. Non-relational databases may include, but are not limited to, distributed databases based on blockchains. The processor involved in the various embodiments provided herein may be, but are not limited to, a general-purpose processor, a central processing unit, a graphics processing unit, a digital signal processor, a programmable logic unit, a data processing logic unit based on quantum computing, and the like.

[0158] The technical features of the above embodiments can be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0159] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present application. It should be noted that a person of ordinary skill in the art may make various modifications and improvements without departing from the spirit of the present application, and these modifications and improvements fall within the scope of protection of the present application. Therefore, the scope of protection of the present application shall be determined by the appended claims.

Claims

1. A method for optimizing a graph representation learning model, characterized in that: The method comprises: Inputting the first enhanced graph and the second enhanced graph into a graph representation learning model respectively to obtain node vectors of each of the plurality of first nodes in the first enhanced graph and node vectors of each of the plurality of second nodes in the second enhanced graph; the first enhanced graph and the second enhanced graph are obtained by performing data augmentation on the initial graph; Based on each of the node vectors, construct a first loss function corresponding to each of the first nodes; Performing community detection on the node vectors of each of the first nodes to obtain a plurality of community center vectors, and determining a community positive sample and a community negative sample corresponding to each of the first nodes based on the community center vectors; For each of the first nodes, constructing a second loss function corresponding to each of the first nodes according to the node vector of the first node, the community positive sample, and the community negative sample; The first loss function and the second loss function are integrated to construct a target loss function, and the graph representation learning model is iteratively optimized based on the target loss function to obtain an optimized graph representation learning model.

2. The method according to claim 1, characterized in that The constructing, based on each of the node vectors, a first loss function corresponding to each of the first nodes includes: For each first node, matching the first node with each second node respectively to obtain a second node that successfully matches the first node; The node vector of the successfully matched second node is used as a node positive sample of the first node, and the node vectors of each second node, except the node positive sample, are used as node negative samples of the first node; Through node comparative learning, based on the node vector of each first node, the node positive sample and the node negative sample, a first loss function corresponding to each first node is constructed.

3. The method according to claim 2, characterized in that The step of constructing a first loss function corresponding to each first node based on the node vector of each first node, the node positive sample, and the node negative sample through node comparative learning includes: For each of the first nodes, obtaining a node positive similarity measurement value between the node vector of the first node and the node positive sample, and a node negative similarity measurement value between the node vector of the first node and the node negative sample; Through the node comparative learning, a first loss function corresponding to each of the first nodes is constructed based on the positive similarity measurement value of the node and the negative similarity measurement value of the node.

4. The method according to claim 1, wherein The performing community detection on the node vectors of each of the first nodes to obtain a plurality of community center vectors, and determining the community positive samples and community negative samples corresponding to each of the first nodes based on the community center vectors includes: Based on a clustering algorithm, performing community detection on the node vector of each of the first nodes to obtain a plurality of node communities and community center vectors corresponding to each of the node communities, wherein each of the first nodes has a corresponding node community; For each first node, the community center vector of the node community corresponding to the first node is used as a community positive sample of the first node, and other community center vectors except the community positive sample are used as community negative samples of the first node.

5. The method according to claim 1, characterized in that The constructing, for each first node, a second loss function corresponding to each first node according to the node vector of the first node, the community positive sample, and the community negative sample includes: For each of the first nodes, obtaining a community positive similarity measurement value between the node vector of the first node and a community positive sample, and a community negative similarity measurement value between the node vector of the first node and a community negative sample; Through community comparative learning, a second loss function corresponding to each first node is constructed based on the community positive similarity measurement value and the community negative similarity measurement value.

6. The method according to claim 1, wherein The fusing of the first loss function and the second loss function to construct a target loss function, and iteratively optimizing the graph representation learning model based on the target loss function to obtain an optimized graph representation learning model includes: Adding the loss term of the first loss function and the loss term of the second loss function corresponding to the same first node to construct a target loss function corresponding to each first node; Iteratively updating model parameters in the graph representation learning model based on each of the target loss functions to iteratively optimize the graph representation learning model; When all the objective loss functions meet the convergence conditions, an optimized graph representation learning model is obtained.

7. An optimization device for a graph representation learning model, characterized in that: The device comprises: a node vector acquisition module, configured to input the first enhanced graph and the second enhanced graph into a graph representation learning model, respectively, to obtain node vectors for each of the plurality of first nodes in the first enhanced graph and node vectors for each of the plurality of second nodes in the second enhanced graph; the first enhanced graph and the second enhanced graph are obtained by performing data augmentation on the initial graph; A first loss function construction module, configured to construct a first loss function corresponding to each of the first nodes based on the node vectors; a community sample determination module, configured to perform community detection on the node vectors of each of the first nodes to obtain a plurality of community center vectors, and determine a community positive sample and a community negative sample corresponding to each of the first nodes based on the community center vectors; A second loss function construction module is configured to construct, for each of the first nodes, a second loss function corresponding to each of the first nodes according to the node vector of the first node, the community positive sample, and the community negative sample; A model iterative optimization module is used to fuse the first loss function and the second loss function to construct a target loss function, and iteratively optimize the graph representation learning model based on the target loss function to obtain an optimized graph representation learning model.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

10. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.