Model training method and apparatus, and computer-readable storage medium

By introducing a contrastive learning mechanism into the training of graph neural network models, constructing positive and negative sample pairs, and optimizing the training process, the problem of decreased prediction accuracy of graph neural networks after modification of graph topology is solved, thereby improving the stability of the model and the prediction accuracy of downstream tasks.

CN117521769BActive Publication Date: 2026-08-25TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210909712.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-29
Publication Date
2026-08-25
Estimated Expiration
2042-07-29

AI Technical Summary

Technical Problem

Graph neural networks can significantly reduce their prediction accuracy by using subtle modifications to the graph's topology or node features. Existing graph contrastive learning algorithms have failed to effectively distinguish between task-related information and redundant information, resulting in a decrease in the model's prediction accuracy in downstream tasks.

Method used

By introducing a contrastive learning mechanism, positive and negative sample pairs are constructed. By utilizing the property of contrastive learning that "positive samples are similar and negative samples are far apart", the training process of the graph neural network is optimized, the amount of redundant information encoded is reduced, and the stability and prediction accuracy of the model are improved.

Benefits of technology

This improves the robustness of the graph neural network model and the prediction accuracy of downstream tasks, avoids the interference of redundant information on model stability, and ensures the clarity of classification boundaries.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117521769B_ABST
    Figure CN117521769B_ABST
Patent Text Reader

Abstract

The application discloses a model training method and device and a computer readable storage medium. The method comprises the following steps: obtaining graph data, the graph data comprising a plurality of graph nodes, a node label of each graph node, and an edge connecting the graph nodes; performing feature extraction on each graph node by using a graph neural network model to obtain a node feature of each graph node; classifying the plurality of graph nodes according to the node label of each graph node, and calculating a class center feature corresponding to each graph node based on a classification result and the node feature of each graph node; constructing a positive sample pair and a negative sample pair of contrast learning based on the node feature of each graph node and the class center feature corresponding to each graph node; and training the graph neural network model according to a training sample pair constructed by the positive sample pair and the negative sample pair to obtain a trained graph neural network model. The method can improve the stability of the graph neural network model, and thus can improve the prediction accuracy of the graph neural network model applied to a downstream task.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of artificial intelligence technology, specifically to a model training method, apparatus, and computer-readable storage medium. Background Technology

[0002] Artificial intelligence (AI) is the theory, methods, technology, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to achieve optimal results. In other words, AI is a comprehensive technology within computer science that attempts to understand the essence of intelligence and produce a new kind of intelligent machine that can react in a way similar to human intelligence. AI studies the design principles and implementation methods of various intelligent machines, enabling them to possess the functions of perception, reasoning, and decision-making.

[0003] Graph Neural Networks (GNNs) are a class of algorithms that utilize deep learning techniques from artificial intelligence to learn graph-structured data, extract and discover features and patterns within the data, and meet the needs of clustering, classification, prediction, segmentation, and graph generation learning tasks. The inventors of this application discovered that even minor modifications to the graph's topology or nodes can significantly degrade GNN performance. In other words, even small perturbations to the original graph can drastically reduce the prediction accuracy of GNNs. Therefore, a method is urgently needed to improve the robustness of GNNs and ensure their prediction accuracy. Summary of the Invention

[0004] This application provides a model training method, apparatus, and computer-readable storage medium. The method can improve the robustness and prediction accuracy of graph neural network models.

[0005] The first aspect of this application provides a model training method, the method comprising: Obtain graph data, which includes multiple graph nodes, node labels for each graph node, and edges connecting the graph nodes; A graph neural network model is used to extract features from each graph node to obtain the node features of each graph node; The multiple graph nodes are classified according to the node label of each graph node, and the class center feature corresponding to each graph node is calculated based on the classification result and the node features of each graph node. Construct positive and negative sample pairs for contrastive learning based on the node features of each graph node and the class center features corresponding to each graph node. The graph neural network model is trained using training samples constructed from the positive and negative sample pairs to obtain the trained graph neural network model.

[0006] Accordingly, a second aspect of this application provides a model training apparatus, the apparatus comprising: An acquisition unit is used to acquire graph data, which includes multiple graph nodes, node labels for each graph node, and edges connecting the graph nodes. The extraction unit is used to extract features from each graph node using a graph neural network model to obtain the node features of each graph node. The classification unit is used to classify the plurality of graph nodes according to the node label of each graph node, and to calculate the class center feature corresponding to each graph node based on the classification result and the node features of each graph node. The building unit is used to construct positive and negative sample pairs for contrastive learning based on the node features of each graph node and the class center features corresponding to each graph node. The training unit is used to train the graph neural network model based on the training samples constructed from the positive sample pairs and the negative sample pairs, so as to obtain the trained graph neural network model.

[0007] In some embodiments, the extraction unit includes: The first acquisition subunit is used to acquire the edge features of each side in the graph data; The first mapping subunit is used to perform feature mapping on the edge features using a preset neural network model to obtain the correlation coefficient between each edge and the preset task. The first extraction subunit is used to extract features from each graph node using a graph neural network model based on the correlation coefficient between each side and the preset task, so as to obtain the node features of each graph node.

[0008] In some embodiments, obtaining a subunit includes: The acquisition module is used to acquire the initial node features of each graph node; The first calculation module is used to determine the nodes of the associated graph connected to each side, and to calculate the edge features of each side based on the initial node features of the associated graph nodes.

[0009] In some embodiments, the first computing module includes: The acquisition submodule is used to obtain the initial node characteristics of the association between the two association graph nodes connected on each side; The splicing submodule is used to splice the associated initial node features to obtain the edge features of each side.

[0010] In some embodiments, extracting a subunit includes: An update module is used to update the transfer function of the graph neural network model based on the correlation coefficient between each side and the preset task. The extraction module is used to extract features from each graph node using a graph neural network model based on the updated transfer function, thereby obtaining the node features of each graph node.

[0011] In some embodiments, the classification unit includes: The first classification subunit is used to classify the node features based on a preset classifier to obtain the predicted classification label of each graph node. The update subunit is used to update the node label of each graph node based on the predicted classification label; The second classification subunit is used to classify the plurality of graph nodes according to the updated node labels.

[0012] In some embodiments, the building unit includes: The first construction subunit is used to construct a positive sample pair for comparative learning based on the node features of any target graph node and the class center features corresponding to the target graph node. The second construction subunit is used to construct negative sample pairs for contrastive learning based on the node features of any target graph node and other class center features besides the class center features corresponding to the target graph node.

[0013] In some embodiments, the training unit includes: A first determining subunit is configured to determine a first training label for the positive sample pair and a second training label for the negative sample pair. The first calculation subunit is used to calculate the first similarity of the positive sample pairs and the second similarity of the negative sample pairs; The second determining subunit is used to determine the contrast loss based on the first difference between the first training label and the first similarity, and the second difference between the second training label and the second similarity; The training subunit is used to optimize and train the graph neural network model based on the contrastive loss to obtain the trained graph neural network model.

