Contrast learning enhanced collaborative knowledge graph recommendation model construction method

By employing a contrastive learning-enhanced approach, a loss function and a multilayer perceptron are constructed to address the issues of sparse interactive data and long-tail phenomena in knowledge graph recommendation models, thereby improving the accuracy of node representation and recommendation performance.

CN116662529BActive Publication Date: 2026-03-20NORTHWEST A & F UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-05-11
Publication Date
2026-03-20

AI Technical Summary

Technical Problem

Existing knowledge graph-based recommendation models suffer from inaccurate node representations of users and items due to sparse interaction data, long-tail phenomenon, and noise interference, which affects recommendation performance.

Method used

We employ a contrastive learning augmentation approach, constructing a loss function through data augmentation and node representation extraction modules. We design three contrastive learning tasks, including user-user, user-item, and entity-entity contrastive learning, and combine them with a multilayer perceptron to optimize node representations.

Benefits of technology

It alleviates the problems of sparse supervision signals, long-tail effect and noise interference, improves the accuracy of node representation, and improves the performance of recommendation systems, especially in sparse datasets and noisy environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116662529B_ABST
    Figure CN116662529B_ABST
Patent Text Reader

Abstract

The application relates to a collaborative knowledge graph recommendation model construction method enhanced by contrast learning. Three contrast learning tasks are designed to supplement the recommendation supervision task, so that the problem that the node representation learned by the graph neural network is inaccurate due to the problems of sparse supervision signal, long tail effect, noise interference and the like can be alleviated. Meanwhile, in order to make the contrast learning more beneficial to the recommendation task, a multilayer perceptron containing two linear layers is introduced between the node representation and the contrast learning to help the contrast learning training. The application promotes the development of the knowledge graph-based recommendation system and has practical significance.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of knowledge graph recommendation, in particular, to a collaborative knowledge graph recommendation model construction method enhanced by contrast learning. BACKGROUND

[0002] Knowledge graphs contain a large amount of information about entities and the relationships between them, which can be used as an effective auxiliary information to enrich the description of users and items. Using knowledge graphs in recommendation systems can effectively alleviate the problems of data sparsity and cold start, and provide interpretability for the recommendation results. Specifically, some studies represent entities and relationships in knowledge graphs, and then bring the semantic information contained in the knowledge graph into the users and items of the recommendation system, thereby improving the effect of the recommendation system. In addition, some researchers construct a heterogeneous information network graph by combining the knowledge graph and the original user-item interaction data, mine different paths between users and items on the graph, and improve the recommendation effect. With the continuous development of graph neural networks, recommendation models combined with GNN are proposed. Representative KGCN model uses graph convolutional neural network to process knowledge graph, thereby obtaining high-order personalized preference information of users. KGAT model combines the ideas of TransR and GNN to model the high-order relationship between users and items on the collaborative knowledge graph. However, the current recommendation models based on knowledge graphs all use user and item interaction data as supervised information, but this interaction data is very sparse in the entire interaction space, which makes it difficult to learn good enough node representations of users and items. Secondly, the success of the recommendation algorithm depends largely on high-quality knowledge graphs, but the entities in the actual application data set all show a long-tail phenomenon (i.e. a small number of entity nodes have many edges, and most entity nodes have few edges), which brings challenges to accurately capturing the relevance of items in the recommendation system. Finally, the noise (users mistakenly click on a certain item) in the user and item interaction data will also affect the accurate learning of user preferences by the model. SUMMARY

[0003] In order to overcome at least one of the deficiencies in the prior art, the present application provides a collaborative knowledge graph recommendation model construction method enhanced by contrast learning.

[0004] In a first aspect, a collaborative knowledge graph recommendation model construction method enhanced by contrast learning is provided, comprising:

[0005] obtaining a collaborative knowledge graph training set; the collaborative knowledge graph training set comprises a plurality of collaborative knowledge graphs; the nodes in the collaborative knowledge graph include user nodes, item nodes and entity nodes;

[0006] inputting each collaborative knowledge graph into a data enhancement module for data enhancement to obtain a first sub-view and a second sub-view;

[0007] input the first sub-view and the second sub-view to the node representation extraction module, and perform node representation extraction on the first sub-view and the second sub-view respectively to obtain the first representation of each node and the second representation of each node respectively;

[0008] mine relevant features from the first representation of each node to obtain the third representation of each node, and mine relevant features from the second representation of each node to obtain the fourth representation of each node;

[0009] construct a loss function based on the third representation of each node and the fourth representation of each node;

