A dual-view enhanced knowledge contrast learning recommendation method, system and electronic device
By generating relation-aware and semantic-aware knowledge views and utilizing cross-view comparative learning methods, the noise and sparsity problems in knowledge graphs are solved, thereby improving the accuracy and ranking performance of recommendation systems.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- XIAMEN UNIV
- Filing Date
- 2023-10-24
- Publication Date
- 2026-06-12
AI Technical Summary
Existing knowledge graph-based recommendation methods suffer from knowledge noise and sparsity, resulting in insufficient collaborative signals and affecting recommendation accuracy.
A dual-view enhanced knowledge comparison learning method is adopted to generate a relationship-aware knowledge view and a semantic-aware knowledge view. Through cross-view comparison learning, knowledge semantic signals and collaborative signals are connected to enhance the item representation of the user-item interaction graph.
By suppressing relational noise and mitigating the long-tail entity problem, the accuracy of item recommendations and ranking quality are improved.
Smart Images

Figure CN117493664B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data processing, and in particular to a dual-view enhanced knowledge comparison learning recommendation method, system, and electronic device. Background Technology
[0002] In the era of information overload, recommender systems have emerged as an effective means to alleviate information overload, aiming to recommend content that users like as accurately as possible. Among various recommendation methods, collaborative filtering (CF) is a fundamental and effective approach, assuming that users with similar interactions have similar interests. However, due to the sparsity of user-item interaction data, early matrix factorization and emerging graph neural network-based recommendation methods both face the challenge of insufficient collaborative signals. To alleviate this data sparsity problem, knowledge graphs (KGs) are integrated into recommender systems as auxiliary information. They contain rich entities and relationships that express the semantic information of items. Existing knowledge graph-based recommendation methods mainly utilize representation learning and knowledge meta-path construction in knowledge graphs to mine semantic information in KGs. However, these methods suffer from two problems: i) Knowledge noise: KGs contain a lot of relational noise irrelevant to recommendations, which is amplified during representation learning. ii) Knowledge sparsity: The exposure frequency of entities in KGs exhibits a long-tail distribution, indicating that the number of triples corresponding to some entities is extremely sparse, which is detrimental to the learning of semantic information. Summary of the Invention
[0003] The purpose of this invention is to provide a dual-view enhanced knowledge comparison learning recommendation method, system, and electronic device that can obtain more accurate item recommendation rankings.
[0004] To achieve the above objectives, the present invention provides the following solution:
[0005] A dual-view enhanced knowledge comparison learning recommendation method, the recommendation method comprising:
[0006] Obtain multiple target items from the user;
[0007] The multiple target items are input into a recommendation model to obtain a recommended ranking of the multiple target items. The recommendation model is obtained by training an initial recommendation model using a training set. The training set includes a knowledge graph of multiple items and a user-item interaction graph constructed based on the user's historical interaction data with each item. The user-item interaction graph includes user representations, initial item representations, and corresponding interaction relationships. The interaction relationship is defined as either an interaction record between the user and the item or no interaction record between the user and the item. The initial recommendation model includes a knowledge view generation model, a relationship-aware attention aggregator, and a cross-view comparison learning model connected in sequence. The knowledge view generation model is used to obtain a relationship-aware knowledge view based on the scores of each relationship in the knowledge graph of the multiple items, and to classify all entities into long-tail entities and non-long-tail entities based on the exposure frequency of each entity in the knowledge graph of the multiple items. The system obtains a semantically aware knowledge view by clustering long-tail entities and replacing the long-tail entities in the knowledge graph of the multiple items with semantic entities. A relation-aware attention aggregator calculates the attention coefficients of the relation-aware knowledge view and the semantically aware knowledge view, and aggregates and stacks the entities in the relation-aware knowledge view and the semantically aware knowledge view based on the attention coefficients to obtain corresponding first and second item representations. A cross-view contrastive learning model calculates the inner product between the user representation and the first item representation, the second item representation, and the initial item representation, respectively, to obtain corresponding first, second, and third matching scores. Based on the first, second, and third matching scores, the recommended ranking of the multiple items is obtained. The number of exposures is the number of triples containing a certain entity.
[0008] Optionally, the construction process of the recommendation model specifically includes:
[0009] Obtain a knowledge graph of multiple items, and construct a user-item interaction graph based on the user's historical interaction data with each item;
[0010] Calculate the score of each relation in the knowledge graph of the multiple items, determine multiple target relations according to the scores and preset rules, and update the knowledge graph of the multiple items according to the multiple target relations to obtain a relation-aware knowledge view;
[0011] Based on the exposure frequency of each entity in the knowledge graph of the multiple items, all entities are divided into long-tail entities and non-long-tail entities;
[0012] The long-tail entities are clustered using a clustering algorithm to obtain semantic entities;
[0013] The long-tail entities in the knowledge graph of the multiple items are updated with the semantic entities to obtain a semantically aware knowledge view;
[0014] The attention coefficients of the relation-aware knowledge view and the semantic-aware knowledge view are calculated respectively to obtain the corresponding relation-aware attention coefficients and semantic-aware attention coefficients;
[0015] The entities in the relation-aware knowledge view are aggregated using the relation-aware attention coefficient and then stacked to obtain the first item representation.
[0016] The entities in the semantically perceived knowledge view are aggregated using the semantically perceived attention coefficient, and then stacked to obtain the second item representation.
[0017] Based on the first item representation, the second item representation, and the initial item representation, a contrastive learning algorithm is applied to calculate the contrastive learning loss between the user item interaction graph, the relationship-aware knowledge view, and the semantic-aware knowledge view; the contrastive learning loss includes a first contrastive learning loss between the user item interaction graph and the relationship-aware knowledge view, a second contrastive learning loss between the relationship-aware knowledge view and the semantic-aware knowledge view, and a third contrastive learning loss between the user item interaction graph and the semantic-aware knowledge view.
[0018] The cross-view contrastive loss is obtained by summing the first contrastive learning loss, the second contrastive learning loss, and the third contrastive learning loss.
[0019] Calculate the inner product between the user representation and the first item representation, the second item representation, and the initial item representation to obtain the corresponding first matching score, second matching score, and third matching score;
[0020] Based on the first matching score, the second matching score, and the third matching score, the Bayesian personalized ranking loss function is applied to obtain the ranking loss;
[0021] Based on the ranking loss and the cross-view comparison loss, the recommendation loss is obtained;
[0022] Based on the aforementioned recommendation loss, a multi-task training strategy is applied for optimization to obtain the recommendation model.
[0023] Optionally, multiple target relationships are determined according to the scores and preset rules, specifically including:
[0024] Based on the scores, the relationships in the knowledge graph of the multiple items are sorted from largest to smallest;
[0025] Starting with the relationship with the highest score, select a preset number of target relationships in sequence to determine multiple target relationships.
[0026] Optionally, the clustering algorithm is the K-means clustering algorithm.
[0027] Optionally, the formula for calculating the relationship-aware attention coefficient is:
[0028]
[0029]
[0030]
[0031]
[0032]
[0033]
[0034] Where β1(h,r,t) is the relation-aware attention coefficient, and LeakyReLU(·) is the non-linear activation function. For e r transpose, e r The vector representation for initializing the relation, e h The vector representation of the initialization of the head entity, e t The initial vector representation of the tail entity. for The set of triples corresponding to the head entity h. For e r' transpose, e r' for Vector representation of the relationship in the middle, e t' for The vector representation of the mid-tail entity, r' is the relation-aware knowledge view. The set of triples corresponding to the middle-head entity h The relation t' represents the relation that corresponds to all head entities h in the relation, and t' is the relation-aware knowledge view. The set of triples corresponding to the middle-head entity h The tail entities corresponding to all head entities h, where h is the head entity, r is the relation, and t is the tail entity. This is a relation-aware knowledge view, where ε is the set of entities. For the new set of relations, s r Let be the score of the relation, s be the set of scores for all relations, and α be a hyperparameter controlling the retention rate of relations. For the original knowledge graph The set of relations, Nr Is relation r in a knowledge graph? The number of triples corresponding to the given information. For knowledge graphs.
[0035] Optionally, the formula for calculating the semantic awareness attention coefficient is:
[0036]
[0037]
[0038]
[0039]
[0040] Where β2(h,r,t) are semantic awareness attention coefficients, and LeakyReLU(·) is a non-linear activation function. For e r transpose, e r The vector representation for initializing the relation, e h The vector representation of the initialization of the head entity, e t The initial vector representation of the tail entity. for The set of triples corresponding to the head entity h. For e r' transpose, e r' for Vector representation of the relationship in the middle, e t' for The vector representation of the mid-tail entity, r' is the relation-aware knowledge view. The set of triples corresponding to the middle-head entity h The relation t' represents the relation that corresponds to all head entities h in the relation, and t' is the relation-aware knowledge view. The set of triples corresponding to the middle-head entity h The tail entities corresponding to all head entities h, where h is the head entity, r is the relation, and t is the tail entity. This is a semantically aware knowledge view, where ε is the set of entities. For knowledge graphs A set of relationships, For knowledge graphs, ε nl Let ε represent the set of non-long-tailed entities. s Represents a set of semantic entities.
[0041] Optionally, the formula for calculating the recommendation loss is:
[0042]
[0043] in, Recommended loss, The ranking loss is represented by λ1, which is the weight controlling the cross-view comparison loss. C To control the cross-view contrast loss, λ² is the weight of the regularization term, and Θ represents all trainable parameters in the model. is the regularization term, and ||·||2 is the L2 norm.
[0044] A dual-view augmented knowledge comparison learning recommendation system, applying the aforementioned dual-view augmented knowledge comparison learning recommendation method, wherein the recommendation system includes:
[0045] Build a module to retrieve multiple target items from a user;
[0046] The recommendation module is used to input the multiple target items into a recommendation model to obtain a recommendation ranking of the multiple target items. The recommendation model is obtained by training an initial recommendation model using a training set. The training set includes a knowledge graph of multiple items and a user-item interaction graph constructed based on the user's historical interaction data with each item. The user-item interaction graph includes user representations, initial item representations, and corresponding interaction relationships. The interaction relationship is either that the user and the item have an interaction record or that the user and the item do not have an interaction record. The initial recommendation model includes a knowledge view generation model, a relationship-aware attention aggregator, and a cross-view comparison learning model connected in sequence. The knowledge view generation model is used to obtain a relationship-aware knowledge view based on the scores of each relationship in the knowledge graph of the multiple items, and to classify all entities into long-tail entities based on the exposure frequency of each entity in the knowledge graph of the multiple items. The system obtains a semantically aware knowledge view by replacing the long-tail entities in the knowledge graph of the multiple items with semantic entities obtained after clustering the long-tail entities; the relationship-aware attention aggregator is used to calculate the attention coefficients of the relationship-aware knowledge view and the semantically aware knowledge view, and to perform aggregation and stacking operations on the entities in the relationship-aware knowledge view and the semantically aware knowledge view according to the attention coefficients to obtain the corresponding first item representation and second item representation; the cross-view contrastive learning model is used to calculate the inner product between the user representation and the first item representation, the second item representation, and the initial item representation respectively to obtain the corresponding first matching score, second matching score, and third matching score, and to obtain the recommendation ranking of the multiple items according to the first matching score, second matching score, and third matching score; the exposure count is the number of triples containing a certain entity.
[0047] An electronic device includes a memory and a processor, the memory storing a computer program, and the processor running the computer program to cause the electronic device to perform the aforementioned dual-view enhanced knowledge comparison learning recommendation method.
[0048] Optionally, the memory is a readable storage medium.
[0049] According to specific embodiments provided by the present invention, the present invention discloses the following technical effects:
[0050] This invention suppresses relation noise through a relation-aware knowledge view, alleviates the long-tail entity problem through a semantically aware knowledge view, and connects knowledge semantic signals with cooperative signals through a contrastive learning algorithm. It enhances the initial item representation in the user-item interaction graph with denoised semantic information, thereby obtaining a more accurate item recommendation ranking. Attached Figure Description
[0051] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0052] Figure 1 A flowchart of a dual-view enhanced knowledge comparison learning recommendation method provided by the present invention;
[0053] Figure 2 This is a schematic diagram of the recommended model provided by the present invention. Detailed Implementation
[0054] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and 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.
[0055] The purpose of this invention is to provide a dual-view enhanced knowledge comparison learning recommendation method, system, and electronic device that can obtain more accurate item recommendation rankings.
[0056] This invention proposes a dual-view enhanced knowledge contrastive learning framework to suppress relation noise and alleviate the long-tail entity problem. The method generates two new knowledge views to address these two issues: a relation-aware knowledge view and a semantic-aware knowledge view. Then, a cross-view contrastive learning mode is employed to connect knowledge semantic signals with collaborative signals, using denoised semantic information to enhance the initial item representation in the user-item interaction graph.
[0057] The concepts and mathematical symbols used in this invention are explained below:
[0058] User-Item Interaction Graph: In recommendation systems, there are numerous user-item interaction records (such as clicks and views). Based on this, this invention naturally constructs a user-item interaction graph. in and Let and represent the sets of users and items in the recommendation system, respectively. If y uv =1 indicates that there is an edge between u and v in the interaction graph, meaning that there is an interaction record between user u and item v. uv =0 means none.
[0059] Knowledge graph: Items have associated attributes under certain relationships. For example, movie "A" has an attribute "B" under the relationship "actors". This forms a knowledge graph. Where ε and Let h, r, and t represent the sets of entities and relations, respectively. A triple (h, r, t) indicates that a head entity h is associated with a tail entity t under relation r. This shows that the set of items is a subset of the set of entities.
[0060] The task of recommendation models: Input user-item interaction graph and knowledge graph The model outputs the probability of user u interacting with item v.
[0061] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0062] Example 1
[0063] like Figure 1 and Figure 2 As shown, this invention provides a dual-view enhanced knowledge comparison learning recommendation method, the recommendation method comprising:
[0064] Step S1: Obtain multiple target items from the user.
[0065] Step S2: Input the multiple target items into the recommendation model to obtain the recommended ranking of the multiple target items; wherein, the recommendation model is obtained by training an initial recommendation model using a training set; the training set includes a knowledge graph of multiple items and a user-item interaction graph constructed based on the user's historical interaction data with each of the items; the user-item interaction graph includes user representation, initial item representation, and corresponding interaction relationships; the interaction relationship is either that the user and the item have an interaction record or that the user and the item do not have an interaction record; the initial recommendation model includes a knowledge view generation model, a relationship-aware attention aggregator, and a cross-view comparison learning model connected in sequence; the knowledge view generation model is used to obtain a relationship-aware knowledge view based on the scores of each relationship in the knowledge graph of the multiple items, and to classify all entities into long-tail entities and... The non-long-tail entities are clustered, and the resulting semantic entities replace the long-tail entities in the knowledge graph of the multiple items to obtain a semantically aware knowledge view. The relation-aware attention aggregator is used to calculate the attention coefficients of the relation-aware knowledge view and the semantically aware knowledge view, and to aggregate and stack the entities in the relation-aware knowledge view and the semantically aware knowledge view according to the attention coefficients to obtain the corresponding first item representation and second item representation. The cross-view contrastive learning model is used to calculate the inner product between the user representation and the first item representation, the second item representation, and the initial item representation, respectively, to obtain the corresponding first matching score, second matching score, and third matching score, and to obtain the recommendation ranking of the multiple items according to the first matching score, second matching score, and third matching score. The number of exposures is the number of triples containing a certain entity.
[0066] The dual-view enhanced knowledge comparison learning recommendation method provided by this invention also includes the construction process of the recommendation model, the specific steps of which are as follows:
[0067] Step 101: Obtain the knowledge graph of multiple items, and construct the user-item interaction graph based on the user's historical interaction data with each item.
[0068] Step 102: Calculate the score of each relation in the knowledge graph of the multiple items, determine multiple target relations according to the scores and preset rules, and update the knowledge graph of the multiple items according to the multiple target relations to obtain a relation-aware knowledge view.
[0069] Among them, multiple target relationships are determined according to the scores and preset rules, specifically including:
[0070] Based on the scores, the relationships in the knowledge graph of the multiple items are sorted from largest to smallest.
[0071] Starting with the relationship with the highest score, select a preset number of target relationships in sequence to determine multiple target relationships.
[0072] Step 103: Based on the exposure frequency of each entity in the knowledge graph of the multiple items, divide all entities into long-tail entities and non-long-tail entities.
[0073] Step 104: Apply a clustering algorithm to cluster the long-tail entities to obtain semantic entities. Specifically, the clustering algorithm is the K-means clustering algorithm.
[0074] Step 105: Update the long-tail entities in the knowledge graph of the multiple items to the semantic entities to obtain a semantically aware knowledge view.
[0075] In practical applications, in order to solve the problems of knowledge noise and knowledge sparsity in the original knowledge graph, this invention generates two kinds of knowledge views: a relation-aware knowledge view and a semantic-aware knowledge view.
[0076] The process of generating a relationship-aware knowledge view is as follows:
[0077] Knowledge noise is caused by task-irrelevant relations. Therefore, it can be addressed by extracting the more critical relations from the knowledge graph and retaining only the corresponding triples.
[0078] First, we design a relation-aware attention mechanism to learn relation scores from knowledge triples:
[0079]
[0080] Among them, e h e t e r N represents the initial vector representation of the head entity, tail entity, and relation, respectively. r Is relation r in a knowledge graph? The number of triples corresponding to the given information, and LeakyReLU(·) is a non-linear activation function.
[0081] Next, only a certain percentage of relations with higher scores are retained; that is, triples corresponding to relations with lower scores in the KG are discarded. This method generates a relation-aware knowledge view.
[0082]
[0083] Where ε is the set of entities. It is a new set of relations, obtained by the following formula:
[0084]
[0085] Where s represents the set of scores for all relations, and α is a hyperparameter controlling the proportion of relations retained. It is the original knowledge graph A set of relationships.
[0086] The process of generating a semantically aware knowledge view is as follows:
[0087] The sparsity of knowledge arises because some entities in the knowledge graph are associated with only a very small number of triples, which is insufficient to support effective semantic learning, even though there may be potential semantic correlations between these entities. Therefore, all entities in the knowledge graph are divided into long-tail entities and non-long-tail entities based on their exposure frequency. An entity's exposure frequency refers to the number of triples containing that entity in the knowledge graph. A long-tail entity is defined as one with fewer than a pre-defined threshold of exposure frequency. Then, the K-means clustering algorithm is used to cluster long-tail entities into K semantic entity classes, and the original entities are replaced with these K semantic entity classes to generate a semantically aware knowledge view.
[0088]
[0089] Where ε nl Let ε represent the set of non-long-tailed entities. s Represents a set of semantic entities.
[0090] Step 106: Calculate the attention coefficients of the relation-aware knowledge view and the semantic-aware knowledge view respectively to obtain the corresponding relation-aware attention coefficients and semantic-aware attention coefficients.
[0091] The formula for calculating the relationship-aware attention coefficient is as follows:
[0092]
[0093]
[0094]
[0095]
[0096]
[0097]
[0098] Where β1(h,r,t) is the relation-aware attention coefficient, and LeakyReLU(·) is the non-linear activation function. For e r transpose, e r The vector representation for initializing the relation, e h The vector representation of the initialization of the head entity, e t The initial vector representation of the tail entity. for The set of triples corresponding to the head entity h. For e r' transpose, e r' for Vector representation of the relationship in the middle, e t' for The vector representation of the mid-tail entity, r' is the relation-aware knowledge view. The set of triples corresponding to the middle-head entity h The relation t' represents the relation that corresponds to all head entities h in the relation, and t' is the relation-aware knowledge view. The set of triples corresponding to the middle-head entity h The tail entities corresponding to all head entities h, where h is the head entity, r is the relation, and t is the tail entity. This is a relation-aware knowledge view, where ε is the set of entities. For the new set of relations, s r Let be the score of the relation, s be the set of scores for all relations, and α be a hyperparameter controlling the retention rate of relations. For the original knowledge graph The set of relations, N r Is relation r in a knowledge graph? The number of triples corresponding to the given information. For knowledge graphs.
[0099] The formula for calculating the semantic awareness attention coefficient is as follows:
[0100]
[0101]
[0102]
[0103]
[0104] Where β2(h,r,t) are semantic awareness attention coefficients, and LeakyReLU(·) is a non-linear activation function. For e r transpose, e r The vector representation for initializing the relation, e h The vector representation of the initialization of the head entity, e tThe initial vector representation of the tail entity. for The set of triples corresponding to the head entity h. For e r' transpose, e r' for Vector representation of the relationship in the middle, e t' for The vector representation of the mid-tail entity, r' is the relation-aware knowledge view. The set of triples corresponding to the middle-head entity h The relation t' represents the relation that corresponds to all head entities h in the relation, and t' is the relation-aware knowledge view. The set of triples corresponding to the middle-head entity h The tail entities corresponding to all head entities h, where h is the head entity, r is the relation, and t is the tail entity. This is a semantically aware knowledge view, where ε is the set of entities. For knowledge graphs A set of relationships, For knowledge graphs, ε nl Let ε represent the set of non-long-tailed entities. s Represents a set of semantic entities.
[0105] Step 107: Use the relationship-aware attention coefficient to perform aggregation operations on entities in the relationship-aware knowledge view, and then perform stacking calculations to obtain the first item representation.
[0106] Step 108: Use the semantic awareness attention coefficient to perform aggregation operation on entities in the semantic awareness knowledge view, and then perform stacking calculation to obtain the second item representation.
[0107] In practical applications, a relation-aware attention aggregator was designed to learn node representations of relation-aware and semantic-aware knowledge views. The relation-aware attention aggregator serves as a relation-aware message passing framework. The design process of the relation-aware attention aggregator is as follows:
[0108] First, we design a relation-aware attention mechanism to distinguish the contributions of different neighboring entities, namely, relation-aware attention coefficient and semantic-aware attention coefficient.
[0109] Next, the obtained attention coefficients are used to aggregate neighbor entities, and multiple propagation layers are stacked to explore higher-order connection information and collect information propagated from high-hop neighbors.
[0110] The formula for the l-th layer obtained using the relation-aware attention coefficient is:
[0111]
[0112] in, It is the representation of entity t generated by the preceding information propagation steps. In the initial information propagation iteration, Set to e t . It is obtained through aggregation operations.
[0113] After propagation through layer L, each entity receives a set of representations. This invention uses a weighted sum operation to obtain the final entity representation:
[0114]
[0115] in, It is obtained through a superposition operation.
[0116] The formula for the l-th layer obtained using semantic-aware attention coefficients is:
[0117]
[0118] in It is the representation of entity t generated by the preceding information propagation steps. In the initial information propagation iteration, Set to e t . It is obtained through aggregation operations.
[0119] After propagation through layer L, each entity receives a set of representations. This invention uses a weighted sum operation to obtain the final entity representation:
[0120]
[0121] in, It is obtained through a superposition operation.
[0122] Since items are subsets of entities, the knowledge-aware item representations learned from the relation-aware knowledge view are denoted as follows: In this invention, the first item representation is used; the knowledge-aware item representation learned from the semantically aware knowledge view is denoted as... In this invention, it is referred to as the second article.
[0123] Step 109: Based on the first item representation, the second item representation, and the initial item representation, apply a contrastive learning algorithm to calculate the contrastive learning loss between the user item interaction graph, the relationship-aware knowledge view, and the semantic-aware knowledge view; the contrastive learning loss includes a first contrastive learning loss between the user item interaction graph and the relationship-aware knowledge view, a second contrastive learning loss between the relationship-aware knowledge view and the semantic-aware knowledge view, and a third contrastive learning loss between the user item interaction graph and the semantic-aware knowledge view.
[0124] Step 110: Calculate the sum of the first contrastive learning loss, the second contrastive learning loss, and the third contrastive learning loss to obtain the cross-view contrastive loss.
[0125] Step 111: Calculate the inner product between the user representation and the first item representation, the second item representation, and the initial item representation to obtain the corresponding first matching score, second matching score, and third matching score.
[0126] Step 112: Based on the first matching score, the second matching score, and the third matching score, apply the Bayesian personalized ranking loss function to obtain the ranking loss.
[0127] Step 113: Obtain the recommendation loss based on the ranking loss and the cross-view comparison loss.
[0128] The formula for calculating the recommendation loss is as follows:
[0129]
[0130] in, Recommended loss, The ranking loss is represented by λ1, which is the weight controlling the cross-view comparison loss. C To control the cross-view contrast loss, λ² is the weight of the regularization term, and Θ represents all trainable parameters in the model. is the regularization term, and ||·||2 is the L2 norm.
[0131] Step 114: Based on the recommendation loss, apply a multi-task training strategy to optimize and obtain the recommendation model.
[0132] In practical applications, based on the item representations in two knowledge views, namely the first item representation and the second item representation, and combined with the item representations in the user item interaction graph, i.e. the initial item representation, cross-view contrastive learning is proposed to obtain the final cross-view contrastive loss.
[0133] The cross-view comparative learning is specifically as follows:
[0134] Compared to the Key-Gate (KG), the User-Item Interaction Graph (UIG) plays a dominant role in recommendation tasks and is referred to as the Interaction View. The classic LightGCN model is used to learn the representations z of users and items on the Interaction View. u and z v Now, having learned item representations from each of the three views, we establish potential associations between different views through cross-view contrastive learning and minimize the distance between similar nodes. Contrastive learning is a self-supervised learning method that encourages consistency between positive contrast pairs and difference between negative contrast pairs. Here, different views of the same node are considered positive contrast pairs, and views of different nodes are considered negative contrast pairs. In this way, the three views form pairwise contrastive views. Based on InfoNCE, we propose cross-view contrastive loss functions, including cross-view contrastive loss functions between relation-aware knowledge views and semantic-aware knowledge views, between relation-aware knowledge views and interaction views, and between semantic-aware knowledge views and interaction views.
[0135] The cross-view comparison loss function between the two knowledge views is as follows:
[0136]
[0137] The cross-view comparison loss function between relationship-aware knowledge views and interaction views is:
[0138]
[0139] The cross-view comparison loss function between semantically aware knowledge views and interactive views is:
[0140]
[0141] In the formula, s(·) represents the similarity calculation between the two representations, here it is the cosine similarity function. τ is the temperature hyperparameter, v' and These are all symbols for items. This indicates that item v' is an item. a subset of z v' Let v' be the initial item representation. Let v' be the first item representation.
[0142] Finally, this invention adds the above three losses together to obtain the final cross-view comparison loss:
[0143]
[0144] S4: Optimize the model using the contrastive loss and ranking loss obtained above. The final optimized model is described in the "Model Task Description" section at the beginning of this chapter.
[0145] (1) Model prediction and training
[0146] After refining the representations from three views and cross-view comparisons, the user representation z is obtained. u And the initial item representation z v The first item represents Second item representation Then, the present invention integrates the above-mentioned item representations and uses the inner product to predict the matching score between the user and the item, as shown below:
[0147]
[0148] in, This indicates the matching score between the user and the item; the "T" in the upper right corner represents the transpose symbol.
[0149] This invention uses the Bayesian Personalized Ranking (BPR) loss function, which is widely used in recommender systems, to optimize model parameters:
[0150]
[0151] in, Let v' represent the training set, and v' be a randomly sampled item that user u has not interacted with. In this invention, the training set refers to the knowledge graph of multiple items and the recommended ranking of each item.
[0152] Finally, a multi-task training strategy is used to jointly optimize the ranking loss and cross-view comparison loss to obtain the recommendation model.
[0153] This invention addresses two problems encountered by existing methods: knowledge noise and knowledge sparsity. For the knowledge noise problem, a relation-aware attention mechanism is used to learn relation scores and remove task-irrelevant relations using these scores, thereby generating a relation-aware knowledge view. For the knowledge sparsity problem, a clustering algorithm is used to cluster long-tail entities to generate semantic entities, and these semantic entities replace the original entities, thus generating a semantically aware knowledge view. Finally, a cross-view contrastive learning mode is employed to connect knowledge semantic signals with collaborative signals, using denoised semantic information to enhance the initial item representation in the user-item interaction graph, thereby improving recommendation performance.
[0154] Example 2
[0155] To implement the method corresponding to Embodiment 1 above and achieve the corresponding functions and technical effects, a dual-view enhanced knowledge comparison learning recommendation system is provided below. The recommendation system includes:
[0156] A module for retrieving multiple target items from a user.
[0157] The recommendation module is used to input the multiple target items into a recommendation model to obtain a recommendation ranking of the multiple target items. The recommendation model is obtained by training an initial recommendation model using a training set. The training set includes a knowledge graph of multiple items and a user-item interaction graph constructed based on the user's historical interaction data with each item. The user-item interaction graph includes user representations, initial item representations, and corresponding interaction relationships. The interaction relationship is either that the user and the item have an interaction record or that the user and the item do not have an interaction record. The initial recommendation model includes a knowledge view generation model, a relationship-aware attention aggregator, and a cross-view comparison learning model connected in sequence. The knowledge view generation model is used to obtain a relationship-aware knowledge view based on the scores of each relationship in the knowledge graph of the multiple items, and to classify all entities into long-tail entities based on the exposure frequency of each entity in the knowledge graph of the multiple items. The system obtains a semantically aware knowledge view by replacing the long-tail entities in the knowledge graph of the multiple items with semantic entities obtained after clustering the long-tail entities; the relationship-aware attention aggregator is used to calculate the attention coefficients of the relationship-aware knowledge view and the semantically aware knowledge view, and to perform aggregation and stacking operations on the entities in the relationship-aware knowledge view and the semantically aware knowledge view according to the attention coefficients to obtain the corresponding first item representation and second item representation; the cross-view contrastive learning model is used to calculate the inner product between the user representation and the first item representation, the second item representation, and the initial item representation respectively to obtain the corresponding first matching score, second matching score, and third matching score, and to obtain the recommendation ranking of the multiple items according to the first matching score, second matching score, and third matching score; the exposure count is the number of triples containing a certain entity.
[0158] Example 3
[0159] This invention provides an electronic device, including a memory and a processor. The memory stores a computer program, and the processor runs the computer program to enable the electronic device to execute the dual-view enhanced knowledge comparison learning recommendation method of Embodiment 1.
[0160] Alternatively, the aforementioned electronic device may be a server.
[0161] In addition, embodiments of the present invention also provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the dual-view enhanced knowledge comparison learning recommendation method of Embodiment 1.
[0162] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the systems disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the descriptions are relatively simple; relevant parts can be referred to the method section.
[0163] This document uses specific examples to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. Furthermore, those skilled in the art will recognize that, based on the ideas of the present invention, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of the present invention.
Claims
1. A dual-view enhanced knowledge comparison learning recommendation method, characterized in that, The recommendation method includes: Obtain multiple target items from the user; The multiple target items are input into a recommendation model to obtain a recommended ranking of the multiple target items. The recommendation model is obtained by training an initial recommendation model using a training set. The training set includes a knowledge graph of multiple items and a user-item interaction graph constructed based on the user's historical interaction data with each item. The user-item interaction graph includes user representations, initial item representations, and corresponding interaction relationships. The interaction relationship is defined as either an interaction record between the user and the item or no interaction record between the user and the item. The initial recommendation model includes a knowledge view generation model, a relationship-aware attention aggregator, and a cross-view comparison learning model connected in sequence. The knowledge view generation model is used to obtain a relationship-aware knowledge view based on the scores of each relationship in the knowledge graph of the multiple items, and to classify all entities into long-tail entities and non-long-tail entities based on the exposure frequency of each entity in the knowledge graph of the multiple items. The system obtains a semantically aware knowledge view by clustering long-tail entities and replacing the long-tail entities in the knowledge graph of the multiple items with semantic entities. A relation-aware attention aggregator calculates the attention coefficients of the relation-aware knowledge view and the semantically aware knowledge view, and aggregates and stacks the entities in the relation-aware knowledge view and the semantically aware knowledge view based on the attention coefficients to obtain corresponding first and second item representations. A cross-view contrastive learning model calculates the inner product between the user representation and the first item representation, the second item representation, and the initial item representation, respectively, to obtain corresponding first, second, and third matching scores. Based on the first, second, and third matching scores, the recommended ranking of the multiple items is obtained. The number of exposures is the number of triples containing a certain entity.
2. The dual-view enhanced knowledge comparison learning recommendation method according to claim 1, characterized in that, The construction process of the recommendation model specifically includes: Obtain a knowledge graph of multiple items, and construct a user-item interaction graph based on the user's historical interaction data with each item; Calculate the score of each relation in the knowledge graph of the multiple items, determine multiple target relations according to the scores and preset rules, and update the knowledge graph of the multiple items according to the multiple target relations to obtain a relation-aware knowledge view; Based on the exposure frequency of each entity in the knowledge graph of the multiple items, all entities are divided into long-tail entities and non-long-tail entities; The long-tail entities are clustered using a clustering algorithm to obtain semantic entities; The long-tail entities in the knowledge graph of the multiple items are updated with the semantic entities to obtain a semantically aware knowledge view; The attention coefficients of the relation-aware knowledge view and the semantic-aware knowledge view are calculated respectively to obtain the corresponding relation-aware attention coefficients and semantic-aware attention coefficients; The entities in the relation-aware knowledge view are aggregated using the relation-aware attention coefficient and then stacked to obtain the first item representation. The entities in the semantically perceived knowledge view are aggregated using the semantically perceived attention coefficient, and then stacked to obtain the second item representation. Based on the first item representation, the second item representation, and the initial item representation, a contrastive learning algorithm is applied to calculate the contrastive learning loss between the user item interaction graph, the relationship-aware knowledge view, and the semantic-aware knowledge view; the contrastive learning loss includes a first contrastive learning loss between the user item interaction graph and the relationship-aware knowledge view, a second contrastive learning loss between the relationship-aware knowledge view and the semantic-aware knowledge view, and a third contrastive learning loss between the user item interaction graph and the semantic-aware knowledge view. The cross-view contrastive loss is obtained by summing the first contrastive learning loss, the second contrastive learning loss, and the third contrastive learning loss. Calculate the inner product between the user representation and the first item representation, the second item representation, and the initial item representation to obtain the corresponding first matching score, second matching score, and third matching score; Based on the first matching score, the second matching score, and the third matching score, the Bayesian personalized ranking loss function is applied to obtain the ranking loss; Based on the ranking loss and the cross-view comparison loss, the recommendation loss is obtained; Based on the aforementioned recommendation loss, a multi-task training strategy is applied for optimization to obtain the recommendation model.
3. The dual-view enhanced knowledge comparison learning recommendation method according to claim 1, characterized in that, Based on the scores, multiple target relationships are determined according to preset rules, specifically including: Based on the scores, the relationships in the knowledge graph of the multiple items are sorted from largest to smallest; Starting with the relationship with the highest score, select a preset number of target relationships in sequence to determine multiple target relationships.
4. The dual-view enhanced knowledge comparison learning recommendation method according to claim 1, characterized in that, The clustering algorithm is the K-means clustering algorithm.
5. The dual-view enhanced knowledge comparison learning recommendation method according to claim 1, characterized in that, The formula for calculating the relationship-aware attention coefficient is as follows: Where β1(h,r,t) are relation-aware attention coefficients, LeakyReLU(·) is a non-linear activation function, h is the head entity, r is the relation, and t is the tail entity. A knowledge view that is aware of relationships. The vector representation e used to initialize the relation r transpose, e r The vector representation for initializing the relation, e h The vector representation of the initialization of the head entity, e t The initial vector representation of the tail entity. Knowledge View for Relationships The set of triples corresponding to the head entity h. For e r' transpose, e r' Knowledge View for Relationships The set of triples corresponding to the middle-head entity h Vector representation of the relationship in the middle, e t' Knowledge View for Relationships The set of triples corresponding to the middle-head entity h The vector representation of the mid-tail entity, r' is the relation-aware knowledge view. The set of triples corresponding to the middle-head entity h The relation t' represents the relation that corresponds to all head entities h in the relation, and t' is the relation-aware knowledge view. The set of triples corresponding to the middle-head entity h Let ε be the set of all head entities h corresponding to the tail entities. For the new set of relations, s r Let be the score of the relation, s be the set of scores for all relations, and α be a hyperparameter controlling the retention rate of relations. For the original knowledge graph The set of relations, N r Is relation r in a knowledge graph? The number of triples corresponding to the given information. For knowledge graphs.
6. The dual-view enhanced knowledge comparison learning recommendation method according to claim 1, characterized in that, The formula for calculating the semantic awareness attention coefficient is as follows: Where β2(h,r,t) are semantic awareness attention coefficients, LeakyReLU(·) is a non-linear activation function, h is the head entity, r is the relation, and t is the tail entity. A semantically perceptive knowledge view. The vector representation e used to initialize the relation r transpose, e r The vector representation for initializing the relation, e h The vector representation of the initialization of the head entity, e t The initial vector representation of the tail entity. for The set of triples corresponding to the middle-head entity h, e r' for Vector representation of the relationship in the middle. for Vector representation of the relationship e r' transpose, e t' for The vector representation of the mid-tail entity, r' is the relation-aware knowledge view. The set of triples corresponding to the middle-head entity h The relation t' represents the relation that corresponds to all head entities h in the relation, and t' is the relation-aware knowledge view. The set of triples corresponding to the middle-head entity h Let ε be the set of all head entities h corresponding to the tail entities. For knowledge graphs, For knowledge graphs The set of relations, ε nl Let ε represent the set of non-long-tailed entities. s Represents a set of semantic entities.
7. The dual-view enhanced knowledge comparison learning recommendation method according to claim 1, characterized in that, The formula for calculating the recommendation loss is: in, To recommend losses, The ranking loss is represented by λ1, which is the weight controlling the cross-view comparison loss. C To control the cross-view contrast loss, λ² is the weight of the regularization term, and Θ represents all trainable parameters in the model. is the regularization term, and ||·||2 is the L2 norm.
8. A dual-view enhanced knowledge comparison learning recommendation system, characterized in that, The recommendation system includes: Build a module to retrieve multiple target items from a user; The recommendation module is used to input the multiple target items into a recommendation model to obtain a recommendation ranking of the multiple target items. The recommendation model is obtained by training an initial recommendation model using a training set. The training set includes a knowledge graph of multiple items and a user-item interaction graph constructed based on the user's historical interaction data with each item. The user-item interaction graph includes user representations, initial item representations, and corresponding interaction relationships. The interaction relationship is either that the user and the item have an interaction record or that the user and the item do not have an interaction record. The initial recommendation model includes a knowledge view generation model, a relationship-aware attention aggregator, and a cross-view comparison learning model connected in sequence. The knowledge view generation model is used to obtain a relationship-aware knowledge view based on the scores of each relationship in the knowledge graph of the multiple items, and to classify all entities into long-tail entities based on the exposure frequency of each entity in the knowledge graph of the multiple items. The system obtains a semantically aware knowledge view by replacing the long-tail entities in the knowledge graph of the multiple items with semantic entities obtained after clustering the long-tail entities; the relationship-aware attention aggregator is used to calculate the attention coefficients of the relationship-aware knowledge view and the semantically aware knowledge view, and to perform aggregation and stacking operations on the entities in the relationship-aware knowledge view and the semantically aware knowledge view according to the attention coefficients to obtain the corresponding first item representation and second item representation; the cross-view contrastive learning model is used to calculate the inner product between the user representation and the first item representation, the second item representation, and the initial item representation respectively to obtain the corresponding first matching score, second matching score, and third matching score, and to obtain the recommendation ranking of the multiple items according to the first matching score, second matching score, and third matching score; the exposure count is the number of triples containing a certain entity.
9. An electronic device, characterized in that, The device includes a memory and a processor, the memory being used to store a computer program, and the processor running the computer program to cause the electronic device to perform the dual-view enhanced knowledge comparison learning recommendation method according to any one of claims 1 to 7.
10. An electronic device according to claim 9, characterized in that, The memory is a readable storage medium.