[0014] In some embodiments, the training subunit includes: The second calculation module is used to calculate the classification loss based on the node label and the predicted classification label of each graph node. The determination module is used to determine the target loss based on the classification loss and the contrast loss; The training module is used to optimize and train the graph neural network model based on the target loss to obtain the trained graph neural network model.

[0015] In some embodiments, the computing unit includes: The third determining subunit is used to determine the set of node features for each category of graph nodes; The second calculation subunit is used to calculate the mean of multiple node features in the feature set of each node to obtain the class center feature corresponding to each category. The fourth determination subunit is used to determine the class center feature corresponding to each graph node based on the class center feature corresponding to each category.

[0016] In some embodiments, the model training apparatus provided in this application further includes: The second acquisition subunit is used to acquire graph data to be encoded, the graph data to be encoded including multiple target graph nodes, target node labels of each target graph node, and target edges connecting the target graph nodes; The third acquisition subunit is used to acquire the target edge features of each target edge in the graph data to be encoded. The second mapping subunit is used to perform feature mapping on the target edge features using the preset neural network model to obtain the target correlation coefficient between each target edge and the preset task. The second extraction subunit is used to extract features from each target graph node based on the target relevance coefficient corresponding to each target edge, using the trained graph neural network model, to obtain the target node features of each target graph node.

[0017] A third aspect of this application also provides a computer-readable storage medium storing a plurality of instructions adapted for loading by a processor to execute steps in the model training method provided in the first aspect of this application.

[0018] A fourth aspect of this application provides a computer device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps in the model training method provided in the first aspect of this application.

[0019] The fifth aspect of this application provides a computer program product, including a computer program / instructions, which, when executed by a processor, implement the steps in the model training method provided in the first aspect.

[0020] The model training method provided in this application involves acquiring graph data, which includes multiple graph nodes, node labels for each graph node, and edges connecting the graph nodes; using a graph neural network model to extract features from each graph node to obtain node features; classifying the multiple graph nodes according to their node labels, and calculating the class center features corresponding to each graph node based on the classification results and the node features; constructing positive and negative sample pairs for contrastive learning based on the node features and the corresponding class center features; and training the graph neural network model using the training samples constructed from the positive and negative sample pairs to obtain the trained graph neural network model.

[0021] Therefore, the model training method provided in this application introduces a contrastive learning mechanism when training a graph neural network model. Specifically, it utilizes the property of contrastive learning that "positive samples are similar and negative samples are far apart" to minimize the intra-class distance of encoded features and maximize the inter-class distance, thereby optimizing the training process of the graph neural network. This reduces the amount of redundant information encoded in the graph, resulting in a graph representation with clearer classification boundaries. This avoids the interference of redundant information on the stability of the graph neural network model, improves the stability of the graph neural network model, and ultimately improves the prediction accuracy of the graph neural network model when applied to downstream tasks. Attached Figure Description

[0022] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0023] Figure 1 This is a schematic diagram of a model training scenario in this application; Figure 2 This is a flowchart illustrating the model training method provided in this application; Figure 3 This is another flowchart illustrating the model training method provided in this application; Figures 4 to 7 Several schematic diagrams showing the distribution of graph node features provided in this application in the feature space; Figure 8 This is a schematic diagram of the structure of the model training device provided in this application; Figure 9 This is a schematic diagram of the structure of the computer device provided in this application. Detailed Implementation

[0024] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are within the scope of protection of the present invention.

[0025] This invention provides a model training method, apparatus, computer-readable storage medium, and computer device. The model training method can be used in a model training apparatus. The model training apparatus can be integrated into a computer device, which can be a terminal or a server. The terminal can be a mobile phone, tablet computer, laptop computer, smart TV, wearable smart device, personal computer (PC), or in-vehicle terminal, etc. The server can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, Content Delivery Network (CDN), and big data and artificial intelligence platforms. The server can also be a node in a blockchain.

[0026] Please see Figure 1 This diagram illustrates a scenario of the model training method provided in this application. As shown, server A receives graph data sent by terminal B. The graph data includes multiple graph nodes, node labels for each node, and edges connecting the nodes. Server A uses a graph neural network model to extract features from each graph node, obtaining node features for each node. It then classifies the multiple graph nodes based on their node labels and calculates the class center features corresponding to each node based on the classification results and the node features. Based on the node features and class center features of each graph node, it constructs positive and negative sample pairs for contrastive learning. The graph neural network model is trained using the training samples constructed from the positive and negative sample pairs, resulting in a trained graph neural network model. Server A can then further deploy the trained graph neural network model to terminal B for downstream tasks, such as classification tasks.

[0027] It should be noted that, Figure 1The illustrated model training scenario diagram is merely an example. The model training scenario described in this application is intended to more clearly illustrate the technical solution of this application and does not constitute a limitation on the technical solution provided in this application. Those skilled in the art will understand that, with the evolution of model training scenarios and the emergence of new business scenarios, the technical solution provided in this application is equally applicable to similar technical problems.

[0028] The implementation scenarios described above will be explained in detail below.

[0029] In related technologies, the GNN algorithm suffers from several problems: even minor modifications to the graph's topology or node features can significantly reduce its performance; that is, even small perturbations to the original graph can drastically decrease its prediction accuracy. The inventors of this application discovered that this occurs because GNNs, when generating graph representations, cannot effectively distinguish between task-related information and redundant information. When noise (which can be considered a form of redundancy) is encoded into the graph representation vector, it reduces the model's prediction accuracy. The redundancy problem mainly has two aspects: firstly, the graph data itself contains redundancy; during modeling, the real-world situation is simulated and mapped onto the graph data structure, but real data contains noise, and this redundant information affects the prediction performance of downstream tasks. Secondly, when encoding graph data, the GNN, as an encoder, indiscriminately aggregates surrounding topological information and its own node information, which includes both task-related and redundant information. The presence of redundant information causes the feature distribution ranges of different classes to overlap, making it difficult to find an effective classification boundary to correctly classify nodes.

[0030] Existing graph contrastive learning algorithms also have problems: they are all unsupervised learning methods, lacking specific design for supervised tasks. This leads to some unreasonable aspects during training. For example, in supervised learning, we assume that nodes belonging to the same type should have similar features. However, in graph contrastive learning, we often treat different nodes of the same type as negative sample pairs (corresponding to different nodes in two augmented views), causing their node representations to be far apart in the feature space. This results in a decrease in the prediction accuracy of the learned GNN when applied to downstream tasks. To address this, this application provides a model training method to improve the robustness of GNNs, avoid redundant information affecting model accuracy, and thus improve the performance of GNNs in downstream tasks.