[0010] train the data augmentation module and the node representation extraction module based on the loss function to obtain a trained data augmentation module and a trained node representation extraction module, and the trained data augmentation module and the trained node representation extraction module constitute the collaborative knowledge graph recommendation model enhanced by contrast learning.

[0011] In one embodiment, each collaborative knowledge graph is input to the data augmentation module for data augmentation to obtain the first sub-view and the second sub-view, including:

[0012] generate a first vector and a second vector for deleting edges according to a random deletion ratio p respectively;

[0013] the first vector acts on the collaborative knowledge graph to obtain the first sub-view;

[0014] the second vector acts on the collaborative knowledge graph to obtain the second sub-view.

[0015] In one embodiment, the node representation extraction module includes a first GNN module and a second GNN module, the first GNN module is used for node representation extraction on the first sub-view to obtain the first representation of each node, and the second GNN module is used for node representation extraction on the second sub-view to obtain the second representation of each node.

[0016] In one embodiment, relevant features are mined from the first representation of each node to obtain the third representation of each node, and the following formula is used:

[0017]

[0018] wherein, Z' x is the third representation of each node, σ is an activation function, W2 and W1 are training parameters of the first multi-layer perceptron, is the first representation of each node, b1 and b2 are bias parameters;

[0019] The second representation of each node mines relevant features to obtain a fourth representation of each node, using the following formula:

[0020]

[0021] wherein Z" x is the fourth representation of each node, σ is an activation function, Q2 and Q1 are training parameters of the second multi-layer perception, is the second representation of each node, and b1 and b2 are bias parameters.

[0022] In one embodiment, a loss function is constructed based on the third representation of each node and the fourth representation of each node, including:

[0023] Constructing a user-side loss function

[0024]

[0025] wherein U is a set of user nodes, u≠v, s is a cosine function, Z' u is the third representation of user node u, Z" u is the fourth representation of user node u, τ is a temperature hyperparameter, Z" v is the fourth representation of user node v.

[0026] Constructing a user-item interaction side loss function

[0027]

[0028] wherein I is a set of item nodes, i∈I, g∈I, i is a user-interacted item node, and g is a non-interacted item node, Z" i is the fourth representation of item node i, Z" g is the fourth representation of item node g.

[0029] Constructing an entity side loss function

[0030]

[0031] wherein E is a set of entity nodes, e≠m, Z' e is the third representation of entity node e, Z" e is the fourth representation of entity node e, Z" m is the fourth representation of entity node m.

[0032] Constructing a contrastive learning loss function

[0033]

[0034] Constructing Bayesian personalized ranking loss

[0035]

[0036]

[0037]

[0038] wherein O is a data record of interaction between a user node and an item node, denotes a sample score of an item node i interacted by a user node u, denotes a sample score of an item node g not interacted by a user node u; is a first representation or a second representation of a user node u, is a first representation or a second representation of an item node i, is a first representation or a second representation of an item node g;

[0039] Constructing loss function

[0040]

[0041] wherein λ1 and λ2 are both hyperparameters, and Θ is an L2 regularization term.

[0042] In an embodiment, the hyperparameter λ1 = 0.01 or λ1 = 0.05, and the temperature hyperparameter τ = 0.50 or τ = 0.05.

[0043] In an embodiment, the random deletion ratio ρ = 0.1 or ρ = 0.3.

[0044] In a second aspect, a collaborative knowledge graph recommendation method enhanced by contrast learning is provided, comprising:

[0045] determining a collaborative knowledge graph; the nodes in the collaborative knowledge graph include user nodes, item nodes and entity nodes;

[0046] inputting the collaborative knowledge graph into a collaborative knowledge graph recommendation model enhanced by contrast learning to obtain a first representation and a second representation of each user node, and a first representation and a second representation of each item node;

[0047] selecting the first representation or the second representation of each user node as the representation of each user node;

[0048] selecting the first representation or the second representation of each item node as the representation of each item node;

[0049] For each user node, the similarity between the representation of the user node and the representation of each item node is calculated, and the item node corresponding to the maximum similarity is recommended to the user node;

[0050] The collaborative knowledge graph recommendation model is obtained according to the collaborative knowledge graph recommendation model construction method enhanced by contrast learning according to any one of claims 1-7.

[0051] In a third aspect, a computer-readable storage medium is provided, and the computer-readable storage medium stores a computer program, and the computer program is executed by a processor to implement the above-mentioned collaborative knowledge graph recommendation model construction method enhanced by contrast learning.

