Node classification method and system based on graph neural network, and related equipment
By predicting the category distribution of multiple neighbor nodes in the graph neural network, sampling and obtaining sampling nodes, and predicting their characteristics with the feature input model of the node to be detected, the problem of poor prediction effect in the graph neural network is solved, and higher computing efficiency and prediction accuracy are achieved.
Patent Information
- Application Number
- CN202311130100.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-31
- Publication Date
- 2025-02-28
AI Technical Summary
The poor prediction effect of the central node in the graph neural network is mainly due to the high computational complexity and low prediction accuracy, which makes it difficult to meet the application requirements.
By predicting the category distribution of multiple neighbor nodes, sampling and obtaining multiple sampling nodes, finally input the characteristics of the sampling node and the characteristics of the node to be detected into the node classification model to make prediction category prediction.
This reduces the computational complexity, improves the prediction accuracy, and avoids the problem of poor prediction effect of the model in a few categories caused by sample imbalance.
Smart Images

Figure CN119538017A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computers, and in particular to a node classification method, system and related equipment based on graph neural network. Background Art
[0002] A graph neural network (GNN) is a neural network used to process graph data. Traditional neural networks can process data in the form of vectors or matrices, while GNN is specifically used to process graph data with complex relationships. Graph data usually includes multiple nodes and edges. Nodes represent individuals or entities in the graph, such as users, etc. Each node has its own characteristics, such as the user's name. The edges between nodes represent the relationship between nodes, such as friend relationships. Edges can contain weights or labels to indicate the strength or type of relationships. A graph neural network obtains aggregate features by aggregating the features of the central node itself and the features of neighboring nodes, and then uses the aggregate features to participate in the training of the neural network. The trained model can predict the category of the node to be detected based on the input graph data of the node to be detected.
[0003] However, a central node in a graph neural network may have many neighboring nodes. If the features of all neighboring nodes are aggregated with the features of the central node, the computational complexity is very high and the prediction accuracy is low, which is difficult to meet application requirements. Summary of the invention
[0004] The present application provides a node classification method, system and related equipment based on graph neural network, which are used to solve the problem of poor prediction effect of graph neural network.
[0005] In a first aspect, a node classification method is provided, which includes the following steps: first, obtaining graph data and inference sampling parameters of a node to be detected, wherein the graph data includes the node to be detected and multiple neighbor nodes connected to the node to be detected; second, inputting the graph data into a node classification model to obtain a category distribution of multiple neighbor nodes; then, based on the inference sampling parameters and the category distribution of multiple neighbor nodes, sampling the multiple neighbor nodes to obtain multiple sampling nodes; finally, inputting features of the multiple sampling nodes and features of the node to be detected into the node classification model to obtain a predicted category of the node to be detected.
[0006] The method described in the first aspect is implemented by first predicting the category distribution of multiple neighbor nodes in the graph data, then using the category distribution to sample multiple neighbor nodes to obtain multiple sampling nodes, and then predicting the predicted category of the node to be detected based on the characteristics of the sampling nodes, thereby reducing the computational complexity. At the same time, the sampling distribution of the sampling nodes is obtained based on the prediction results of multiple neighbor nodes, rather than based on the labels of a small number of labeled neighbor nodes, so that the sampling nodes can obtain the characteristics of more neighbor nodes, thereby improving the prediction accuracy.
[0007] In a possible implementation manner, the similarity between the category distribution of the plurality of sampling nodes and the category distribution of the plurality of neighboring nodes is higher than a first threshold.
[0008] In the above implementation, when sampling multiple neighbor nodes, the sampling distribution is the same as or similar to the category distribution of the multiple neighbor nodes. In this way, the features of the sampled nodes obtained by sampling can not only summarize the features of all neighbor nodes, but also avoid the problem of poor prediction effect of the model on a minority category due to sample imbalance.
[0009] In one possible implementation, the nodes to be detected include labeled nodes and unlabeled nodes, and the category distribution of multiple neighbor nodes is obtained based on the labels of the labeled nodes and the prediction results of the unlabeled nodes. The prediction results of the unlabeled nodes are obtained after inputting the graph data into the node classification model.
[0010] In the above implementation method, the category distribution of neighbor nodes used in this application is obtained based on the labels of labeled neighbor nodes and the predicted results of unlabeled neighbor nodes. The prior art will input the node classification model based on the feature input of labeled neighbor nodes and the feature input of the node to be detected. There is a gap between the category distribution of labeled neighbor nodes and the category distribution of real neighbor nodes, because not every neighbor node has a label. The present application obtains the category distribution of multiple neighbor nodes through prediction, so that each neighbor node has a labeled classification or a predicted classification. Therefore, the predicted category distribution will be closer to the real distribution than the category distribution of labeled neighbor nodes, and the category distribution of the sampling nodes obtained by sampling will also be closer to the real distribution. Using sampling nodes close to the real distribution for reasoning can not only reduce the amount of calculation and improve the reasoning efficiency, but also obtain more accurate results and improve the prediction effect.
[0011] In one possible implementation, the inference sampling parameters include the number of sampling nodes, that is, the total number of neighbor nodes that need to be sampled. Based on the total number and the category distribution of the neighbor nodes, the number of sampling nodes of each category sampled can be determined, so that the category distribution of the sampling nodes finally obtained is similar to or consistent with the category distribution of the neighbor nodes.
[0012] Optionally, the inference sampling parameters include the number of sampling layers, and the number of sampling layers is used to perform stratified sampling on multiple neighbor nodes according to the category distribution of multiple neighbor nodes to obtain multiple sampling nodes, wherein each sampling layer includes multiple sampling nodes of the same category, and each category of sampling nodes corresponds to one or more sampling layers. In a specific implementation, after obtaining the category distribution of multiple neighbor nodes, the multiple neighbor nodes can be divided into multiple levels according to the number of sampling layers, and the nodes in each level are of the same category. Then, stratified sampling is performed in different sampling layers, so that the category distribution of the multiple sampling nodes obtained after sampling is similar or consistent with the category distribution of the multiple neighbor nodes. Different stratified sampling methods can be used according to needs, such as equidistant stratified sampling, geometric stratified sampling, etc., which are not specifically limited in this application.
[0013] It should be noted that the number of sampling layers input by the user can be the same as or different from the number of categories of neighbor nodes. In other words, the same category can be divided into one level or multiple levels. For example, if the neighbor nodes have 5 categories and the user sets the number of sampling layers to 10, then the neighbor nodes of one category are divided into 2 levels. This application does not make specific limitations.
[0014] In the above implementation, users can flexibly set the number of samples or sampling parameters according to business needs, so that the solution provided by this application can be flexibly adapted to various application scenarios. At the same time, the number of neighbor nodes in certain categories may be significantly less than that in other categories. By dividing a category into multiple levels and sampling in each level, the impact of the classification imbalance problem of neighbor nodes on model training can be reduced. By extracting neighbor nodes from the same category in multiple different levels, the sampled neighbor nodes can better represent the characteristics of the entire category and better cover the different characteristics and change trends of the category. The model trained using such sampling nodes can better adapt to changes in each level when processing new unseen samples, thereby making the trained model have stronger generalization capabilities.
[0015] In one possible implementation, the inference sampling parameters include the number of samplings, which is used to perform multiple samplings on multiple neighbor nodes. The multiple collection nodes include multiple collection node sets, and one collection node set corresponds to one sampling. The predicted category of the node to be detected is obtained based on multiple prediction results, and one prediction result is obtained by inputting a sampling node set into a node classification model.
[0016] In a specific implementation, the prediction category of the node to be detected can be determined based on multiple prediction results through voting strategies such as majority voting, weighted voting, probability fusion, and voting threshold, wherein majority voting refers to voting based on the prediction results, and the category with the most votes is determined as the prediction category of the node to be detected; weighted voting refers to assigning a weight to each prediction result, calculating the average value based on the weight to obtain the final prediction result, and determining the prediction category of the node to be detected based on the final prediction result; probability fusion can calculate the average probability or the maximum probability of the probability value corresponding to each prediction result to obtain the fusion probability, and then determine the prediction category of the node to be detected based on the fusion probability; voting threshold refers to setting a threshold, and when the number of votes for the category with the most votes exceeds the threshold, the category can be confirmed as the prediction category of the node to be detected. It should be understood that the above examples are for illustration, and this application does not limit the voting strategies.
[0017] In the above implementation, multiple neighbor nodes are sampled multiple times according to the sampling times input by the user to obtain multiple prediction results, and then the final prediction category is obtained by voting. The sampling node sets obtained by sampling different times may have the same or different neighbor nodes, thereby ensuring to the greatest extent that the characteristics of each neighbor node can participate in the reasoning of the model and improve the prediction accuracy of the model.
[0018] In one possible implementation, before obtaining the graph data and inference sampling parameters of the node to be detected, the method also includes the following steps: obtaining a graph data sample and training parameters of the central node, the graph data sample includes the central node and multiple neighbor node samples connected to the central node, the training sampling parameters include the number of sampling nodes or the number of sampling layers, the graph data of the node to be detected and the graph data sample of the central node are different subgraphs in the same graph, the graph data sample is input into the initial model, and the category distribution of multiple neighbor node samples is obtained, and according to the training sampling parameters and the category distribution of the neighbor node samples, the multiple neighbor node samples are sampled to obtain multiple sampling node samples, the similarity between the category distribution of the multiple sampling nodes and the category distribution of the multiple neighbor nodes is higher than a second threshold, and the features of the multiple sampling node samples and the features of the central node are input into the initial model for training to obtain a node classification model.
[0019] In the above implementation, when training the node classification model, multiple neighbor node samples are first predicted to obtain the category distribution of multiple neighbor node samples, and such category distribution is closer to the real distribution. It should be understood that the number of labeled neighbor nodes in the graph data sample is limited, and many neighbor node samples are not labeled, so there is a certain gap between the data distribution of labeled neighbor nodes and the data distribution of potential real neighbor nodes. This application is based on the prediction results of neighbor node samples combined with the data distribution determined by the labels of labeled neighbor node samples, which is more in line with the real distribution. Then, the neighbor node samples are sampled according to such data distribution. The obtained sampled node samples can not only summarize the characteristics of the neighbor node samples, but also this feature is a feature that fits the characteristics of the potential real distribution. Using such sampled node samples to participate in model training can not only reduce the computational complexity, but also improve the model performance.
[0020] In a possible implementation, the generation time of the samples of the multiple sampling nodes is earlier than the generation time of the central node.
[0021] In a specific implementation, each node in the graph data sample has corresponding feature information, and the generation time can be a certain feature of the neighbor node sample and the central node. The definition of generation time is different in different scenarios. For example, in the graph data sample of the transaction network in the above example, each node represents a transaction, so the generation time can be the transaction time, and the transaction time of the transaction corresponding to the neighbor node sample in the subgraph sample is earlier than the transaction time of the transaction corresponding to the central node. For another example, in the graph data sample of a social network, each node represents a social media account, and the generation time can be the creation time of the account, so the creation time of the account corresponding to the neighbor node sample in the subgraph sample is earlier than the creation time of the account corresponding to the central node. The above examples are for illustration only and are not specifically limited in this application.
[0022] In the above implementation, when training the node classification model, the sample generation time of the sampling nodes participating in the training is the generation time of the node to be detected. This is because the future neighbor nodes cannot participate in the reasoning in the actual reasoning process. Therefore, in the model training process, the neighbor node samples whose generation time is earlier than the central node are also used to participate in the model training. This can make the multiple neighbor node samples in the sub-graph samples more consistent with the actual distribution. Model training based on the sub-graph samples can improve the accuracy of the trained model in the reasoning stage.
[0023] In one possible implementation, the feature vectors of the sampling node samples and the feature vector of the central node can be obtained first, and then the feature aggregation of multiple sampling node samples and the central node is realized through an aggregation function to obtain the aggregated features of the central node. Then, the initial model is trained according to the aggregated features until the model converges to obtain a trained first model.
[0024] Specifically, when the initial model is trained according to the aggregated features, the aggregated features can be first input into the initial model to obtain the output result, and then the loss value (loss) is obtained according to the gap between the output result and the label of the central node, and then the model parameters of the initial model are adjusted according to the loss to obtain an updated initial model, and then the graph data samples of the new central node are used to input the updated initial model to generate new subgraph samples, and the new subgraph samples are sampled to obtain new sampling nodes, and the features of the new sampling nodes are aggregated with the features of the new central node to obtain new aggregated features, and then the new aggregated features are input into the updated initial model to obtain new output results, and the loss is obtained according to the gap between the new output result and the label of the new central node, and the model parameters of the updated initial model are adjusted again according to the loss to obtain the updated initial model again, and so on, through multiple rounds of training until the model converges, the first model is obtained.
[0025] For example, suppose the central node includes 100 neighbor nodes, of which there are 61 real class A nodes and 39 class B nodes, that is, the potential real distribution ratio is 61:39. However, there are only 10 labeled neighbor nodes, and the remaining 90 nodes are unlabeled neighbor nodes, of which 5 labeled neighbor nodes are class A and 5 labeled neighbor nodes are class B. Then the category distribution obtained based on the labeled neighbor nodes is 1:1, which is quite different from the potential real distribution ratio of 61:39. Sampling based on the category distribution of labeled neighbor nodes will make the sampled data distribution have a large gap with the real distribution, and the model training effect is poor.
[0026] Using the node classification method provided in the present application, the initial model is first used to predict 90 unlabeled neighbor nodes. Assuming that 60 unlabeled neighbor nodes are predicted to be class A and 30 unlabeled neighbor nodes are predicted to be class B, then based on the prediction results of the unlabeled neighbor nodes and the labels of the labeled neighbor nodes, it can be determined that the category distribution of these 100 neighbor nodes in the first round is 65:35=13:7. If the number of sampled nodes is 20, then there are 13 sampled nodes of class A and 7 sampled nodes of class B. It should be understood that compared with the category distribution of 1:1 obtained according to the labeled neighbor nodes, the category distribution of 13:7 obtained according to the prediction results of the unlabeled neighbor nodes and the labels of the labeled neighbor nodes is closer to the potential true distribution of 61:39. Sampling according to the category distribution obtained according to the prediction results of the unlabeled nodes and the labels of the labeled nodes can obtain sampling nodes that are closer to the true distribution, so model training in this way can improve model performance.
[0027] Furthermore, the model is trained in the first round using the 20 sampling nodes that are close to the potential true distribution to obtain a trained first model. The prediction ability of the first model is better than that of the initial model used in the first round. By using the first model to predict the category of the unlabeled neighbor nodes, a more accurate prediction result can be obtained than the initial model. The category distribution of multiple neighbor nodes obtained in this way will be closer to the potential true distribution than the category distribution of the first round obtained according to the initial model. Still taking the above example, the first model obtained in the first round of training is used to predict the above 90 unlabeled neighbor nodes, and 55 neighbor nodes of category A and 35 neighbor nodes of category B are determined. Combined with the labels of the 10 labeled neighbor nodes, the category distribution of the neighbor nodes in the second round can be obtained as 60:40=3:2. Compared with the category distribution of 65:35=13:7 in the first round, the category distribution of 60:40=3:2 determined in the second round is closer to the potential true distribution of 61:39. If the number of sampling nodes is 20, then there are 12 sampling nodes of category A and 8 sampling nodes of category B in the second round of sampling. Based on these 20, it is closer to the potential true distribution. A second model is obtained by performing a second round of training on the first model at the sampling nodes of the true distribution. The performance of the second model is better than that of the first model. The second model is used to predict the unlabeled neighbor nodes to obtain more accurate prediction results than the first model. The category distribution of the third round determined in this way will be closer to the potential true distribution 61:39 than the second round. Then the third round of sampling is performed, and so on, until the model converges. The above method makes the distribution of neighbor nodes used in each round of training gradually approach the potential true distribution during multiple rounds of training. Sampling is performed using a category distribution close to the true distribution, and the obtained sampling nodes are used to train the model to improve model performance.
[0028] The above implementation method predicts the category of neighbor node samples to obtain the category distribution of multiple neighbor node samples, then samples multiple neighbor nodes based on the category distribution, and then trains the model based on the sampled nodes, and back-propagates the model parameters. The trained new model continues to predict the category of neighbor node samples in the second round of training, and then trains the model based on the predicted category distribution. The trained new model continues to repeat the above steps in the third round of training until the model converges. In this way, multiple rounds of training make the category distribution of neighbor node samples predicted by the model gradually fit the actual distribution, thereby making the training effect better and better, thereby improving the performance of the model.
[0029] In one possible implementation, features of samples of multiple sampling nodes are input into an initial model for training to obtain a first model, pseudo labels of graph data samples are generated based on the first model, and the pseudo labels are used to train the first model to obtain a node classification model.
[0030] In the above implementation, unlabeled neighbor nodes are predicted to obtain pseudo labels of the unlabeled neighbor nodes, and then the pseudo labels are used to continue training the first model, which can increase the number of samples involved in training and improve model performance.
[0031] In a possible implementation, the training sampling parameters include a pseudo label threshold, and the confidence of the pseudo label is higher than the pseudo label threshold.
[0032] Optionally, the pseudo-label threshold can be a threshold set by the user or a default threshold, which is not specifically limited in this application. Confidence refers to the degree of confidence or certainty of the model in its prediction results. In classification tasks, confidence usually refers to the model's prediction probability or score for a certain category.
[0033] The above implementation method, by retaining high-confidence pseudo-labels, can improve the accuracy of pseudo-labels involved in training, reduce the introduction of noise, and improve the effect of model training. At the same time, the number of labeled neighbor nodes in the graph data sample is limited, and many neighbor nodes are not labeled, so there is a certain gap between the data distribution of labeled neighbor nodes and the data distribution of real neighbor nodes. By marking high-confidence pseudo-labels, the training set participating in the next round of training includes labeled neighbor nodes and pseudo-label neighbor nodes. The data distribution of neighbor nodes in the training set is more consistent with the data distribution of potential real neighbor nodes. Using such a training set to further train the model can further improve the accuracy of the model.
[0034] In one possible implementation, a round of training is performed on the first model using graph data samples annotated with the above-mentioned pseudo-labels. The training process can refer to the above-mentioned content, and then the second model is verified using the verification set to obtain a verification result. If the verification result shows that the model performance has decreased, the above-mentioned pseudo-labels are removed. If the verification result shows that the model performance has improved, the above-mentioned pseudo-labels are retained. Then the next round of training is performed, and so on, until the model converges and a trained node classification model is obtained. The model convergence at this time can be that the performance reaches the preset index, or it can be that the pseudo-labels can no longer improve the model performance. This application does not limit the specific criteria for model convergence.
[0035] Among them, the evaluation criteria of the above performance can be determined according to the specific application scenario. For example, the evaluation criteria of model performance may include accuracy, which indicates the proportion of samples correctly predicted by the model to the total number of samples; it may also include precision and recall, which are a pair of interrelated indicators. Precision indicates the proportion of samples predicted by the model to be positive examples that are actually positive examples, while recall indicates the proportion of samples predicted to be positive examples by the model to be positive examples; it may also include F1 score, which is the harmonic mean of precision and recall, and can comprehensively consider the accuracy and recall performance of the model. It should be understood that the above examples are for illustration and are not specifically limited in this application.
[0036] The above implementation method, by training the model for multiple rounds and verifying the generated pseudo-labels in each round of training, can ensure that the pseudo-labels used in each round of training are pseudo-labels that can provide positive and beneficial effects to the model, so that the information in the unlabeled neighbor node samples can be maximized during the model training process to achieve the effect of data enhancement. In some scenarios where the number of real labels is small and difficult to label, a large number of unlabeled neighbor node samples can also be used to complete the model training, so that the node classification model obtained through training has better accuracy and robustness.
[0037] At the same time, in the above-mentioned training method, when sampling neighbor node samples, the sampling distribution fits the data distribution of neighbor node samples, and when using pseudo labels to further train the model, the data distribution of neighbor node samples marked with pseudo labels fits the data distribution of neighbor node samples with real labels, so that the data distribution of neighbor node samples participating in model training is consistent with the real distribution, which can avoid the problem of poor prediction effect of the model on a few categories due to sample imbalance. It should be understood that in some application scenarios, such as risk control scenarios, the number of fraudulent nodes is much lower than the number of normal nodes, and the impact of small category samples on the loss function is very small, which can be easily ignored during the optimization process. Sample imbalance can easily make it difficult for the model to predict fraudulent nodes. The training method provided in this application can greatly avoid the occurrence of such situations.
[0038] In one possible implementation, the graph data includes any one of social media network graph data, transaction network graph data, commodity network graph data, knowledge graph, and biological molecular structure graph data.
[0039] It should be understood that the node classification method provided in the present application is applicable to a wide range of scenarios, and users can flexibly set the inference sampling parameters and training sampling parameters according to actual business needs, making the node classification method of the present application more universal and more feasible.
[0040] In a second aspect, a node classification system based on a graph neural network is provided, characterized in that the system includes: an acquisition unit, used to acquire graph data and inference sampling parameters of a node to be detected, the graph data including the node to be detected and multiple neighbor nodes connected to the node to be detected, a prediction unit, used to input the graph data into a node classification model to obtain the category distribution of multiple neighbor nodes, a prediction unit, used to sample multiple neighbor nodes according to the inference sampling parameters and the category distribution of multiple neighbor nodes to obtain multiple sampling nodes, and a prediction unit, used to input features of the multiple sampling nodes and features of the node to be detected into the node classification model to obtain a predicted category of the node to be detected.
[0041] The method described in the first aspect is implemented by first predicting the category distribution of multiple neighbor nodes in the graph data, then using the category distribution to sample multiple neighbor nodes to obtain multiple sampling nodes, and then predicting the predicted category of the node to be detected based on the characteristics of the sampling nodes, thereby reducing the computational complexity. At the same time, the sampling distribution of the sampling nodes is obtained based on the prediction results of multiple neighbor nodes, rather than based on the labels of a small number of labeled neighbor nodes, so that the sampling nodes can obtain the characteristics of more neighbor nodes, thereby improving the prediction accuracy.
[0042] In a possible implementation manner, the similarity between the category distribution of the plurality of sampling nodes and the category distribution of the plurality of neighboring nodes is higher than a first threshold.
[0043] In one possible implementation, the nodes to be detected include labeled nodes and unlabeled nodes, and the category distribution of multiple neighbor nodes is obtained based on the labels of the labeled nodes and the prediction results of the unlabeled nodes. The prediction results of the unlabeled nodes are obtained after inputting the graph data into the node classification model.
[0044] In one possible implementation, the inference sampling parameters include the number of sampling nodes, or the inference sampling parameters include the number of sampling layers, and the number of sampling layers is used to perform stratified sampling on multiple neighbor nodes according to the category distribution of the multiple neighbor nodes to obtain multiple sampling nodes, wherein each sampling layer includes multiple sampling nodes of the same category, and each category of sampling nodes corresponds to one or more sampling layers.
[0045] In one possible implementation, the inference sampling parameters include the number of samplings, which is used to perform multiple samplings on multiple neighbor nodes. The multiple collection nodes include multiple collection node sets, and one collection node set corresponds to one sampling. The predicted category of the node to be detected is obtained based on multiple prediction results, and one prediction result is obtained by inputting a sampling node set into a node classification model.
[0046] In one possible implementation, the system also includes a training unit and a sampling unit. The training unit is used to obtain graph data samples and training parameters of the central node before the acquisition unit obtains the graph data and inference sampling parameters of the node to be detected. The graph data samples include the central node and multiple neighbor node samples connected to the central node. The training sampling parameters include the number of sampling nodes or the number of sampling layers. The graph data of the node to be detected and the graph data sample of the central node are different subgraphs in the same graph. The training unit is used to input the graph data samples into the initial model to obtain the category distribution of multiple neighbor node samples. The sampling unit is used to sample multiple neighbor node samples according to the training sampling parameters and the category distribution of the neighbor node samples to obtain multiple sampling node samples. The similarity between the category distribution of the multiple sampling nodes and the category distribution of the multiple neighbor nodes is higher than a second threshold. The training unit is used to input the features of the multiple sampling node samples and the features of the central node into the initial model for training to obtain a node classification model.
[0047] In a possible implementation, the generation time of the multiple sampling node samples is earlier than the generation time of the node to be detected.
[0048] In one possible implementation, the system includes a label generation unit, a training unit, which is used to input the features of samples of multiple sampling nodes into an initial model for training to obtain a first model, and a label generation unit, which is used to generate pseudo labels for graph data samples based on the first model, and train the first model using the pseudo labels to obtain a node classification model.
[0049] In a possible implementation, the training sampling parameters include a pseudo label threshold, and the confidence of the pseudo label is higher than the pseudo label threshold.
[0050] In one possible implementation, the graph data includes any one of social media network graph data, transaction network graph data, commodity network graph data, knowledge graph, and biological molecular structure graph data.
[0051] In a third aspect, a computing device is provided, the computing device comprising a processor and a memory, the memory being used to store instructions, and the processor being used to execute instructions, so that the computing device implements the method described in the first aspect.
[0052] In a fourth aspect, a computing device cluster is provided, which includes at least one computing device, each of the at least one computing device includes a processor and a memory, and the processor of the at least one computing device is used to execute instructions stored in the memory of the at least one computing device, so that the computing device cluster implements the method described in the first aspect.
[0053] In a fifth aspect, a computer-readable storage medium is provided, in which instructions are stored. When the instructions are executed by a computing device or a computing device cluster, the method described in the first aspect is implemented.
[0054] In a sixth aspect, a computer program product comprising instructions is provided, wherein the computer program product includes instructions that can be run on a computing device or software or a program product stored in any available medium, and when the computer program product is run on a computing device or a computing device cluster, the computing device or the computing device cluster executes the method described in the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] Figure 1 It is an architectural diagram of a node classification method provided by this application;
[0056] Figure 2 It is a structural diagram of the node classification system provided by this application;
[0057] Figure 3 This is a schematic diagram of the steps of a node classification method in the training phase provided by the present application;
[0058] Figure 4 This is a schematic diagram of the steps of the training phase of a node classification method provided by the present application in an application scenario;
[0059] Figure 5 This is a schematic diagram of the steps of a node classification method provided by the present application in the reasoning stage;
[0060] Figure 6 This is a schematic diagram of the steps of the reasoning phase of a node classification method provided by the present application in an application scenario;
[0061] Figure 7 This is an exemplary interface display diagram of the node classification method provided by this application;
[0062] Figure 8 It is a structural schematic diagram of a computing device provided by this application. DETAILED DESCRIPTION
[0063] First, the application scenario "graph neural network algorithm" involved in this application is explained.
[0064] A graph neural network (GNN) is a neural network used to process graph data. Traditional neural networks can process data in the form of vectors or matrices, while GNN is specifically used to process graph data with complex relationships. Graph data usually includes multiple nodes and edges. Nodes represent individuals or entities in the graph, such as users, etc. Each node has its own characteristics, such as the user's name. The edges between nodes represent the relationship between nodes, such as friend relationships. Edges can contain weights or labels to indicate the strength or type of relationships. A graph neural network obtains aggregate features by aggregating the features of the central node itself and the features of neighboring nodes, and then uses the aggregate features to participate in the training of the neural network. The trained model can obtain the inference result corresponding to the node to be detected based on the input graph data of the node to be detected.
[0065] For example, in a recommendation task scenario, if you want to recommend friends to a user, you need to input information about the user and the friends, place of residence, hobbies, etc. associated with the user. This information can be represented by graph structure data. Nodes are used to represent users, and edges between nodes are used to represent the friendship between users. The features recorded on the nodes may include the features of the user corresponding to the node, including information such as friends, place of residence, hobbies, etc. The graph neural network aggregates the features of the central node with the features of the surrounding neighboring nodes, inputs the aggregated features into the neural network for training, and back-propagates the model parameters of the neural network based on the labels and the prediction results of the neural network. After the model converges, a trained model is obtained. After receiving the graph structure data of the new central node, the model can obtain the recommendation results of the user corresponding to the central node based on the graph structure data.
[0066] However, a central node in a graph neural network may have many neighboring nodes. If the features of all neighboring nodes are aggregated with the features of the central node, the computational complexity is very high, the training efficiency and inference efficiency of the graph neural network are low, the model performance is poor, and it is difficult to meet application requirements. If the neighbor nodes are sampled and then the features of the sampled neighbor nodes are aggregated with the features of the central node, although the complexity can be reduced, the features of the sampled neighbor nodes are difficult to summarize the features of all neighbor nodes, which will lead to a decrease in model performance.
[0067] In order to solve the problem that graph neural networks are difficult to aggregate the features of all neighbor nodes with the features of the central node, resulting in high computational complexity and poor model performance, the present application provides a node classification system, which first predicts the category distribution of multiple neighbor nodes in the graph data, then obtains the training sampling parameters input by the user, samples multiple neighbor node samples in the graph data sample to obtain multiple sampling nodes, so that the category distribution of the multiple sampling nodes is similar or consistent with the category distribution of the predicted multiple neighbor node samples, so that the features of the sampled sampling nodes can not only summarize the features of all neighbor nodes, but also avoid the problem of poor prediction effect of the model on a few categories due to sample imbalance; and the node classification system takes into account the future neighbor node distribution in the actual reasoning process. Points cannot participate in reasoning, so the generation time of the sampling nodes participating in the training is earlier than that of the central nodes, which can make the sampling nodes participating in the training more consistent with the actual distribution in the reasoning stage, further improving the model performance; finally, the model is trained for multiple rounds according to the sampling nodes until the model converges. At the end of each round of training, the converged model will be used to predict the pseudo-labels of the neighboring nodes, and the pseudo-labels will be verified through the validation set. The pseudo-labels that are beneficial to the model are retained, and the pseudo-labels that are not beneficial to the model are removed. Then, the next round of training is carried out. In this way, the pseudo-labels used in each round of training are pseudo-labels that can provide positive and beneficial effects to the model. During the model training process, the information in the unlabeled neighbor node samples can be maximized to achieve the effect of data enhancement and improve the performance of the graph neural network.
[0068] Figure 1 This is an architecture diagram of a node classification method provided by this application, such as Figure 1 As shown, the architecture includes a client 100, a node classification system 200, and a storage system 300, wherein the client 100, the node classification system 200, and the storage system 300 establish a communication connection through a network, which can be a wired connection or a wireless connection, which is not specifically limited in this application. The number of clients 100 and storage systems 300 that establish a communication connection with the node classification system 200 can be one or more, which is not specifically limited in this application.
[0069] The client 100 is used to realize human-computer interaction and can be deployed on terminal devices, including personal computers, smart phones, wearable devices, handheld processing devices, tablet computers, mobile notebooks, augmented reality (AR) devices, virtual reality (VR) devices, integrated handheld devices, wearable devices, vehicle-mounted devices, smart conference devices, smart advertising devices, smart home appliances, etc. Smart home appliances can be sweeping robots, mopping robots, etc., which are not specifically limited here.
[0070] In a specific implementation, the above-mentioned client 100 can be a software or application running on a terminal device or computing device controlled by a user, such as a personal computer (PC) client, or a web client accessed based on a browser, or an application (APP) client running on a mobile terminal, which is not specifically limited in this application.
[0071] Optionally, the client 100 may be a client specifically used for node classification, and the predicted node categories are different in different application scenarios. For example, in a risk control scenario, the client 100 may be a client for predicting user risk categories or risk coefficients. The client may receive graph data input by the user and feedback the risk coefficients of each node in the graph data to the user. In a recommendation scenario, the client 100 may be a client for commodity recommendation. The client may receive graph data input by the user and feedback the recommendation coefficient or preference of each node in the graph data to the user. Of course, it can also be applied to other fields, which are not illustrated here one by one. It should be understood that the recommendation coefficient, preference or risk coefficient of the predicted node can also be regarded as a classification task of a continuous value, and this continuous value can also be discretized and then trained. For example, the recommendation coefficient is discretized into three categories: low, medium and high, and then a classification algorithm is used to train the model for prediction. The above examples are for illustration and are not specifically limited in this application.
[0072] The client 100 may also be some application clients including node classification plug-ins. For example, in the risk control scenario, the client 100 may be an e-commerce management application, which includes a submodule of e-commerce risk control, specifically used to predict the risk coefficient or risk category of users who purchase e-commerce products. The node category here is the risk coefficient or risk category. For example, in the recommendation scenario, the client 100 may be a social media application, which includes a submodule of user recommendation, specifically used to predict the friends that the user may want to make or the goods that the user may want to buy. The node category here is the recommendation coefficient of the user or the goods. Of course, it can also be applied to other fields, which will not be explained one by one here.
[0073] Optionally, the client 100 can also be a console of the cloud platform, which provides the node classification function of the node to the user as a sub-service of the cloud platform. The user can use the node classification method provided by this application by purchasing cloud services. Optionally, the user can purchase the training service of the node classification method provided by this application, and the cloud platform can provide the user with a training platform. The user can input the training sampling parameters and graph data samples through the training platform in combination with business needs. The cloud platform uses the node classification method provided by this application to train the node classification model. The node classification model obtained in this way can adapt to the business needs of the user, and the user can flexibly customize the node classification model that matches its own business function. Optionally, the user can also purchase the reasoning service of the node classification method provided by this application. The cloud platform can provide the user with a trained node classification model. The user can input the graph data to be detected and the reasoning sampling parameters into the node classification model to obtain the prediction result. The node classification model obtained in this way is usually a general model, and the performance effect is not as strong as the above-mentioned flexible customized classification model, but the user does not need to train the model by himself, and the operation is more convenient. The user can choose to use the training service or reasoning service in combination with his own business needs, and this application does not make specific restrictions. The console may be a web-based client, an application client, or an application programming interface (API), which is not specifically limited in this application.
[0074] The node classification system 200 is used to receive the graph data of the node sent by the client 100, classify the node according to the graph data, obtain the category of the node, and then return the category to the client 100. In some application scenarios, the node classification system 200 can also send the category of the node to the storage system 300 for storage.
[0075] The storage system 300 is used to receive the category of the node sent by the node classification system 200, and store the category of the node. In different application scenarios, the storage system 300 may have different functions. For example, in a risk control scenario, the category of the node may be the risk category of the user corresponding to the node. The storage system 300 may store records of multiple high-risk users, so that a reminder can be given directly the next time a high-risk user visits. It should be understood that the above examples are for illustration only and are not specifically limited in this application. In a specific implementation, the storage system 300 may be a database, a file system, or a cloud storage system, etc., which is not specifically limited in this application.
[0076] The node classification system 200 and the storage system 300 can be deployed on a computing device, a computing device cluster or a terminal device, wherein the computing device includes a bare metal server (BMS), a virtual machine, a container or an edge computing device. BMS refers to a general physical server, such as an ARM server or an X86 server; a virtual machine refers to a complete computer system with complete hardware system functions and running in a completely isolated environment simulated by software. All the work that can be done in a physical computer can be done in a virtual machine. When creating a virtual machine in a computing device, part of the hard disk and memory capacity of the physical machine needs to be used as the hard disk and memory capacity of the virtual machine. Each virtual machine has an independent basic input / output system (CMOS), hard disk and operating system, and can operate the virtual machine like a physical machine; a container is a portable software unit that can merge an application and all its dependencies into a software package that is not limited by the underlying host operating system, so there is no need to build a complex environment, simplifying the process from application development to deployment; an edge computing device refers to a device that is closer to the data source and end user, with low latency and high bandwidth characteristics, such as smart routing, edge servers, etc. The computing device cluster may include multiple computing devices as described above, such as a data center, which is not specifically limited in this application; the description of the terminal device can refer to the aforementioned content and will not be repeated here.
[0077] Optionally, the node classification system 200 can be deployed on the same terminal device as the client 100; or, the node classification system 200 is deployed on a computing device and the client 100 is deployed on a terminal device; or, the node classification system 200 is deployed in a computing device cluster and the client 100 is deployed on a terminal device. It should be understood that the above examples are for illustration only and the specific deployment of the node classification system 200 and the client 100 can be determined based on the actual application scenario.
[0078] Optionally, the node classification system 200 can be deployed on the same computing device as the storage system 300; or, the node classification system 200 and the storage system 300 are deployed on different computing devices in the same computing device cluster; or, the node classification system 200 and the storage system 300 are deployed on different computing devices in different computing device clusters, and this application does not make specific limitations. For example, the node classification system 200 can be any one in a data center, and the storage system 300 is deployed on another computing device in the data center, or the storage system 300 is deployed in other data centers. The above examples are for illustration only and this application does not make specific limitations.
[0079] The node classification system provided in the present application can be applied to node classification scenarios of graph neural networks, including but not limited to social network analysis, recommendation scenarios, knowledge graph scenarios, risk control scenarios, bioinformatics scenarios, etc., and the present application does not make specific limitations. Among them, the social network analysis scenario can use the node classification system 200 provided in the present application to predict users' interests and hobbies, users' community affiliations, etc., and the recommendation scenario can use the node classification system 200 provided in the present application to predict users' preferences for products; the knowledge graph scenario can use the node classification system 200 provided in the present application to perform tasks such as entity classification; the bioinformatics scenario can use the node classification system 200 provided in the present application to predict the functional classification of proteins. It should be understood that the above examples are some examples of node classification scenarios, and the node classification system 200 can also be applied to other node classification scenarios. In the process of explaining the node classification system 200 below, some examples introduced are intended to enable the present application to be better understood, rather than to limit the application scenarios of the present application. The present application does not limit the specific application scenarios of the node classification system 200.
[0080] Further, Figure 2 The node classification system 200 in the embodiment can be further divided into a plurality of unit modules. For example, Figure 2 is a schematic diagram of the structure of the node classification system 200 provided by the present application, such as Figure 2 As shown, the node classification system 200 may include a training module 220 and a reasoning module 210, wherein the training module 220 may include a training unit 221, a subgraph generation unit 222, a sampling unit 223, an aggregation unit 224, and a label generation unit 225, and the reasoning module 210 may include an acquisition unit 211, a prediction unit 212, a voting unit 213, and an output unit 214. It should be understood that Figure 1 This is an exemplary division method. The node classification system 200 may also include more or fewer units. For example, the reasoning module 210 may also include an reasoning sampling unit. For example, the training module 220 may not have a label generation unit 225, or the aggregation unit 224 and the training unit 221 may be combined into one training unit 221, or the training module 220 may not have a subgraph generation unit 222. The unit module may be determined according to the actual application scenario, and this application does not make any specific limitation.
[0081] Among them, the training unit 221, the sub-graph generation unit 222, the sampling unit 223, the aggregation unit 224, the label generation unit 225, the acquisition unit 211, the prediction unit 212, the voting unit 213 and the output unit 214 can be implemented by software or by hardware. Exemplarily, the implementation of the training unit 221 is introduced below by taking the training unit 221 as an example. Similarly, the implementation of the sub-graph generation unit 222, the sampling unit 223, the aggregation unit 224, the label generation unit 225, the acquisition unit 211, the prediction unit 212, the voting unit 213 and the output unit 214 can refer to the implementation of the training unit 221.
[0082] The training unit 221 is an example of a software functional unit. The training unit 221 may include code running on a computing instance. The computing instance may include at least one of a physical host (computing device), a virtual machine, and a container. Furthermore, the computing instance may be one or more. For example, the training unit 221 may include code running on multiple hosts / virtual machines / containers. It should be noted that the multiple hosts / virtual machines / containers for running the code may be deployed in the same data center or in different data centers. When the multiple hosts / virtual machines / containers for running the code are deployed in different data centers, the different data centers may be distributed in the same region or in different regions. The region here is used to describe the location of the data center. The data centers in the same region share public services such as elastic computing, block storage, and object storage. The different data centers may also be distributed in the same availability zone (AZ) or in different AZs. Each AZ includes one data center or multiple data centers with similar geographical locations. An AZ is a collection of one or more physical data centers. The computing, network, storage, and other resources are logically divided into multiple clusters within the AZ. Usually, a region can include multiple AZs, and multiple AZs in a region are connected by high-speed optical fibers to meet the needs of users to build high-availability systems across AZs.
[0083] The training unit 221 is an example of a hardware functional unit. The training unit 221 can also be implemented by an application-specific integrated circuit (ASIC) or a programmable logic device (PLD). The PLD can be a complex programmable logical device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL) or any combination thereof. For example, the training unit 221 can be implemented by a data processing unit (DPU), which is not limited in the present application.
[0084] Need to explain, Figure 2 The structure shown may be an implementation of the node classification system 200 deployed on a single computing device. When the node classification system 200 is deployed on a computing device cluster consisting of multiple computing devices, different computing devices in the computing device cluster may respectively store instructions for implementing the functions of the training unit 221, the subgraph generation unit 222, the sampling unit 223, the aggregation unit 224, the label generation unit 225, the acquisition unit 211, the prediction unit 212, the voting unit 213, and the output unit 214. For example, computing device A in the computing device cluster stores instructions for implementing the training module 220, specifically including instructions for implementing the functions of the training unit 221, the subgraph generation unit 222, the sampling unit 223, the aggregation unit 224, and the label generation unit 225. Computing device B stores instructions for implementing the reasoning module 210, specifically including instructions for implementing the functions of the acquisition unit 211, the prediction unit 212, the voting unit 213, and the output unit 214. This application does not make any specific limitations. Of course, different computing devices may also store the same instructions. For example, computing device B and computing device C both store instructions of acquisition unit 211, prediction unit 212, voting unit 213, and output unit 214, which are used to combine and implement the functions of acquisition unit 211, prediction unit 212, voting unit 213, and output unit 214. This application does not make specific limitations.
[0085] Among them, the training unit 221, subgraph generation unit 222, sampling unit 223, and aggregation unit 224 in the training module 220 are used to train the node classification model and run in the model training stage, and the acquisition unit 211, prediction unit 212, voting unit 213 and output unit 214 in the inference module 210 are used to use the node classification model for inference and run in the model inference stage.
[0086] The functions of each unit module in the training module 220 in the node classification system 200 are described below.
[0087] The acquisition unit 211 is used to obtain the graph data sample and the initial model of the central node, and send the graph data sample and the initial model to the training unit 221. The training unit 221 is used to input the graph data sample into the initial model to obtain the prediction results of one or more neighbor node samples of the central node.
[0088] Optionally, the initial model can be obtained by training the graph neural network using labeled samples or unlabeled samples. The graph neural network may include graph sampling and aggregated networks (GraphSAGE), graph convolutional networks (GCN), graph attention networks (GAT), etc.; the initial model can also be a supervised model, such as random forests (RandomForests), multilayer perceptron (Multilayer Perceptron, MLP), etc., which is not specifically limited in this application.
[0089] Optionally, the graph data sample input into the initial model is a graph structure data, and the graph data sample includes multiple nodes and multiple edges. Different nodes are used to represent different things, and there are edges connecting the associated nodes. In the specific implementation, the nodes and edges of the graph data sample can represent different information in different application scenarios. For example, in the case of describing a commodity network, each node in the graph data sample can be used to represent a different commodity. If two commodities are often purchased by the same user, their purchase relationship can be represented by an edge. If one commodity depends on the use or existence of another commodity, this dependency can also be represented by an edge. In the case of describing a transaction network, each node in the graph data sample can be used to represent a different transaction. If the delivery addresses of two transactions are the same, their association relationship can be represented by an edge. If the consignees of two transactions are the same, their association relationship can also be represented by an edge. It should be understood that in the above examples, there is only one type of node category, that is, all nodes are commodities or all nodes are users. In some embodiments, the number of node categories and the number of edge categories may also be multiple, that is, the graph data sample may be a heterogeneous graph containing different types of nodes and edges. At the same time, the edges of the graph data sample may be directed or undirected, and this application does not limit this.
[0090] It should be noted that the graph data samples participating in the training can be obtained after sending an application to the user or relevant department and obtaining approval and authorization. Unauthorized and unapproved graph data cannot be used as samples for training.
[0091] Furthermore, the nodes in the graph data sample also have corresponding feature information, which is used to describe the characteristics of the nodes. These features can be the attributes, status or content of the nodes, etc., which can be determined according to the actual application scenario. For example, the feature information of the nodes in the above-mentioned commodity network can be the type of commodity (such as daily necessities, clothing, food, etc.), purchase time, purchasing user, etc. The feature information of the nodes in the above-mentioned transaction network can be the time of the transaction, the delivery address of the transaction, the recipient of the transaction, the payee of the transaction, the payee of the transaction, etc., which is not specifically limited in this application. It should be understood that the above examples are for illustration, and the node classification method provided in this application can also be used to process graph data samples in other application scenarios, which is not specifically limited in this application.
[0092] Furthermore, the nodes in the graph data sample may also include labels, and the labels of the nodes are the real categories of the nodes, and the graph data sample may include labeled nodes and unlabeled nodes, that is, each node in the graph data sample may have a label or may not have a label, or some nodes may have labels and some nodes may not have labels, which is not specifically limited in this application. In an embodiment of the present application, the categories corresponding to the labels vary in different application scenarios. For example, in the application scenario of product recommendation, the label of the node may be the category corresponding to the node, which may be a continuous value, such as a recommendation coefficient, or a discrete category, such as labels divided into highly recommended, relatively recommended, and not recommended; in the risk control scenario, the label of the node may be the category corresponding to the node, which may be a continuous value, such as a risk coefficient, or a discrete category, such as labels divided into high risk, medium risk, and low risk, which is not specifically limited in this application.
[0093] Optionally, the neighbor node samples of the central node may be nodes directly connected to the central node, that is, other nodes connected to the central node through edges are all neighbor node samples of the central node; the neighbor node samples may also be nodes indirectly connected to the central node, that is, the first neighbor node samples are directly connected to the central node, and the second neighbor node samples connected to the first neighbor node samples may also be called neighbor node samples of the central node. This type of neighbor node samples may be called 2-hop neighbor node samples, and similarly, 3-hop neighbor node samples, 4-hop neighbor node samples, etc. may be obtained, which are not specifically limited in this application. It should be understood that the neighbor node samples involved in the embodiments of the present application may include 1-hop neighbor node samples, and may also include neighbor node samples of more than 2 hops, which may be determined according to the actual application scenario, which is not specifically limited in this application.
[0094] Optionally, the prediction results of one or more neighbor node samples obtained by the initial model can be the prediction category or prediction score obtained by each neighbor node sample. For example, in the application scenario of product recommendation, the prediction result can be the recommendation score or recommendation category of the neighbor node sample, such as highly recommended, relatively recommended and not recommended. For example, in the risk control scenario, the prediction result can be the risk coefficient or risk level of the neighbor node sample, such as high risk, medium risk and low risk. The above examples are for illustration only and are not specifically limited in this application.
[0095] Optionally, the initial model can predict the unlabeled neighbor node samples in the graph data samples to obtain the prediction results of the unlabeled neighbor node samples, and the neighbor node samples with labels can be not predicted. In the specific implementation, the initial model can predict the category of each unlabeled neighbor node sample in the graph data sample, and can also predict some unlabeled neighbor node samples. The specific method can be determined according to the actual application scenario. For example, in the actual application scenario, if the scale of the graph data sample is small, the initial model can directly predict the classification results of all unlabeled neighbor node samples. If the scale of the graph data sample is large, the initial model cannot predict the classification results of all unlabeled neighbor node samples. Then, the neighboring subgraph can be extracted from the graph data sample according to the preset extraction strategy, and then the unlabeled neighbor node samples in the neighboring subgraph are predicted. The extraction strategy here may include but is not limited to: sorting multiple neighbor nodes according to the proximity to the generation time of the central node, and extracting the neighboring subgraph according to the sorting result. It should be understood that the above examples are used for illustration, and the extraction strategies adopted in different application scenarios are different, and this application does not make specific limitations.
[0096] The subgraph generation unit 222 is used to obtain a subgraph sample of the graph data sample according to the generation time of the central node and the generation time of the neighbor node samples, and the subgraph sample includes a central node and multiple neighbor node samples, wherein the central node of the subgraph sample is the central node in the graph data sample, and the multiple neighbor node samples in the subgraph sample are neighbor node samples in the graph data sample whose generation time is earlier than that of the central node.
[0097] Referring to the foregoing content, it can be known that each node in the graph data sample has corresponding feature information, and the generation time can be a certain feature of the neighbor node sample and the central node. The definition of generation time is different in different scenarios. For example, in the graph data sample of the transaction network in the above example, each node represents a transaction, then the above generation time can be the transaction time, and the transaction time of the corresponding transaction of the neighbor node sample in the subgraph sample is earlier than the transaction time of the corresponding transaction of the central node. For another example, in the graph data sample of the social network, each node represents a social media account, and the above generation time can be the creation time of the account, then the creation time of the corresponding account of the neighbor node sample in the subgraph sample is earlier than the creation time of the corresponding account of the central node. The above examples are for illustration only and are not specifically limited in this application.
[0098] It is understandable that during the model reasoning process, the generation time of the neighbor node samples is earlier than that of the central node. Because in the actual reasoning process, the future neighbor nodes cannot participate in the reasoning, the neighbor node samples whose generation time is earlier than that of the central node are also used to participate in the model training during the model training process. This can make the multiple neighbor node samples in the sub-graph samples more consistent with the actual distribution. Model training based on the sub-graph samples can improve the accuracy of the trained model in the reasoning stage.
[0099] In the above implementation, the graph data sample is first input into the initial model to obtain the prediction results of the neighbor node samples in the graph data sample, and then the subgraph sample is obtained according to the generation time of the neighbor node sample. In another possible implementation, the node classification system 200 may also first obtain the initial subgraph of the graph data sample through the subgraph generation unit 222, and the generation time of the neighbor node samples in the initial subgraph is earlier than the central node, but the neighbor node samples in the initial subgraph include true labels, and some neighbor node samples may be unlabeled nodes. Then, the initial subgraph is input into the initial model through the training unit 221 to obtain the prediction results of each unlabeled neighbor node sample in the initial subgraph, thereby obtaining a subgraph sample in which the generation time of the neighbor node samples is earlier than the central node, and each neighbor node sample includes a true label or a prediction result.
[0100] The sampling unit 223 is used to sample the subgraph sample according to the prediction results of the above-mentioned multiple neighbor node samples to obtain multiple sampling nodes. Specifically, the above-mentioned multiple sampling nodes are nodes screened from multiple neighbor node samples in the subgraph sample according to the sampling strategy. It should be understood that by sampling multiple neighbor node samples in the subgraph sample, model training based on the sampling nodes can reduce the amount of calculation and improve the efficiency of model training.
[0101] In a possible implementation, the above sampling strategy may include: the similarity between the category distribution of multiple sampling nodes and the category distribution of multiple neighbor node samples in the subgraph sample is higher than the second threshold. Wherein, the category distribution of multiple neighbor node samples here refers to the category distribution of labeled neighbor nodes and unlabeled neighbor nodes. The unlabeled neighbor nodes can determine their categories according to the prediction results, and the labeled neighbor nodes determine their categories according to their labels, so that each neighbor node can have its corresponding category, thereby obtaining the category distribution of multiple neighbor node samples. It should be understood that the number of labeled neighbor nodes in the graph data sample is limited, and many neighbor node samples are not labeled, so there is a certain gap between the data distribution of labeled neighbor nodes and the data distribution of potential real neighbor nodes. The data distribution determined by the present application based on the prediction results of the neighbor node samples combined with the labels of the labeled neighbor nodes is more in line with the real distribution, and then the neighbor nodes are sampled according to such data distribution. The obtained sampling nodes can not only summarize the characteristics of the neighbor nodes, but also this feature is a feature that fits the characteristics of the potential real distribution. Using such sampling nodes to participate in model training can not only reduce the computational complexity, but also improve the model performance.
[0102] For example, suppose the central node in the subgraph node includes 100 neighbor nodes, and suppose there are 61 real class A nodes and 39 class B nodes among these 100 neighbor nodes, that is, the potential real distribution ratio is 61:39. However, there are only 10 labeled neighbor nodes, and the remaining 90 nodes are unlabeled neighbor nodes, of which 5 labeled neighbor nodes are class A and 5 labeled neighbor nodes are class B. Then the category distribution obtained based on the labeled neighbor nodes is 1:1, which is quite different from the potential real distribution ratio of 61:39. Sampling based on the category distribution of labeled neighbor nodes will make the sampled data distribution have a large gap with the real distribution, and the model training effect is poor.
[0103] Using the node classification method provided in the present application, the initial model is first used to predict 90 unlabeled neighbor nodes. Assuming that 60 unlabeled neighbor nodes are predicted to be class A and 30 unlabeled neighbor nodes are predicted to be class B, then based on the prediction results of the unlabeled neighbor nodes and the labels of the labeled neighbor nodes, it can be determined that the category distribution of these 100 neighbor nodes in the first round is 65:35=13:7. If the number of sampled nodes is 20, then there are 13 sampled nodes of class A and 7 sampled nodes of class B. It should be understood that compared with the category distribution of 1:1 obtained according to the labeled neighbor nodes, the category distribution of 13:7 obtained according to the prediction results of the unlabeled neighbor nodes and the labels of the labeled neighbor nodes is closer to the potential true distribution of 61:39. Sampling according to the category distribution obtained according to the prediction results of the unlabeled nodes and the labels of the labeled nodes can obtain sampling nodes that are closer to the true distribution, so model training in this way can improve model performance.
[0104] Furthermore, the model is trained in the first round using the 20 sampling nodes that are close to the potential true distribution to obtain a trained first model. The prediction ability of the first model is better than that of the initial model used in the first round. By using the first model to predict the category of the unlabeled neighbor nodes, a more accurate prediction result can be obtained than the initial model. The category distribution of multiple neighbor nodes obtained in this way will be closer to the potential true distribution than the category distribution of the first round obtained according to the initial model. Still taking the above example, the first model obtained in the first round of training is used to predict the above 90 unlabeled neighbor nodes, and 55 neighbor nodes of category A and 35 neighbor nodes of category B are determined. Combined with the labels of the 10 labeled neighbor nodes, the category distribution of the neighbor nodes in the second round can be obtained as 60:40=3:2. Compared with the category distribution of 65:35=13:7 in the first round, the category distribution of 60:40=3:2 determined in the second round is closer to the potential true distribution of 61:39. If the number of sampling nodes is 20, then there are 12 sampling nodes of category A and 8 sampling nodes of category B in the second round of sampling. Based on these 20, it is closer to the potential true distribution. A second model is obtained by performing a second round of training on the first model at the sampling nodes of the true distribution. The performance of the second model is better than that of the first model. The second model is used to predict the unlabeled neighbor nodes to obtain more accurate prediction results than the first model. The category distribution of the third round determined in this way will be closer to the potential true distribution 61:39 than the second round. Then the third round of sampling is performed, and so on, until the model converges. The above method makes the distribution of neighbor nodes used in each round of training gradually approach the potential true distribution during multiple rounds of training. Sampling is performed using a category distribution close to the true distribution, and the obtained sampling nodes are used to train the model to improve model performance.
[0105] In a specific implementation, the category distribution of multiple neighbor node samples around the central node can be determined based on the prediction results of multiple neighbor node samples obtained by the training unit 221 and the labels of the neighbor node samples, and then the multiple neighbor node samples are sampled according to the category distribution and the training sampling parameters. In a specific implementation, the above training sampling parameters can be set in advance by the user.
[0106] Optionally, the training sampling parameters may include the number of sampling nodes, that is, the number of neighbor node samples to be sampled. Then, the number of sampling nodes of each category to be sampled may be determined according to the category distribution of the neighbor node samples, so that the category distribution of the sampling nodes finally obtained is similar or consistent with the category distribution of the neighbor node samples.
[0107] Optionally, the training sampling parameters may include the number of sampling layers, which is used to perform stratified sampling on multiple neighbor node samples so that the category distribution of the finally obtained sampling nodes is similar or consistent with the category distribution of the neighbor node samples. In a specific implementation, after obtaining the category distribution of multiple neighbor node samples, the multiple neighbor node samples can be divided into multiple levels according to the number of sampling layers, and the samples in each level are samples of the same category. Then, stratified sampling is performed in different sampling layers so that the category distribution of the multiple sampling nodes obtained after sampling is similar or consistent with the category distribution of the multiple neighbor node samples. Different stratified sampling methods can be used according to needs, such as equidistant stratified sampling, geometric stratified sampling, etc., which are not specifically limited in this application.
[0108] It should be noted that the number of sampling layers input by the user can be the same as or different from the number of categories of neighbor node samples. In other words, samples of the same category can be divided into one level or multiple levels. For example, if the neighbor node samples have 5 categories and the number of sampling layers set by the user is 10, then the neighbor node samples of one category are divided into 2 levels. This application does not make specific restrictions. It is understandable that the number of neighbor node samples of certain categories may be significantly less than that of other categories. By dividing a category into multiple levels and sampling in each level, the impact of the classification imbalance problem of neighbor node samples on model training can be reduced. At the same time, by extracting neighbor node samples from the same category in multiple different levels, the sampled neighbor node samples can better represent the characteristics of the entire category and better cover the different characteristics and changing trends of the category. The model trained using such sampling nodes can better adapt to the changes at each level when processing new unseen samples, thereby making the trained model have stronger generalization ability.
[0109] It should be understood that sampling can be completed only by the number of samplings and the category distribution of samples of neighboring nodes, sampling can be completed only by the number of sampling layers and the sample distribution of neighboring nodes, and sampling can also be completed according to the number of samplings, the number of sampling layers and the category distribution of samples of neighboring nodes. The present application does not limit the training sampling parameters. At the same time, although the above-mentioned number of sampling layers and the number of samplings are specific implementations of the training sampling parameters provided by the present application, Figure 2 The training sampling parameters including the number of sampling layers are used as an example, however, the training sampling parameters may also be other parameters that can make the category distribution of the multiple sampling nodes finally collected similar or consistent with the category distribution of the neighboring node samples, and this application is not limited to this.
[0110] In some application scenarios, the features of the nodes in the graph data samples do not include features of the time dimension. In this case, the graph data samples can be sampled directly to obtain multiple sampling nodes. That is to say, after obtaining the prediction results of the neighbor node samples through the initial model, each neighbor node sample in the graph data sample has a corresponding classification. This classification may be the real classification provided by the real label, or it may be the classification predicted by the prediction result. Then, according to the category distribution formed by multiple neighbor node samples and combined with the training sampling parameters input by the user, the multiple neighbor node samples in the graph data sample are stratified and sampled to obtain multiple sampling nodes.
[0111] It should be understood that the above schemes are only some possible implementation methods provided by the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent repairs or replacements within the technical scope disclosed in the present application, and these repairs or replacements should be included in the protection scope of the present application.
[0112] The aggregation unit 224 is used to aggregate the features of multiple sampling nodes with the features of the central node to obtain the aggregated features of the central node.
[0113] In a specific implementation, the features of the sampling nodes and the features of the central node may be vectorized first to obtain the feature vectors of the sampling nodes and the feature vectors of the central node, and then the feature aggregation of multiple sampling nodes and the central node may be realized through an aggregation function.
[0114] Optionally, the aggregation function may include a sum pooling function, an average pooling function, a maximum pooling function, an attention function, etc. Sum pooling refers to weighted summing of the feature vectors of the sampling nodes and the feature vectors of the central node to obtain aggregate features; average pooling refers to weighted averaging of the feature vectors of the sampling nodes and the feature vectors of the central node to obtain aggregate features; maximum pooling refers to taking the maximum value of the feature vectors of the sampling nodes and the feature vectors of the central node as the aggregate feature; the attention function is used to calculate the weights of the central node and different sampling nodes, so that important node features can be automatically focused on during the aggregation process, and then the aggregate features are obtained by weighted summing or weighted averaging. In a specific implementation, the most appropriate aggregation function can be selected to obtain the aggregate features of the central node according to the actual application scenario and business needs, and this application does not limit this.
[0115] In the embodiment of the present application, after the aggregation unit 224 obtains the aggregation features of the central node, the training unit 221 trains the initial model according to the aggregation features until the model converges to obtain a trained first model. In a specific implementation, the training unit 221 can input the aggregation features into the initial model to obtain the output result of the model, obtain the loss value (loss) according to the difference between the output result and the label of the central node, and then back-propagate the model parameters of the initial model according to the loss value to obtain an updated initial model, and then use the graph data sample of the new central node to input the updated initial model, generate a new subgraph sample through the subgraph generation unit 222, and then sample the new subgraph sample through the sampling unit 223 to obtain a new sampling node, and aggregate the features of the new sampling node with the features of the new central node through the aggregation unit 224 to obtain a new aggregation feature, and then input the new aggregation feature into the updated initial model to obtain a new output result, and obtain the loss value according to the difference between the new output result and the label of the new central node, and back-propagate the updated initial model again according to the loss value to obtain the updated initial model again, and so on, through multiple rounds of iterative updates until the model converges to obtain the first model.
[0116] In a specific implementation, the multiple graph data samples participating in the training may be different subgraphs of the same large graph or graph data set at the same time, and each subgraph may include the same or different nodes. The graph data samples used in each round of training are subgraphs corresponding to different central nodes in the large graph or graph data. For example, the graph data at a certain time includes nodes 1 to 10, then graph data sample 1 may be a sample with node 1 as the central node and nodes 2 to 10 as neighboring nodes, graph data sample 2 may be a sample with node 2 as the central node and nodes 1 and 3 to 10 as neighboring nodes, and so on. The present application does not limit this. The graph data samples participating in the training may also be different subgraphs of the same large graph at different times. For example, graph data sample 1 is a transaction network composed of transaction records before August 8, and graph data sample 2 is a transaction network composed of transaction records before August 9. Graph data sample 2 includes part of the content in graph data sample 1. The above examples are for illustration only and the present application does not limit this.
[0117] It should be understood that the present application obtains subgraph samples based on graph data samples, then samples the subgraph samples to obtain sampling nodes, and then trains the model based on the aggregated features of the sampling nodes and the central node. This not only ensures that the generation time of the neighbor node samples participating in the training is earlier than the central node, but also ensures that the data distribution of the neighbor node samples participating in the training is consistent with the data distribution of all neighbor node samples, so that the features learned in the training phase are more consistent with the features in the inference phase, thereby improving the accuracy of the model.
[0118] The label generation unit 225 is used to input the graph data sample into the trained first model, obtain the prediction results of the neighbor node samples in the graph data sample, and generate pseudo labels for the neighbor node samples according to the prediction results of the neighbor node samples. Referring to the foregoing content, it can be seen that the graph data sample includes labeled nodes and unlabeled nodes, and the label generation unit 225 can generate pseudo labels for unlabeled nodes, and then retain the real labels of labeled nodes.
[0119] Optionally, the confidence of the pseudo-label generated by the label generation unit 225 is higher than the pseudo-label threshold, where the pseudo-label threshold can be a threshold set by the user or a default threshold, which is not specifically limited in this application. Confidence refers to the degree of confidence or certainty of the model in its prediction results. In classification tasks, confidence usually refers to the prediction probability or score of the model for a certain category.
[0120] It should be understood that by retaining high-confidence pseudo-labels, the accuracy of pseudo-labels participating in training can be improved, the introduction of noise can be reduced, and the effect of model training can be improved. At the same time, the number of labeled neighbor nodes in the graph data sample is limited, and many neighbor nodes are not labeled, so there is a certain gap between the data distribution of labeled neighbor nodes and the data distribution of real neighbor nodes. By marking high-confidence pseudo-labels, the training set participating in the next round of training includes labeled neighbor nodes and pseudo-label neighbor nodes. The data distribution of neighbor nodes in the training set is more consistent with the data distribution of potential real neighbor nodes. Using such a training set to further train the model can further improve the accuracy of the model.
[0121] In one embodiment, the training unit 221 can use the graph data samples marked with the above-mentioned pseudo-labels to perform a round of training on the first model. The training process can refer to the description of the aforementioned subgraph generation unit 222, sampling unit 223 and aggregation unit 224 to obtain the second model, and then use the verification set to verify the second model to obtain a verification result. If the verification result shows that the model performance has decreased, the above-mentioned pseudo-labels are removed. If the verification result shows that the model performance has improved, the above-mentioned pseudo-labels are retained. Then the next round of training is carried out, and so on, until the model converges to obtain a trained node classification model 230. The model convergence at this time can be that the performance reaches the preset index, or it can be that the pseudo-labels can no longer improve the model performance. This application does not limit the specific standard for model convergence.
[0122] Among them, the evaluation criteria of the above performance can be determined according to the specific application scenario. For example, the evaluation criteria of model performance may include accuracy, which indicates the proportion of samples correctly predicted by the model to the total number of samples; it may also include precision and recall, which are a pair of interrelated indicators. Precision indicates the proportion of samples predicted by the model to be positive examples that are actually positive examples, while recall indicates the proportion of samples predicted to be positive examples by the model to be positive examples; it may also include F1 score, which is the harmonic mean of precision and recall, and can comprehensively consider the accuracy and recall performance of the model. It should be understood that the above examples are for illustration and are not specifically limited in this application.
[0123] The above-mentioned training method performs multiple rounds of training on the model and verifies the generated pseudo-labels in each round of training, so that the pseudo-labels used in each round of training are pseudo-labels that can provide positive and beneficial effects to the model, so that the information in the unlabeled neighbor node samples can be maximized during the model training process to achieve the effect of data enhancement. In some scenarios where the number of real labels is small and difficult to label, a large number of unlabeled neighbor node samples can also be used to complete the model training, so that the node classification model 230 obtained by training has better accuracy and robustness.
[0124] At the same time, in the above training method, when sampling neighbor node samples, the sampling distribution fits the data distribution of neighbor node samples. When using pseudo labels to further train the model, the data distribution of neighbor node samples marked with pseudo labels fits the data distribution of neighbor node samples with real labels, so that the data distribution of neighbor node samples participating in model training fits the real distribution, which can avoid the problem of poor prediction effect of the model on a few categories due to sample imbalance. It should be understood that in some application scenarios, such as risk control scenarios, the number of fraudulent nodes is much lower than the number of normal nodes, and the influence of small category samples on the loss function is very small, which is easily ignored during the optimization process. Sample imbalance can easily make it difficult for the model to predict fraudulent nodes. The training method provided in this application can greatly avoid the occurrence of such situations.
[0125] The functions of each unit module in the reasoning module 210 are described below.
[0126] The acquisition unit 211 is used to receive the graph data of the node to be predicted and the inference sampling parameters sent by the client 100.
[0127] In a specific implementation, graph data may include a node to be predicted and multiple neighboring nodes of the node to be predicted. The node to be predicted here is the central node in the aforementioned content. In order to distinguish the central nodes in the training phase and the inference phase, the central nodes in the training phase are collectively referred to as central nodes, and the central nodes in the inference phase are collectively referred to as nodes to be predicted.
[0128] Optionally, the graph data of the node to be predicted and the graph data sample used in the training phase may be different subgraphs in the same graph, or different subgraphs of the same graph in different time periods. For example, the node to be predicted may be a node newly added to the graph data sample. For example, after the model is trained using the graph data sample corresponding to the transaction network to obtain the node classification model 230, a new transaction is added to the transaction network, and it is necessary to predict whether the transaction is a high-risk transaction. Then, the new transaction can be used as the node to be predicted, and other nodes associated with the new transaction can be used as neighbor nodes to generate graph data of the node to be predicted. For another example, after the node classification model 230 is obtained by training using the graph data sample corresponding to the commodity recommendation network, a new commodity is added to the commodity recommendation network, and it is necessary to predict the user's preference for the commodity. Then, the new commodity can be used as the node to be predicted, and other commodities associated with the new commodity can be used as neighbor nodes to generate graph data of the node to be detected. It should be understood that the above examples are for illustration and are not specifically limited in this application.
[0129] In a specific implementation, the above-mentioned inference sampling parameters include the number of samplings or the number of sampling layers. The description of the number of samplings and the number of sampling layers can refer to the relevant description in the training stage, which will not be repeated here. It should be noted that the number of sampling layers and the number of samplings input by the user in the inference stage may be the same as or different from the number of sampling layers and the number of samplings in the training stage, and this application does not make any collective limitation.
[0130] The prediction unit 212 is used to input the graph data of the node to be predicted into the node classification model 230, and obtain one or more prediction results of the node to be detected according to the inference sampling parameters and sampling times input by the user.
[0131] Optionally, the prediction unit 212 can input graph data into the node classification model 230 to obtain predicted categories of multiple neighboring nodes of the node to be detected, and then sample the multiple neighboring nodes according to the predicted categories of the multiple neighboring nodes and the category distribution of the true labels in combination with the inference sampling parameters input by the user to obtain multiple sampling nodes, and then aggregate the features of the multiple sampling nodes with the features of the node to be detected to obtain aggregated features, and input the aggregated features into the node classification model 230 to obtain the prediction result of the node to be detected.
[0132] Optionally, the above-mentioned reasoning sampling parameters may also include the number of samplings. The prediction unit 212 may also perform multiple samplings on multiple neighbor nodes according to the number of samplings input by the user. Each sampling may obtain a sampling node set, and then perform feature aggregation based on the multiple sampling node sets obtained by the multiple samplings to obtain the aggregated features corresponding to each sampling, thereby obtaining multiple prediction results. The number of samplings is the same as the number of prediction results. Among them, the sampling node sets obtained by sampling at different times have different neighbor nodes, thereby ensuring to the greatest extent that the features of each neighbor node can participate in the reasoning of the model and improve the prediction accuracy of the model.
[0133] It should be noted that if there are neighbor nodes in the graph data whose generation time is later than that of the node to be detected, then according to the description of the subgraph generation unit 222, the prediction unit 212 can first generate the subgraph to be detected corresponding to the graph data, and the generation time of the neighbor nodes in the subgraph to be detected is earlier than that of the node to be detected, and then the subgraph to be detected is sampled multiple times based on the above-mentioned inference sampling parameters and sampling times. The specific description of sampling can refer to the relevant description of the aforementioned sampling unit 223, which will not be repeated here. Among them, the number of samples and the number of sampling layers in the above-mentioned inference sampling parameters can be the same as or different from the training sampling parameters in the training stage, which can be determined according to the actual application scenario, and this application does not make specific limitations.
[0134] The voting unit 213 is used to determine the prediction category of the node to be detected according to the sampling times input by the user and the multiple prediction results generated by the prediction unit 212.
[0135] In a specific implementation, the voting unit 213 can determine the predicted category of the node to be detected through voting strategies such as majority voting, weighted voting, probability fusion, and voting threshold, wherein majority voting refers to voting based on the prediction results, and the category with the most votes is determined as the predicted category of the node to be detected; weighted voting refers to assigning a weight to each prediction result, calculating the average value based on the weight to obtain the final prediction result, and determining the predicted category of the node to be detected based on the final prediction result; probability fusion can calculate the average probability or the maximum probability of the probability value corresponding to each prediction result to obtain the fusion probability, and then determine the predicted category of the node to be detected based on the fusion probability; voting threshold refers to setting a threshold, and when the number of votes for the category with the most votes exceeds the threshold, the category can be confirmed as the predicted category of the node to be detected. It should be understood that the above examples are for illustration, and this application does not limit the voting strategy used by the voting unit 213.
[0136] It should be noted that the above voting strategy may also be a voting strategy set by the user. Specifically, the node classification system 200 may provide the user with multiple voting strategies to choose from, or it may be a voting strategy written by the user himself. This application does not limit this.
[0137] The output unit 214 is used to feed back the predicted category determined by the voting unit 213 to the client 100 .
[0138] In a specific implementation, the output unit 214 may also send the predicted category to the storage system 300 for storage. Specifically, it may be determined based on the actual business scenario whether the predicted result is sent to the client 10 or the storage system 300, or both are fed back. This application does not make any specific limitation.
[0139] In summary, the present application provides a node classification system, which first predicts the category distribution of multiple neighbor node samples in a graph data sample, then obtains the training sampling parameters input by the user, samples the multiple neighbor node samples in the graph data sample to obtain multiple sampling nodes, so that the data distribution of the multiple sampling nodes is similar or consistent with the data distribution of the predicted multiple neighbor node samples, so that the data distribution of the sampled nodes is closer to the distribution of potential real neighbor nodes, and the sampling nodes obtained in this way are used to participate in model training to improve model performance; and, the node classification system takes into account that future neighbor nodes cannot participate in reasoning in the actual reasoning process, so the generation time of the sampling nodes participating in the training is earlier than that of the central node, so that the sampling nodes participating in the training can be more consistent with the real distribution in the reasoning stage, further improving the model. model performance; finally, the model is trained for multiple rounds according to the sampling nodes until the model converges. At the end of each round of training, the converged model is used to predict high-confidence pseudo-labels of neighbor nodes, and the pseudo-labels are verified through the validation set. The pseudo-labels that are beneficial to the model are retained, and the pseudo-labels that are not beneficial to the model are removed. Then, the next round of training is carried out. In this way, the pseudo-labels used in each round of training are pseudo-labels that can provide positive and beneficial effects to the model. During the model training process, the information in the unlabeled neighbor node samples can be maximized to achieve the effect of data enhancement. At the same time, by annotating high-confidence pseudo-labels, the category distribution of the new training set formed by the labeled and pseudo-labeled samples is more consistent with the potential true distribution. Using such a training set to further train the model can further improve the accuracy of the model and improve the performance of the graph neural network.
[0140] Combined with the above Figure 1 and Figure 2 , describes in detail the node classification system provided by this application, and will be combined with Figures 3 to 6 , describes the node classification method provided by this application. Among them, Figure 3 and Figure 4 Describes the steps of the model training phase in the node classification method provided by this application, Figure 5 and Figure 6The present invention describes the steps of the model reasoning phase in the node classification method.
[0141] Figure 3 This is a schematic diagram of the steps of a node classification method in the training phase provided by the present application. The method can be applied to Figure 1 and Figure 2 In the node classification system 200 shown, Figure 3 As shown, the model training method in the node classification method may include the following steps:
[0142] S310: The client 100 sends a graph data sample and training sampling parameters to the node classification system 200. This step can be performed by Figure 2 The acquisition unit 211 in the embodiment is implemented.
[0143] The graph data sample is a graph data sample of a central node, which includes a central node and one or more neighbor nodes connected to the central node. The central node of the graph data sample may include a label, and the multiple neighbor nodes may include labeled nodes and unlabeled nodes. The label here is the true category of the node. Both the central node and the neighbor nodes have corresponding feature information. For a specific explanation of the graph data sample, please refer to Figure 2 The relevant descriptions in the embodiments are not repeated here.
[0144] In the embodiment of the present application, the training sampling parameters may include one or more of the number of samples, the number of sampling layers, and the pseudo-label threshold. The description of the number of samples, the number of sampling layers, and the pseudo-label threshold in the training sampling parameters can be referred to. Figure 2 The relevant descriptions in the embodiments are not repeated here.
[0145] S320: The node classification system 200 inputs the graph data sample into the initial model to obtain the category distribution of multiple neighbor node samples. This step can be performed by Figure 2 The training unit 221 in the embodiment is implemented.
[0146] Referring to the foregoing content, it can be known that the multiple neighbor nodes in the graph data sample include labeled nodes and unlabeled nodes. The initial model can predict the unlabeled nodes to obtain the predicted category of the unlabeled nodes, and then determine the category distribution of the multiple neighbor nodes in the graph data sample according to the labels of the labeled nodes and the predicted category of the unlabeled nodes, that is, the proportion of neighbor nodes of each category in the multiple neighbor nodes. Among them, the initial model can be obtained by training the graph neural network using labeled samples or unlabeled samples. The graph neural network may include GraphSAGE, GCN, GAT, etc.; the initial model can also be a supervised model, such as Random Forests, Multilayer Perceptron (MLP), etc., which is not specifically limited in this application.
[0147] For details, please refer to Figure 2 The relevant descriptions in the embodiments are not repeated here.
[0148] S330: The node classification system 200 determines the subgraph sample of the graph data sample according to the generation time of the central node. This step can be performed by Figure 2 Two sub-graph generation units 222 are implemented.
[0149] In an embodiment of the present application, the subgraph sample includes a central node and multiple neighbor node samples, wherein the central node of the subgraph sample is the central node in the graph data sample, and the multiple neighbor node samples in the subgraph sample are neighbor node samples in the graph data sample whose generation time is earlier than that of the central node. It can be understood that during the model reasoning process, the generation time of the neighbor node samples is earlier than that of the central node. Because the future neighbor nodes cannot participate in the reasoning in the actual reasoning process, the neighbor node samples whose generation time is earlier than that of the central node are also used to participate in the model training during the model training process. This can make the multiple neighbor node samples in the subgraph sample more consistent with the actual distribution. Model training based on the subgraph sample can improve the accuracy of the trained model in the reasoning stage. For a specific description of the generated event, please refer to Figure 2 The relevant descriptions in the embodiments are not repeated here.
[0150] The subgraph samples obtained in the above steps S310 to S330 are one possible implementation method. In another possible implementation method, the node classification system 200 may also first obtain an initial subgraph of the graph data sample, in which the generation time of the neighbor node samples in the initial subgraph is earlier than that of the central node, but the neighbor node samples in the initial subgraph include true labels, and some neighbor node samples may be unlabeled nodes. The initial subgraph is then input into the initial model to obtain the prediction results of each unlabeled neighbor node sample in the initial subgraph, thereby obtaining a subgraph sample in which the generation time of the neighbor node samples is earlier than that of the central node, and each neighbor node sample includes a true label or a prediction result.
[0151] S340: The node classification system 200 samples multiple neighbor nodes in the subgraph sample according to the training sampling parameters and the category distribution of multiple neighbor node samples to obtain multiple sampled node samples. This step can be performed by Figure 2 The sampling unit 223 in the embodiment is implemented.
[0152] In the embodiment of the present application, the similarity between the category distribution of the plurality of sampled nodes and the category distribution of the plurality of neighbor node samples in the subgraph sample is higher than the second threshold. Such a sampling method helps to maintain the category balance of the sampled nodes, ensuring that the neighbor node samples of each category have sufficient participation during the model training process, thereby improving the accuracy of the model.
[0153] In one possible implementation, multiple sampling nodes can be obtained according to the sampling number in the training sampling parameters. Specifically, the category distribution of the sampling nodes can be determined according to the category distribution of the neighboring nodes, which are the same or similar category distributions. Then, the number of sampling nodes of each category is determined according to the category distribution of the sampling nodes and the sampling number. Then, neighboring nodes of corresponding numbers and categories are extracted from multiple neighboring nodes to obtain multiple sampling nodes.
[0154] In another possible implementation, multiple sampling nodes can be obtained according to the number of sampling layers in the training sampling parameters. In a specific implementation, after obtaining the category distribution of multiple neighbor node samples, the number of neighbor node samples of each category can be determined according to the total number of neighbor node samples, and then the number of neighbor node samples contained in each sampling layer can be determined according to the number of sampling layers input by the user combined with the category of the neighbor node samples, wherein the samples of a sampling layer are samples of the same category, and the samples of a category can correspond to one or more sampling layers, and then sampling is performed in different sampling layers, so that the category distribution of the multiple sampling nodes obtained after sampling is similar or consistent with the category distribution of the multiple neighbor node samples, and different sampling methods can be used according to the needs, such as simple random sampling, stratified cluster sampling, etc., which are not specifically limited in this application.
[0155] It should be noted that the number of sampling layers input by the user can be the same as or different from the number of categories of neighbor node samples. In other words, samples of the same category can be divided into one level or multiple levels. It is understandable that the number of neighbor node samples of certain categories may be significantly less than that of other categories. By dividing a category into multiple levels and sampling in each level, the impact of the classification imbalance problem of neighbor node samples on model training can be reduced.
[0156] For example, assuming that the number of sampling layers input by the user is 6, and the category distribution of neighbor node samples is 1:2:3, that is, the number of categories of neighbor node samples is 3, so the first category can be assigned to the first layer, the second category to the second and third layers, and the third category to the fourth to sixth layers. Assuming that the total number of neighbor node samples is N, the number of neighbor node samples in each layer is N / 6. Then, a neighbor node sample is randomly selected from each layer as a round of sampling, and multiple rounds of random sampling are performed. In this way, no matter how many rounds of sampling are performed, the category distribution of the collected nodes is 1:2:3. To ensure that the category distribution of the obtained sampling nodes is the same or similar to the category distribution of the neighbor nodes. The above examples are for illustration only and are not specifically limited in this application.
[0157] In some application scenarios, the features of the nodes in the graph data samples do not include features of the time dimension. In this case, the graph data samples can be sampled directly to obtain multiple sampling nodes. That is to say, after obtaining the prediction results of the neighbor node samples through the initial model, each neighbor node sample in the graph data sample has a corresponding classification. This classification may be the real classification provided by the real label, or it may be the classification predicted by the prediction result. Then, according to the category distribution formed by multiple neighbor node samples and combined with the training sampling parameters input by the user, the multiple neighbor node samples in the graph data sample are stratified and sampled to obtain multiple sampling nodes.
[0158] S350: The node classification system 200 inputs the features of the plurality of sampled node samples into the initial model for training to obtain a first model. This step can be performed by Figure 2 The aggregation unit 224 and the training unit 221 in the embodiment are implemented.
[0159] In an embodiment of the present application, the features of the sampling node samples and the features of the central node can be vectorized first to obtain the feature vectors of the sampling node samples and the feature vectors of the central node, and then the features of multiple sampling node samples and the central node can be aggregated through an aggregation function to obtain the aggregated features of the central node, and then the initial model can be trained according to the aggregated features until the model converges to obtain a trained first model.
[0160] Optionally, the aggregation function may include a sum pooling function, an average pooling function, a maximum pooling function, an attention function, etc. For detailed explanations of the above functions, please refer to Figure 2 The relevant description of the aggregation unit 224 in the embodiment will not be repeated here. In the specific implementation, the most appropriate aggregation function can be selected according to the actual application scenario and business requirements to obtain the aggregation characteristics of the central node, and this application does not limit this.
[0161] In an embodiment of the present application, when the initial model is trained according to the aggregated features, the aggregated features can be first input into the initial model to obtain the output result, and then the loss is obtained according to the gap between the output result and the label of the central node, and then the model parameters of the initial model are adjusted according to the loss to obtain an updated initial model, and then the graph data sample of the new central node is used to input the updated initial model to generate a new subgraph sample, and the new subgraph sample is sampled to obtain a new sampling node, and the features of the new sampling node are aggregated with the features of the new central node to obtain a new aggregated feature, and then the new aggregated feature is input into the updated initial model to obtain a new output result, and the loss is obtained according to the gap between the new output result and the label of the new central node, and the model parameters of the updated initial model are adjusted again according to the loss to obtain a further updated initial model, and so on, through multiple rounds of training until the model converges, a first model is obtained.
[0162] It should be understood that the present application obtains subgraph samples based on graph data samples, then samples the subgraph samples to obtain sampling nodes, and then trains the model based on the aggregated features of the sampling nodes and the central node. This not only ensures that the generation time of the neighbor node samples participating in the training is earlier than the central node, but also ensures that the data distribution of the neighbor node samples participating in the training is consistent with the data distribution of all neighbor node samples, so that the features learned in the training phase are more consistent with the features in the inference phase, thereby improving the accuracy of the model.
[0163] S360: The node classification system 200 generates pseudo labels for graph data samples based on the first model and the pseudo label threshold, and uses the pseudo labels to train the first model to obtain a node classification model. This step can be performed by Figure 2 The label generation unit 225 and the training unit 221 in the embodiment are implemented.
[0164] In the embodiment of the present application, the confidence of the pseudo-label is higher than the pseudo-label threshold input by the user. It should be understood that by retaining the high-confidence pseudo-label, the accuracy of the pseudo-label involved in the training can be improved, the introduction of noise can be reduced, and the effect of model training can be improved. At the same time, the number of labeled samples in the graph data samples is limited, and many samples are not labeled, so there is a certain gap between the data distribution of the labeled samples and the actual true distribution. By marking the high-confidence pseudo-label, the category distribution of the new training set formed by the labeled and pseudo-label samples finally obtained is more consistent with the potential true distribution. Using such a training set to further train the model can further improve the accuracy of the model.
[0165] In the embodiment of the present application, the first model is trained for one round using the graph data samples marked with the above pseudo labels to obtain the second model, and then the second model is verified using the verification set to obtain the verification result. If the verification result shows that the model performance has decreased, the pseudo labels are removed. If the verification result shows that the model performance has improved, the pseudo labels are retained. Then the next round of training is performed until the model converges to obtain a trained node classification model.
[0166] The above implementation method can make the pseudo labels used in each round of training provide positive and beneficial effects to the model by training the model for multiple rounds, and verifying the generated pseudo labels in each round of training, so that the information in the unlabeled neighbor node samples can be maximized during the model training process to achieve the effect of data enhancement. In some scenarios where the number of real labels is small and difficult to label, a large number of unlabeled neighbor node samples can also be used to complete the training of the model, so that the node classification model 230 obtained by training has better accuracy and robustness. At the same time, when the model is further trained using pseudo labels, the data distribution of the training set formed by the pseudo labels and the real labels is more in line with the real data distribution, which can improve the model performance. It should be understood that in some application scenarios, such as in risk control scenarios, the number of fraudulent nodes is much lower than the number of normal nodes, and the small category samples have little effect on the loss function, which is easily ignored during the optimization process. Sample imbalance can easily lead to the model being difficult to predict fraudulent nodes. The training method provided by this application can greatly avoid the occurrence of such situations.
[0167] S370: The node classification system 200 returns a training completion message to the client 100.
[0168] In one embodiment, the user can generate graph data based on his or her historical business data, and then input the graph data and training sampling parameters into the node classification system 200, and then wait for the node classification system 200 to complete the training of the node classification model based on the graph data. After receiving the message from the node classification system 200 that the training is completed, the user can input the graph data updated over time into the node classification model to obtain the predicted category of the newly added node. The node classification model obtained using this training method can fit the user's business scenario, and more accurate classification results can be obtained in the prediction stage.
[0169] Figure 3 The step flow shown is a possible implementation of the present application. The present application also provides other possible implementations, which are summarized below.
[0170] In a first possible implementation, graph data samples are input into an initial model to obtain a category distribution of multiple neighbor node samples, and then multiple neighbor nodes in multiple subgraph samples are sampled according to training sampling parameters and the category distribution of multiple neighbor node samples to obtain samples of multiple sampled nodes. The features of the multiple sampled node samples are then input into the initial model for training to obtain a node classification model. The training module 220 of the node classification system in this implementation only includes a sampling unit 223, a training unit 221 and an aggregation unit 224. The step flow of this implementation includes step S310 and step S330 to step S350.
[0171] In another possible implementation, after obtaining the category distribution of multiple neighbor node samples, the subgraph samples of the graph data samples are determined according to the generation time of the central node, and then the subgraph samples are sampled to obtain multiple sampled node samples, and the features of the multiple sampled node samples are input into the initial model for training to obtain the first model. The training module of the node classification system in this implementation includes a sampling unit 223, a training unit 221, an aggregation unit 224, and a subgraph generation unit 222, and the step flow of this implementation includes steps S310 to S350.
[0172] In another possible implementation, after obtaining the first model, a pseudo-label is generated for the graph data sample based on the first model and the pseudo-label threshold, and the first model is trained using the pseudo-label to obtain a node classification model. The training module of the node classification system in this implementation includes a sampling unit 223, a training unit 221, an aggregation unit 224, a subgraph generation unit 222, and a label generation unit 225. The step flow of this implementation includes steps S310 to S370.
[0173] It should be understood that the various schemes listed above are only some possible implementation methods provided by the present application, but the scope of protection of the present application is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent repairs or replacements within the technical scope disclosed in the present application, and these repairs or replacements should be included in the scope of protection of the present application.
[0174] In order to make this application better understood, Figure 4 The above steps S310 to S370 are described with examples. Figure 4 This is a flowchart of the steps of the training phase of a node classification method provided by the present application in an application scenario. Figure 4 In the application scenario shown, the graph data of the central node includes multiple neighbor nodes, and the multiple neighbor nodes include labeled nodes and unlabeled nodes. For example, Figure 4 Four unlabeled nodes and one labeled node are given, and the label of the labeled node is category 2.
[0175] Execute S310 to obtain training sampling parameters and graph data samples. The training sampling parameters may include the number of sampling layers and the pseudo label threshold. Assume that the number of sampling layers is 2 and the pseudo label threshold is X.
[0176] Execute S320 to input the graph data sample into the initial model, obtain the predicted category of each unlabeled node, and then obtain the category distribution of neighbor nodes as 1:1, that is, 50% of the neighbor nodes are of category 1 and 50% of the neighbor nodes are of category 2.
[0177] Executing S330 may determine a subgraph sample of the graph data sample according to the generation time of the central node and the generation time of the neighbor nodes, wherein the generation time of each neighbor node in the subgraph sample is earlier than the generation time of the central node. For example, Figure 4 The subgraph sample shown includes 2 samples of category 1 and 2 samples of category 2, so the category distribution of neighbor nodes in this subgraph sample is 1:1.
[0178] Execute S340 to sample the subgraph sample according to the sampling layer number input by the user to obtain multiple sampling node samples, wherein the category distribution of the sampling node samples is the same as the category distribution among multiple neighboring nodes in the subgraph sample, so Figure 4 In the example shown, the number of sampling layers is 2, the first layer corresponds to the neighbor node samples of category 1, and the second layer corresponds to the neighbor node samples of category 2. Random sampling is performed alternately in the first layer and the second layer, and the category distribution of the neighbor nodes in the subgraph samples is 1:1, so the number of sampled node samples of category 1 and the number of sampled node samples of category 2 obtained by sampling are the same. The specific steps of performing stratified sampling according to the number of sampling layers can be referred to S340 and the detailed description of the sampling unit 223, which will not be repeated here.
[0179] Execute S350 to aggregate the features of multiple sampling nodes and the features of the central node to obtain the aggregated features of the central node, input the aggregated features into the initial model to obtain the output result, and back-propagate the model parameters of the initial model according to the loss value between the output result and the label of the central node to obtain the first model. If the first model has not converged, then the first model can continue to be trained using the new graph data sample of the central node, and then obtain new aggregated features through S310~S350 again, and then use the new aggregated features to train the first model, and so on, until the first model converges. Among them, the convergence here can refer to the state where the model performance stops improving significantly and tends to be stable. The judgment conditions of convergence are different in different application scenarios. For example, the convergence condition can be that the loss function reaches a stable state, and the model can be considered to have converged on the loss function; for another example, the convergence condition can be that the parameter changes of the model reach a stable state, and when the model parameters no longer need to be adjusted, the model parameters can be considered to have converged; for another example, the convergence condition can be that the accuracy of the model reaches a stable state, and the model can be considered to have converged on the accuracy. The above examples are for illustration, and this application is not specifically limited.
[0180] After the first model converges, step S360 can be executed, the graph data sample is input into the first model to obtain the prediction result of each neighbor node, and then according to the pseudo-label threshold X input by the user, the prediction result with a confidence level exceeding the pseudo-label threshold X is retained as the pseudo-label of the neighbor node, and the graph data sample carrying the pseudo-label is obtained. The first model is trained using the graph data sample, and the aggregation features of the graph data sample carrying the pseudo-label are obtained again through S310 to S350. The first model is trained using the aggregation features to obtain the second model, and then the second model is verified on the verification set. If the model performance of the second model is reduced compared with the first model, Then the pseudo labels generated by this round of training are removed. If the model performance is improved, the pseudo labels used in this round of training are retained, and then the next round of training is carried out. In the next round, new graph data samples will be used to generate new pseudo labels, and then the first model is trained. After S310 to S350, the aggregated features of the graph data samples carrying the new pseudo labels are obtained, and the aggregated features are used to train the first model to obtain the second model, and then the second model is verified on the verification set. According to the verification results, the pseudo labels used in this round of training are retained or deleted, until N consecutive rounds fail to improve the performance of the second model, the model training is completed, and a trained node classification model is obtained.
[0181] The training method provided by the present application, in the early stage, continuously samples the neighbor nodes to obtain the sampling nodes that fit the data distribution of the neighbor node samples, and then uses the aggregated features of the sampling nodes to train the model, which can not only reduce the amount of calculation, but also ensure that the data distribution of the sampling nodes fits the real distribution, and can avoid the problem of poor prediction effect of the model on a few categories caused by sample imbalance. Later, the model is trained one step further through pseudo-labels, so that the nodes that have not been sampled can also be sampled through multiple rounds of training, and each round of training verifies the generated pseudo-labels, so that the pseudo-labels used in each round of training can be pseudo-labels that can provide positive and beneficial effects to the model, so that the information in the unlabeled neighbor node samples can be maximized during the model training process to achieve the effect of data enhancement. In some scenarios where the number of real labels is small and difficult to label, a large number of unlabeled neighbor node samples can also be used to complete the model training, so that the node classification model 230 obtained by training has better accuracy and robustness.
[0182] Combination of the above Figure 3 and Figure 4 The steps of model training in the node classification method provided by this application are described in detail. Figure 5 and Figure 6 , the step flow of model reasoning in the node method provided in this application is explained.
[0183] Figure 5 This is a schematic diagram of the steps of a node classification method provided by this application in the reasoning stage, such as Figure 5 As shown, the method may include the following steps:
[0184] S510: The client 100 sends the graph data and reasoning sampling parameters of the node to be detected to the node classification system 200. This step can be performed by Figure 2 The acquisition unit 211 in the embodiment is implemented.
[0185] Optionally, the above-mentioned inference sampling parameters include the number of samplings or the number of sampling layers, and the definitions of the number of samplings and the number of sampling layers are the same as the number of samplings and the number of sampling layers in the training sampling parameters. It should be noted that the number of sampling layers and the number of samplings input by the user in the inference stage may be the same as or different from the number of sampling layers and the number of samplings in the training stage, and this application does not make any collective limitation.
[0186] Optionally, the above-mentioned inference sampling parameters also include sampling times, which refers to the number of times the node classification system 200 samples multiple neighbor nodes. It should be understood that if the user does not enter the sampling times, then one sampling can be performed, and the prediction result obtained based on the sampling is the predicted category of the node to be detected.
[0187] S520: The node classification system 200 inputs the graph data into the node classification model to obtain the category distribution of multiple neighbor nodes. This step can be performed by Figure 2 The prediction unit 212 in the embodiment implements.
[0188] The specific implementation method of this step is similar to step S320 in the training stage, and will not be repeated here.
[0189] S530: The node classification system 200 performs multiple sampling on multiple neighbor nodes according to the inference sampling parameters and the category distribution of multiple neighbor nodes to obtain multiple sampling node sets. This step can be performed by Figure 2 The prediction unit 212 in the embodiment implements.
[0190] In a specific implementation, the node classification system 200 can perform multiple samplings on multiple neighbor nodes according to the sampling times in the inference sampling parameters. Each sampling can obtain a sampling node set. There may be intersections between different sampling node sets, and the similarity between the category distribution of the sampling nodes in each sampling node set and the categories of multiple neighbor points is higher than a first threshold.
[0191] It should be noted that if there are neighbor nodes in the graph data whose generation time is later than that of the node to be detected, then a subgraph to be detected corresponding to the graph data can be generated first, in which the generation time of the neighbor nodes in the subgraph to be detected is earlier than that of the node to be detected, and then the subgraph to be detected can be sampled multiple times based on the above-mentioned inference sampling parameters and sampling times.
[0192] The specific implementation method of this step is similar to step S330 in the training stage, and will not be repeated here.
[0193] S540: The node classification system 200 inputs the features of each sampled node set into the node classification model to obtain multiple prediction results of the nodes to be detected. Figure 2 The prediction unit 212 in the embodiment implements.
[0194] In a specific implementation, a sampling node set is input into a node classification model to obtain a prediction result of a node to be detected, that is, a sampling node set corresponds to a prediction result.
[0195] S550: The node classification system 200 determines the prediction category of the node to be detected based on the multiple prediction results of the node to be detected. Figure 2 The voting unit 213 in the embodiment is implemented.
[0196] In a specific implementation, the prediction category of the node to be detected can be determined by voting strategies such as majority voting, weighted voting, probability fusion, and voting threshold. The description of the voting strategy can refer to the relevant description of the aforementioned voting unit 213, which will not be repeated here.
[0197] S560: The node classification system 200 returns the predicted category of the node to be detected to the client 100. This step can be performed by Figure 2 The output unit 214 in the embodiment is implemented.
[0198] Optionally, the node classification system 200 may send the predicted category to the storage system 300 for storage. It should be understood that after obtaining the predicted category of the node to be detected, different application scenarios may have different business processes for the predicted category, which is not specifically limited in this application.
[0199] In order to make this application better understood, Figure 6 The above steps S510 to S560 are described with examples. Figure 6 This is a schematic diagram of the steps of the reasoning phase of a node classification method provided by the present application in an application scenario. Figure 6 In the application scenario shown, the graph data of the node to be detected includes multiple neighbor nodes, and the multiple neighbor nodes include labeled nodes and unlabeled nodes. For example, Figure 4 Given 4 unlabeled nodes and 1 labeled node, the label of the labeled node is category 1. It should be noted that, Figure 6 and Figure 4 The structure of the graph data in the inference phase is very similar, but in actual application scenarios, the structure of the graph data in the reasoning phase may be the same as or different from the graph data structure in the training phase, and this application does not make specific limitations.
[0200] Execute S510 to obtain graph data and inference sampling parameters. The inference sampling parameters include the number of sampling layers and the number of sampling times. Assume that the number of sampling layers is 2 and the number of sampling times is Y.
[0201] Execute S520, input the graph data into the node classification model, obtain the predicted categories of multiple neighbor nodes in the graph data, and then obtain the category distribution of the neighbor nodes as 1:1, that is, 50% of the neighbor nodes are category 1 and 50% of the neighbor nodes are category 2. The node classification model is Figure 4 and Figure 5 The model obtained by training S310~S370 in .
[0202] Execute S530 to obtain a set of Y sampling nodes according to the sampling number Y in the inference sampling parameter. Figure 6 Three sampling node sets are given as examples, and the sampling nodes in each sampling node set are different. However, in actual applications, some sampling nodes in the Y sampling node sets may be combined to form an intersection, which is not limited in the present application.
[0203] Execute S540 to input each sampling node set into the node classification model to obtain multiple prediction results of the nodes to be detected.
[0204] Execute S550 to determine the predicted category of the node to be detected according to the multiple prediction results. For example, vote on the category to which the node to be detected belongs according to the multiple prediction results, and the category with the highest number of votes is the predicted category of the node to be detected.
[0205] It should be understood that the above reasoning method, which obtains multiple prediction results through multiple sampling and then obtains the prediction category of the node to be detected based on voting of multiple prediction results, can reduce the impact of random sampling on the prediction results, thereby improving the stability and reliability of the final results.
[0206] In order to make this application better understood, Figure 7 The node classification method provided in this application is further described. Figure 7 This is an exemplary interface display diagram of the node classification method provided by this application. Figure 7 The interface shown is an example and is not specifically limited in this application. Figure 7 As shown, the interface may include a first input area 710 , a second input area 720 , and a third input area 730 .
[0207] The first input area 710 is used to input training sampling parameters, including but not limited to one or more of the number of sampling nodes, the number of sampling layers, and the pseudo-label threshold. The description of the number of sampling nodes, the number of sampling layers, and the pseudo-label threshold is as described above. Figure 2 to Figure 4 The contents in the embodiments are not repeated here.
[0208] The second input area 720 is used to input inference sampling parameters, including but not limited to one or more of the number of sampling nodes, the number of sampling layers, and the number of sampling times. The description of the number of sampling nodes, the number of sampling layers, and the number of sampling times can refer to the aforementioned Figure 2 , Figure 5 and Figure 6 The contents in the embodiments are not repeated here.
[0209] The third input area 730 is used to input the graph data samples used in the training phase. Figure 7 Some parameter settings of the graph data sample are given as examples, including but not limited to data type, data set name, import method, description, etc., which are not limited in this application. The input method of the graph data used in the inference stage is similar to that of the third input area 730. Figure 7 It is not shown. It should be understood that Figure 7is an exemplary interface. In actual application scenarios, the first input area 710, the second input area 720 and the third input area 730 may also include more content, and, Figure 7 The interface shown may also include more input areas, such as the input area for the graph data of the nodes to be detected used in the inference phase described above. Figure 7 To be limited.
[0210] It can be understood that the node classification method provided by the present application performs stratified sampling of multiple neighbor nodes in the graph data sample according to the predicted categories of multiple neighbor nodes based on the training sampling parameters input by the user during the training phase, and the data distribution of the obtained sampling nodes is similar or consistent with the data distribution of multiple neighbor nodes, which can avoid the problem of poor prediction effect of the model on a few categories due to sample imbalance. It should be understood that in some application scenarios, such as risk control scenarios, the number of fraudulent nodes is much lower than the number of normal nodes, and the influence of small category samples on the loss function is very small, which can be easily ignored during the optimization process. Sample imbalance can easily make it difficult for the model to predict fraudulent nodes. The training method provided by the present application can greatly avoid the occurrence of such situations. At the same time, according to the inference sampling parameters input by the user, multiple pseudo-labels of the graph data samples are obtained, and then the model is further trained using the pseudo-labels. In addition, the generated pseudo-labels are verified in each round of training, so that the pseudo-labels used in each round of training can provide positive and beneficial effects on the model, so that the information in the unlabeled neighbor node samples can be maximized during the model training process to achieve the effect of data enhancement. In some scenarios where the number of real labels is small and difficult to label, a large number of unlabeled neighbor node samples can also be used to complete the model training.
[0211] In the inference stage, according to the inference sampling parameters input by the user, multiple neighbor nodes in the graph data are sampled multiple times to obtain multiple sampling node sets, and then multiple prediction results of the nodes to be detected are obtained based on the multiple sampling node sets. The prediction category of the nodes to be detected is obtained by voting based on the multiple prediction results, which can reduce the impact of random sampling on the prediction results, thereby improving the stability and reliability of the final results.
[0212] In summary, the present application provides a node classification method, which first predicts and obtains the category distribution of multiple neighbor nodes in the graph data, then obtains the training sampling parameters input by the user, and samples multiple neighbor node samples in the graph data sample to obtain multiple sampling nodes, so that the category distribution of the multiple sampling nodes is similar or consistent with the category distribution of the predicted multiple neighbor node samples, so that the data distribution of the sampled sampling nodes is closer to the distribution of potential real neighbor nodes, and the sampling nodes obtained in this way are used to participate in model training to improve model performance; and the node classification system takes into account that the future neighbor nodes cannot participate in reasoning in the actual reasoning process, so the generation time of the sampling nodes participating in the training is earlier than that of the central node, so that the sampling nodes participating in the training can be more consistent with the actual distribution in the reasoning stage, further improving the model performance. Finally, the model is trained for multiple rounds according to the sampling nodes until the model converges. At the end of each round of training, the converged model is used to predict high-confidence pseudo-labels of neighbor nodes, and the pseudo-labels are verified through the validation set. The pseudo-labels that are beneficial to the model are retained, and the pseudo-labels that are not beneficial to the model are removed. Then the next round of training is carried out. In this way, the pseudo-labels used in each round of training are pseudo-labels that can provide positive and beneficial effects to the model. During the model training process, the information in the unlabeled neighbor node samples can be maximized to achieve the effect of data enhancement. At the same time, by annotating high-confidence pseudo-labels, the category distribution of the new training set formed by the labeled and pseudo-labeled samples is more consistent with the potential true distribution. Using such a training set to further train the model can further improve the accuracy of the model and improve the performance of the graph neural network.
[0213] Combined with the above Figures 2 to 7 , describes in detail the node classification method provided by this application, and will be combined with Figure 8 , describing the computing device provided by this application. Figure 8 It is a structural diagram of a computing device provided in the present application. The computing device 800 may be the node classification system 200 in the aforementioned content.
[0214] Furthermore, the computing device 800 includes a processor 801, a storage unit 802, a storage medium 803 and a communication interface 804, wherein the processor 801, the storage unit 802, the storage medium 803 and the communication interface 804 communicate through a bus 805, and also communicate through other means such as wireless transmission.
[0215] The processor 801 is composed of a plurality of general-purpose processors, such as a CPU, an NPU, or a combination of a CPU and a hardware chip. The above-mentioned hardware chip is an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The above-mentioned PLD is a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), a data processing unit (DPU), a system on chip (SoC), or any combination thereof. The processor 801 executes various types of digital storage instructions, such as software or firmware programs stored in the storage unit 802, which enables the computing device 800 to provide a wide variety of services.
[0216] In a specific implementation, as an embodiment, the processor 801 includes one or more CPUs, such as Figure 8 CPU0 and CPU1 are shown in the figure.
[0217] In a specific implementation, as an embodiment, the computing device 800 also includes multiple processors, such as Figure 8 801 and processor 806 shown in . Each of these processors can be a single-core processor (single-CPU) or a multi-core processor (multi-CPU). The processor here refers to one or more devices, circuits, and / or processing cores for processing data (such as computer program instructions).
[0218] The storage unit 802 is used to store program codes, and is controlled by the processor 801 to execute the above Figure 1-Figure 7 The processing steps of the node classification method in any embodiment of the present invention. The program code includes one or more software units. The one or more software units are Figure 2 One or more of the training unit, subgraph generation unit, sampling unit, aggregation unit, label generation unit, acquisition unit, output unit, prediction unit and voting unit in the embodiment, wherein the acquisition unit user acquires the graph data and reasoning sampling parameters of the node to be detected, specifically for implementing Figure 3 and Figure 4 Step S310 and its optional steps in the embodiment, Figure 5 and Figure 6In step S510 and its optional steps in the embodiment, the prediction unit is used to input the graph data into the node classification model to obtain the category distribution of multiple neighbor nodes, and then sample the multiple neighbor nodes according to the inference sampling parameters and the category distribution of the multiple neighbor nodes to obtain multiple sampled nodes, and then input the features of the multiple sampled nodes and the features of the nodes to be detected into the node classification model to obtain the predicted category of the nodes to be detected, which is specifically used to implement Figure 5 and Figure 6 Steps S520 to S560 and their optional steps in the embodiment. The training samples are used to input the graph data into the initial model to obtain the category distribution of multiple neighbor node samples, and are also used to train the initial model according to the characteristics of multiple sampled node samples and the characteristics of the central node to obtain a node classification model, which is specifically used to implement Figure 3 and Figure 4 In the step S320 and step S350 of the embodiment and the optional steps thereof, the sampling unit is used to sample multiple neighbor node samples according to the training sampling parameters and the category distribution of the neighbor node samples to obtain multiple sampling node samples, which is specifically used to implement Figure 3 and Figure 4 In step S340 and its optional steps in the embodiment, the label generation unit is used to generate pseudo labels according to the training sampling parameters, specifically for implementing Figure 3 and Figure 4 Step S360 and its optional steps in the embodiment. It should be understood that the specific description of the above multiple software units can refer to Figure 2 The contents in the embodiments are not repeated here.
[0219] The storage unit 802 includes a read-only memory and a random access memory, and provides instructions and data to the processor 801. The storage unit 802 also includes a non-volatile random access memory. The storage unit 802 is a volatile memory or a non-volatile memory, or includes both volatile and non-volatile memories. Among them, the non-volatile memory is a read-only memory (ROM), a programmable ROM (PROM), an erasable PROM (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory is a random access memory (RAM), which is used as an external cache. By way of example but not limitation, many forms of RAM are used, such as static RAM (SRAM), dynamic random access memory (DRAM), synchronous DRAM (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM) and direct rambus RAM (DR RAM). It can also be a hard disk, a universal serial bus (USB), a flash memory, a secure digital memory card (SD card), a memory stick, etc. The hard disk is a hard disk drive (HDD), a solid state disk (SSD), a mechanical hard disk (HDD), etc., and this application does not make specific limitations.
[0220] The storage medium 803 is a carrier for storing data, such as a hard disk, a USB flash drive (universal serialbus), a flash memory, a secure digital memory card (SD card), a memory stick, etc. The hard disk can be a hard disk drive (HDD), a solid state disk (SSD), a mechanical hard disk (HDD), etc., and this application does not make specific limitations.
[0221] The communication interface 804 is a wired interface (such as an Ethernet interface), an internal interface (such as a high-speed serial computer expansion bus (Peripheral Component Interconnect express, PCIe) bus interface), a wired interface (such as an Ethernet interface) or a wireless interface (such as a cellular network interface or a wireless local area network interface) for communicating with other servers or units.
[0222] The bus 805 is a Peripheral Component Interconnect Express (PCIe) bus, an extended industry standard architecture (EISA) bus, a unified bus (Ubus or UB), a compute express link (CXL), a cache coherent interconnect for accelerators (CCIX), etc. The bus 805 is divided into an address bus, a data bus, a control bus, etc.
[0223] The bus 805 includes not only a data bus but also a power bus, a control bus, and a status signal bus, etc. However, for the sake of clarity, various buses are labeled as the bus 805 in the figure.
[0224] Need to explain, Figure 8 This is only one possible implementation of the embodiment of the present application. In practical applications, the computing device 800 may also include more or fewer components, which is not limited here. Figure 1-Figure 6 The relevant explanations in the embodiments will not be repeated here.
[0225] The embodiment of the present application further provides a computing device cluster, which includes at least one computing device 800. The memory 803 in one or more computing devices 800 in the computing device cluster may store the same or different instructions for executing the node classification method.
[0226] The embodiment of the present application also provides a computer program product including instructions. The computer program product may be a software or program product including instructions that can be run on a computing device or stored in any available medium. When the computer program product is run on at least one computing device, the at least one computing device executes the node classification method.
[0227] The embodiment of the present application also provides a computer-readable storage medium. The computer-readable storage medium can be any available medium that can be stored by the computing device or a data storage device such as a data center containing one or more available media. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a high-density digital video disc (DVD)), or a semiconductor medium (e.g., a solid-state hard disk). The computer-readable storage medium includes instructions that instruct the computing device to execute the node classification method.
[0228] The above embodiments may be implemented in whole or in part by software, hardware, firmware or any other combination thereof. When implemented using software, the above embodiments may be implemented in whole or in part in the form of a computer program product. The computer program product includes a plurality of computer instructions. When the computer program instructions are loaded or executed on a computer, the process or function according to the embodiment of the present invention is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium.
[0229] The above are only specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent repairs or replacements within the technical scope disclosed by the present invention, and these repairs or replacements should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.
Claims
1. A node classification method based on graph neural network, characterized in that: The method comprises: Acquire graph data and reasoning sampling parameters of a node to be detected, wherein the graph data includes the node to be detected and a plurality of neighboring nodes connected to the node to be detected; Inputting the graph data into a node classification model to obtain category distribution of the plurality of neighbor nodes; According to the inference sampling parameter and the category distribution of the plurality of neighbor nodes, sampling the plurality of neighbor nodes to obtain a plurality of sampling nodes; The features of the multiple sampling nodes and the features of the node to be detected are input into the node classification model to obtain the predicted category of the node to be detected.
2. The method according to claim 1, characterized in that The similarity between the category distribution of the plurality of sampling nodes and the category distribution of the plurality of neighboring nodes is higher than a first threshold.
3. The method according to claim 1 or 2, characterized in that: The nodes to be detected include labeled nodes and unlabeled nodes. The category distribution of the multiple neighbor nodes is obtained based on the labels of the labeled nodes and the prediction results of the unlabeled nodes. The prediction results of the unlabeled nodes are obtained after the graph data is input into the node classification model.
4. The method according to any one of claims 1 to 3, characterized in that: The inference sampling parameters include the number of the sampling nodes; Alternatively, the inference sampling parameters include the number of sampling layers, which is used to perform stratified sampling on the multiple neighbor nodes according to the category distribution of the multiple neighbor nodes to obtain multiple sampling nodes, wherein each sampling layer includes multiple sampling nodes of the same category, and each category of sampling nodes corresponds to one or more sampling layers.
5. The method according to claim 4, characterized in that The inference sampling parameters include sampling times, which are used to perform multiple sampling on the multiple neighbor nodes. The multiple acquisition nodes include multiple acquisition node sets, and one acquisition node set corresponds to one sampling. The predicted category of the node to be detected is obtained based on multiple prediction results, and one prediction result is obtained by inputting the sampling node set into the node classification model.
6. The method according to any one of claims 1 to 5, characterized in that: Before obtaining the graph data and reasoning sampling parameters of the node to be detected, the method further includes: Obtain graph data samples and training parameters of the central node, wherein the graph data samples include the central node and a plurality of neighboring node samples connected to the central node, the training sampling parameters include the number of sampling nodes or the number of sampling layers, and the graph data of the node to be detected and the graph data sample of the central node are different subgraphs in the same graph; Inputting the graph data sample into an initial model to obtain the category distribution of the plurality of neighbor node samples; Sampling the plurality of neighbor node samples according to the training sampling parameters and the category distribution of the neighbor node samples to obtain a plurality of sampling node samples, wherein the similarity between the category distribution of the plurality of sampling nodes and the category distribution of the plurality of neighbor nodes is higher than a second threshold; The features of the multiple sampling node samples and the features of the central node are input into the initial model for training to obtain the node classification model.
7. The method according to claim 6, characterized in that The generation time of the samples of the multiple sampling nodes is earlier than the generation time of the central node.
8. The method according to claim 6 or 7, characterized in that: Inputting the features of the plurality of sampled node samples into the initial model for training to obtain the node classification model comprises: Inputting the features of the samples of the plurality of sampling nodes into the initial model for training to obtain a first model; Generate pseudo labels for the graph data samples based on the first model, and use the pseudo labels to train the first model to obtain the node classification model.
9. The method according to claim 8, characterized in that The training sampling parameters include a pseudo label threshold, and the confidence of the pseudo label is higher than the pseudo label threshold.
10. The method according to any one of claims 1 to 9, characterized in that: The graph data includes any one of social media network graph data, transaction network graph data, commodity network graph data, knowledge graph, and biological molecular structure graph data.
11. A node classification system based on graph neural network, characterized in that: The system comprises: An acquisition unit, used to acquire graph data and reasoning sampling parameters of a node to be detected, wherein the graph data includes the node to be detected and a plurality of neighboring nodes connected to the node to be detected; A prediction unit, configured to input the graph data into a node classification model to obtain a category distribution of the plurality of neighbor nodes; The prediction unit is used to sample the multiple neighbor nodes according to the inference sampling parameters and the category distribution of the multiple neighbor nodes to obtain multiple sampling nodes; The prediction unit is used to input the features of the multiple sampling nodes and the features of the node to be detected into the node classification model to obtain the predicted category of the node to be detected.
12. The system according to claim 10, characterized in that The similarity between the category distribution of the plurality of sampling nodes and the category distribution of the plurality of neighboring nodes is higher than a first threshold.
13. The system according to claim 11 or 12, characterized in that The nodes to be detected include labeled nodes and unlabeled nodes. The category distribution of the multiple neighbor nodes is obtained based on the labels of the labeled nodes and the prediction results of the unlabeled nodes. The prediction results of the unlabeled nodes are obtained after the graph data is input into the node classification model.
14. The system according to any one of claims 11 to 13, characterized in that: The inference sampling parameters include the number of the sampling nodes; Alternatively, the inference sampling parameters include the number of sampling layers, which is used to perform stratified sampling on the multiple neighbor nodes according to the category distribution of the multiple neighbor nodes to obtain multiple sampling nodes, wherein each sampling layer includes multiple sampling nodes of the same category, and each category of sampling nodes corresponds to one or more sampling layers.
15. The system according to claim 14, characterized in that The inference sampling parameters include sampling times, which are used to perform multiple sampling on the multiple neighbor nodes. The multiple acquisition nodes include multiple acquisition node sets, and one acquisition node set corresponds to one sampling. The predicted category of the node to be detected is obtained based on multiple prediction results, and one prediction result is obtained by inputting the sampling node set into the node classification model.
16. The system according to any one of claims 11 to 15, characterized in that: The system also includes a training unit and a sampling unit. The training unit is used to obtain a graph data sample and training parameters of a central node before the acquisition unit obtains the graph data and reasoning sampling parameters of the node to be detected. The graph data sample includes the central node and a plurality of neighboring node samples connected to the central node. The training sampling parameters include the number of sampling nodes or the number of sampling layers. The graph data of the node to be detected and the graph data sample of the central node are different subgraphs in the same graph. The training unit is used to input the graph data sample into an initial model to obtain the category distribution of the plurality of neighbor node samples; The sampling unit is used to sample the multiple neighbor node samples according to the training sampling parameters and the category distribution of the neighbor node samples to obtain multiple sampling node samples, and the similarity between the category distribution of the multiple sampling nodes and the category distribution of the multiple neighbor nodes is higher than a second threshold; The training unit is used to input the features of the multiple sampling node samples and the features of the central node into the initial model for training to obtain the node classification model.
17. The system according to claim 16, characterized in that The generation time of the samples of the multiple sampling nodes is earlier than the generation time of the central node.
18. The system according to claim 16 or 17, characterized in that The system comprises a label generating unit, The training unit is used to input the features of the samples of the multiple sampling nodes into the initial model for training to obtain a first model; The label generation unit is used to generate pseudo labels for the graph data samples based on the first model, and use the pseudo labels to train the first model to obtain the node classification model.
19. The system according to claim 18, characterized in that The training sampling parameters include a pseudo label threshold, and the confidence of the pseudo label is higher than the pseudo label threshold.
20. The system according to any one of claims 11 to 19, characterized in that: The graph data includes any one of social media network graph data, transaction network graph data, commodity network graph data, knowledge graph, and biological molecular structure graph data.
21. A computing device, characterized in that The computing device includes a processor and a memory, wherein the memory is used to store instructions, and the processor is used to execute the instructions, so that the computing device implements the system according to any one of claims 1 to 10.
22. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, and the instructions are executed by a computing device or a computing device cluster to implement the system according to any one of claims 1 to 10.
Citation Information
Cited By
Ethereum malicious sample detection method and system for homogeneous enhanced compression modeling
CN120546989A
Node classification method and system based on graph neural network, and related device
EP4726579A1
Node classification method and system based on graph neural network, and related device
WO2025045151A1