[0031] This application will describe the embodiments from the perspective of a model training device, which can be integrated into a computer device. The computer device can be a terminal or a server. The terminal can be a mobile phone, tablet computer, laptop computer, smart TV, wearable smart device, personal computer (PC), or in-vehicle terminal, etc. The server can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery network (CDN) acceleration services, and big data and artificial intelligence platforms. Figure 2 The diagram shown is a flowchart of the model training method provided in this application. The method includes: Step 101: Obtain graph data, which includes multiple graph nodes, node labels for each graph node, and edges connecting the graph nodes.

[0032] The graph data can be training data obtained from a preset dataset. Graph data includes graph nodes and edges connecting the nodes. Each graph node may also have a corresponding node label. In this embodiment, the node label can be a single label, meaning this application addresses a single-label node classification problem. This reduces the impact of redundant information on the robustness of GNNs in single-label node classification problems.

[0033] Redundant information can be information in the original data that is irrelevant to the prediction task. The specific definition of redundant information varies for different prediction tasks.

[0034] For example, Table 1 shows a student information statistics table.

[0035]

[0036] Table 1 records the raw data for a certain prediction task, including basic information about some students at a certain school, such as name, age, and GPA. (The recording and use of the above information are based on authorization from relevant personnel and in compliance with relevant national laws and regulations.) If our prediction task is "to predict whether a student's grades meet the school's excellent standard," then only the "GPA" column in the raw data is task-relevant; the other information is redundant. Similarly, if our prediction task is "to predict whether a student meets the school's requirements for outstanding female graduates," then only the "gender" and "GPA" attributes are task-relevant. The other data is redundant.

[0037] Step 102: Use a graph neural network model to extract features from each graph node to obtain the node features of each graph node.

[0038] After acquiring the graph data, a graph neural network (GNN) model can be used to extract features from each graph node. This involves encoding the features of the graph nodes in the graph data to obtain the node features of each node. The GNN model can be a pre-trained GNN model or a graph neural network model that is not yet trained. The GNN model can be the aforementioned GNN, or it can be a graph convolutional network (GCN), GraphSAGE, GIN, or GAT model structure, etc. This application uses GNN as an example for illustration.

[0039] In some embodiments, a graph neural network model is used to extract features from the graph data to obtain the node features of each graph node, including: 1. Obtain the edge features of each side in the graph data; 2. Use a pre-defined neural network model to perform feature mapping on the edge features to obtain the correlation coefficient between each edge and the pre-defined task; 3. Based on the correlation coefficient between each side and the preset task, a graph neural network model is used to extract features from each graph node to obtain the node features of each graph node.

[0040] In this embodiment of the application, before encoding the graph nodes in the graph data using a graph neural network model, the graph data itself can be deredundanted to avoid the influence of noise data carried in the graph data on the training of the graph neural network model.

[0041] Specifically, the edge features of each side in the graph data can be obtained first. Then, the features of each side are input into a preset neural network model to perform feature mapping, thereby obtaining the correlation coefficient between each side and the preset task. Here, the preset neural network model can be a pre-trained correlation evaluation model. This model can evaluate the correlation between the graph nodes connected to each side and the preset task, removing nodes with low correlation to the preset task and retaining nodes with high correlation to the preset task, that is, removing redundant data in the graph data.

[0042] After determining the correlation coefficient of each side, we can use a graph neural network model to encode the features of each graph node based on the correlation coefficient of each side, and obtain the node features of each graph node.

[0043] In some embodiments, obtaining the edge features of each side in the graph data includes: 1.1 Obtain the initial node features for each node in the graph; 1.2 Determine the nodes of the associated graph connected to each side, and calculate the edge features of each side based on the initial node features of the associated graph nodes.

[0044] In this embodiment, the edge features of each side in the graph data can be calculated based on the initial node features of each graph node. Specifically, the initial node features of each graph node can be obtained by encoding the relevant attribute data of the graph node. Specifically, the initial node features of each graph node can be obtained by word vector mapping of the relevant attribute data of each graph node.

[0045] After determining the initial node features of each graph node, we can further determine the two specific graph nodes connected to each side, and use the initial node features corresponding to these two graph nodes to calculate the edge features of each side.

[0046] In some embodiments, the association graph nodes connected to each side are determined, and the edge features of each side are calculated based on the initial node features of the association graph nodes, including: 1.2.1 Obtain the initial node characteristics of the two associated graph nodes connected on each side; 1.2.2. Concatenate the features of the initial associated nodes to obtain the edge features of each side.

[0047] In this embodiment of the application, the edge feature can be obtained by concatenating the initial node features of the two graph nodes connected by an edge in the graph data. Specifically, the associated initial node features corresponding to the two graph nodes (here referred to as associated graph nodes) connected by an edge can be determined first, and then the two associated initial node features can be concatenated to obtain the edge feature.

[0048] Specifically, the concatenation of features from two associated initial nodes can be achieved using a pre-defined vector concatenation function.

[0049] In some embodiments, based on the correlation coefficient between each side and the preset task, a graph neural network model is used to extract features from each graph node to obtain the node features of each graph node, including: 3.1 Update the transfer function of the graph neural network model based on the correlation coefficient between each side and the preset task; 3.2 Based on the updated transfer function, a graph neural network model is used to extract features from each graph node to obtain the node features of each graph node.

[0050] In this embodiment, after determining the relevance coefficient of each side, the specific process of encoding graph nodes using a graph neural network based on the relevance coefficient of each side can be as follows: first, update the transfer function of the graph neural network model according to the relevance coefficient of each side corresponding to the preset task. Generally, GNNs directly transfer node features during aggregation encoding. In this embodiment, a relevance coefficient is added during transfer. By assigning a smaller relevance coefficient to edges unrelated to the task, edges are filtered out, thereby mitigating the negative impact of redundant information propagating through irrelevant edges.

[0051] Step 103: Classify multiple graph nodes according to the node label of each graph node, and calculate the class center feature corresponding to each graph node based on the classification results and the node features of each graph node.

[0052] In this embodiment, after determining the graph node features corresponding to each graph node, the graph nodes can be further clustered based on their node labels, and the cluster center features of each cluster can be calculated. Specifically, multiple graph nodes in the graph data can first be classified according to the node labels of each graph node, for example, graph nodes with node labels within a certain range can be grouped into one class. After dividing the graph nodes into multiple classes, the cluster center features of each class can be calculated based on the node features of the graph nodes in each class. Specifically, the cluster center features of a class can be determined based on the mean of the node features of all graph nodes in that class.

[0053] In some embodiments, classifying multiple graph nodes based on the node label of each graph node includes: 1. Classify node features based on a preset classifier to obtain the predicted classification label for each graph node; 2. Update the node labels of each graph node based on the predicted classification labels; 3. Classify multiple graph nodes based on the updated node labels.

