Long-tail recommendation algorithm based on knowledge graph comparative learning and sampling
By performing comparative learning and sampling operations on the knowledge graph, the embedding quality and recommendation diversity of long-tail items are improved, the problem of existing recommendation systems biased towards popular items is solved, and a higher recall rate and aggregation diversity are achieved.
Patent Information
- Application Number
- CN202410733686.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-07
- Publication Date
- 2024-10-15
AI Technical Summary
Existing recommendation systems tend to recommend popular items during the model training process, making it difficult for long-tail items to appear in the recommendation list. They lack diversity and contingency, affecting user experience and corporate profits.
A long-tail recommendation algorithm based on comparative learning and sampling of knowledge graphs. By building a collaborative knowledge graph and using TransR to learn entity and relationship embeddings, it performs data enhancement, association-aware relationship pruning, candidate sample selection and high-order knowledge aggregation to generate enhanced Positive and negative samples improve the embedding quality of long-tail items.
It improves the embedding quality and recommendation diversity of long-tail items, enhances the model's ability to learn long-tail user/item features, significantly improves recall and aggregate diversity indicators, the number and accuracy of recommended long-tail items.
Smart Images

Figure CN118780885A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of recommendation technology, and in particular to a long-tail recommendation algorithm based on knowledge graph comparative learning and sampling. Background Art
[0002] Recommendation systems are widely used in many areas of life, such as online shopping, short video recommendations, and various search engines. Currently, recommendation systems that incorporate neural networks are gradually becoming the dominant recommendation system due to their high recommendation accuracy. However, during the model training process, the model may be more inclined to recommend popular items, and many long-tail items cannot appear in the recommendation list. If popular items are always recommended to users, the recommendation list lacks the diversity and contingency provided by long-tail recommendations. On the one hand, users may find it difficult to see and buy their favorite items, which makes users feel bored; on the other hand, for companies, because long-tail items are not recommended, it will affect the company's profitability. Summary of the invention
[0003] The present invention aims to solve the above-mentioned technical problems existing in the prior art and provide a long-tail recommendation algorithm based on knowledge graph comparative learning and sampling.
[0004] The technical solution of the present invention is: a long-tail recommendation algorithm based on knowledge graph comparative learning and sampling, which is carried out in the following steps:
[0005] Step 1. Obtain the user-item interaction graph G1 = {(u, i)|u∈U, i∈I}, the knowledge graph G2 = {(h, r, t)|h, t∈ε, r∈R}, and construct the collaborative knowledge graph G3 = {(h, r, t)|h, t∈ε′, r∈R′} through G1 and G2;
[0006] In the user-item interaction graph G1, (u, i) indicates that user u has interacted with item i, U = {u1, u2, ..., u |U|} represents the user set, I = {i1, i2, ..., i |I|} represents a set of items; in the knowledge graph G2, ε={e1,e2,...,e |ε|} represents an entity set, R = {r1, r2, ..., r |R|} represents a set of relationships; in the collaborative knowledge graph G3, ε′=ε∪U, R′=R∪{interaction}, |U| represents the total number of users, |I| represents the total number of items, |ε| represents the total number of entities, and |R| represents the total number of relationships; TransR is used in the collaborative knowledge graph G3 to learn the embedding of each entity node and relationship node, and its training relationship is as shown in formula (1):
[0007]
[0008] Among them, e h , e r , e t Respectively represent the head entity, relation entity, and tail entity embedding, W r is a transformation matrix based on the relation r;
[0009] Step 2. Generate two data views on the collaborative knowledge graph G3 using data enhancement operators ψ1 and ψ2 according to formula (2) and formula (3) respectively;
[0010]
[0011] in, Represents the masking vector of the relation r∈R′ in the lth layer of the neural network;
[0012] Step 3. Relation pruning based on association awareness;
[0013] The probability of a relationship being masked is determined by using the correlation between the relationship r in the lth layer of the neural network and the target user and item, as shown in formulas (4) and (5) respectively:
[0014]
[0015] in, They represent the probability of the target user and the target object covering the relationship r, They represent the embedding representation of the relationship r for the target user u and the target item i under the l-th layer of the neural network, and c() represents the cosine similarity, which is used to calculate e u and The similarity and e i and similarity;
[0016] Step 4. Selection of candidate samples based on knowledge perception;
[0017] Step 4.1: Knowledge-aware entity candidate sample selection;
[0018] Given any set of user and item interactions (u, i), the set of entity neighbor nodes for item i is defined as N i ={h|(i, r, h)∈G3}, for any entity h∈N i , use formula (6) to calculate the association between user u and entity h:
[0019]
[0020] Then use softmax to normalize according to formula (7):
[0021]
[0022] Select the n1 entity nodes with the highest correlation as candidate nodes, denoted as
[0023] Step 4.2: Selection of candidate item samples based on knowledge perception;
[0024] For any entity Define h's item neighbor nodes as N h ={i|(h, r, i)∈G3}, for any item i′∈N h , use formula (8) to define the association between user u and item i:
[0025]
[0026] Use formula (9) to normalize using softmax:
[0027]
[0028] Then, they are sorted in descending order according to the relevance, and the n2 item nodes with the highest probability are selected as candidate nodes, denoted as C;
[0029] Step 4.3 candidate sample classification;
[0030] For all i∈C, if i is a long-tail item, the item is divided into enhanced positive samples, denoted as i + , if i is a popular item, the item is divided into enhanced negative samples, denoted as i - :
[0031]
[0032] Step 5. High-level knowledge aggregation based on relation-aware attention;
[0033] Step 5.1 For any triple (h, r, t) ∈ G3, the attention weights generated based on different relations are as follows:
[0034] π′(h,r,t)=(W r e t ) T tanh((W r e h +e r )) (11)
[0035] Among them, W r is a trainable transformation matrix based on the r relationship, T represents the matrix transpose operation, and softmax is used for normalization according to formula (12):
[0036]
[0037] Step 5.2: Use formula (13) to perform weighted summation on all triples with h as the head entity to obtain neighbor information:
[0038]
[0039] The head entity h can be a user node, an item node or an entity node, N h represents the neighbor set of head entity h, The l-th order representation representing the neighborhood information of the head entity h;
[0040] Step 5.3: Aggregate high-level knowledge according to formula (14):
[0041]
[0042] Among them, W1 is the trainable transformation matrix;
[0043] Step 6. Embed the user u and item embedding i Do the inner product to predict the degree of interaction between user u and item i;
[0044]
[0045] in and It is obtained by concatenating user embeddings of each order and item embeddings of each order, as shown in formulas (16) and (17):
[0046]
[0047] Step 7. Use the following formula to iteratively train the parameters to the optimal value;
[0048]
[0049] Where L BPR , and As shown in formulas (19), (20) and (21).
[0050]
[0051] Among them, λ1, λ2, λ3 represent regularization weights, θ represents the parameter set, i + ,i - Positive samples and negative samples respectively, and They represent the embeddings of the target user and target item generated by the two data views of formula (2) and formula (3) in step 2, respectively, and τ represents a hyperparameter;
[0052] Step 8. Predict the interaction score between user u and item i again using formula (15) in step 6, and select the first N items in the descending sorted set of the predicted scores as the recommendation results and recommend them to user u.
[0053] Compared with the prior art, the present invention has the following advantages:
[0054] 1. This invention uses the rich relational information in the knowledge graph for the first time to construct two data enhancement operators and further construct two data views. Compared with the existing contrastive learning method that performs self-supervised learning on the user-item interaction graph to improve the embedding quality of long-tail items, this invention introduces a correlation-aware relation pruning operation on the knowledge graph to perform graph contrast self-supervised learning, further enhancing the embedding quality of long-tail items.
[0055] 2. The present invention develops a discriminative sampling operation driven by knowledge graphs to generate enhanced samples that supplement long-tail items in positive samples and short-head items in negative samples. Different from the existing method of performing random negative sampling from the set of uninteracted items during training, the present invention utilizes the semantic information in the knowledge graph to perform discriminative sampling from the set of uninteracted items, thereby generating enhanced negative / positive samples and enhancing the model's ability to learn long-tail user / item features. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] Figure 1 is a flow chart of an embodiment of the present invention.
[0057] Figure 2 The collaborative knowledge graph constructed in step 1 of the embodiment of the present invention.
[0058] Figure 3 It is a schematic diagram of the corresponding results of the Recall index according to the embodiment of the present invention and the prior art as the number of recommendations changes.
[0059] Figure 4 It is a schematic diagram of the corresponding results of the AD index according to the embodiment of the present invention and the prior art as the recommended quantity changes. DETAILED DESCRIPTION
[0060] The present invention provides a long-tail recommendation algorithm based on knowledge graph contrast learning and sampling, such as Figure 1 As shown, follow the steps below:
[0061] Step 1. Obtain the user-item interaction graph G1 = {(u, i)|u∈U, i∈I}, the knowledge graph G2 = {(h, r, t)|h, t∈ε, r∈R}, and construct the collaborative knowledge graph G3 = {(h, r, t)|h, t∈ε′, r∈R′ through G1 and G2;
[0062] In the user-item interaction graph G1, (u, i) indicates that user u has interacted with item i, U = {u1, u2, ..., u |U|} represents the user set, I = {i1, i2, ..., i |I|} represents a set of items. In the knowledge graph G2, ε = {e1, e2, ..., e |ε|} represents an entity set, R = {r1, r2, ..., r |R|} represents a set of relationships; in the collaborative knowledge graph G3, ε′=ε∪U, R′=R∪{interaction}, |U| represents the total number of users, |I| represents the total number of items, |ε| represents the total number of entities, and |R| represents the total number of relationships; TransR is used in the collaborative knowledge graph G3 to learn the embedding of each entity node and relationship node, and its training relationship is as follows:
[0063]
[0064] Among them, e h , e r , e t Respectively represent the head entity, relation entity, and tail entity embedding, W r is the transformation matrix based on the relation r.
[0065] In the user-item interaction graph G1: U = {user 1, user 2, user 3} represents the user set;
[0066] I = {item 1, item 2, item 3} represents a set of items;
[0067] In the knowledge graph G2:
[0068] ε = {item 1, item 2, item 3, item 4, item 5, entity 6, entity 7, entity 8, entity 9, entity 10} represents an entity set, and R = {relation 1, relation 2, relation 3} represents a relation set;
[0069] Then the user-item interaction graph G1 is shown in Table 1. In Table 1, the values of user u and item i are 1, which means that user u has an interaction relationship with item i; the values of user u and item i are 0, which means that there is no interaction relationship;
[0070] Table 1
[0071] User\Item Item 1 Item 2 Item 3 User 1 0 1 1 User 2 1 1 1 User 3 1 0 0
[0072] From Table 1, we can see that:
[0073] User 1's interactive items are {item 2, item 3};
[0074] User 2's interactive items are {item 1, item 2, item 3};
[0075] User 3's interactive item is {item 1};
[0076] The attribute information of the item in the knowledge graph G2 is shown in Table 2. A row of data in Table 2 indicates that there is a connection between the head entity and the tail entity based on the relationship of the row;
[0077] Table 2
[0078] Head Entity relation Tail Entity Item 1 Relationship 1 Entity 5 Item 1 Relationship 2 Entity 6 Item 2 Relationship 1 Entity 7 Item 2 Relationship 1 Entity 5 Item 3 Relationship 3 Entity 8 Item 3 Relationship 2 Entity 9
[0079] From Table 2, we can see that:
[0080] Under relationship 1, (item 1, entity 5), (item 2, entity 7), (item 2, entity 5), and (item 5, entity 9) are connected;
[0081] Under relationship 2, (item 1, entity 6) and (item 3, entity 9) are connected;
[0082] Under relationship 3, (item 3, entity 8) is connected;
[0083] By combining the above user-item interaction graph G1 and knowledge graph G2, and defining the interaction relationship as relationship 4, we can obtain the collaborative knowledge graph G3, as shown in Figure 2 As shown in Table 3:
[0084] Table 3
[0085] Head Entity relation Tail Entity Item 1 Relationship 1 Entity 5 Item 1 Relationship 2 Entity 6 Item 2 Relationship 1 Entity 7 Item 2 Relationship 1 Entity 5 Item 3 Relationship 3 Entity 8 Item 3 Relationship 2 Entity 9 User 1 Relationship 4 Item 2 User 1 Relationship 4 Item 3 User 1 Relationship 4 Item 5 User 2 Relationship 4 Item 1 User 2 Relationship 4 Item 2 User 2 Relationship 4 Item 3 User 3 Relationship 4 Item 1
[0086] Step 2. Generate two data views on the collaborative knowledge graph G3 using data enhancement operators ψ1 and ψ2 according to equations (2) and (3) respectively;
[0087]
[0088] in, Represents the masking vectors of relation r∈R′ in the l-th layer of the neural network. These vectors will mask the relation r with a certain probability to generate two subgraphs of the collaborative knowledge graph;
[0089] Step 3. Relation pruning based on association awareness;
[0090] The probability of the relation r in the l-th layer of the neural network being masked is determined by the correlation between the target user and the item. The probability of the relation r in the l-th layer of the neural network being masked is defined as follows:
[0091]
[0092] in, They represent the probability of the target user and the target object covering the relationship r, They represent the embedding representation of the relationship r for the target user u and the target item i under the l-th layer of the neural network, and c() represents the cosine similarity, which is used to calculate e u and The similarity and e i and similarity;
[0093] For user 1, its embedding is represented as e 用户1 , the probability that relation r is masked in the l-th layer of the neural network is Similarly, for item 1, the probability that relation r is obscured in the l-th layer of the neural network is
[0094] Step 4. Selection of candidate samples based on knowledge perception;
[0095] Step 4.1: Knowledge-aware entity candidate sample selection;
[0096] Given any set of user and item interactions (u, i), the set of entity neighbor nodes for item i is defined as N i ={h|(h, r, t)∈G3}, for any entity h∈N i , use the following formula to calculate the association between user u and entity h:
[0097]
[0098] Then use softmax to normalize:
[0099]
[0100] In order to prevent some low-correlation nodes from being selected and thus introducing noise, the n1 entity nodes with the highest correlation are selected as candidate nodes, denoted as
[0101] For the interaction pair (user 3, item 1), the entity neighbor set of item 1 is N 物品1 ={entity 5, entity 6}, the degree of association between user 3 and entity 5 is:
[0102]
[0103] The degree of association between user 3 and entity 6 is:
[0104]
[0105] Step 4.2: Selection of candidate item samples based on knowledge perception;
[0106] For any entity Define h's item neighbor nodes as N h={i|(h, r, i)∈G3}, for any item i′∈N h , the association between user u and item i is defined by the following formula:
[0107]
[0108] Then use softmax to normalize:
[0109]
[0110] Then, they are sorted in descending order according to the relevance, and the n2 item nodes with the highest probability are selected as candidate nodes, denoted as C;
[0111] Taking entity 5 as an example, the set of item neighbor nodes of entity 5 is N 实体5 ={item 1, item 2}, the association between user 3 and item 2 is:
[0112]
[0113] Step 4.3 candidate sample classification;
[0114] For all i∈C, if i is a long-tail item, the item is divided into enhanced positive samples, denoted as i + , if i is a popular item, the item is divided into enhanced negative samples, denoted as i - :
[0115]
[0116] Step 5. High-level knowledge aggregation based on relation-aware attention;
[0117] Step 5.1 For any triple (h, r, t) ∈ G3, the attention weights generated based on different relations are as follows:
[0118] π′(h,r,t)=(W r e t ) T tanh((W r e h +e r )) (11)
[0119] Where W r is a trainable transformation matrix based on the r relationship, e h , e r , e t They correspond to the head entity embedding, relation embedding, and tail entity embedding respectively. T represents the matrix transpose operation, and then softmax is used for normalization:
[0120]
[0121] Step 5.2: Use formula (5) to perform weighted summation on all triples with h as the head entity to obtain neighbor information:
[0122]
[0123] The head entity h can be a user node, an item node or an entity node, N h represents the neighbor set of head entity h, The l-th order representation representing the neighborhood information of the head entity h;
[0124] Step 5.3 High-level knowledge aggregation:
[0125]
[0126] Among them, W1 is the trainable transformation matrix;
[0127] For user 1, his attention to item 2 is:
[0128] π′(user 1, relation 4, item 2) = (W 关系4 e 物品2 ) T tanh((W 关系4 e 用户1 +e 关系4 ));
[0129] The attention to item 3 is:
[0130] π′(user 1, relation 4, item 3) = (W 关系4 e 物品3 ) T tanh((W 关系4 e 用户1 +e 关系4 ));
[0131] The normalized result is:
[0132]
[0133] The neighbor information of user 1 at layer l is:
[0134]
[0135] The representation of the lth layer of user 1 is:
[0136]
[0137] Step 6. Embed the user u and item embedding i Do the inner product to predict the degree of interaction between user u and item i;
[0138]
[0139] Formula (16) and Formula (17) concatenate each order of user embedding and each order of item embedding;
[0140] The vector after concatenation of user 1 is expressed as:
[0141]
[0142] Similarly, the vector of item 1 after concatenation is expressed as:
[0143]
[0144] The interaction score between user 1 and item 1 is:
[0145]
[0146] Step 7. Use the following formula to iteratively train the parameters to the optimal value;
[0147]
[0148] Where L BPR , and As shown in formulas (19), (20) and (21).
[0149]
[0150] Among them, λ1, λ2, λ3 represent regularization weights, θ represents the parameter set, i + ,i - Positive samples and negative samples respectively, and They represent the embeddings of the target user and target item generated by the two data views of formula (2) and formula (3) in step 2, respectively, and τ represents a hyperparameter;
[0151] Step 8. Predict the interaction degree between user u and item i again through step 6, and select the first N items in the descending sorted set of the predicted scores as the recommendation results and recommend them to user u.
[0152] The method of the embodiment of the present invention is experimentally demonstrated, which specifically includes:
[0153] (1) Using public datasets
[0154] The dataset used in the present invention is Last-FM, which is a music listening dataset provided by the Last.FM music platform, in which tracks are identified as items. This dataset includes 3,034,796 pieces of interaction data from 23,566 users and 48,123 items, with each user having at least 10 pieces of interaction information.
[0155] (2) Evaluation indicators
[0156] The present invention uses recall and aggregation diversity (AD) as evaluation indicators for this experiment. Recall can show the recommendation accuracy, while AD can show the performance of recommending long-tail items. The higher the Recall value, the higher the recommendation accuracy, and the higher the AD value, the more long-tail items are recommended. The calculation formula is as follows:
[0157]
[0158] Among them, Top u (N) represents the N items finally recommended to user u.
[0159] The algorithm proposed in this paper is compared with the classic knowledge graph-based recommendation algorithm KGAT (Knowledge Graph Attention Network). The results are as follows: Figure 3 and Figure 4 shown. Figure 3 The experimental results of Recall are shown. Figure 4 The experimental results of AD are shown. It can be seen from the experimental results that as the number of recommendations increases, the Recall and AD results of the algorithm of the present invention are significantly higher than those of the KGAT algorithm. Since the larger the Recall value, the higher the recommendation accuracy, and the higher the AD value, the more long-tail items are recommended, the algorithm of the present invention can recommend more long-tail items with higher accuracy than KGAT.
Claims
1. A long-tail recommendation algorithm based on knowledge graph comparative learning and sampling is carried out in the following steps: Step 1. Obtain the user-item interaction graph G1 = {(ui, i) | u∈U, i∈I}, the knowledge graph G2 = {(h, r, t} | h, t∈ε, r∈R}, and construct the collaborative knowledge graph G3 = {(h, r, t} | h, t∈ε′, r∈R′} through G1 and G2; In the user-item interaction graph G1, (u, i) indicates that user u has interacted with item i, U = {u1, u2, ..., u |U|} represents the user set, I = {i1, i2, ..., i |I|} represents a set of items; in the knowledge graph G2, ε={e1,e2,...,e |ε|} represents an entity set, R = {r1, r2, ..., r |R|} represents a set of relations; in the collaborative knowledge graph G3, ε′=ε∪U, R′=R∪{interaction}, |U| represents the total number of users, |I| represents the total number of items, |ε| represents the total number of entities, and |R| represents the total number of relations; In the collaborative knowledge graph G3, TransR is used to learn the embedding of each entity node and relationship node. The training relationship is as shown in formula (1): in, e h , e r , e t Respectively represent the head entity, relation entity, and tail entity embedding, W r is a transformation matrix based on the relation r; Step 2. Generate two data views on the collaborative knowledge graph G3 using data enhancement operators ψ and ψ2 according to formula (2) and formula (3) respectively; in, Represents the masking vector of the relation r∈R′ in the lth layer of the neural network; Step 3. Relation pruning based on association awareness; The probability of a relationship being masked is determined by using the correlation between the relationship r in the lth layer of the neural network and the target user and item, as shown in formulas (4) and (5) respectively: in, They represent the probability of the target user and the target object covering the relationship r, They represent the embedding representation of the relationship r for the target user u and the target item i under the l-th layer of the neural network, and c() represents the cosine similarity, which is used to calculate e u and The similarity and e i and similarity; Step 4. Knowledge-aware candidate sample selection; Step 4.1: Selection of entity candidate samples based on knowledge perception; Given any set of user and item interactions (u, i), the set of entity neighbor nodes for item i is defined as N i ={h|(i, r, h)∈G3}, for any entity h∈N i , use formula (6) to calculate the association between user u and entity h: Then use softmax to normalize according to formula (7): Select the n1 entity nodes with the highest correlation as candidate nodes, denoted as Step 4.2: Selection of candidate item samples based on knowledge perception; For any entity Define h's item neighbor nodes as N h ={i|(h, r, i)∈G3}, for any item i′∈N h , use formula (8) to define the association between user u and item i: Use formula (9) to normalize using softmax: Then, they are sorted in descending order according to the relevance, and the n2 item nodes with the highest probability are selected as candidate nodes, denoted as C; Step 4.3 candidate sample classification; For all i∈C, if i is a long-tail item, the item is divided into enhanced positive samples, denoted as i + , if i is a popular item, the item is divided into enhanced negative samples, denoted as i _ : Step 5. High-level knowledge aggregation based on relation-aware attention; Step 5.1 For any triple (h, r, t) ∈ G3, the attention weights generated based on different relations are as follows: π′(h,r,t)=(W r e t ) T tanh((W r e h +e r )) (11) Among them, W r is a trainable transformation matrix based on the r relationship, T represents the matrix transpose operation, and softmax is used for normalization according to formula (12): Step 5.2: Use formula (13) to perform weighted summation on all triples with h as the head entity to obtain neighbor information: The head entity h can be a user node, an item node or an entity node, N h represents the neighbor set of head entity h, The l-th order representation representing the neighborhood information of the head entity h; Step 5.3: Aggregate high-level knowledge according to formula (14): Among them, W1 is the trainable transformation matrix; Step 6. Embed the user u and item embedding i Do the inner product to predict the degree of interaction between user u and item i; in and It is obtained by concatenating user embeddings of each order and item embeddings of each order, as shown in formulas (16) and (17): Step 7. Use the following formula to iteratively train the parameters to the optimal value; Where L BPR , and As shown in formulas (19), (20) and (21); Among them, λ1, λ2, λ3 represent regularization weights, θ represents the parameter set, i + ,i - Positive samples and negative samples respectively, and They represent the embeddings of the target user and target item generated by the two data views of formula (2) and formula (3) in step 2, respectively, and τ represents a hyperparameter; Step 8. Predict the interaction score between user u and item i again using formula (15) in step 6, and select the first N items in the descending sorted set of the predicted scores as the recommendation results and recommend them to user u.
Citation Information
Cited By
Knowledge graph and contrast learning fusion-based intention perception recommendation method
CN120611100A
Long-tail data distribution-oriented tail sensing gating double-view sequence recommendation method
CN122796297A