[0052] In a fourth aspect, a computer program product is provided, and the computer program product includes computer programs / instructions, and the computer programs / instructions are executed by a processor to implement the above-mentioned collaborative knowledge graph recommendation model construction method enhanced by contrast learning.

[0053] Compared with the prior art, the present application has the following beneficial effects: the present application supplements the recommendation supervision task by designing three contrast learning tasks, which can alleviate the problem that the node representation learned by the graph neural network is inaccurate due to the problems such as sparse supervision signal, long tail effect, and noise interference; at the same time, in order to make the contrast learning more beneficial to the recommendation task, a multilayer perceptron including two linear layers is introduced between the node representation and the contrast learning to help the contrast learning training, which promotes the development of the knowledge graph-based recommendation system and has practical significance. BRIEF DESCRIPTION OF DRAWINGS

[0054] The present application can be better understood by referring to the description given below in conjunction with the accompanying drawings, which are included in the specification and form a part of the specification. In the drawings:

[0055] Figure 1 A schematic diagram of constructing a collaborative knowledge graph is shown;

[0056] Figure 2 A flowchart of the collaborative knowledge graph recommendation model construction method enhanced by contrast learning according to an embodiment of the present application is shown;

[0057] Figure 3 A schematic diagram of contrast learning is shown;

[0058] Figure 4 A graph showing the influence of different values of λ1 on the performance of the method is shown, where (a) is a graph showing the influence of different values of λ1 on the performance of the method on the MovieLens-1M dataset, and (b) is a graph showing the influence of different values of λ1 on the performance of the method on the Amazon-Book dataset;

[0059] Figure 5 Figures showing experimental results of the method of the present application at different τ values, wherein (a) is a figure showing experimental results of the method of the present application at different τ values on the MovieLens-1M dataset, (b) is a figure showing experimental results of the method of the present application at different τ values on the Amazon-Book dataset;

[0060] Figure 6 Figures showing experimental results of the method of the present application at different ρ values;

[0061] Figure 7 Figures showing experimental results of the model (CFKG) of the present application and existing models on datasets without long-tail distribution and datasets with long-tail distribution, wherein (a) is a figure showing experimental results of the model (CFKG) of the present application and existing models on the MovieLens-1M dataset, (b) is a figure showing experimental results of the model (CFKG) of the present application and existing models on the Amazon-Book dataset;

[0062] Figure 8 Figures showing experimental results of different models on noise datasets, wherein (a) is a figure showing experimental results of different models on the MovieLens-1M dataset, (b) is a figure showing experimental results of different models on the Amazon-Book dataset;

[0063] Figure 9 Figure showing a flowchart of a contrastive learning enhanced collaborative knowledge graph recommendation method according to an embodiment of the present application. DETAILED DESCRIPTION

[0064] In the following, exemplary embodiments of the present application will be described with reference to the accompanying drawings. In the description, not all features of a practical embodiment are described for the sake of clarity and conciseness. It should be appreciated, however, that many embodiment-specific decisions can be made in the course of developing any such practical embodiment in order to achieve the specific objectives of the developer, and these decisions can vary from embodiment to embodiment.

[0065] It should also be noted here that, in order to avoid obscuring the present application due to unnecessary details, only the device structures closely related to the scheme according to the present application are shown in the drawings, and other details not closely related to the present application are omitted.

[0066] It should be understood that the present application is not limited to the described embodiments by virtue of the following description with reference to the drawings. In this text, embodiments can be combined with each other, features can be replaced or borrowed between different embodiments, and one or more features can be omitted in an embodiment, if possible.

[0067] The application provides a collaborative knowledge graph recommendation model construction method enhanced by contrast learning. The collaborative knowledge graph recommendation model enhanced by contrast learning is used to recommend items that are consistent with users to different users. The items can be books, movies, goods, music, advertisements, etc. First, a user-item interaction matrix and an item knowledge graph need to be constructed. Then, a collaborative knowledge graph is obtained according to the user-item interaction matrix and the item knowledge graph. The collaborative knowledge graph is input into the collaborative knowledge graph recommendation model to obtain a recommendation result, that is, specific items recommended to each user.

[0068] Figure 1 A schematic diagram of constructing a collaborative knowledge graph is shown. Referring to Figure 1 , the user-item interaction matrix is constructed according to the feedback of users. A given user set U = {u1, u2, …, u |U|} is provided, wherein each element represents a user. In the collaborative knowledge graph, the user set can also be referred to as a user node set. |U| is the number of users in the user set U. A given item set I = {i1, i2, …, i |I|} is provided, wherein each element represents an item. In the collaborative knowledge graph, the item set can also be referred to as an item node set. |I| is the number of items in the item set I. A user-item interaction matrix Y is constructed according to the feedback of users. Each element y ui is defined as follows:

[0069]

[0070] According to formula (1), y ui is recorded as 1 only when the user u is observed to have an interaction behavior (such as reading a book, watching a movie, buying goods, listening to music, clicking an advertisement, etc.) with the item i. In other cases, y ui is recorded as 0.

[0071] Here, the item knowledge graph is used as auxiliary information. The item knowledge graph is represented as G = (ε, R), wherein ε represents a node set and R represents an edge set. The node set in the item knowledge graph includes entity nodes and item nodes. If the item node is a book, the entity node can be the author of the book. Figure 1 The entity nodes in the item knowledge graph include e1, e2, e3, e4, and e5. The item nodes include i1, i2, i3, i4, and i5.

[0072] According to the user-item interaction matrix Y and the item knowledge graph G, the user-item interaction is converted into triples (user, interaction, item). Then, the item and the alignment relationship between the entity in the item knowledge graph are combined into a unified directed graph, that is, a collaborative knowledge graph, denoted as G cThe nodes in the collaborative knowledge graph include user nodes, item nodes and entity nodes.

[0073] The embodiment of the application provides a collaborative knowledge graph recommendation model construction method enhanced by contrast learning, Figure 2 The flowchart of the collaborative knowledge graph recommendation model construction method enhanced by contrast learning is shown, and the flowchart is shown in FIG. 1. Figure 2 The method comprises the following steps.

[0074] In step S21, a collaborative knowledge graph training set is obtained; the collaborative knowledge graph training set includes a plurality of collaborative knowledge graphs; the nodes in the collaborative knowledge graph include user nodes, item nodes and entity nodes.

[0075] In step S22, each collaborative knowledge graph CKG is input into a data enhancement module for data enhancement to obtain a first sub-view and a second sub-view.

[0076] Specifically, a first vector and a second vector for deleting edges are respectively generated according to a random deletion ratio ρ; the first vector acts on the collaborative knowledge graph to obtain a first sub-view CKG-SubGragh-1, which can be abbreviated as CKG-1; the second vector acts on the collaborative knowledge graph to obtain a second sub-view CKG-SubGragh-2, which can be abbreviated as CKG-2, which can be represented by the following formula:

[0077] s1(G c )=(E′,M1⊙R′) (2)

[0078] s2(G c )=(E′,M2⊙R′) (3)

[0079] Wherein, s1(G c ) is the first sub-view, s2(G c ) is the second sub-view, ε' is the set of all nodes in the collaborative knowledge graph, M1, M2∈{0,1} |R'| respectively represent the first vector and the second vector, and R' is the set of all edges in the collaborative knowledge graph.

[0080] In step S23, the first sub-view and the second sub-view are input into a node representation extraction module, and node representation extraction is performed on the first sub-view and the second sub-view respectively to obtain the first representation of each node and the second representation of each node.

[0081] Specifically, the node representation extraction module can include a first GNN module and a second GNN module, the first GNN (graph neural network) module is used for node representation extraction on the first sub-view to obtain a first representation of each node, and the second GNN module is used for node representation extraction on the second sub-view to obtain a second representation of each node. Here, the first GNN module and the second GNN module each have l graph neural network layers, and the first representation of each node and the second representation of each node can be obtained by using the following formula:

[0082]

[0083]

[0084] wherein, is the first representation of each node, that is, the output of the lth graph neural network layer in the first GNN module, is the second representation of each node, that is, the output of the lth graph neural network layer in the second GNN module; is the output of the (l-1)th graph neural network layer in the first GNN module, is the second representation of each node, that is, the output of the (l-1)th graph neural network layer in the second GNN module.

[0085] In step S24, relevant features are mined from the first representation of each node to obtain a third representation of each node, and relevant features are mined from the second representation of each node to obtain a fourth representation of each node. Here, two multi-layer perceptrons MLPs can be set to mine relevant features from the first representation of each node and the second representation of each node, respectively, and the two multi-layer perceptrons MLPs are denoted as a first multi-layer perceptron MLP and a second multi-layer perceptron MLP. Here, the multi-layer perceptron MLP includes two linear layers, batch normalization is performed after each linear layer, and a ReLU activation function is used for activation, as shown in the following expression. The multi-layer perceptron uses training parameters W1 and W2 to complete linear combination of features, and uses an activation function to introduce nonlinear features, which can better mine relevant features, improve the feature extraction capability of the model, and speed up the fitting of training data. Specifically, the following formula can be used to represent:

[0086]

[0087]

[0088] wherein, Z’ x is the third representation of each node, σ is an activation function, which can be a ReLU activation function, W2 and W1 are training parameters of the first multi-layer perceptron, is the first representation of each node, b1 and b2 are bias parameters; Z” xQ2 and Q1 are training parameters of the second multi-layer perception for each node, is the second representation of each node.

[0089] In step S25, a loss function is constructed based on the third representation of each node and the fourth representation of each node; this step can be implemented using a contrastive learning module.

[0090] In step S26, the data augmentation module and the node representation extraction module are trained based on the loss function to obtain a trained data augmentation module and a trained node representation extraction module, and the trained data augmentation module and the trained node representation extraction module constitute the contrastive learning enhanced collaborative knowledge graph recommendation model.

[0091] In this embodiment, the loss function is constructed based on the third representation of each node and the fourth representation of each node for contrastive learning, which can alleviate the problem of inaccurate node representation learned by the graph neural network due to sparse supervision signal, long tail effect, noise interference, etc.; at the same time, the multi-layer perception containing two linear layers is introduced between the node representation and the contrastive learning to help the contrastive learning training, so that the contrastive learning can be more beneficial to the recommendation task.

[0092] In one embodiment, to overcome the phenomenon that not only a large number of long-tail users and long-tail items are not paid attention to by the model in the knowledge graph-based recommendation system, but also a large number of long-tail entities (the relationship of the entity is very few, and the degree of the node is small) are not fully learned by the model, three contrastive learning tasks are designed to alleviate the long-tail problem of users, items and entities respectively. Figure 3 The schematic diagram of contrastive learning is shown, wherein (a) is user-user contrastive learning, (b) is user-item contrastive learning, and (c) is entity-entity contrastive learning, see Figure 3 In step S25, the loss function is constructed based on the third representation of each node and the fourth representation of each node, including:

[0093] Firstly, the contrastive learning of the user node, the two sub-views of the same user are regarded as positive sample pairs, and the views of different users in the same training batch are regarded as negative sample pairs. The loss function adopts contrastive loss InfoNCE, and the goal of this loss function is to maximize the consistency of the positive sample pairs and minimize the consistency of the negative sample pairs, and the user-side loss function is constructed as The following formula is adopted:

[0094]

[0095] Wherein, U is the user node set, u≠v, s is the cosine function, which is used to calculate the similarity between user vectors, Z' u is the third representation of the user node u, and Z" uZ is the fourth representation of user node u, T is the temperature hyper-parameter, and Z v Z is the fourth representation of user node v;

[0096] Then, the user-item contrastive learning is performed, in which the items interacted by the user are regarded as positive samples, and the items not interacted by the user in the same training batch are regarded as negative samples. The contrastive learning is used to reduce the distance between the user node representation and the positive samples, and to increase the distance between the user node representation and the negative samples. A user-item interaction side loss function is constructed The following formula is used:

[0097]

[0098] where I is a set of item nodes, i∈I, g∈I, i is an item node interacted by the user, and g is an item node not interacted by the user, Z i Z is the fourth representation of item node i, Z g Z is the fourth representation of item node g; Z u Z i Z is a positive sample pair, Z u Z g Z is a negative sample pair.

[0099] Then, an entity side loss function is constructed The following formula is used:

[0100]

[0101] where E is a set of entity nodes, e≠m, Z e Z is the third representation of entity node e, Z e Z is the fourth representation of entity node e, Z m Z is the fourth representation of entity node m.

[0102] Then, a contrastive learning loss function is constructed The following formula is used:

[0103]

[0104] Here, The optimization goal is to maximize the similarity between the same node representation vectors and to minimize the similarity between different node representation vectors.

[0105] Finally, the recommendation supervision task and the contrastive learning task are jointly optimized, the learning goal of the recommendation supervision task is to find the items that the user is more interested in, and a higher prediction score is given, and finally a list of item prediction scores in order is returned for each user. The higher the item is ranked in the list, the higher the user's preference for the item. The evaluation method of the list takes the following assumptions: compared with the items that have not been interacted, the user prefers the items that have been interacted. The method takes the items that have been interacted as positive samples, and selects negative samples from the items that have not been interacted, and the optimization goal is simplified as a Bayesian personalized ranking (BPR) loss, and the Bayesian personalized ranking loss is constructed The following formula is used:

[0106]

[0107]

[0108]