[0054] In this embodiment, after encoding the graph nodes in the graph data using a graph neural network model to obtain the node features of each graph node, the node features of each graph node can be further input into a preset classifier for classification to obtain the predicted classification label corresponding to each graph node. This classifier can be a pre-trained classifier. Then, the node label corresponding to each graph node can be updated using the predicted classification label. Specifically, node labels that do not belong to the training set can be replaced with the predicted classification label of the node, thereby avoiding the leakage of node information.

[0055] Then, the updated node labels can be used to classify multiple graph nodes and obtain the classification results.

[0056] In some embodiments, the class center feature corresponding to each graph node is calculated based on the classification result and the node features of each graph node, including: a. Determine the set of node features for each category of graph nodes; b. Calculate the mean of multiple node features in the feature set of each node to obtain the class center feature corresponding to each category; c. Determine the class center feature corresponding to each graph node based on the class center feature corresponding to each category.

[0057] In this embodiment of the application, the class center feature of each class can be obtained by calculating the average value of the node features of all graph nodes in that class.

[0058] Step 104: Construct positive and negative sample pairs for contrastive learning based on the node features of each graph node and the class center features corresponding to each graph node.

[0059] After encoding the node features of each graph node and the cluster center features corresponding to each graph node, positive and negative sample pairs can be constructed based on these node features and cluster center features. Ideally, the node features of the two classes learned by the GNN should be independent in the two-dimensional feature space. However, in practical applications, because GNNs cannot effectively distinguish between task-related information and redundant information when encoding graph data, the presence of redundant information can cause the feature distribution ranges of different classes to overlap, making it difficult to find an effective classification boundary to correctly separate the two feature categories. Therefore, we hope that the encoded graph node features satisfy the following two conditions: minimizing the intra-class distance of the encoded features and maximizing the inter-class distance of the encoded features. That is, we hope that the encoded graph node features of the same class are less distant from their corresponding cluster centers and more distant from the cluster centers of other classes.

[0060] Based on the above objectives, a positive sample pair can be constructed by combining the node features of each graph node with their corresponding class center features, and a negative sample pair can be constructed by combining the node features of each graph node with other class center features. Then, positive sample pairs are placed closer together, and negative sample pairs are placed further apart. This reduces the amount of redundant information encoded, thus clarifying the classification boundaries of the samples and improving the prediction accuracy of downstream tasks.

[0061] That is, constructing positive and negative sample pairs for contrastive learning based on the node features of each graph node and the class center features corresponding to each graph node, including: 1. Construct positive sample pairs for contrastive learning based on the node features of any target graph node and the class center features corresponding to the target graph node; 2. Construct negative sample pairs for contrastive learning based on the node features of any target graph node and other class center features besides the class center features corresponding to the target graph node.

[0062] Step 105: Train the graph neural network model using training samples constructed from positive and negative sample pairs to obtain the trained graph neural network model.

[0063] After constructing positive and negative sample pairs and determining the training objective as making positive sample pairs closer together and negative sample pairs farther apart, the GNN can be trained and optimized based on the constructed positive and negative sample pairs and the training objective.

[0064] In some embodiments, the graph neural network model is trained using training samples constructed from the positive sample pairs and the negative sample pairs to obtain a trained graph neural network model, including: 1. Determine the first training label for positive sample pairs and the second training label for negative sample pairs; 2. Calculate the first similarity of positive sample pairs and the second similarity of negative sample pairs; 3. Determine the contrast loss based on the first difference between the first training label and the first similarity, and the second difference between the second training label and the second similarity; 4. The graph neural network model is optimized and trained based on contrastive loss to obtain the trained graph neural network model.

[0065] As mentioned earlier, the training objective is to ensure positive sample pairs are close together and negative sample pairs are far apart; that is, to achieve higher similarity for positive sample pairs and lower similarity for negative sample pairs. Thus, the label for a positive sample pair is determined to be 1, and the label for a negative sample pair is 0. Furthermore, the similarity between the two samples in each positive and negative sample pair can be calculated separately, i.e., the first similarity of the positive sample pair and the second similarity of the negative sample pair are calculated. Specifically, the similarity calculation of sample pairs involves inputting the sample pairs into a discriminator for processing, obtaining the output similarity score.

[0066] Then, a loss function can be constructed based on the actual similarity of positive and negative sample pairs and the training labels to obtain the contrastive loss function, and then the graph neural network model can be trained based on the contrastive loss function.

[0067] In some embodiments, the graph neural network model is optimized and trained based on contrastive loss to obtain a trained graph neural network model, including: The classification loss is calculated based on the node label and the predicted classification label of each graph node. Determine the target loss based on classification loss and contrastive loss; The graph neural network model is optimized and trained based on the target loss to obtain the trained graph neural network model.

[0068] In order to further improve the accuracy of the trained graph neural network model, the classification loss can be calculated based on the node labels and predicted classification labels of the graph nodes. Then, the target loss is determined based on the classification loss and the contrast loss. Finally, the parameters of the graph neural network model are optimized based on the target loss to obtain the trained graph neural network model.

[0069] As described above, the model training method provided in this application involves acquiring graph data, which includes multiple graph nodes, node labels for each graph node, and edges connecting the graph nodes; using a graph neural network model to extract features from each graph node to obtain node features for each graph node; classifying multiple graph nodes according to the node labels of each graph node, and calculating the class center features corresponding to each graph node based on the classification results and the node features of each graph node; constructing positive and negative sample pairs for contrastive learning based on the node features and the class center features corresponding to each graph node; and training the graph neural network model using the training samples constructed from the positive and negative sample pairs to obtain the trained graph neural network model.

[0070] Therefore, the model training method provided in this application introduces a contrastive learning mechanism when training a graph neural network model. Specifically, it utilizes the property of contrastive learning that "positive samples are similar and negative samples are far apart" to minimize the intra-class distance of encoded features and maximize the inter-class distance, thereby optimizing the training process of the graph neural network. This reduces the amount of redundant information encoded in the graph, resulting in a graph representation with clearer classification boundaries. This avoids the interference of redundant information on the stability of the graph neural network model, improves the stability of the graph neural network model, and ultimately improves the prediction accuracy of the graph neural network model when applied to downstream tasks.

[0071] This application also provides a model training method that can be used in a computer device, which can be a terminal or a server. Figure 3 The diagram shown is another flowchart illustrating the model training method provided in this application. The method specifically includes: Step 201: The computer device acquires the image data.

[0072] In this context, the information obtained by encoding graph data using the trained GNN model represents the "minimum necessary and sufficient" objective for the prediction task, meaning that no redundant information is encoded into the node feature vectors. Since nodes are single-label nodes, there are no confusing samples. Therefore, it is reasonable to assume that the intersection of the feature distribution ranges of graph nodes from any two classes is an empty set, i.e.:

