A recommendation method based on community awareness and multi-scale graph contrastive learning
By adopting the methods of community-perceptual map enhancement and multi-scale map comparison learning in the social network recommendation system, the problems of insufficient data sparsity and multi-scale information utilization are solved, which significantly improves the accuracy of user classification and the personalized ability of the recommendation system.
Patent Information
- Application Number
- CN202411536296.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-31
- Publication Date
- 2025-03-04
- Estimated Expiration
- 2044-10-31
AI Technical Summary
The existing social network recommendation system faces the problems of data sparseness, damage to the community structure and insufficient utilization of multi-scale information, resulting in poor user classification results.
Using the recommended method based on community perception and multi-scale graph comparison learning, we use the design of community perception graph enhancement strategies and multi-scale comparison modes to capture local and global information and optimize model parameters.
Effectively utilize community information and multi-scale information on the graph, improve the accuracy of user classification and enhance the personalized recommendation capabilities of the recommendation system.
Smart Images

Figure CN119046541B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of social network recommendation, and in particular relates to a recommendation method based on community perception and multi-scale graph comparative learning. Background Art
[0002] With the rapid development of Internet technology, social networks have become an important part of people's daily lives. As one of the core functions of social networks, recommendation systems provide users with personalized content recommendations by analyzing user behavior data, interest preferences and social relationships, thereby improving user experience and platform activity. However, existing recommendation systems face many challenges, such as data sparsity, community structure destruction, and insufficient use of multi-scale information. Through graph comparative learning, multiple attribute information can be effectively utilized for recommendation tasks or other applications.
[0003] In the prior art, the GRACE method performs data enhancement by randomly perturbing the topological structure of the graph. The GCA method performs data enhancement by calculating the centrality of nodes and edges. The HomoGCL method only compares node-level representations in the comparison target. The NCLA method uses the homogeneity assumption of the graph to screen more positive samples, but it ignores the global structural information. These prior art methods often have unsatisfactory classification results for users in social networks because the community information on the graph is not fully explored and the multi-scale information is not fully mined. Summary of the invention
[0004] In order to solve the above problems, the present invention proposes a recommendation method based on community awareness and multi-scale graph comparative learning. Firstly, a community-aware graph enhancement strategy is designed, which assigns different weights to different edges on the graph, considers the weight information of the edges during topology enhancement, and generates a k-nearest neighbor graph based on node features, thereby protecting the community information on the graph. At the same time, a new comparison mode is designed, which can capture not only local user and product information but also global information by comparing the node-level information and graph-level information of multiple enhanced views.
[0005] The technical solution of the present invention is as follows:
[0006] A recommendation method based on community perception and multi-scale graph comparative learning builds a graph neural network recommendation model and makes personalized recommendations based on user behavior and attribute information; the graph neural network recommendation model includes a community perception graph enhancement module, a graph neural network encoder, a multi-scale graph comparison module, and a social network attribute information learning module; the recommendation method specifically includes the following steps:
[0007] Step 1: Obtain the relationship between users and products in the social network, and establish an attribute graph based on whether there is a link relationship between users and products;
[0008] Step 2: Use the community-aware graph enhancement module to perform topological structure enhancement and node feature enhancement to obtain three enhanced views;
[0009] Step 3: Pass the three enhanced views through the graph neural network encoder to obtain node representation;
[0010] Step 4: Capture multi-scale representations through a multi-scale graph comparison module to optimize model parameters;
[0011] Step 5: Learn the vector representation of user information through the social network attribute information learning module to make personalized recommendations.
[0012] Furthermore, in step 1, the attribute graph established is , Represents a collection of nodes. For the nodes, is the total number of nodes, represents the set of edges, For the Strip edge, is the total number of edges; construct the node feature matrix , Indicates Node features, is the total number of node features; construct an adjacency matrix , the adjacency matrix The rows represent user nodes, and the columns represent product nodes. for Middle Line The value of the column, Indicates User nodes and Is there a link between the commodity nodes? User nodes and There are links between commodity nodes, then the matrix Line The value of the column is set to 1, that is , otherwise it is 0, that is .
[0013] Furthermore, the specific process of step 2 is as follows:
[0014] Step 2.1: Perform community division based on the community detection algorithm Leiden. Calculate the community strength of each community based on the divided communities, as follows:
[0015] (1);
[0016] in, For the community community strength; Represents the number of all edges on the attribute graph; Representing the community the number of inner edges; is the degree of the node;
[0017] Step 2.2: Calculate the weight of each edge and enhance the topological structure as follows:
[0018] (2);
[0019] in, For the User nodes and The weight of the edge between product nodes; , Respectively User nodes, The community strength of the community to which the commodity node belongs; is an indicative matrix, is the total number of nodes, is the total number of communities; is the transpose symbol; is the Hadamard product; is the mean value of community strength;
[0020] Step 2.3: Calculate the probability that each edge belongs to the enhanced view as follows:
[0021] (3);
[0022] in, for The probability of belonging to the enhanced view; for The average value of for The maximum value of Indicates the ratio of the edge of the enhanced view to the edge of the original image;
[0023] Based on the probability that each edge belongs to the enhanced view, the topological structure is enhanced twice to obtain the adjacency matrix of the two enhanced views, which are the first enhanced view The adjacency matrix of , Second Enhanced View The adjacency matrix of ;
[0024] Step 2.4: Reconstruct a k-nearest neighbor graph based on the feature cosine similarity of the nodes, and calculate the similarity of the nodes to obtain a similarity matrix, as follows:
[0025] (4);
[0026] in, is the cosine similarity function; , Respectively User nodes, The feature vector representation of each commodity node; is the magnitude of the vector;
[0027] Select the first k similar user node pairs to connect them, and then obtain a k-nearest neighbor graph with a community structure. The adjacency matrix of the k-nearest neighbor graph is defined as the third enhanced view The adjacency matrix of ;
[0028] Step 2.5: Randomly generate three vectors , , Represent the probability values of the three enhanced view mask node features, is the feature dimension, and node feature enhancement is performed on the three enhanced views. The specific calculation formula is as follows:
[0029] (5);
[0030] (6);
[0031] (7);
[0032] in, , , They are the node feature matrices after enhancement of the three enhanced views; For the Node features.
[0033] Furthermore, in step 3, the graph neural network encoder includes two layers of graph convolutional neural networks; the three enhanced views are respectively passed through the graph neural network encoder to obtain different node representations, and different node-level representation matrices are constructed; specifically as follows:
[0034] (8);
[0035] (9);
[0036] (10);
[0037] in, Represents a graph neural network encoder; , , Respectively , , The node-level representation matrix obtained after passing through the graph neural network encoder.
[0038] Furthermore, in step 4, the multi-scale representation includes a local node-level representation and a global graph-level representation; the specific process is:
[0039] Step 4.1: The capture of local node-level representation adopts the InfoNCE loss in graph contrastive learning, and the calculation formula is as follows:
[0040] (11);
[0041] in, InfoNCE loss; definition , The node sets The Node, nodes; For the Nodes in the first enhanced view The nodes below represent; For the nodes in the second enhanced view The nodes below represent; for and The loss value of for and The loss value of The calculation formula is:
[0042] (12);
[0043] in, represents the temperature coefficient; For the Nodes in the first enhanced view The nodes below represent; For the nodes in the second enhanced view The nodes below represent;
[0044] Compare the node representations under the three enhanced views and calculate the final node-level loss. The specific calculation formula is as follows:
[0045] (13);
[0046] (14);
[0047] (15);
[0048] in, First enhanced view With the second enhanced view loss; First enhanced view With the third enhanced view loss; is the final node-level loss; For the Nodes in the third enhanced view The nodes below represent;
[0049] Step 4.2: Pass the node-level representation matrix through a graph pooling layer to obtain the global graph-level representation. The specific calculation is as follows:
[0050] (16);
[0051] in, It is a global graph-level representation; is the read function; It is the node-level representation matrix obtained after different enhanced views pass through the graph neural network encoder; is the activation function; For the Node representation of nodes;
[0052] Define the global graph-level representations of the three enhanced views as positive samples for each other, and shuffle the topological structures and node features of the three enhanced views to obtain three shuffled adjacency matrices , , And three shuffled node feature matrices , , For each round of training, each enhanced view has two positive samples and three negative samples at the image level. The comparison target calculation formula is as follows:
[0053] (17);
[0054] in, is the loss value at the graph level; , , They are , , A global graph-level representation of ; , , They are the global graph-level representations of the three enhanced views after shuffling;
[0055] The final graph-level loss in each round The calculation formula is as follows:
[0056] (18);
[0057] in, Indicates the number of attribute graphs;
[0058] Step 4.3. Final model loss The calculation formula is as follows:
[0059] (19);
[0060] in, is the importance of graph-level representation loss relative to node-level representation loss.
[0061] Furthermore, the specific process of step 5 is as follows:
[0062] The social network attribute graph information is passed through the graph neural network encoder with optimized parameters, and the final embedding representation of the node is obtained through a multi-layer perceptron:
[0063] (20);
[0064] in, For the The final embedding representation of each node is the learned representation of user and product information. Then, personalized recommendations or predictions of user preferences are made based on user behavior and attribute information. It is a multi-layer perceptron.
[0065] The beneficial technical effects brought by the present invention are as follows: different weights are assigned to different edges through the community information on the graph, and a k-nearest neighbor graph is constructed through the feature information of the node, thereby achieving full utilization of the community information on the graph; by capturing local node-level information and global graph-level information, the multi-scale information of multiple enhanced views is compared, thereby improving the accuracy of the comparison target, and thus better optimizing the model parameters. The present invention utilizes graph contrast learning to simultaneously protect the rich community information and attribute information on the graph, effectively utilizes the multi-scale information on the graph, thereby improving the accuracy of user classification, and thus recommending more accurate products to users. BRIEF DESCRIPTION OF THE DRAWINGS
[0066] Figure 1 This is a flow chart of the recommendation method based on community perception and multi-scale graph comparative learning of the present invention. DETAILED DESCRIPTION
[0067] The present invention is further described in detail below with reference to the accompanying drawings and specific embodiments:
[0068] The present invention takes social networks as the research object and takes improving the classification of users in social networks as the core goal. The key technical problems that need to be solved include: First, the community information on the graph has not been fully explored. Second, multi-scale information has not been fully mined. Solving these two problems can complete the modeling of complex social networks.
[0069] Therefore, the specific key issues to be solved by the present invention are:
[0070] Key technical problem 1: Community information on the graph has not been fully explored;
[0071] The present invention designs a graph enhancement method based on community-aware information. Specifically, different weights are assigned to different edges according to the community information of the nodes. The weight of the edge within the community is greater than the weight of the edge between communities. The importance of the edge connecting strong communities is greater than the importance of the edge connecting two weak communities. The k-nearest neighbor graph with community structure is reconstructed according to the node characteristics. This method can fully explore the community information on the graph.
[0072] Key technical issue 2: Multi-scale information has not been fully explored;
[0073] The present invention designs a multi-scale comparison mode to capture local node-level information and global graph-level information, and simultaneously compares the multi-scale information of multiple enhanced views to optimize the parameters of the model, thereby realizing the mining of multi-scale information in social networks.
[0074] like Figure 1 As shown, the present invention proposes a recommendation method based on community perception and multi-scale graph comparative learning, builds a graph neural network recommendation model, and performs personalized recommendations based on user behavior and attribute information; the graph neural network recommendation model includes a community perception graph enhancement module, a graph neural network encoder, a multi-scale graph comparison module, and a social network attribute information learning module; the method comprises the following steps:
[0075] Step 1: Obtain the relationship between users and products in the social network, and establish an attribute graph based on whether there is a link relationship between users and products. The attribute graph is a network that represents a complex relationship network. The social network is an abstract representation, and the network data needs to be modeled in the form of a matrix vector to transform the abstract into the concrete, and then apply knowledge learning. Therefore, the attribute graph established by the present invention is used express, Represents a collection of nodes. For the nodes, is the total number of nodes, represents the set of edges, For the Strip edge, The node set of the present invention includes user nodes and commodity nodes, and defines For the User nodes, define For the Product nodes. Construct node feature matrix , , is the feature dimension, Indicates Node features, is the total number of node features, the total number of node features is the same as the total number of nodes, that is, ; Construct the adjacency matrix , the adjacency matrix The rows represent user nodes, and the columns represent product nodes. for Middle Line The value of the column, Indicates User nodes and Is there a link between the commodity nodes? User nodes and There are links between commodity nodes, then the matrix Line The value of the column is set to 1, that is , otherwise it is 0, that is .
[0076] Step 2: The community-aware graph enhancement module calculates the weight of the edge based on the established attribute graph, performs topological structure enhancement based on the community information, reconstructs the k-nearest neighbor graph based on the feature information, and performs node feature enhancement on the k-nearest neighbor graph. Finally, three enhanced views are obtained to obtain richer attribute information. After two times of topological enhancement based on community information and node feature enhancement, two enhanced views with different probabilities are obtained, namely the first enhanced view , Second Enhanced View ; Property graph The third enhanced view is obtained by constructing a k-nearest neighbor graph and enhancing node features. .
[0077] The communities are divided and optimized based on the modularity information, the community strength of each community is calculated based on the divided communities, and different probabilities are assigned to each edge based on the community strength; in order to strengthen the connections within the community, a k-nearest neighbor graph with a community structure is reconstructed based on the node features, which can not only serve as a supplement to the original graph information, but also is very suitable for the graph neural network encoder. The community information of the graph plays an important role in the message passing of the graph neural network. This topological enhancement method can well preserve the community information of the graph. Feature-level enhancement is achieved by randomly masking node features. This graph enhancement strategy (also known as community-aware enhancement strategy) not only ensures that the community information on the graph is not destroyed, but also provides rich semantic information. The specific process is:
[0078] Step 2.1: Perform community division based on the community detection algorithm Leiden. Calculate the community strength of each community based on the divided communities, as follows:
[0079] (1);
[0080] in, For the community community strength; Represents the number of all edges on the attribute graph; Representing the community the number of inner edges; is the degree of the node;
[0081] Step 2.2: Based on the message passing mechanism of the graph neural network and the community structure information, the present invention believes that the edges within a community are more important than the edges between communities, the edges within a strong community are more important than the edges within a weak community, and the edges connecting two relatively strong communities are more important than the edges connecting two relatively weak communities. The weight of each edge is calculated according to formula (2) to enhance the topological structure, as follows:
[0082] (2);
[0083] in, For the User nodes and The weight of the edge between product nodes; , Respectively User nodes, The community strength of the community to which the commodity node belongs; is an indicative matrix, is the total number of nodes, is the total number of communities, for example Explain, for example Indicates User Node Belong to the community ; is the transpose symbol; is the Hadamard product; Indicates User nodes and Product nodes belong to the same community; is the mean value of community strength.
[0084] Step 2.3: Normalize the obtained edge weights and then multiply them by the overall probability to get the probability that each edge belongs to the enhanced view, as follows:
[0085] (3);
[0086] in, for The probability of belonging to the enhanced view; for The average value of for The maximum value of Indicates the ratio of the edge of the enhanced view to the edge of the original image;
[0087] Based on the probability that each edge belongs to the enhanced view, the topological structure is enhanced twice to obtain the adjacency matrix of the two enhanced views, which are the first enhanced view The adjacency matrix of , Second Enhanced View The adjacency matrix of ;
[0088] Step 2.4: Reconstruct a k-nearest neighbor graph based on the feature cosine similarity of the nodes, and calculate the similarity of the nodes to obtain a similarity matrix, as follows:
[0089] (4);
[0090] in, is the cosine similarity function; , Respectively User nodes, The feature vector representation of each commodity node; is the magnitude of the vector.
[0091] In order to supplement the community information on the original graph, the k-nearest neighbor graph based on node feature similarity is reconstructed as another enhanced view. This view captures rich attribute similarity information between nodes and strengthens the connection within the community. For each product node, the first k similar user node pairs are selected to connect them, and then a k-nearest neighbor graph with a community structure is obtained. The adjacency matrix of the k-nearest neighbor graph is defined as the third enhanced view The adjacency matrix of .
[0092] Step 2.5: Randomly generate three vectors , , Represent the probability values of the three enhanced view mask node features, is the feature dimension, and each dimension is subject to the probability Bernoulli distribution of ; , , They are the first The probability values of the dimensional mask node features, and the corresponding Bernoulli distributions are: , , , , is the Bernoulli distribution function, It is the probability of controlling the overall mask node feature. The node feature enhancement is performed on the three enhanced views, and the specific calculation formula is as follows:
[0093] (5);
[0094] (6);
[0095] (7);
[0096] in, , , They are the node feature matrices after enhancement of the three enhanced views; For the Node features.
[0097] Step 3: Pass the three enhanced views through a graph neural network encoder to obtain rich node representations; the graph neural network encoder used in the present invention includes a two-layer graph convolutional neural network, which can learn enough information in the neighborhood and avoid over-smoothing of the model. The specific process is:
[0098] The three enhanced views are respectively passed through the graph neural network encoder to obtain different node representations and construct different node-level representation matrices; the details are as follows:
[0099] (8);
[0100] (9);
[0101] (10);
[0102] in, Represents a graph neural network encoder; , , Respectively , , The node-level representation matrix obtained after passing through the graph neural network encoder.
[0103] Step 4: The multi-scale graph comparison module captures multi-scale representations to optimize model parameters. In order to mine multi-scale information, the local node-level representation and the global graph-level representation are captured during the comparison process. At the same time, the multi-scale representations of the three enhanced views (i.e., local node-level representation and global graph-level representation) are compared to optimize the parameters of the graph neural network recommendation model (i.e., perform global information optimization). The specific process is as follows:
[0104] Step 4.1: The capture of local node-level representation adopts the InfoNCE loss in graph contrastive learning, and the calculation formula is as follows:
[0105] (11);
[0106] in, InfoNCE loss; definition , The node sets The Node, nodes; For the Nodes in the first enhanced view The nodes below represent; For the nodes in the second enhanced view The nodes below represent; for and The loss value of for and The loss value of The calculation formula is:
[0107] (12);
[0108] in, represents the temperature coefficient; For the Nodes in the first enhanced view The nodes below represent; For the The nodes are represented as nodes in the second enhanced view.
[0109] In order to obtain the mutual information of multiple views, the node representations under the three enhanced views are compared and the final node-level loss is calculated. The specific calculation formula is as follows:
[0110] (13);
[0111] (14);
[0112] (15);
[0113] in, First enhanced view With the second enhanced view loss; First enhanced view With the third enhanced view loss; is the final node-level loss; For the Nodes in the third enhanced view The nodes below represent;
[0114] Step 4.2: Pass the node-level representation matrix through a graph pooling layer to obtain the global graph-level representation. The specific calculation is as follows:
[0115] (16);
[0116] in, It is a global graph-level representation; is the read function; is the node-level representation matrix obtained after different enhanced views pass through the graph neural network encoder. Substitution , or , we get the global graph-level representation of different enhanced views: , , , , , They are , , The global graph-level representation of for , or ; is the activation function; For the Node representation of nodes;
[0117] The global graph-level representations of the three enhanced views are defined as positive samples of each other. In order to obtain better graph-level representation negative samples, the topological structures and node features of the three enhanced views are shuffled to obtain three shuffled adjacency matrices. , , And three shuffled node feature matrices , , , so that for each round of training, each enhanced view will have two positive samples and three negative samples at the image level. The comparison target calculation formula is as follows:
[0118] (17);
[0119] in, is the loss value at the graph level; , , They are , , A global graph-level representation of ; , , They are the global graph-level representations of the three enhanced views after shuffling;
[0120] The final graph-level loss in each round The calculation formula is as follows:
[0121] (18);
[0122] in, Indicates the number of attribute graphs;
[0123] Step 4.3: After obtaining the node-level and graph-level losses, the final model loss is The calculation formula is as follows:
[0124] (19);
[0125] in, is the importance of graph-level representation loss relative to node-level representation loss.
[0126] Step 5: The social network attribute information learning module learns the vector representation of user and product information and makes personalized recommendations. The specific process is as follows:
[0127] The social network attribute graph information is passed through the graph neural network encoder with optimized parameters, and the final embedding representation of the node is obtained through a multi-layer perceptron:
[0128] (20);
[0129] in, For the The final embedding representation of each node is the learned representation of user and product information. Then, personalized recommendations or predictions of user preferences are made based on user behavior and attribute information. It is a multi-layer perceptron.
[0130] In order to prove the feasibility and superiority of the present invention, the following comparative experiments were carried out.
[0131] Experiment 1: The graph neural network recommendation model constructed by the present invention is referred to as the MSCA-GCL model. The experimental data sets of the present invention include five data sets: Cora, CiteSeer, PubMed, Amazon-Photo, and Amazon-Computers. For Cora, CiteSeer, and PubMed, the public data set division method is adopted, that is, 20 nodes of each type are selected as the training set. For the Amazon-Photo and Amazon-Computers data sets, the ratio of the training set, the validation set, and the test set is set to 1:1:8. First, the results of the twelve baseline models of the MSCA-GCL model of the present invention and GCN (graph convolutional neural network), GAT (graph attention neural network), DGI (maximizing the mutual information between graph-level representation and node representation), GRACE (random data enhancement, maximizing the mutual information between nodes), MVGRL (using graph diffusion to enhance the mutual information between the representation of nodes and graphs in different perspectives), BGRL (contrast between nodes without introducing negative samples), GCA (graph contrast learning for adaptive graph enhancement), COLES (graph contrast learning method based on Laplacian eigenmap), COSTA (representation enhancement to obtain enhanced views), gCool (considering the community information of the graph when optimizing the model), MA-GCL (using three strategies to optimize the model), and HomoGCL (using the homogeneity hypothesis of the graph to expand the positive sample pairs) on semi-supervised node classification were evaluated. The evaluation index method selected the accuracy (Acc), and the specific data results are shown in Table 1. The present invention is compared with twelve representative algorithm models. The higher the value of Acc, the higher the accuracy of the model. Among them, GCN and GAT are semi-supervised representation learning methods, DGI, GRACE, MVGRL, and BGRL use random data enhancement, which will destroy the original community information on the graph. GCA and gCool use adaptive data enhancement, taking into account the centrality of nodes and edges, and also ignore the community information in the data enhancement process. COLES, COSTA, and MA-GCL only compare local node-level information on the comparison target, ignoring the global graph-level information. HomoGCL uses the homogeneity assumption of the graph when screening positive samples, but also fails to capture multi-scale information. The present invention processes social network data into a suitable format, feeds it back to the model, and tests the superiority of the present invention.
[0132] Table 1 Results of each model on semi-supervised node classification (%)
[0133] .
[0134] in, is the node feature matrix, is the adjacency matrix, is the node label matrix. As shown in Table 1, the proposed model MSCA-GCL has good performance on five datasets: Cora, CiteSeer, PubMed, Amazon-Photo, and Amazon-Computers.
[0135] In general, the model MSCA-GCL of the present invention introduces the community information of the graph into the process of graph enhancement, and the obtained user representation is better than the representation obtained by not considering the community information on the graph and only considering the single information of the node. This is because the MSCA-GCL model not only considers the topological structure of the community, but also reconstructs the k-nearest neighbor graph with community structure based on the characteristic information of the node. MSCA-GCL optimizes the parameters of the model by capturing information at different scales, and the obtained representation is better than the representation obtained by only considering information at a single scale. This is because the information at different scales on the graph can provide richer node attribute information, and MSCA-GCL fully captures this information.
[0136] Experiment 2: The present invention also conducts an ablation experiment to verify the performance of the model MSCA-GCL of the present invention. Specifically, by deleting the test module, the model MSCA-GCL is subjected to an ablation experimental analysis. The present invention designs two variants to verify the degree of improvement of the performance of MSCA-GCL by the community-aware graph enhancement module and the multi-scale contrastive learning module, and the symbol usage is shown in Table 2.
[0137] Table 2 Description of ablation experiment variants
[0138] .
[0139] Using the same data set and experimental indicators as Experiment 1, the experimental results are shown in Table 3:
[0140] Table 3 Experimental results of ablation experiment variants (%)
[0141] .
[0142] As can be seen from Table 3, the performance advantages of the MSCA-GCL model on five different datasets are particularly significant compared to its variant models. This indicates that different components play different roles in improving the performance of the overall model. This also means that when constructing and optimizing graph contrastive learning models, it is necessary to fully consider the effects of each component in order to more fully mine user and product information in social network graphs.
[0143] Of course, the above description is not a limitation of the present invention, and the present invention is not limited to the above examples. Changes, modifications, additions or substitutions made by technicians in this technical field within the essential scope of the present invention should also fall within the protection scope of the present invention.
Claims
1. A recommendation method based on community perception and multi-scale graph contrast learning, characterized in that: Build a graph neural network recommendation model and make personalized recommendations based on user behavior and attribute information; the graph neural network recommendation model includes a community-aware graph enhancement module, a graph neural network encoder, a multi-scale graph comparison module, and a social network attribute information learning module; The recommended method specifically includes the following steps: Step 1: Obtain the relationship between users and products in the social network, and establish an attribute graph based on whether there is a link relationship between users and products; Step 2: Use the community-aware graph enhancement module to perform topological structure enhancement and node feature enhancement to obtain three enhanced views; The specific process is: Step 2.1: Perform community division based on the community detection algorithm Leiden. Calculate the community strength of each community based on the divided communities, as follows: Among them, S c is the community strength of community c; |ε| represents the number of all edges on the attribute graph; |ε c | represents the number of edges in community c; d(·) is the degree of the node; Step 2.2: Calculate the weight of each edge and enhance the topological structure as follows: in, is the weight of the edge between the i-th user node and the j-th product node; C i :S, C j : S is the community strength of the community to which the i-th user node and the j-th commodity node belong respectively; C∈{0,1} N × |c| is an indicative matrix, N is the total number of nodes, |c| is the total number of communities; T is the transpose symbol; ° is the Hadamard product; is the mean value of community strength; Step 2.3: Calculate the probability that each edge belongs to the enhanced view as follows: in, for The probability of belonging to the enhanced view; for The average value of for The maximum value of P o Indicates the ratio of the edge of the enhanced view to the edge of the original image; Perform two topological structure enhancements based on the probability that each edge belongs to an enhanced view, and obtain adjacency matrices of two enhanced views, namely, adjacency matrix A1 of the first enhanced view G1 and adjacency matrix A2 of the second enhanced view G2; Step 2.4: Reconstruct a k-nearest neighbor graph based on the feature cosine similarity of the nodes, and calculate the similarity of the nodes to obtain a similarity matrix, as follows: Among them, θ(·) is the cosine similarity function; z i 、z j are the feature vector representations of the i-th user node and the j-th product node respectively; ‖·‖ is the modulus of the vector; Select the first k similar user node pairs to connect them, and then obtain a k nearest neighbor graph with a community structure, and define the adjacency matrix of the k nearest neighbor graph as the adjacency matrix A3 of the third enhanced view G3; Step 2.5: Randomly generate three vectors They represent the probability values of the mask node features of the three enhanced views respectively, and F is the feature dimension. The node features of the three enhanced views are enhanced. The specific calculation formula is as follows: Among them, X1, X2, and X3 are the node feature matrices after enhancement of the three enhanced views; For the Node features; Step 3: Pass the three enhanced views through the graph neural network encoder to obtain node representation; Step 4: Capture multi-scale representations through a multi-scale graph comparison module to optimize model parameters; In step 4, the multi-scale representation includes local node-level representation and global graph-level representation; the specific process is: Step 4.1: The capture of local node-level representation adopts the InfoNCE loss in graph contrastive learning, and the calculation formula is as follows: Among them, L InfoNCE InfoNCE loss; definition The node set The pth node and the qth node in u p is the node representation of the p-th node in the first enhanced view G1; v p is the node representation of the p-th node in the second enhanced view G2; node (u p ,v p ) is u p With v p The loss value of node (v p ,u p ) is v p with u p The loss value of node (u p ,v p ) is calculated as: Where τ represents the temperature coefficient; u q is the node representation of the qth node in the first enhanced view G1; v q is the node representation of the qth node in the second enhanced view G2; Compare the node representations under the three enhanced views and calculate the final node-level loss. The specific calculation formula is as follows: L node =L UV +L UK (15); Among them, L UV is the loss of the first enhanced view G1 and the second enhanced view G2; L UK is the loss of the first enhanced view G1 and the third enhanced view G3; L node is the final node-level loss; w p is the node representation of the p-th node in the third enhanced view G3; Step 4.2: Pass the node-level representation matrix through a graph pooling layer to obtain the global graph-level representation. The specific calculation is as follows: Where S is the global graph-level representation; R(·) is the readout function; Z is the node-level representation matrix obtained after different enhanced views pass through the graph neural network encoder; σ(·) is the activation function; is the node representation of the p-th node; Define the global graph-level representations of the three enhanced views as positive samples for each other, and shuffle the topological structures and node features of the three enhanced views to obtain three shuffled adjacency matrices And three shuffled node feature matrices For each round of training, each enhanced view has two positive samples and three negative samples at the image level. The comparison target calculation formula is as follows: Among them, l graph (·) is the loss value at the graph level; s u 、s v 、s w They are the global graph-level representations of G1, G2, and G3 respectively; They are the global graph-level representations of the three enhanced views after shuffling; Finally, the loss L of each round of graph level graph The calculation formula is as follows: Where |G| represents the number of attribute graphs; Step 4.3, the loss L of the final model is calculated as follows: L=L node +βL graph (19); Among them, β is the importance of graph-level representation loss relative to node-level representation loss; Step 5: Learn the vector representation of user information through the social network attribute information learning module to make personalized recommendations.
2. The recommendation method based on community perception and multi-scale graph comparative learning according to claim 1, characterized in that: In step 1, the attribute graph established is Represents a collection of nodes. is the nth node, N is the total number of nodes, represents the set of edges, For the Strip edge, is the total number of edges; construct the node feature matrix Indicates Node features, is the total number of node features; Construct an adjacency matrix A, where the rows of the adjacency matrix A represent user nodes and the columns represent product nodes. ij ∈R N × N is the value of row i and column j in A, a ij Indicates whether there is a link between the i-th user node and the j-th product node. If there is a link between the i-th user node and the j-th product node, the value of the i-th row and j-th column of the matrix is set to 1, that is, a ij =1, otherwise 0, i.e. a ij =0.
3. The recommendation method based on community perception and multi-scale graph comparative learning according to claim 1, characterized in that: In step 3, the graph neural network encoder includes two layers of graph convolutional neural networks; the three enhanced views are respectively passed through the graph neural network encoder to obtain different node representations, and different node-level representation matrices are constructed; the details are as follows: in, represents the graph neural network encoder; Z1, Z2, and Z3 represent the node-level representation matrices obtained after G1, G2, and G3 pass through the graph neural network encoder, respectively.
4. The recommendation method based on community perception and multi-scale graph contrast learning according to claim 3 is characterized in that: The specific process of step 5 is as follows: The social network attribute graph information is passed through the graph neural network encoder with optimized parameters, and the final embedding representation of the node is obtained through a multi-layer perceptron: in, is the final embedding representation of the nth node, which is the learned representation of user and product information. Then, personalized recommendations or predictions of user preferences are made based on user behavior and attribute information. MLP(·) is a multi-layer perceptron.
Citation Information
Patent Citations
Graph neural network method based on multi-scale graph contrast learning
CN115994560A
Commodity recommendation system and method based on comparative learning and community perception
CN117495511A