[0109] Wherein, O is a data record of interaction between a user node and an item node, represents a sample score of the item node i interacted by the user node u, represents a sample score of the item node g not interacted by the user node u; is the first representation or the second representation of the user node u, is the first representation or the second representation of the item node i, is the first representation or the second representation of the item node g.

[0110] In order to improve the knowledge graph-based recommendation algorithm by using contrastive learning, the application adopts a multi-task training strategy, jointly optimizes the objective function by combining the recommendation supervision task and the contrastive learning auxiliary task, and constructs a loss function The following formula is used:

[0111]

[0112] Wherein, λ1 and λ2 are hyperparameters, and Θ is an L2 regularization term.

[0113] In this embodiment, the recommendation supervision task is supplemented by designing three contrastive learning tasks, which can alleviate the problem that the node representation learned by the graph neural network is inaccurate due to the problems such as sparse supervision signal, long tail effect and noise interference.

[0114] In one embodiment, the hyperparameter λ1=0.01 or λ1=0.05, and the temperature hyperparameter τ=0.50 or τ=0.05.

[0115] The role of the hyperparameter λ1 is to control the proportion of the contrast learning auxiliary task in the joint learning task. To verify the influence of the hyperparameter λ1 on the algorithm performance, the experimental results of the method under different λ1 values are compared, Figure 4 Figures showing the influence of different λ1 values on the performance of the method are shown, wherein (a) is a figure showing the influence of different λ1 values on the performance of the method on the MovieLens-1M dataset, and (b) is a figure showing the influence of different λ1 values on the performance of the method on the Amazon-Book dataset. Here, the evaluation indexes of the algorithm performance are selected as the recall and the normalized discount cumulative gain (NDCG).

[0116] According to Figure 4 It can be known that, on the MovieLens-1M dataset, when λ1 = 0.01, the performance of the method is best, and when λ1 > 0.1, the model performance sharply decreases. On the Amazon-Book dataset, when λ1 = 0.05, the performance of the method is best, and when λ1 > 0.3, the model performance sharply decreases. This is because only a suitable λ1 value can balance the relationship between the recommendation supervised task and the contrast learning auxiliary task, and better results can be obtained.

[0117] The role of the temperature hyperparameter τ is to distinguish between difficult negative samples and positive samples. To verify the influence of the hyperparameter τ on the algorithm performance, the experimental results of the method under different τ values are compared, Figure 5 Figures showing the experimental results of the method under different τ values are shown, wherein (a) is a figure showing the experimental results of the method under different τ values on the MovieLens-1M dataset, and (b) is a figure showing the experimental results of the method under different τ values on the Amazon-Book dataset.

[0118] According to Figure 5 On the MovieLens-1M dataset, when τ = 0.50, the performance of the method is optimal. On the Amazon-Book dataset, when τ = 0.05, the performance of the method is optimal. This is because the smaller the τ value, the lower the score of the difficult negative sample and the higher the score of the positive sample. After the scores have a distinguishing degree, the model will be trained better. However, if the τ value is too small, it will cause the model to be difficult to converge or the generalization ability to be poor, which is not conducive to the recommendation task.

[0119] In an embodiment, the random deletion ratio ρ = 0.1 or ρ = 0.3.

[0120] The application randomly deletes edges on the collaborative knowledge graph at a ratio p to perform data enhancement on the collaborative knowledge graph to obtain two sub-views. To verify the influence of the random deletion ratio p on the algorithm performance, the experimental results of the method of the application at different p values are compared, Figure 6 The experimental result graphs of the method of the application at different p values are shown. It can be seen that, on the MovieLens-1M dataset, the best effect is obtained when p = 0.1, and on the Amazon-Book dataset, the best effect is obtained when p = 0.3. This is because the collaborative knowledge graph constituted by the MovieLens-1M dataset is denser, and the more the interaction data randomly deleted at a larger p, the greater the influence on the dense graph than the sparse graph. Figure 6

[0121] To further verify the effectiveness of the model obtained by the collaborative knowledge graph recommendation model construction method enhanced by the contrastive learning of the application, the experimental results of the model obtained by the collaborative knowledge graph recommendation model construction method enhanced by the contrastive learning of the application and other several models on two different datasets are shown in Table 1.

[0122] Table 1 Comparison of experimental results of different models on two datasets

[0123]