[0073] Where C represents the number of categories.

[0074] Ideally, the node features of the two classes learned by the GNN are disjoint in the two-dimensional feature space, such as... Figure 4 The node features of the first class 10 and the second class 20 shown are mutually exclusive in the two-dimensional feature space. In practical applications, when GNNs are used as encoders to encode graph data, they cannot effectively distinguish between task-related information and redundant information. The presence of redundant information can cause the feature distribution ranges of different classes to overlap. Figure 5 As shown, the node features of the first category 10 and the second category 20 overlap in their distribution range. At this point, it is difficult to find an effective classification boundary to correctly separate the two feature categories.

[0075] To address the issue of overlapping class distribution ranges, we can simultaneously employ two measures to reduce the overlap: First, it allows for a more "compact" distribution of each class, i.e., minimizing the intra-class distance of the encoded features. This is equivalent to minimizing the distance between each feature vector. and its corresponding class center point Distance: Objective 1:

[0076] Specifically, such as Figure 6 As shown, taking the first class 10 as an example, the objective is to minimize the intra-class distance 11 between the distribution of any graph node feature in the feature space and the class center of the class.

[0077] Secondly, it can make the distribution centers of different classes far apart, that is, maximize the inter-class distance of the encoded features. Since the class center point is obtained by averaging the node features, this is equivalent to maximizing the distance between each feature vector. Other class center points Distance: Objective 2:

[0078] Specifically, such as Figure 7 As shown, the objective is to maximize the inter-class distance 12 between the distribution of features of any graph node in the second class 20 in the feature space and the class center of the first class 10.

[0079] Contrastive learning can make the feature distances of positive sample pairs similar and the feature distances of negative sample pairs large. Therefore, we can use contrastive learning to achieve the above two goals by simply constructing positive and negative sample pairs appropriately. The method for training GNNs provided in this application is described in detail below.

[0080] First, obtain the graph data. This graph data can be from any dataset and will be used as training samples for training the GNN. The graph data includes multiple graph nodes, edges connecting the nodes, and node labels for each node. Specifically, the obtained graph data can be represented as follows: Its adjacency matrix .

[0081] Step 202: The computer device determines the edge features of each side based on the initial node features of the graph nodes.

[0082] After acquiring the graph data, the computer device can encode the attribute data of the graph nodes in the graph data to obtain the initial node features of each graph node. The node representation matrix of the l-th layer of the GNN is defined as follows: ,node exist The corresponding eigenvector in is denoted as Assume one edge in the graph is... We can obtain the edge feature input of this edge, denoted as . :

[0083] The concat function is a vector concatenation function, which directly concatenates the input features of the two nodes connected by an edge as the edge input features.

[0084] Step 203: The computer device inputs the edge features of each side into the scoring model for scoring, and obtains the correlation coefficient of each side. Specifically, the scoring model can be a multilayer perceptron (MLP). Specifically, the input layer dimension of this MLP can be... The number of hidden units is The output layer is The three-layer neural network uses the Sigmoid activation function.

[0085] The edge features are input into the scoring model MLP to obtain the task relevance coefficient of each edge, which is denoted here as... :

[0086] Step 204: Based on the correlation coefficient of each side, the computer device uses a graph neural network model to encode the node features of the graph nodes in the graph data, thereby obtaining the node features of each graph node.

[0087] Once the correlation coefficient of each side is determined, a graph neural network can be used to encode the graph nodes in the graph to obtain the node features of the graph nodes.

[0088] Specifically, the transfer function of the GNN can be modified based on the edge features, so that when the GNN aggregates the features of neighboring nodes, it multiplies the features of each neighboring node by the task relevance coefficient of each edge, i.e., for the target node... , and its border entry The transfer function formula for GNN is modified as follows:

[0089] in This refers to the layer number of the GNN. The above formula is equivalent to... Each element in the matrix is ​​multiplied by a correlation coefficient. .

[0090] Then, following the aggregation and update functions of the GNN, it is continuously iterated. Node representation:

[0091]

[0092] Finally, the node feature matrix output by the GNN is denoted as... .

[0093] Step 205: The computer device inputs the node features of each graph node into a preset classifier to obtain the classification prediction result of each graph node.

[0094] Furthermore, the node features can be input into a pre-defined classifier for classification to obtain the classification prediction result for each graph node. Specifically, the node feature matrix can be... Input the data into the classifier to obtain the predicted classification results for the nodes. .

[0095] Step 206: The computer device updates the node labels of the graph nodes based on the classification prediction results of each graph node.

[0096] In order to avoid information leakage, one can utilize... Replace node labels with classification results The node labels of the graph nodes are updated by including the labels of nodes that are not in the training set. Here, a single symbol is used. Let represent the set of tags we reconstructed, where: .

[0097] Step 207: The computer device classifies the graph nodes according to the updated node labels and calculates the class center features of each category based on the node features of each graph node.

[0098] Furthermore, the computer device can classify the graph nodes based on the updated node labels. Then, the node feature matrix is ​​used. Calculate the class center feature vector for each class. , From all belonging to the category The average value of the node features is obtained as follows:

[0099] Step 208: The computer device constructs positive sample pairs using node features and the class center features corresponding to the node itself, and constructs negative sample pairs using node features and class center features other than the class center features corresponding to the node.

[0100] Then, the aforementioned positive and negative sample pairs can be constructed based on the node features of each graph node and its corresponding class center features. Specifically, positive sample pairs are constructed using graph node features and the class center features of their respective categories, and negative sample pairs are constructed using graph node features and the class center features of other categories.

[0101] Record by node Node features The constructed positive sample pairs are Let the negative sample pairs constructed be denoted as . Then the following formula is defined: ,

[0102] Step 209: The computer device inputs positive and negative sample pairs into the discriminator to obtain the similarity value of each sample pair, and calculates the comparison loss based on the similarity value and the preset label.

[0103] The positive and negative sample pairs are then input into the discriminator, which is equivalent to performing a bilinear transformation on the vectors in the sample pair and outputting a similarity score. Here, the discriminator is denoted as... For example, the formula for calculating positive sample pairs is as follows:

[0104] in, It is a learnable parameter matrix. This is a non-linear sigmoid activation function. The discriminator scores the similarity of input sample pairs. The higher the similarity of the sample pairs, the closer the discriminator's output value is to 1; the lower the similarity of the sample pairs, the closer the discriminator's output value is to 0. The objective is: , .

[0105] Based on the above objectives, the contrastive loss can be viewed as a binary classification problem, where positive samples are labeled 1 and negative samples are labeled 0. Therefore, the contrastive loss function can be defined. : .

[0106] Step 210: The computer device calculates the classification loss based on the classification prediction result and node label of each graph node.

[0107] Furthermore, to improve the accuracy of the GNN model, classification loss can be considered, which can be calculated from the classification prediction result of each graph node and the node label: .

