A graph contrastive learning based debiasing recommendation method and system
By employing a graph-based contrastive learning approach, semantic loss and contrastive loss are used to filter out biased information, thereby improving the accuracy and efficiency of recommendation methods. This addresses the issues of high computational complexity and poor generalization ability in existing technologies, achieving more efficient bias-free recommendation.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-27
- Publication Date
- 2026-04-14
AI Technical Summary
Existing deep learning-based recommendation methods suffer from high computational complexity, poor generalization ability, and strong dependence on labeled data in removing bias information. They are difficult to efficiently and automatically filter bias information in complex recommendation scenarios, which affects recommendation accuracy and user experience.
We employ a graph-based contrastive learning approach, which learns vector representations of entities and relations through semantic loss, filters out biased information using contrastive loss, and combines BPR loss for interactive prediction to improve bias removal capabilities.
On the Amazon-Book, Yelp, and MIND datasets, this method improves recommendation precision, recall, and cumulative gain of normalized depreciation compared to existing methods, outperforming the current state-of-the-art KGCL method.
Smart Images

Figure CN116701767B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of deep learning recommendation system technology, and in particular to a bias-free recommendation method and system based on graph contrastive learning. Background Technology
[0002] Recommendation systems have become a crucial application in numerous fields, including e-commerce, social media, and news recommendation. Their purpose is to provide personalized decision support and services to users through technologies such as collaborative filtering or deep learning, thereby improving user experience and satisfaction. For example, in e-commerce, recommendation methods analyze users' purchase, review, browsing, and search histories to identify their interests and preferences, thus increasing purchase rates. In social media, recommendation methods analyze users' posting and interaction histories to recommend potential friends and topics of interest. In news recommendation, recommendation methods analyze users' reading, like, and commenting histories to recommend articles or news that match their interests. In recent years, deep learning has been widely applied in recommendation methods due to its ability to automatically extract features from large amounts of data and learn potential patterns, making recommendations based on predicting users' preferences for unknown products. However, in real-world scenarios, due to various interference factors, the collected historical data often contains a large amount of biased information unrelated to user interaction, such as random clicks and abnormal user behavior. This biased information can seriously affect the accuracy of recommendation methods, ultimately harming user experience and satisfaction. Therefore, removing biased information is crucial for improving the recommendation quality of recommendation methods.
[0003] Existing deep learning-based recommendation methods primarily utilize techniques such as adversarial learning and causal inference for bias removal. Adversarial learning-based methods construct adversarial samples, and their game-theoretic mechanism allows the model to focus more on important features and information, thereby improving its robustness and distinguishing biased samples. Causal inference-based methods analyze the causal relationships between variables to separate biased information from user data, thus improving recommendation accuracy. However, existing methods generally suffer from several drawbacks. For example, some methods are computationally inefficient, requiring significant computational resources and training costs. Furthermore, some methods have poor generalization ability, making them unsuitable for complex recommendation scenarios and even requiring large amounts of labeled data and manual intervention. Therefore, developing a more efficient, time-saving, and automatically bias-filtering recommendation method has become an urgent need in the recommendation field. Summary of the Invention
[0004] This invention overcomes the shortcomings of existing technologies and improves a bias-removing recommendation method and system based on graph contrastive learning in order to solve the problem of poor performance of existing recommendation methods. It learns better vector representations through semantic loss, filters biased entities using contrastive loss, and performs interactive prediction using BPR loss, thereby improving the system's bias removal capability and effect.
[0005] To solve the above-mentioned technical problems, the technical solution adopted by the present invention is: a bias-removing recommendation method based on graph contrast learning, comprising the following steps:
[0006] Step S1: Obtain the knowledge graph dataset and the historical interaction dataset between users and products;
[0007] Step S2: Input the knowledge graph dataset into the TransE model and apply semantic loss. The learning process yields vector representations of entities and relationships; this is achieved through the head entity vector x. h With relation vector Similarity and head entity vector x h With tail entity vector x t The similarity of knowledge graphs Perform data augmentation to generate the first augmented knowledge graph. With the second augmented knowledge graph
[0008]
[0009] Step S3: Based on the first augmented knowledge graph With the second augmented knowledge graph Calculate the consistency score p of each product from different perspectives. i Simultaneously, based on the user's historical interaction dataset with the product, personalized user preferences are calculated. Based on the consistency score p of each product i and users' personalized preferences Calculate the potential probability p of each product interaction ui And generate the first enhanced interaction graph based on the Bernoulli distribution. With the second enhanced interaction graph
[0010]
[0011] Step S4: In the first enhanced interaction graph With the second enhanced interaction graph The LightGCN model is used to aggregate the neighbor information of each node to obtain the first vector representation of users and products on the two enhanced interaction graphs. With the second vector representation
[0012] Step S5: Represent the first vector based on KL divergence With the second vector representation Perform comparative learning with explicit invariant constraints, based on the comparative loss. Update the vector representation of each user and each product across different views to filter out bias information in the knowledge graph;
[0013] Step S6: Predict the interaction probability based on the final vector representations of the user and product in different views.
[0014] Step S7: Based on the predicted probability Constructing BPR loss And combined with BPR loss Semantic loss Comparative loss Obtain the total loss function and update the model parameters based on the total loss function;
[0015] Step S8: Obtain the recommended product order based on the interaction probabilities output by the model.
[0016] The specific method for learning the vector representations of entities and relations in step S2 is as follows:
[0017] Obtaining knowledge graph datasets Where (h,r,t) is a triple, h is the head entity, r is the relation, t is the tail entity, and ε represents the entity set. Represents a set of relations. Representing a knowledge graph; given a randomly initialized vector for each entity and relation, a head entity vector x is obtained. h relation vector Tail entity vector x t ;in, This represents a vector of size F×1;
[0018] For each triple, calculate the attention coefficient of the tail entity t relative to the head entity h through the relation r. Where σ(·) is the Sigmoid activation function, W is the parameter matrix, and || is the vector concatenation operation. W[x] represents the attention coefficient; h ||x t ] indicates that vector x h With vector x t After concatenation, multiply with the parameter matrix W;
[0019] Then, based on the attention coefficient and the vectors of the head entity's neighbors, update the head entity vector using the following formula:
[0020]
[0021] Where, x h ' represents the updated head entity vector. The set of tail entities connected to the head entity h;
[0022] Finally, based on the TransE model, vector representations of all entities and relations are learned. The semantic loss of the TransE model is as follows:
[0023]
[0024] in, x t′ For the negatively sampled tail entity, σ(·) is the sigmoid activation function.
[0025] In step S2, the knowledge graph The specific methods for data augmentation are as follows:
[0026] The similarity between the head entity and relation, and between the head entity and tail entity, is calculated using the following formula:
[0027]
[0028]
[0029] in, and The head entity vector x h With relation vector x r Similarity, head entity vector x h With tail entity vector x t The similarity; σ(·) is the sigmoid activation function, Represents the head entity vector x h transpose;
[0030] In a knowledge graph dataset, triples with a similarity less than 0.5 are removed, and the probability of each triple being retained is generated. and Obtain the first augmented knowledge graph With the second augmented knowledge graph
[0031] In step S3, the consistency score p of each product i The calculation formula is:
[0032]
[0033] in, and These represent product i in the first enhanced knowledge graph. With the second augmented knowledge graph The vector representation on the knowledge graph, where the head entity represents the product, and s(·) is the computational vector. and The cosine similarity function between them and The first augmented knowledge graph With the second augmented knowledge graph Add the adjacency matrix of the identity matrix. and They are respectively and The degree matrix.
[0034] In step S4, the calculation process of the aggregate node features of LightGCN is as follows:
[0035]
[0036] in, and Let be the vector representations of the user and the product, respectively, during propagation at the k-th layer. A collection of products that user u has interacted with. This is the set of users who have purchased product i.
[0037] In step S5, the comparison loss is... The calculation formula is:
[0038]
[0039] Where s(·) represents the cosine similarity calculation, τ represents the temperature coefficient, and KL represents the divergence. These represent two ways to enhance the interaction graph, constrained by KL divergence. Indicates positive examples cosine similarity, Indicates negative pairs cosine similarity, Indicates negative pairs Cosine similarity between them; for any user, their nodes in any view This is called the anchor point, while the node in another view... It forms a positive pair with it, that is The remaining nodes in both views and It forms multiple negative pairs with it, that is and
[0040] In step S6, the interaction probability is predicted. The formula is:
[0041]
[0042] Where sigmoid(·) is the activation function. and These are the vector representations of user u in the two views, respectively. and Let i be the vector representation of product i in the two views. Let be the probability of interaction between user u and product i.
[0043] In step S7, BPR loss The calculation formula is:
[0044]
[0045] Among them, (u,i + (u,i) represents a positive pair of user-product interactions. - ) represents the negative pairs of user interactions with the product; σ(·) represents the sigmoid activation function;
[0046] Total loss function The calculation formula is:
[0047]
[0048] Where λ1 and λ2 are the regularization coefficients controlling the strength of the contrastive loss function and the joint loss function, respectively, and Θ is all the parameters to be learned in the model, including vector representations of entities, relations, users, and products.
[0049] Furthermore, this invention also provides a bias-free recommendation system based on graph contrastive learning, comprising the following modules:
[0050] Interaction module: Used to acquire knowledge graph datasets and historical user-product interaction datasets;
[0051] The graph attention learning module is used to initialize vectors for all entities and relations based on a given knowledge graph dataset, calculate the attention coefficient of each tail entity relative to the head entity through the relation, aggregate all triple information through the attention mechanism, and then learn the vector representation of the semantic information of all entities and relations in the knowledge graph based on the TransE model.
[0052] Knowledge Graph Augmentation Module: This module calculates the similarity between the head entity and the relation, and between the head entity and the tail entity, based on the vector representations of entities and relations. It then augments the knowledge graph, generating the first augmented knowledge graph. With the second augmented knowledge graph
[0053] Interactive Graph Enhancement Module: Used for enhancing knowledge graphs based on the first enhanced knowledge graph With the second augmented knowledge graph Calculate the consistency score p of each product from different perspectives. i Simultaneously, based on the user's historical interaction dataset with the product, personalized user preferences are calculated. Based on the consistency score p of each product i and users' personalized preferences Calculate the potential probability p of each product interaction ui And generate the first enhanced interaction graph based on the Bernoulli distribution. With the second enhanced interaction graph
[0054] Node vector update module: used in the first enhanced interaction graph With the second enhanced interaction graph The LightGCN model is used to aggregate the neighbor information of each node to obtain the first vector representation of the user and product on the two interactive views. With the second vector representation
[0055] Comparison constraint module: used for the first vector representation based on KL divergence. With the second vector representation Perform comparative learning with explicit invariant constraints, based on the comparative loss. Update the vector representation of each user and each product across different views to filter out bias information in the knowledge graph;
[0056] Model prediction module: used to fuse the vector representations of users and products on two interactive views after comparative learning, and to predict the probability of interaction;
[0057] Model optimization module: used to optimize the model based on the predicted probability. Constructing BPR loss And combined with BPR loss Semantic loss Comparative loss Obtain the total loss function and update the model parameters based on the total loss function;
[0058] Output module: Used to obtain the recommended product order based on the interaction probabilities output by the model.
[0059] Compared with the prior art, the present invention has the following advantages:
[0060] 1. This invention utilizes attention mechanisms and the TransE model to learn vector representations of entity and relation semantics on a knowledge graph. Semantic loss helps the model learn better vector representations. Data augmentation is performed based on the vector representations of entities and relations to obtain augmented knowledge graphs from different perspectives. The augmented knowledge graphs retain semantic information related to user interaction, which helps the model to automatically correct biases during subsequent training.
[0061] 2. This invention calculates the consistency score of each product based on the enhanced knowledge graph and generates two enhanced interactive views by combining user preferences; it generates vector representations of users and products on the enhanced interactive views; it performs comparative learning training on the vector representations of users and products with explicit invariant constraints, automatically filters out bias information that is irrelevant to user interaction, and improves the accuracy of the bias-removing recommendation method.
[0062] 3. This invention uses the filtered vector representation for recommendation interaction prediction, which further improves the accuracy of biased leg recommendations;
[0063] 4. This invention optimizes the model by combining semantic, contrastive, and predictive losses. In three real-world recommendation scenarios—the Amazon-Book book recommendation dataset, the Yelp business venue recommendation dataset, and the MIND news recommendation dataset—this invention achieves optimal performance in precision, recall, and normalized depreciation cumulative gain compared to the current best KGCL method. Specifically, on the Amazon-Book dataset, the three metrics are improved by 3.77%, 3.74%, and 4.16%, respectively; on the Yelp dataset, by 2.16%, 1.98%, and 2.23%; and on the MIND dataset, by 6.14%, 3.63%, and 3.65%. Attached Figure Description
[0064] Figure 1 This is a flowchart illustrating a bias-removing recommendation method based on graph contrastive learning, provided in Example 1.
[0065] Figure 2 A flowchart illustrating the process of attention learning;
[0066] Figure 3 A flowchart to enhance the knowledge graph;
[0067] Figure 4 A flowchart illustrating processes to enhance user interaction with the product;
[0068] Figure 5 This is a schematic diagram of the structure of a bias-free recommendation system based on graph comparison learning, as provided in Embodiment 2. Detailed Implementation
[0069] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below. Obviously, the described embodiments are some embodiments of the present invention, but not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0070] Example 1
[0071] like Figure 1 As shown, Embodiment 1 of the present invention provides a flowchart of a bias-removal recommendation method based on graph contrastive learning, which specifically includes the following steps:
[0072] Step S1: Obtain the knowledge graph dataset and the historical interaction dataset between users and products.
[0073] Acquired knowledge graph dataset and historical interaction datasets between users and products Where (h,r,t) is a triple, h is the head entity, r is the relation, t is the tail entity, and ε represents the entity set. Represents a set of relations. This represents a knowledge graph dataset.
[0074] Step S2: Input the knowledge graph dataset into the TransE model and apply semantic loss. The learning process yields vector representations of entities and relationships; this is achieved through the head entity vector x. h With relation vector Similarity and head entity vector x h With tail entity vector x t The similarity of knowledge graphs Perform data augmentation to generate the first augmented knowledge graph. With the second augmented knowledge graph
[0075] In this embodiment, an attention mechanism is used to aggregate all triple information, and a semantic loss is constructed based on the TransE model. Learning vector representations of entities and relations Figure 2 This is a flowchart illustrating the process of attention learning.
[0076] Given a knowledge graph dataset Where (h,r,t) is a triple, h is the head entity, r is the relation, t is the tail entity, and ε represents the entity set. Represents a set of relations. Represents a knowledge graph.
[0077] The specific method for step S2 is as follows:
[0078] (1) Given a randomly initialized vector for each entity and relation, obtain the head entity vector. relation vector Tail entity vector The head entity vector also represents the product. By designing a graph attention propagation layer on the knowledge graph as the basic structure for information aggregation, the aim is to extract unbiased entities from a large amount of entity information to enrich the vector representation of the product. This represents a vector of size F×1;
[0079] (2) For each triple, calculate the attention coefficient of the tail entity t relative to the head entity h through the relation r. Where σ(·) is the Sigmoid activation function, and W is the parameter matrix. A vector of size F×2F, where || is the vector concatenation operation. W[x] represents the attention coefficient; h ||x t ] indicates that vector x h With vector x t After concatenation, with the parameter matrix Perform multiplication;
[0080] (3) Based on Update the head entity vector and learn vector representations of all entities and relations based on the TransE model, where x h ' represents the updated head entity vector. The semantic loss of the TransE model is the set of tail entities connected to the head entity h. The calculation formula is as follows:
[0081]
[0082] in, The purpose of using negatively sampled triples is to prevent all vectors from approaching 0 during optimization. Let x be the vector representation of the relation. t′ The tail entity vectors are negatively sampled and used to form negatively sampled triples. σ(·) is the Sigmoid activation function, and the semantic loss is applied as described above. This causes the TransE model to predict vectors As the tail entity vector x t The representation updates the vector representations of entities and relations by minimizing the distance between the predicted vector and the true vector. Lower scores result in higher values for the vector representations. This indicates that the probability of the corresponding triple (h,r,t) being true is higher. Furthermore, to prevent all vectors from approaching 0 during model training, a negative sampling optimization model is constructed for each triple.
[0083] like Figure 3 The diagram shows a flowchart of the augmented knowledge graph process. The specific steps of the augmented knowledge graph process are as follows:
[0084] Based on head entities and relationships Similarity between head entity and tail entity (x h ,x t The similarity between knowledge graphs and other graphs can be used to evaluate knowledge graphs. The purpose of data augmentation is to remove triplet information that is irrelevant to the recommendation task, i.e., to remove biased information from the knowledge graph. The function representation of the augmentation method is as follows:
[0085]
[0086]
[0087] in, and These are the similarities between the head entity and its relation, and between the head entity and its tail entity, respectively, based on... and The probability that the triple generated on the knowledge graph will be retained. and Triples with a similarity of less than 0.5 are removed to further enhance the knowledge graph. and When performing data augmentation, the model aims to preserve the heterogeneous structural information of the knowledge graph to the greatest extent possible, while removing triples that are irrelevant to user interaction, i.e., deleting knowledge graph elements. This operation removes unimportant edges from the knowledge graph, avoiding the need for manual annotation and filtering of all triples and improving data processing efficiency.
[0088] Step S3: Based on the first augmented knowledge graph With the second augmented knowledge graph Calculate the consistency score p of each product from different perspectives. i Simultaneously, based on the user's historical interaction dataset with the product, personalized user preferences are calculated. Based on the consistency score p of each product i and users' personalized preferences Calculate the potential probability p of each product interaction ui And generate the first enhanced interaction graph based on the Bernoulli distribution. With the second enhanced interaction graph
[0089] like Figure 4 The diagram illustrates a process for enhancing user interaction with the product. Step S3 specifically involves: [The process is described in the original text, but the provided text is incomplete and requires further context.] and The consistency score of a product across different views is calculated using the following formula:
[0090]
[0091] in, and These represent product i in the first enhanced knowledge graph. With the second augmented knowledge graph The vector representation on the knowledge graph, where the head entity represents the product, and s(·) is the computational vector. and The cosine similarity function between them and They are respectively and Add the adjacency matrix of the identity matrix. and They are respectively and The purpose of this is to normalize the degree matrix after aggregating the features of neighboring nodes, ultimately resulting in p. i p represents the consistency score of product i across different views. i The larger the value, the less product i is affected by the deviation entity, and the more stable the vector representation of product i is.
[0092] Based on this, in the original historical interaction dataset Calculate users' personalized preferences For the user's final vector representation, x i To obtain the final vector representation of the product, the user's personalized preferences for the product are obtained by taking the inner product of two vectors; then, the personalized preferences are multiplied by the product's consistency score to obtain the potential probability of each interaction.
[0093]
[0094] Where, p ui Let σ(·) represent the potential probability of interaction between product i and user u, and let σ(·) be the sigmoid activation function.
[0095] The first enhanced interaction graph is generated by using the potential probabilities of each interaction and based on the Bernoulli distribution. With the second enhanced interaction graph Similar to augmentation operations on knowledge graphs, the purpose of interaction graph augmentation is to remove interaction information that is irrelevant to the recommendation task and improve model performance by retaining interaction items that are more meaningful to users. This data augmentation can better serve the subsequent learning of user vector representations, thereby further improving the robustness of the model.
[0096] Step S4: In the first enhanced interaction graph With the second enhanced interaction graph The LightGCN model is used to aggregate the neighbor information of each node to obtain the first vector representation of users and products on the two enhanced interaction graphs. With the second vector representation
[0097] In step S4, the classic Lightweight Graph Convolutional Neural Network (LightGCN) model is used to perform weighted aggregation of the vector representations of users and products on the two interaction graphs. Unlike traditional graph convolutional neural networks, LightGCN does not perform complex nonlinear transformation operations. This is done to reduce the learning parameters caused by feature transformations, thereby greatly improving the training speed of the model and reducing computational costs, thus enhancing the interaction graph. and The LightGCN model is used to aggregate the neighbor information of each node (user, product) to obtain vector representations of users and products on the two interactive views. and The process of LightGCN aggregating node features is as follows:
[0098]
[0099] in, and Let be the vector representations of the user and the product, respectively, during propagation at the k-th layer. A collection of products that user u has interacted with. This is the set of users who have purchased product i.
[0100] Step S5: Enhance the interaction graph based on KL divergence pairs and Perform comparative learning with explicit invariant constraints to construct a comparative loss. Update the vector representation of each user and product to filter out bias information in the knowledge graph;
[0101] Specifically, step S5 is as follows:
[0102] In the enhanced interaction graph and The node features are aggregated to obtain a pair of vector representations of the same node in both views, and the interaction graph is enhanced based on the KL divergence pair. and Perform comparative learning with explicit invariant constraints to construct a comparative loss. Update the vector representations of each user and product to filter out bias information in the knowledge graph and compare the losses. for:
[0103]
[0104] Where s(·) is the cosine similarity between positive or negative pairs, τ represents the temperature coefficient used to control the model's discrimination of negative samples, and KL divergence is used to constrain the two enhancement interaction graphs. and Predicted distribution of users and products between them Indicates positive examples cosine similarity, Indicates negative pairs cosine similarity, Indicates negative pairs Cosine similarity between them; for any user, their nodes in any view This is called the anchor point, while the node in another view... It forms a positive pair with it, that is The remaining nodes in both views and It forms multiple negative pairs with it, that is and The product's sampling method is consistent with that of the user. Ultimately, the loss function with contrast constraints enables the model to automatically filter out bias information that is irrelevant to user interaction. Let n be the vector of the nth node in the first enhanced interactive view. The nth node is a negative example in the first enhanced interactive view. Let n be the anchor point of the nth node in the second enhanced interactive view. This is a negative instance of the nth node in the second enhanced view. and These are two ways to enhance the interaction graph, constrained by KL divergence.
[0105] Step S6: Calculate the vector representation x of the end user and the product. u With x i Predicting interaction probability
[0106] Specifically, step S6 involves: from the enhanced interaction graph and The vector representations of users and products are obtained above, and the magnitude of the interaction probability is predicted:
[0107]
[0108] Where sigmoid(·) is the activation function. and These are the vector representations of user u in the two views, respectively. and Let i be the vector representation of product i in the two views. Let be the probability of interaction between user u and product i.
[0109] Step S7: Based on the predicted probability Construction loss And combined with losses and The method was optimized.
[0110] Specifically, step S7 is as follows:
[0111] Construct the BPR loss function based on the predicted probabilities:
[0112]
[0113] Among them, (u,i + (u,i) represents a positive pair of user-product interactions. - ) represents the negative pairs of user-product interactions, and σ(·) is the sigmoid activation function used for vector normalization to prevent gradient vanishing and gradient exploding when updating model parameters; Based on the losses, combined with the losses and After joint optimization and parameter updates, the model's total loss function is:
[0114]
[0115] Where λ1 and λ2 are the regularization coefficients that control the strength of the contrastive loss function and the joint loss function, respectively, and Θ is all the parameters to be learned in the model, including the vector representations of entities, relations, users, and products. The regularization constraint in this term is to prevent the model from overfitting.
[0116] Example 2
[0117] like Figure 5 As shown, Embodiment 2 of the present invention provides a bias-free recommendation system based on graph contrastive learning, which specifically includes the following modules:
[0118] Interaction module: Used to acquire knowledge graph datasets and historical user-product interaction datasets;
[0119] The graph attention learning module is used to initialize vectors for all entities and relations based on a given knowledge graph dataset, calculate the attention coefficient of each tail entity relative to the head entity through the relation, aggregate all triple information through the attention mechanism, and then learn the vector representation of the semantic information of all entities and relations in the knowledge graph based on the TransE model.
[0120] Knowledge Graph Augmentation Module: This module calculates the similarity between the head entity and the relation, and between the head entity and the tail entity, based on the vector representations of entities and relations. It then augments the knowledge graph, generating the first augmented knowledge graph. With the second augmented knowledge graph
[0121] Interactive Graph Enhancement Module: Used for enhancing knowledge graphs based on the first enhanced knowledge graph With the second augmented knowledge graph Calculate the consistency score p of each product from different perspectives. i Simultaneously, based on the user's historical interaction dataset with the product, personalized user preferences are calculated. Based on the consistency score p of each product i and users' personalized preferences Calculate the potential probability p of each product interaction ui And generate the first enhanced interaction graph based on the Bernoulli distribution. With the second enhanced interaction graph
[0122] Node vector update module: used in the first enhanced interaction graph With the second enhanced interaction graph The LightGCN model is used to aggregate the neighbor information of each node to obtain the first vector representation of the user and product on the two interactive views. With the second vector representation
[0123] Comparison constraint module: used for the first vector representation based on KL divergence. With the second vector representation Perform comparative learning with explicit invariant constraints, based on the comparative loss. Update the vector representation of each user and each product across different views to filter out bias information in the knowledge graph;
[0124] Model prediction module: used to fuse the vector representations of users and products on two interactive views after comparative learning, and to predict the probability of interaction;
[0125] Model optimization module: used to optimize the model based on the predicted probability. Constructing BPR loss And combined with BPR loss Semantic loss Comparative loss Obtain the total loss function and update the model parameters based on the total loss function;
[0126] Output module: Used to obtain the recommended product order based on the interaction probabilities output by the model.
[0127] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A bias-removing recommendation method based on graph contrastive learning, characterized in that, Includes the following steps: Step S1: Obtain the knowledge graph dataset and the historical interaction dataset between users and products; Step S2: Input the knowledge graph dataset into the TransE model and apply semantic loss. The learning process yields vector representations of entities and relationships; this is achieved through head entity vectors. With relation vector Similarity and head entity vector With tail entity vector The similarity of knowledge graphs Perform data augmentation to generate the first augmented knowledge graph. With the second augmented knowledge graph The semantic loss is: ; in, Indicates semantic loss, , , For the tail entity of negative sampling, for Activation function; For head entity, For relationships, For tail entity, The tail entity is negatively sampled; For the head entity vector, For relation vectors, Represents the tail entity vector. The tail entity vector is the negative sampled value; Step S3: Based on the first augmented knowledge graph With the second augmented knowledge graph Calculate the consistency score of each product from different perspectives. Simultaneously, based on the user's historical interaction dataset with the product, personalized user preferences are calculated. Based on the consistency score of each product and users' personalized preferences Calculate the potential probability of each product interaction. And generate the first enhanced interaction graph based on the Bernoulli distribution. With the second enhanced interaction graph ; Step S4: In the first enhanced interaction graph With the second enhanced interaction graph The LightGCN model is used to aggregate the neighbor information of each node to obtain the first vector representation of users and products on the two enhanced interaction graphs. With the second vector representation ; Step S5: Represent the first vector based on KL divergence With the second vector representation Perform comparative learning with explicit invariant constraints, based on the comparative loss. Update the vector representation of each user and each product across different views to filter out bias information in the knowledge graph; Step S6: Predict the interaction probability based on the final vector representations of the user and product in different views. ; Step S7: Based on the predicted interaction probability Constructing BPR loss And combined with BPR loss semantic loss Comparative loss Obtain the total loss function and update the model parameters based on the total loss function; Step S8: Obtain the recommended product order based on the interaction probabilities output by the model; In step S5, the comparison loss is... The calculation formula is: ; in, For cosine similarity calculation, KL represents the temperature coefficient, and KL represents the divergence. These represent two ways to enhance the interaction graph, constrained by KL divergence. Indicates positive examples cosine similarity, Indicates negative pairs cosine similarity, Indicates negative pairs Cosine similarity between them; for any user, their nodes in any view This is called the anchor point, while the node in another view... It forms a positive pair with it, that is The remaining nodes in both views and It forms multiple negative pairs with it, that is and .
2. The bias-removing recommendation method based on graph contrastive learning according to claim 1, characterized in that, The specific method for learning the vector representations of entities and relations in step S2 is as follows: Obtaining knowledge graph datasets ,in For a triple, For head entity, For relationships, For tail entities, Represents a set of entities. Represents a set of relations. Representing a knowledge graph; given a randomly initialized vector for each entity and relation, a head entity vector is obtained. relation vector Tail entity vector ;in, , , , Indicates the dimension size as ; Calculate the tail entity for each triplet. Through relationships Relative to head entity Attention coefficient ,in for Activation function For parameter matrices, This is a vector concatenation operation. Attention coefficient; Indicates the vector with vector After concatenation, with the parameter matrix Perform multiplication; Then, based on the attention coefficient and the vectors of the head entity's neighbors, update the head entity vector using the following formula: ; in, This represents the updated head entity vector. The set of tail entities connected to the head entity h; Finally, vector representations of all entities and relations are learned based on the TransE model.
3. The bias-removing recommendation method based on graph contrastive learning according to claim 1, characterized in that, In step S2, the knowledge graph The specific methods for data augmentation are as follows: The similarity between the head entity and relation, and between the head entity and tail entity, is calculated using the following formula: in, and Head entity vectors With relation vector Similarity, head entity vector With tail entity vector Similarity; for Activation function Represents the head entity vector transpose; In a knowledge graph dataset, triples with a similarity less than 0.5 are removed, and the probability of each triple being retained is generated. and The first augmented knowledge graph is obtained. With the second augmented knowledge graph .
4. The bias-removing recommendation method based on graph contrastive learning according to claim 1, characterized in that, In step S3, the consistency score of each product The calculation formula is: ; in, and They represent the products. First Enhanced Knowledge Graph With the second augmented knowledge graph In the vector representation of a knowledge graph, the head entity represents a product. For calculation and The cosine similarity function between them and The first augmented knowledge graph With the second augmented knowledge graph Add the adjacency matrix of the identity matrix. and They are respectively and The degree matrix.
5. The bias-removing recommendation method based on graph contrastive learning according to claim 1, characterized in that, In step S4, the calculation process of the aggregate node features of LightGCN is as follows: ; in, and Let be the vector representations of the user and the product, respectively, during propagation at the k-th layer. For users The collection of products that have been interacted with For those who have purchased products The user set.
6. The bias-removing recommendation method based on graph contrastive learning according to claim 1, characterized in that, In step S6, the interaction probability is predicted. The formula is: ; in, For activation function, and Users in two views respectively The vector representation of , and Products in two views respectively The vector representation of , For users With products The probability of interaction.
7. The bias-removing recommendation method based on graph contrastive learning according to claim 1, characterized in that, In step S7, BPR loss The calculation formula is: ; in, As a positive example of user interaction with the product, For negative examples of user-product interaction; for Activation function; Total loss function The calculation formula is: ; in, and To control the strength of the contrastive loss function and the regularization coefficient of the joint loss function, This represents all the parameters to be learned in the model, including vector representations of entities, relationships, users, and products.
8. A bias-free recommendation system based on graph contrastive learning, characterized in that, Includes the following modules: Interaction module: Used to acquire knowledge graph datasets and historical user-product interaction datasets; The graph attention learning module is used to initialize vectors for all entities and relations based on a given knowledge graph dataset, calculate the attention coefficient of each tail entity relative to the head entity through the relation, aggregate all triple information through the attention mechanism, and then learn the vector representation of the semantic information of all entities and relations in the knowledge graph based on the TransE model. Knowledge Graph Augmentation Module: This module calculates the similarity between the head entity and the relation, and between the head entity and the tail entity, based on the vector representations of entities and relations. It then augments the knowledge graph, generating the first augmented knowledge graph. With the second augmented knowledge graph ; Interactive Graph Enhancement Module: Used for enhancing knowledge graphs based on the first enhanced knowledge graph With the second augmented knowledge graph Calculate the consistency score of each product from different perspectives. Simultaneously, based on the user's historical interaction dataset with the product, personalized user preferences are calculated. Based on the consistency score of each product and users' personalized preferences Calculate the potential probability of each product interaction. And generate the first enhanced interaction graph based on the Bernoulli distribution. With the second enhanced interaction graph ; Node vector update module: used in the first enhanced interaction graph With the second enhanced interaction graph The LightGCN model is used to aggregate the neighbor information of each node to obtain the first vector representation of the user and product on the two interactive views. With the second vector representation ; Comparison constraint module: used for the first vector representation based on KL divergence. With the second vector representation Perform comparative learning with explicit invariant constraints, based on the comparative loss. Update the vector representations of each user and each product across different views to filter out bias information in the knowledge graph; contrastive loss. The calculation formula is: ; in, For cosine similarity calculation, KL represents the temperature coefficient, and KL represents the divergence. These represent two ways to enhance the interaction graph, constrained by KL divergence. Indicates positive examples cosine similarity, Indicates negative pairs cosine similarity, Indicates negative pairs Cosine similarity between them; for any user, their nodes in any view This is called the anchor point, while the node in another view... It forms a positive pair with it, that is The remaining nodes in both views and It forms multiple negative pairs with it, that is and ; Model prediction module: used to fuse the vector representations of users and products on two interactive views after comparative learning, and to predict the probability of interaction; Model optimization module: used to optimize the model based on the predicted probability. Constructing BPR loss And combined with BPR loss semantic loss Comparative loss Obtain the total loss function and update the model parameters based on the total loss function; Output module: Used to obtain the recommended product order based on the interaction probabilities output by the model.
Citation Information
Patent Citations
Multi-contrast learning recommendation method based on knowledge graph
CN116010708A