[0124] From the results in Table 1, it can be seen that, on the MovieLens-1M dataset, the model CFKG of the application has a 5.40% improvement in Recall@10 and a 2.54% improvement in NDCG@10 compared with the KGAT model; on the Amazon-Book dataset, the model of the application has a 23.53% improvement in Recall@10 and a 21.78% improvement in NDCG@10 compared with the KGAT model, proving the effectiveness of the model of the application. It can be found that the improvement of the model of the application on the Amazon-Book dataset is higher than that on the MovieLens-1M dataset, because the Amazon-Book dataset is more sparse, and the introduction of contrastive learning can effectively alleviate the problem of sparse supervision signals, so the improvement on this dataset is more obvious. At the same time, it is found that the improvement of the model of the application in Recall is more obvious than that in NDCG, because contrastive learning can improve the distribution of node representation vectors and find out related item nodes, thereby improving the recall rate, while NDCG needs to consider the order factor, and contrastive learning is not helpful to it.

[0125] Secondly, the long tail effect is analyzed. The nodes with a degree less than 10 and the nodes with a degree higher than 40 in the collaborative knowledge graphs constituted by the MovieLens-1M dataset and the Amazon-Book dataset are filtered out to constitute a dataset without long tail distribution,​Figure 7 Experimental results of the model (CFKG) of this application and existing models are shown on datasets without long-tail distribution and datasets with long-tail distribution. Among them, (a) shows the experimental results of the model (CFKG) of this application and existing models on the MovieLens-1M dataset, and (b) shows the experimental results of the model (CFKG) of this application and existing models on the Amazon-Book dataset.

[0126] Depend on Figure 7 As can be seen, all models perform well on datasets without a long-tailed distribution. On datasets with a long-tailed distribution, the performance of other models drops significantly, while our application (CFKG) still maintains good results. This is because the contrastive learning loss function uses cosine similarity to measure the similarity between items, which makes the distribution of nodes in the projection space of the graph more uniform, preserving more of the personalized information of each item, and ensuring that there is no significant difference between popular items with more interactions and unpopular items with fewer interactions.

[0127] The robustness of the model to noisy data was further analyzed. While keeping the MovieLens-1M and Amazon-Book test sets unchanged, a certain proportion of noisy data (i.e., 5%, 10%, and 15% of user-uninteracted items) was added to contaminate the training set. Figure 8 The experimental results of different models on noisy datasets are shown, where (a) shows the experimental results of different models on the MovieLens-1M dataset, and (b) shows the experimental results of different models on the Amazon-Book dataset.

[0128] Depend on Figure 8 As the noise ratio increases, the recommendation performance of other models declines significantly, while the KRCL model proposed in this application still maintains good experimental results. This indicates that KRCL, by comparing the two sub-views obtained after data augmentation of nodes, can identify the structural information of nodes in the collaborative knowledge graph and reduce the dependence of node representation learning on certain edges. In summary, contrastive learning provides a novel approach to removing noise from user-item interaction data in recommender systems.

[0129] This application also provides a collaborative knowledge graph recommendation method enhanced by contrastive learning. Figure 9 A flowchart illustrating a contrastive learning-enhanced collaborative knowledge graph recommendation method according to an embodiment of this application is shown. See also... Figure 9 The methods include:

[0130] Step S91: Determine the collaborative knowledge graph; the nodes in the collaborative knowledge graph include user nodes, project nodes, and entity nodes.

[0131] Step S92, input the collaborative knowledge graph into the collaborative knowledge graph recommendation model enhanced by contrastive learning, to obtain the first representation and the second representation of each user node, and the first representation and the second representation of each item node; the collaborative knowledge graph recommendation model enhanced by contrastive learning is obtained by the method for constructing the collaborative knowledge graph recommendation model enhanced by contrastive learning in the above embodiment.

[0132] Step S93, select the first representation or the second representation of each user node as the representation of each user node.

[0133] Step S94, select the first representation or the second representation of each item node as the representation of each item node.

[0134] Step S95, for each user node, calculate the similarity between the representation of the user node and the representation of each item node, and recommend the item node corresponding to the maximum similarity to the user node.

[0135] It should be noted that when the representation of each user node is selected as the first representation, the representation of the item node is also selected as the first representation, and when the representation of each user node is selected as the second representation, the representation of the item node is also selected as the second representation.

[0136] The embodiment of the present application provides a computer readable storage medium, the computer readable storage medium stores a computer program, and the computer program is executed by a processor to implement the above-mentioned method for constructing a collaborative knowledge graph recommendation model enhanced by contrastive learning.

[0137] The embodiment of the present application provides a computer program product, including computer programs / instructions, which are executed by a processor to implement the above-mentioned method for constructing a collaborative knowledge graph recommendation model enhanced by contrastive learning.