[0108] Among them, superscript represent It is a node The label vector.

[0109] Step 211: The computer device calculates the final loss based on the classification loss and contrast loss, and trains the graph neural network model based on the final loss to obtain the trained graph neural network model.

[0110] Furthermore, the classification loss and the weighted average of the losses can be used to determine the final loss function, and the GNN model can be optimized and trained based on the final loss function. Thus, the overall optimization objective can be determined as:

[0111] in, It will increase with the number of training epochs. As the classification loss converges, the features of different classes of samples become increasingly distinctive. Only when the sample features are distinctive can the distribution ranges of different classes be effectively distinguished, thus making the contrastive loss meaningful. Define an initial value. Let the total number of training epochs be epoch_total, and the current training epoch be epoch, then... The value can be represented as follows: .

[0112] The following is a brief introduction to the actual performance of the graph neural network model trained by the model training method provided in this application on several datasets in the node classification task: Table 2 shows an example table of basic cases for several datasets.

[0113]

[0114] The comparative experiments primarily compare the prediction accuracy of graph neural networks and graph contrastive learning methods on three datasets. The graph neural network models used for comparison include GCN, GraphSAGE, GAT, and GIN; the graph contrastive learning methods used include DGI, GraphCL, and GCA. It should be noted that general graph contrastive learning refers to unsupervised learning, where training typically involves two independent stages: the first stage optimizes the contrastive loss, essentially pre-training the model; the second stage optimizes the classification loss for the downstream task's classifier. However, since this application addresses supervised learning, for fairness, the graph contrastive learning models (GraphCL, DGI, GCA) mentioned in this experiment all employ a joint training mode, simultaneously optimizing both the contrastive and classification losses to ensure the participation of supervisory signals during training.

[0115] The method proposed in this paper is a graph representation learning algorithm based on minimum redundancy contrastive learning (hereinafter referred to as Graph Representation Learning). The subscript GNN represents the specific implementation of the basic graph neural network in the algorithm.

[0116] Table 3 shows a schematic diagram of the comparative experimental results.

[0117]

[0118] As can be seen from the data in the table, the model trained by the model training method provided in this application can achieve better prediction accuracy in related downstream tasks compared with the baseline model.

[0119] As described above, the model training method provided in this application involves acquiring graph data, which includes multiple graph nodes, node labels for each graph node, and edges connecting the graph nodes; using a graph neural network model to extract features from each graph node to obtain node features for each graph node; classifying multiple graph nodes according to the node labels of each graph node, and calculating the class center features corresponding to each graph node based on the classification results and the node features of each graph node; constructing positive and negative sample pairs for contrastive learning based on the node features and the class center features corresponding to each graph node; and training the graph neural network model using the training samples constructed from the positive and negative sample pairs to obtain the trained graph neural network model.

[0120] Therefore, the model training method provided in this application introduces a contrastive learning mechanism when training a graph neural network model. Specifically, it utilizes the property of contrastive learning that "positive samples are similar and negative samples are far apart" to minimize the intra-class distance of encoded features and maximize the inter-class distance, thereby optimizing the training process of the graph neural network. This reduces the amount of redundant information encoded in the graph, resulting in a graph representation with clearer classification boundaries. This avoids the interference of redundant information on the stability of the graph neural network model, improves the stability of the graph neural network model, and ultimately improves the prediction accuracy of the graph neural network model when applied to downstream tasks.

[0121] To better implement the above model training methods, this application also provides a model training device that can be integrated into a terminal or server.

[0122] For example, such as Figure 8 The diagram shown is a schematic representation of the structure of a model training device provided in an embodiment of this application. The model training device may include an acquisition unit 301, an extraction unit 302, a classification unit 303, a construction unit 304, and a training unit 305, as follows: The acquisition unit 301 is used to acquire graph data, which includes multiple graph nodes, node labels of each graph node, and edges connecting the graph nodes. The extraction unit 302 is used to extract features from each graph node using a graph neural network model to obtain the node features of each graph node. The classification unit 303 is used to classify multiple graph nodes according to the node label of each graph node, and calculate the class center feature corresponding to each graph node based on the classification result and the node features of each graph node. The construction unit 304 is used to construct positive and negative sample pairs for contrastive learning based on the node features of each graph node and the class center features corresponding to each graph node. Training unit 305 is used to train the graph neural network model based on training samples constructed from positive and negative sample pairs to obtain the trained graph neural network model.

[0123] In some embodiments, the extraction unit includes: Obtain sub-units to retrieve edge features of each side in the graph data; The mapping subunit is used to perform feature mapping on the edge features using a preset neural network model to obtain the correlation coefficient between each edge and the preset task. Extract sub-units, which are used to extract features from each graph node based on the correlation coefficient between each side and the preset task, using a graph neural network model to obtain the node features of each graph node.

[0124] In some embodiments, obtaining a subunit includes: The acquisition module is used to acquire the initial node features of each graph node; The first calculation module is used to determine the nodes of the associated graph connected to each side, and to calculate the edge features of each side based on the initial node features of the associated graph nodes.

[0125] In some embodiments, the first computing module includes: The acquisition submodule is used to obtain the initial node characteristics of the association between the two association graph nodes connected on each side; The splicing submodule is used to splice the features of the associated initial nodes to obtain the edge features of each side.

[0126] In some embodiments, extracting a subunit includes: The update module is used to update the transfer function of the graph neural network model based on the correlation coefficient between each side and the preset task. The extraction module is used to extract features from each graph node using a graph neural network model based on the updated transfer function, thereby obtaining the node features of each graph node.

[0127] In some embodiments, the classification unit includes: The first classification subunit is used to classify node features based on a preset classifier to obtain the predicted classification label of each graph node. The update subunit is used to update the node labels of each graph node based on the predicted classification labels; The second classification subunit is used to classify multiple graph nodes based on the updated node labels.

[0128] In some embodiments, the building unit includes: The first construction subunit is used to construct positive sample pairs for contrastive learning based on the node features of any target graph node and the class center features corresponding to the target graph node. The second construction subunit is used to construct negative sample pairs for contrastive learning based on the node features of any target graph node and other class center features besides the class center features corresponding to the target graph node.

[0129] In some embodiments, the training unit includes: The first determining subunit is used to determine the first training label of positive sample pairs and the second training label of negative sample pairs; The first calculation subunit is used to calculate the first similarity of positive sample pairs and the second similarity of negative sample pairs; The second determining subunit is used to determine the contrast loss based on the first difference between the first training label and the first similarity, and the second difference between the second training label and the second similarity; The training subunit is used to optimize the training of the graph neural network model based on contrastive loss, resulting in the trained graph neural network model.

[0130] In some embodiments, the training subunit includes: The second calculation module is used to calculate the classification loss based on the node label and the predicted classification label of each graph node. The determination module is used to determine the target loss based on classification loss and contrastive loss; The training module is used to optimize and train the graph neural network model based on the target loss, so as to obtain the trained graph neural network model.

[0131] In some embodiments, the computing unit includes: The third determining subunit is used to determine the set of node features for each category of graph nodes; The second calculation subunit is used to calculate the mean of multiple node features in the feature set of each node to obtain the class center feature corresponding to each category. The fourth determination subunit is used to determine the class center feature corresponding to each graph node based on the class center feature corresponding to each category.

[0132] In some embodiments, the model training apparatus provided in this application further includes: The second acquisition subunit is used to acquire graph data to be encoded, which includes multiple target graph nodes, target node labels for each target graph node, and target edges connecting the target graph nodes. The third acquisition subunit is used to acquire the target edge features of each target edge in the graph data to be encoded. The second mapping subunit is used to perform feature mapping on the target edge features using a preset neural network model to obtain the target correlation coefficient between each target edge and the preset task. The second extraction subunit is used to extract features from each target graph node based on the target relevance coefficient corresponding to each target edge, using a trained graph neural network model to obtain the target node features of each target graph node.

[0133] In practice, each of the above units can be implemented as an independent entity or can be arbitrarily combined to be implemented as the same or several entities. For the specific implementation of each of the above units, please refer to the previous method embodiments, which will not be repeated here.

[0134] As described above, the model training apparatus provided in this application embodiment acquires graph data through an acquisition unit 301. The graph data includes multiple graph nodes, node labels for each graph node, and edges connecting the graph nodes. An extraction unit 302 uses a graph neural network model to extract features from each graph node, obtaining node features for each graph node. A classification unit 303 classifies multiple graph nodes according to the node labels of each graph node, and calculates the class center features corresponding to each graph node based on the classification results and the node features of each graph node. A construction unit 304 constructs positive and negative sample pairs for contrastive learning based on the node features of each graph node and the class center features corresponding to each graph node. A training unit 305 trains the graph neural network model based on the training samples constructed from the positive and negative sample pairs, obtaining the trained graph neural network model.

[0135] Therefore, the model training method provided in this application introduces a contrastive learning mechanism when training a graph neural network model. Specifically, it utilizes the property of contrastive learning that "positive samples are similar and negative samples are far apart" to minimize the intra-class distance of encoded features and maximize the inter-class distance, thereby optimizing the training process of the graph neural network. This reduces the amount of redundant information encoded in the graph, resulting in a graph representation with clearer classification boundaries. This avoids the interference of redundant information on the stability of the graph neural network model, improves the stability of the graph neural network model, and ultimately improves the prediction accuracy of the graph neural network model when applied to downstream tasks.

[0136] This application also provides a computer device, which can be a terminal or a server, such as... Figure 9 The diagram shown is a structural schematic of the computer device provided in this application. Specifically: The computer device may include components such as a processing unit 401 with one or more processing cores, a storage unit 402 with one or more storage media, a power module 403, and an input module 404. Those skilled in the art will understand that... Figure 9 The computer device structure shown does not constitute a limitation on the computer device and may include more or fewer components than shown, or combine certain components, or have different component arrangements. Wherein: The processing unit 401 is the control center of the computer device. It connects various parts of the computer device via various interfaces and lines, and performs various functions and processes data by running or executing software programs and / or modules stored in the storage unit 402, and by calling data stored in the storage unit 402. Optionally, the processing unit 401 may include one or more processing cores; preferably, the processing unit 401 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the modem processor mainly handles wireless communication. It is understood that the modem processor may not be integrated into the processing unit 401.

[0137] Storage unit 402 can be used to store software programs and modules. Processing unit 401 executes various functional applications and data processing by running the software programs and modules stored in storage unit 402. Storage unit 402 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback, image playback, and web page access), etc.; the data storage area may store data created based on the use of the computer device. In addition, storage unit 402 may include high-speed random access memory and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, storage unit 402 may also include a memory controller to provide processing unit 401 with access to storage unit 402.

[0138] The computer equipment also includes a power supply module 403 that supplies power to various components. Preferably, the power supply module 403 can be logically connected to the processing unit 401 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system. The power supply module 403 may also include one or more DC or AC power supplies, recharging systems, power fault detection circuits, power converters or inverters, power status indicators, and other arbitrary components.

[0139] The computer device may also include an input module 404, which can be used to receive input numeric or character information and generate keyboard, mouse, joystick, optical or trackball signal inputs related to object settings and function control.

[0140] Although not shown, the computer device may also include a display unit, etc., which will not be described in detail here. Specifically, in this embodiment, the processing unit 401 in the computer device loads the executable files corresponding to the processes of one or more applications into the storage unit 402 according to the following instructions, and the processing unit 401 runs the applications stored in the storage unit 402 to realize various functions, as follows: Acquire graph data, which includes multiple graph nodes, node labels for each node, and edges connecting the nodes. Use a graph neural network model to extract features from each graph node, obtaining its node features. Classify the multiple graph nodes based on their node labels, and calculate the class center features for each node based on the classification results and its corresponding node features. Construct positive and negative sample pairs for contrastive learning based on the node features and their corresponding class center features. Train the graph neural network model using the training samples constructed from the positive and negative sample pairs, obtaining the trained graph neural network model.

[0141] It should be noted that the computer device provided in this application embodiment and the method in the above embodiment belong to the same concept. The specific implementation of each of the above operations can be found in the previous embodiments, and will not be repeated here.

[0142] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be performed by instructions, or by instructions controlling related hardware. These instructions can be stored in a computer-readable storage medium and loaded and executed by a processor.

[0143] Therefore, embodiments of the present invention provide a computer-readable storage medium storing a plurality of instructions that can be loaded by a processor to execute steps in any of the methods provided in the embodiments of the present invention. For example, the instructions can execute the following steps: Acquire graph data, which includes multiple graph nodes, node labels for each node, and edges connecting the nodes. Use a graph neural network model to extract features from each graph node, obtaining its node features. Classify the multiple graph nodes based on their node labels, and calculate the class center features for each node based on the classification results and its corresponding node features. Construct positive and negative sample pairs for contrastive learning based on the node features and their corresponding class center features. Train the graph neural network model using the training samples constructed from the positive and negative sample pairs, obtaining the trained graph neural network model.

[0144] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.

[0145] The computer-readable storage medium may include: read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.

[0146] Since the instructions stored in the computer-readable storage medium can execute the steps of any of the methods provided in the embodiments of the present invention, the beneficial effects that any of the methods provided in the embodiments of the present invention can achieve can be realized, as detailed in the preceding embodiments, and will not be repeated here.

[0147] According to one aspect of this application, a computer program product or computer program is provided, comprising computer instructions stored in a storage medium. A processor of a computer device reads the computer instructions from the storage medium and executes the computer instructions, causing the computer device to perform the methods provided in various optional implementations of the above-described model training method.