[0138] The above is only various embodiments of the present application, but the protection scope of the present application is not limited to this, any person skilled in the art can easily think of changes or replacements within the technical range disclosed in the present application, which should be covered in the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.

Claims

1. A method for constructing a collaborative knowledge graph recommendation model enhanced by contrastive learning, characterized in that, include: Obtain a training set of collaborative knowledge graphs; the training set of collaborative knowledge graphs includes multiple collaborative knowledge graphs. The nodes in the collaborative knowledge graph include user nodes, project nodes, and entity nodes. The project node is a book, and the entity node is the author of the book. The collaborative knowledge graph training set was constructed based on the Amazon-Book dataset; Each collaborative knowledge graph is input into the data augmentation module for data augmentation, resulting in a first subview and a second subview, including: According to the random deletion ratio Generate the first and second vectors for deleting edges, respectively; The first vector is applied to the collaborative knowledge graph to obtain a first sub-view; The second vector is applied to the collaborative knowledge graph to obtain a second sub-view; The first subview and the second subview are input into the node representation extraction module, and node representation extraction is performed on the first subview and the second subview respectively to obtain the first representation and the second representation of each node respectively. For each node, the first representation is mined to obtain the third representation, and for each node, the second representation is mined to obtain the fourth representation, using the following formula: in, The third representation for each node, For activation function, and These are all training parameters for the first multilayer perceptron. The first representation of each node, Both b2 and b2 are deviation parameters; in, The fourth representation for each node, For activation function, and These are all training parameters for the second multilayer perceptron. The second representation for each node, Both b2 and b2 are deviation parameters; Based on the third representation and the fourth representation of each node, a loss function is constructed, including: Constructing the user-side loss function : Where U is the set of user nodes. , It is a cosine function. For user nodes u The third characteristic, For user nodes u The fourth characteristic, For temperature hyperparameters, For user nodes v The fourth characteristic; Constructing the user project interaction side loss function : Where I represents the set of project nodes. 'i' represents the project nodes that the user has interacted with, and 'g' represents the project nodes that have not been interacted with. This is the fourth representation of project node i. This is the fourth representation of project node g; Constructing the entity-side loss function : Where E is the set of entity nodes, , For entity nodes e The third characteristic, For entity nodes e The fourth characteristic, This is the fourth representation of entity node m; Constructing a contrastive learning loss function : Building Bayesian Personalized Ranking Loss : Where O represents the data records of the interaction between user nodes and project nodes. This represents the sample score of project node i that user node u has interacted with. This represents the sample score of the project node g that user node u has not interacted with; This represents either the first or second representation of user node u. This represents the first or second representation of project node i. This represents the first or second representation of the project node g; Constructing the loss function : in, and All of these are hyperparameters. For L2 regularization terms; The data augmentation module and the node representation extraction module are trained based on the loss function to obtain the trained data augmentation module and the trained node representation extraction module. The trained data augmentation module and the trained node representation extraction module constitute the contrastive learning-enhanced collaborative knowledge graph recommendation model.

2. The method as described in claim 1, characterized in that, The node representation extraction module includes a first GNN module and a second GNN module. The first GNN module is used to extract node representations from the first subview to obtain a first representation of each node. The second GNN module is used to extract node representations from the second subview to obtain a second representation for each node.

3. The method as described in claim 1, characterized in that, Hyperparameters or Temperature overparameter or .

4. The method as described in claim 1, characterized in that, Random deletion ratio or .

5. A collaborative knowledge graph recommendation method enhanced by contrastive learning, characterized in that, include: Define the collaborative knowledge graph; The nodes in the collaborative knowledge graph include user nodes, project nodes, and entity nodes; the project node is a book, and the entity node is the author of the book; The collaborative knowledge graph is input into a contrastive learning-enhanced collaborative knowledge graph recommendation model to obtain the first and second representations of each user node, as well as the first and second representations of each project node. Select either the first representation or the second representation of each user node as the representation of each user node; Select either the first or the second representation of each project node as the representation of each project node; For each user node, calculate the similarity between the user node's representation and the representation of each item node, and recommend the item node with the highest similarity to the user node. The collaborative knowledge graph recommendation model is obtained by the contrastive learning-enhanced collaborative knowledge graph recommendation model construction method according to any one of claims 1-4.

6. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the contrastive learning-enhanced collaborative knowledge graph recommendation model construction method according to any one of claims 1-4.

7. A computer program product, characterized in that, It includes a computer program / instruction that, when executed by a processor, implements the contrastive learning-enhanced collaborative knowledge graph recommendation model construction method as described in any one of claims 1-4.