[0148] The model training method, apparatus, and computer-readable storage medium provided in the embodiments of the present invention have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, those skilled in the art will recognize that there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.

Claims

1. A model training method, characterized in that, The method includes: Obtain graph data, which includes multiple graph nodes, node labels for each graph node, and edges connecting the graph nodes; A graph neural network model is used to extract features from each graph node to obtain the node features of each graph node; The multiple graph nodes are classified according to the node label of each graph node, and the class center feature corresponding to each graph node is calculated based on the classification result and the node features of each graph node. Positive and negative sample pairs for contrastive learning are constructed based on the node features of each graph node and the class center features corresponding to each graph node. Positive sample pairs for contrastive learning are constructed based on the node features of any target graph node and the class center features corresponding to the target graph node. Negative sample pairs for contrastive learning are constructed based on the node features of any target graph node and other class center features besides the class center features corresponding to the target graph node. The graph neural network model is trained using training samples constructed from the positive and negative sample pairs to obtain the trained graph neural network model. The process includes: determining a first training label for the positive sample pairs and a second training label for the negative sample pairs; calculating a first similarity for the positive sample pairs and a second similarity for the negative sample pairs; determining a contrastive loss based on a first difference between the first training label and the first similarity, and a second difference between the second training label and the second similarity; calculating a classification loss based on the node label and the predicted classification label of each graph node; weighting the classification loss and the contrastive loss to determine a target loss, wherein the weight of the contrastive loss increases with the number of training iterations; and optimizing the graph neural network model based on the target loss to obtain the trained graph neural network model. The student's information is input into the trained graph neural network model, and the model outputs a prediction result of whether the student's performance meets the excellent standard. The student information includes name, age, and average GPA.

2. The method according to claim 1, characterized in that, The step of using a graph neural network model to extract features from the graph data to obtain the node features of each graph node includes: Obtain the edge features of each side in the graph data; A preset neural network model is used to perform feature mapping on the edge features to obtain the correlation coefficient between each edge and the preset task; Based on the correlation coefficient between each side and the preset task, a graph neural network model is used to extract features from each graph node to obtain the node features of each graph node.

3. The method according to claim 2, characterized in that, The step of obtaining the edge features of each side in the graph data includes: Obtain the initial node features for each node in the graph; Determine the nodes of the associated graph connected to each side, and calculate the edge features of each side based on the initial node features of the associated graph nodes.

4. The method according to claim 3, characterized in that, The process of determining the nodes of the associated graph connected to each side and calculating the edge features of each side based on the initial node features of the associated graph nodes includes: Obtain the initial node characteristics of the two associated graph nodes connected on each side; The features of the associated initial nodes are concatenated to obtain the edge features of each side.

5. The method according to claim 2, characterized in that, Based on the correlation coefficient between each side and the preset task, a graph neural network model is used to extract features from each graph node to obtain the node features of each graph node, including: The transfer function of the graph neural network model is updated based on the correlation coefficient between each side and the preset task. Based on the updated transfer function, a graph neural network model is used to extract features from each graph node, thus obtaining the node features of each graph node.

6. The method according to any one of claims 1 to 5, characterized in that, The classification of the plurality of graph nodes based on the node label of each graph node includes: The node features are classified based on a preset classifier to obtain the predicted classification label for each graph node. The node labels of each graph node are updated based on the predicted classification labels; The multiple graph nodes are classified according to the updated node labels.

7. The method according to claim 1, characterized in that, The calculation of the class center features corresponding to each graph node based on the classification results and the node features of each graph node includes: Determine the set of node features for each category of graph nodes; Calculate the mean of multiple node features in the feature set of each node to obtain the class center feature corresponding to each category; The class center feature corresponding to each graph node is determined based on the class center feature corresponding to each category.

8. The method according to claim 1, characterized in that, After training the graph neural network model using training samples constructed from the positive and negative sample pairs to obtain the trained graph neural network model, the method further includes: Obtain graph data to be encoded, which includes multiple target graph nodes, target node labels for each target graph node, and target edges connecting the target graph nodes; Obtain the target edge features of each target edge in the graph data to be encoded; A preset neural network model is used to perform feature mapping on the target edge features to obtain the target correlation coefficient between each target edge and the preset task; Based on the target relevance coefficient corresponding to each target edge, the trained graph neural network model is used to extract features from each target graph node to obtain the target node features of each target graph node.

9. A model training device, characterized in that, The device includes: An acquisition unit is used to acquire graph data, which includes multiple graph nodes, node labels for each graph node, and edges connecting the graph nodes. The extraction unit is used to extract features from each graph node using a graph neural network model to obtain the node features of each graph node. The classification unit is used to classify the plurality of graph nodes according to the node label of each graph node, and to calculate the class center feature corresponding to each graph node based on the classification result and the node features of each graph node. A construction unit is configured to construct positive and negative sample pairs for contrastive learning based on the node features of each graph node and the class center features corresponding to each graph node. The construction unit includes a first construction subunit and a second construction subunit. The first construction subunit is configured to: construct positive sample pairs for contrastive learning based on the node features of any target graph node and the class center features corresponding to the target graph node; the second construction subunit is configured to: construct negative sample pairs for contrastive learning based on the node features of any target graph node and other class center features besides the class center features corresponding to the target graph node. A training unit is used to train the graph neural network model based on training samples constructed from the positive sample pairs and the negative sample pairs to obtain a trained graph neural network model. The training unit includes a first determining subunit, a first calculating subunit, a second determining subunit, and a training subunit. The first determining subunit is used to: determine a first training label for the positive sample pairs and a second training label for the negative sample pairs. The first calculating subunit is used to: calculate a first similarity for the positive sample pairs and a second similarity for the negative sample pairs. The second determining subunit is used to: calculate a first difference between the first training label and the first similarity, and a second similarity between the second training label and the second similarity. The second difference in degree determines the contrast loss; the training subunit includes a second calculation module, a determination module, and a training module. The second calculation module is used to calculate the classification loss based on the node label and the predicted classification label of each graph node; the determination module is used to determine the target loss by weighting the classification loss and the contrast loss, wherein the weight of the contrast loss increases with the increase of the training rounds; the training module is used to optimize and train the graph neural network model based on the target loss to obtain the trained graph neural network model. The graph neural network model is used to input student information and output a prediction result of whether the student's performance meets the excellent standard. The student information includes name, age, and average GPA.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a plurality of instructions adapted for loading by a processor to perform the steps of the model training method according to any one of claims 1 to 8.

11. A computer device, characterized in that, It includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the model training method according to any one of claims 1 to 8.

12. A computer program product comprising a computer program / instructions, characterized in that, When the computer program / instructions are executed by the processor, they implement the steps in the model training method according to any one of claims 1 to 8.