Recommendation method and device based on knowledge graph, equipment and medium
Through the cross-compression algorithm and multi-head attention model combined with factor decomposition machine, deep neural network and multi-layer perception machine, the problem of neglecting the importance of recommendation tasks and knowledge graph tasks in the existing technology is solved, and more refined user preference capture and improvement in the accuracy of recommendation algorithms is achieved.
Patent Information
- Application Number
- CN202510383372.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-28
- Publication Date
- 2025-07-18
AI Technical Summary
The existing knowledge graph-based recommendation methods ignore the relative importance between recommendation tasks and knowledge graph tasks, and cannot capture user preferences more finely, resulting in low accuracy of recommendation algorithms.
The item vectors and knowledge graph entity vectors associated with user behavior are calculated by pre-installed cross-compression algorithm, combined with multi-head attention model, factor decomposition machine and deep neural network model to extract feature combinations, and a multi-layer perceptron is used to obtain the knowledge graph embedding loss function, and the recommended model is trained to improve recommendation accuracy.
It improves the accuracy of the recommendation algorithm, captures potential useful information in the implicit feature combination, enhances the model's ability to mine deep domain features, and improves the overall performance of the recommendation system.
Smart Images

Figure CN120336623A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of deep learning, and particularly to a recommendation method, device, equipment and medium based on a knowledge graph. Background Art
[0002] With the rapid development of Internet technology and the explosive growth of information volume, people often feel confused and exhausted when facing a vast amount of choices and information, and it is difficult to quickly find the content they are really interested in. In this context, recommendation systems are particularly important, as they can provide personalized and accurate content recommendations based on users' preferences and behavior patterns. Currently, recommendation systems have been widely applied in multiple fields, including movies, music, products, etc., greatly optimizing the user's information consumption experience.
[0003] Recommendation algorithms are the core of recommendation systems. Currently, recommendation algorithms can be divided into collaborative filtering-based recommendation systems, content-based recommendation systems, and hybrid recommendation systems. Collaborative filtering is one of the most popular technologies at present, but it often suffers from data sparsity and cold start problems. To solve the above dilemmas faced by recommendation systems, researchers have proposed various methods of using auxiliary information. In addition to common information such as social networks, item attributes, and user reviews, knowledge graphs have also become a high-quality source of auxiliary information due to their rich entity and relationship information. A knowledge graph is a structured semantic knowledge base used to describe concepts in the physical world and their interrelationships in symbolic form. It organizes entities and relations in the form of a graph to form a complex network structure, thereby achieving efficient storage and retrieval of knowledge. According to the different ways of combining the knowledge graph with the recommendation model, existing work can mainly be divided into sequential training, joint training, and alternating training. These three types of methods have explored the idea of applying knowledge graph feature learning to recommendation systems from different perspectives, and they have all achieved certain performance improvements.
[0004] However, most of the above-mentioned recommendation methods based on knowledge graphs ignore the relative importance between the recommendation task and the knowledge graph task, and cannot capture users' preferences more precisely, resulting in the technical problem of low accuracy of the recommendation algorithm.
[0005] In addition, their research focus often lies in the learning of explicit feature combinations, while those implicit feature combinations that have not been captured may contain potentially useful information. Losing this information may limit the model's ability to mine deep domain features, thus affecting the overall performance of the recommendation system. Summary of the Invention
[0006] In view of the deficiencies of the above-mentioned prior art, the purpose of the present invention is to provide a recommendation method, device, equipment and medium based on a knowledge graph that can be applied to deep learning or other related fields, aiming at the technical problem that most of the existing recommendation methods based on knowledge graphs ignore the relative importance between the recommendation task and the knowledge graph task, and cannot capture the user's preferences more precisely, resulting in low accuracy of the recommendation algorithm.
[0007] The technical solution of the present invention is as follows:
[0008] The present invention provides a recommendation method based on a knowledge graph, which includes:
[0009] Calculating the item vector associated with the user behavior and the entity vector of the preset knowledge graph through a preset cross-compression algorithm, and obtaining the corresponding item and entity vector pair;
[0010] Inputting the pre-obtained user and relationship vector pair and the item and entity vector pair into a preset multi-head attention model, and calculating the user feature vector and item feature vector corresponding to the user behavior;
[0011] Extracting the low-order feature combination and high-order feature combination corresponding to the user feature vector and item feature vector through a factorization machine and a deep neural network model, and obtaining a recommendation prediction function, and calculating the corresponding recommendation task loss function;
[0012] Extracting the tail entity vector of the preset knowledge graph through a multi-layer perceptron, and obtaining the loss function of the knowledge graph embedding;
[0013] Training the recommendation model through the recommendation task loss function and the knowledge graph embedding loss function, and obtaining the final recommendation task model.
[0014] Optionally, calculating the item vector associated with the user behavior and the entity vector of the preset knowledge graph through a preset cross-compression algorithm, and obtaining the corresponding item and entity vector pair, includes:
[0015] Calculating the feature interaction matrix of the item vector associated with the user behavior and the entity vector of the preset knowledge graph through a cross-feature algorithm;
[0016] Projecting the feature interaction matrix into the next-layer feature space for interaction matrix compression processing, and obtaining the corresponding item and entity vector pair.
[0017] Optionally, after the step of inputting the pre-obtained user and relationship vector pair and the item and entity vector pair into a preset multi-head attention model and calculating the user feature vector and item feature vector corresponding to the user behavior, it further includes:
[0018] Output the user feature vector and the item feature vector of each layer through a feedforward network for the user feature vector and the item feature vector, and perform normalization processing.
[0019] Optionally, the steps of extracting the low-order feature combination and the high-order feature combination corresponding to the user feature vector and the item feature vector through a factorization machine and a deep neural network model, and obtaining a recommendation prediction function and calculating the corresponding recommendation task loss function include:
[0020] Extract the low-order feature combination corresponding to the user feature vector and the item feature vector through a factorization machine;
[0021] Extract the high-order feature combination corresponding to the user feature vector and the item feature vector through a deep neural network model;
[0022] Perform non-linear transformation processing on the low-order feature combination and the high-order feature combination to obtain a recommendation prediction function and calculate the corresponding recommendation task loss function.
[0023] Optionally, the steps of extracting the tail entity vector of the pre-set knowledge graph through a multi-layer perceptron and obtaining the loss function of the knowledge graph embedding include:
[0024] Extract the head entity vector and the relationship vector of the pre-set knowledge graph;
[0025] Extract the tail entity vector of the pre-set knowledge graph through the multi-layer perceptron;
[0026] Calculate the head entity vector, the relationship vector and the tail entity vector through a similarity function to obtain the loss function of the knowledge graph embedding.
[0027] Optionally, after the steps of extracting the tail entity vector of the pre-set knowledge graph through a multi-layer perceptron and obtaining the loss function of the knowledge graph embedding, it further includes:
[0028] Calculate the regularization loss function of the recommendation model.
[0029] Optionally, training a recommendation model through the recommendation task loss function and the loss function of the knowledge graph embedding to obtain a final recommendation task model includes:
[0030] Train a recommendation model through the recommendation task loss function, the loss function of the knowledge graph embedding and the regularization loss function to obtain a final recommendation task model.
[0031] On the other hand, this embodiment also provides a recommendation device based on a knowledge graph, including:
[0032] A cross-compression module, configured to calculate an item vector associated with user behavior and an entity vector of a preset knowledge graph through a preset cross-compression algorithm, and obtain a corresponding item and entity vector pair;
[0033] A multi-head attention module, configured to input a pre-obtained user and relationship vector pair and the item and entity vector pair into a preset multi-head attention model, and calculate and output a user feature vector and an item feature vector corresponding to user behavior;
[0034] A task loss function module, configured to extract a low-order feature combination and a high-order feature combination corresponding to the user feature vector and the item feature vector through a factorization machine and a deep neural network model, and obtain a recommendation prediction function, and calculate a corresponding recommendation task loss function;
[0035] A loss function module for knowledge graph embedding, configured to extract a tail entity vector of the preset knowledge graph through a multi-layer perceptron, and obtain a loss function for knowledge graph embedding;
[0036] A training module, configured to train a recommendation model through the recommendation task loss function and the loss function for knowledge graph embedding, and obtain a final recommendation task model.
[0037] On the other hand, this embodiment also provides a recommendation device based on a knowledge graph. The device includes at least one processor; and,
[0038] A memory communicatively connected to the at least one processor; wherein,
[0039] The memory stores instructions executable by the at least one processor. When the instructions are executed by the at least one processor, the at least one processor is enabled to execute the above-mentioned recommendation method based on a knowledge graph.
[0040] On the other hand, this embodiment also provides a non-volatile computer-readable storage medium. The non-volatile computer-readable storage medium stores computer-executable instructions. When the computer-executable instructions are executed by one or more processors, the one or more processors can be enabled to execute the above-mentioned recommendation method based on a knowledge graph.
[0041] Advantageous effects: The present invention discloses a recommendation method, device, equipment and medium based on a knowledge graph. Compared with the prior art, the present invention calculates the item vector associated with user behavior through a preset cross-compression algorithm and the entity vector of the preset knowledge graph, obtains the corresponding item and entity vector pair, and then inputs the pre-obtained user and relationship vector pair and the item and entity vector pair into the preset multi-head attention model to calculate and output the user feature vector and item feature vector corresponding to the user behavior. Then, a factorization machine and a deep neural network model are used to extract the low-order feature combination and high-order feature combination corresponding to the user feature vector and the item feature vector, and a recommendation prediction function is obtained, and the corresponding recommendation task loss function is calculated. In addition, the tail entity vector of the preset knowledge graph is extracted through a multi-layer perceptron to obtain the loss function of the knowledge graph embedding. Finally, the recommendation model is trained through the recommendation task loss function and the knowledge graph embedding loss function to obtain the final recommendation task model, solving the technical problem that existing recommendation methods based on knowledge graphs mostly ignore the relative importance between the recommendation task and the knowledge graph task and cannot capture users' preferences more precisely, resulting in low accuracy of the recommendation algorithm.
[0042] In addition, by using a factorization machine and a deep neural network model to extract the low-order feature combination and high-order feature combination corresponding to the user feature vector and the item feature vector, the technical problem that existing technologies often focus on the learning of explicit feature combinations, while those implicit feature combinations that cannot be captured may contain potentially useful information, and the loss of this information may limit the model's ability to mine deep domain features, thus affecting the overall performance of the recommendation system is solved. Brief Description of the Drawings
[0043] The present invention will be further described below in conjunction with the drawings and embodiments. In the drawings:
[0044] Figure 1 It is a flowchart of a recommendation method based on a knowledge graph provided by an embodiment of the present invention;
[0045] Figure 2 It is a schematic diagram of the functional modules of an automatic test data generation device provided by an embodiment of the present invention;
[0046] Figure 3 It is a schematic diagram of the hardware structure of an automatic test data generation device provided by an embodiment of the present invention;
[0047] Figure 4 It is an overall framework diagram of a recommendation method based on a knowledge graph provided by an embodiment of the present invention. Detailed Embodiments
[0048] To make the objectives, technical solutions and effects of the present invention clearer and more explicit, the present invention will be further described in detail below. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention. The embodiments of the present invention will be introduced below with reference to the accompanying drawings.
[0049] To solve the above-mentioned problems, the present invention proposes a recommendation method based on a knowledge graph. Please refer to Figure 1 , Figure 1 which is a flowchart of an embodiment of the recommendation method based on a knowledge graph provided by the present invention.
[0050] The recommendation method based on a knowledge graph provided in this embodiment is applied to mobile devices, fixed terminal devices, etc. based on artificial intelligence. The operating systems thereof may include handheld device operating systems (iPhone operating system, iOS system), Android system or other operating systems, including but not limited to smartphones, tablets, portable computers, desktop servers, and so on. As Figure 1 shown, the method specifically includes the following steps:
[0051] S101. Calculate the item vector associated with the user behavior and the entity vector of the preset knowledge graph through a preset cross-compression algorithm, and obtain the corresponding item and entity vector pair;
[0052] In this embodiment, it can be applied in multiple fields such as computer vision, natural language processing, medical artificial intelligence, etc. Set a set of user sets U = {u1,..., u m}, and the item set is V = {v1,..., v n}. The user-item interaction matrix is defined according to the implicit feedback of the user, where y uv =1 indicates that the user has participated in a temporary operation, such as clicking, watching, browsing, or purchasing behavior; otherwise y uv =0.
[0053] Given the knowledge graph where represents the knowledge graph, E represents the entity set in the knowledge graph, R represents the relationship set, and its triple form is represented as where h represents the head entity in the triple, t represents the tail entity in the triple, and r represents the relationship between entities.
[0054] It can be understood that by effectively capturing the feature interactions between the recommendation task and the knowledge graph task, and focusing on the parts important for the final recommendation task.
[0055] First, it is necessary to calculate the item vector associated with the user behavior and the entity vector of the pre - set knowledge graph through the pre - set cross - compression algorithm, and obtain the corresponding item - entity vector pairs.
[0056] Specifically, it includes:
[0057] Calculate the feature interaction matrix of the item vector associated with the user behavior and the entity vector of the pre - set knowledge graph through the cross - feature algorithm;
[0058] Project the feature interaction matrix into the next - layer feature space for interaction matrix compression processing to obtain the corresponding item - entity vector pairs.
[0059] It should be noted that for the recommendation task, the input is the recommended item vector v and the user vector u. Taking the item vector and the entity vector of the knowledge graph as the input of the cross - compression unit, by modeling any possible feature interaction between the item and the entity, the output formula of its cross - feature is:
[0060]
[0061] Where is a d - dimensional real vector, is the cross - feature matrix of the l - th layer.
[0062] The weight vector in the compression operation projects the cross - matrix from the space to the feature space Project the feature cross - matrix to the next layer of the latent representation space, and output the feature vectors of the item and the entity in the next layer:
[0063]
[0064] Where C l is the result of , vectors and are the corresponding learnable weights and biases. In addition, vectors v (l+1) and e (l+1) are the values calculated by the cross - compression function .
[0065] The item v after interacting with the entity e can be obtained in the cross - compression unit.
[0066] For the user u, it is fed into the multi - layer perceptron in the l - th layer:
[0067]
[0068] Among them, S(v) is the set of associated items of an item, f(x) = σ(Wx + b) is a fully connected neural network layer, W is the weight, b is the bias, and σ(·) is a non-linear activation function.
[0069] S102. Input the pre-acquired user and relationship vector pairs and the item and entity vector pairs into a pre-set multi-head attention model, and calculate and output user feature vectors and item feature vectors corresponding to user behaviors.
[0070] After inputting the pre-acquired user and relationship vector pairs and the item and entity vector pairs into a pre-set multi-head attention model and calculating and outputting user feature vectors and item feature vectors corresponding to user behaviors, it can be to output the user feature vectors and item feature vectors of each layer through a feed-forward network for the user feature vectors and the item feature vectors, and perform normalization processing.
[0071] It can be understood that on this basis, an attention mechanism is introduced to adaptively learn the different importance between the recommendation task and the knowledge graph embedding task. Specifically, the user and relationship vector pair (u, r), and the item and entity vector pair (v, e) after passing through the cross-compression unit are jointly fed into the Transformer encoder by the multi-head attention mechanism, and the multi-head attention mechanism allows the model to converge and jointly focus on the input features from different representation subspaces, and its representation formula is:
[0072]
[0073] where x ∈ {u, v, e, r}, and are weight matrices, and Concat(·) is an operation that connects different attention heads.
[0074] Then the output x of the multi-head attention layer mha is fed into the position fully connected feed-forward network of the subsequent layer:
[0075] FFN(x mha ) = f2(ReLU(f1(x mha )))
[0076] where f1(·) and f2(·) are feed-forward functions in the form of Wx + b. In addition, residual connections and layer normalization are added to each sub-layer for fusion and normalization processing, and the output of the sub-layer can be expressed as:
[0077] syb_layer_output = LayerNorm(x + (SubLayer(x)))
[0078] Each layer contains two main sub - layers: a multi - head self - attention layer and a fully - connected feed - forward network.
[0079] For example, the multi - head attention mechanism is used to adaptively learn the different importances between the recommendation task and the knowledge graph embedding task. It allows the model to converge and co - focus on input features from different representation sub - spaces, thereby improving the accuracy and personalization of recommendations.
[0080] 1. Input of multi - head attention:
[0081] o The user - and - relation vector pair (u, r).
[0082] o The item - and - entity vector pair (v, e) after passing through the cross - compression unit.
[0083] o For example, the vector u of user Alice, the vector r of the relation "likes science - fiction movies", the vector v of movie A, and the vector e of director Steven Spielberg.
[0084] Calculation of multi - head attention:
[0085] Calculation formula for each attention head:
[0086]
[0087] where W q , W k , W v are weight matrices corresponding to Query, Key, and Value respectively.
[0088] Output of multi - head attention:
[0089]
[0090] For example, for the vector u of user Alice, calculate the outputs of multiple attention heads, concatenate them, and project them into the target space through the weight matrix W o .
[0091] Then send the output x mha of the multi - head attention layer into the feed - forward network:
[0092] FFN(x mha ) = f2(ReLU(f1(x mha )))
[0093] Residual connection and layer normalization: Output of each sub - layer:
[0094] sub_layer_output = LayerNorm(x+(SubLayer(x)))
[0095] For example, for the vector u of user Alice, after the multi-head attention layer and the feed-forward network layer, through residual connection and layer normalization processing, the final user feature representation is obtained.
[0096] It can be understood that assuming user Alice likes science fiction movies, the system can, through the multi-head attention mechanism: adaptively learn the preference weights of user Alice for different movie features (such as genre, director). Pay attention to other information related to science fiction movies in the knowledge graph, such as the cooperation between directors and the genre classification of movies. Further process these features through the feed-forward network to finally generate the personalized feature representation of user Alice.
[0097] S103. Extract the low-order feature combination and high-order feature combination corresponding to the user feature vector and the item feature vector through the factorization machine and the deep neural network model, obtain the recommendation prediction function, and calculate the corresponding recommendation task loss function;
[0098] Adopt a feature-aware learning module to effectively mine the high-order and low-order information with implicit combined features between users and items.
[0099] Extract the low-order feature combination corresponding to the user feature vector and the item feature vector through the factorization machine;
[0100] Extract the high-order feature combination corresponding to the user feature vector and the item feature vector through the deep neural network model;
[0101] Perform non-linear transformation processing on the low-order feature combination and the high-order feature combination, obtain the recommendation prediction function, and calculate the corresponding recommendation task loss function.
[0102] After obtaining the features of users and items, use the prediction function to predict the possibility of their interaction. The prediction function is used to form the loss function of the recommendation task, and its expression is as follows:
[0103]
[0104] Here is the factorization machine (FM) part. Use the factorization interaction layer to extract the one-hot encoded embedded user vector u and item vector v for low-order feature combination. <w,m> is the first-order feature, m is a real-valued vector that contains all the feature vectors of users and items, and w is a learnable parameter. is the latent factor vector corresponding to the i-th feature m that must be learned. p is the length of the vector and represents the dimension of the factorization, which also reflects a measure of the complexity of the FM model. The right part can obtain the second-order feature combinations of users and items.
[0105] y (0) = Concat(u, v)
[0106] y (l+1) = σ(w l ·y l + b l )
[0107] y DNN = y H = σ(W H ·y (H-1) + b H )
[0108] where y (0) represents the input of the deep neural network (DNN). Then, it will be fed into the DNN with l layers. l is the depth of this layer, H is the number of hidden layers, and y H is the output representation and bias of the H-th layer of the fully connected feedforward neural network.
[0109] By accumulating the outputs of the above FM and DNN parts, interacting and fusing low-order and high-order features, and then performing a sigmoid non-linear transformation, the predicted probability output is obtained:
[0110]
[0111] Factorization Machine (FM) part
[0112] First-order features:
[0113] <w, m> represents the first-order feature combination of users and movies, where w is a learnable parameter and m is a real-valued vector containing all the features of users and movies.
[0114] For example, features such as the age, gender, and viewing history of user Alice, and the genre, director, and actors of movie A.
[0115] Second-order features:
[0116] represents the second-order feature combination of users and movies, where a i and a j are the latent factor vectors corresponding to the features m i and m j .
[0117] For example, the interaction between user Alice's preference for science fiction movies and the science fiction genre feature of movie A.
[0118] Deep Neural Network (DNN) part
[0119] Input: y (l+1) = σ(W l ·y l + b l ), representing the output of the l-th layer of the DNN, where W l and b l are learnable weights and biases, and σ is a non-linear activation function.
[0120] For example, through multiple layers of non-linear transformations, the DNN can learn the complex interaction features between user Alice and movie A.
[0121] Output: y DNN = y H = σ(W H ·y (H-1) + b H ).
[0122] Calculating the loss function for the recommendation task Use the cross-entropy loss function to calculate the loss of the recommendation task, where y is the actual label (0 or 1), is the probability predicted by the model.
[0123] Suppose a movie recommendation platform is being built, with the goal of recommending movies that users may like based on their viewing history and movie attributes (such as genre, director, actors, etc.). At the same time, we hope to introduce movie-related knowledge through the knowledge graph, such as the cooperation relationship between directors and actors, movie genre classification, etc., so as to improve the accuracy and interpretability of the recommendation.
[0124] Loss of the recommendation task: Use the cross-entropy loss function to calculate the difference between the probability of a user clicking on a movie predicted by the model and the actual click behavior. For example, if user Alice watched movie A, then the actual label y is 1, and the probability predicted by the model should be close to 1.
[0125] S104. Extract the tail entity vector of the pre-set knowledge graph through a multi-layer perceptron to obtain the loss function of the knowledge graph embedding;
[0126] Extract the head entity vector and relationship vector of the pre-set knowledge graph;
[0127] Extract the tail entity vector of the pre-set knowledge graph through the multi-layer perceptron;
[0128] Calculate the head entity vector, relationship vector, and the tail entity vector through a similarity function to obtain the loss function of the knowledge graph embedding.
[0129] For the knowledge graph embedding task, the inputs are the head entity vector h and the relation vector r.
[0130] For the knowledge graph For a given triple (h, r, t) in it, the features of the original head entity h and relation r that are relevant to the recommendation task and carry key information are obtained by the mutual information capture module, and then their latent features are concatenated and passed through a multi-layer neural network to obtain the predicted value of the vector corresponding to the tail entity
[0131]
[0132] where S(h) is the set of associated items of entity h.
[0133] Extract the relation features through an l-layer multi-layer perceptron:
[0134] r l = f l (r)
[0135]
[0136] where a k-layer multi-layer perceptron is used to predict the tail entity t.
[0137] To make the obtained predicted tail entity vector similar to the true tail entity vector t, calculate the similarity function f KG to obtain the score of the final triple (h, r, t). The function f KG can be the inner product of t and and then take the sigmoid:
[0138]
[0139] Knowledge graph embedding loss: Evaluate the score difference between positive and negative triples:
[0140]
[0141] where the negative triples are generated by replacing the head entity or the tail entity, λ1 is the weight of the loss function, which is a hyperparameter, is all the positive triples in the knowledge graph, S(h, r, t) is the score of the triple (h, r, t), usually calculated from the similarity between the tail entity vector predicted by the model and the true tail entity vector, (h', r, t') is the negative triple, generated by replacing the head entity or the tail entity in the positive triple.
[0142] The role of the knowledge graph embedding loss is to enable the model to better learn the structure and relationships in the knowledge graph by minimizing the score difference between positive and negative triples. This helps improve the model's representation ability of entities and relationships in the knowledge graph, thereby enhancing the performance of related tasks (such as entity linking, relationship prediction, etc.).
[0143] It should be noted that after the step of extracting the tail entity vector of the pre-set knowledge graph through a multi-layer perceptron and obtaining the loss function of the knowledge graph embedding, the following steps are further included:
[0144] Calculate the regularization loss function of the recommendation model.
[0145] Among them, Θ ∈ {W, b} are hyperparameters, which are all learnable parameters of the model, including weights and biases, and λ2 is the regularization coefficient, which is a hyperparameter used to control the strength of the regularization term.
[0146] The role of the regularization loss is to prevent overfitting by penalizing the complexity of the model. During the model training process, the regularization term will make the model's parameters tend to smaller values, thereby reducing the risk of overfitting of the model. The selection of the regularization coefficient λ2 has an important impact on the generalization ability of the model, and usually needs to be determined by methods such as cross-validation.
[0147] S105. Train the recommendation model through the recommendation task loss function and the loss function of the knowledge graph embedding to obtain the final recommendation task model.
[0148] It should be noted that the recommendation model is trained through the recommendation task loss function, the loss function of the knowledge graph embedding, and the regularization loss function to obtain the final recommendation task model.
[0149] The loss function of the entire function is as follows:
[0150]
[0151] The first part uses the cross-entropy loss function to calculate the loss of the recommendation task. The second part evaluates the score difference between positive and negative triples. The third part comes from regularization and is used to prevent overfitting.
[0152] The recommendation method based on a knowledge graph provided in this embodiment calculates the item vectors associated with user behavior through a preset cross-compression algorithm and the entity vectors of the preset knowledge graph, obtains the corresponding item and entity vector pairs, and then inputs the pre-obtained user and relationship vector pairs and the item and entity vector pairs into the preset multi-head attention model to calculate and output the user feature vector and item feature vector corresponding to the user behavior. Then, a factorization machine and a deep neural network model are used to extract the low-order feature combinations and high-order feature combinations corresponding to the user feature vector and the item feature vector, and a recommendation prediction function is obtained. The corresponding recommendation task loss function is calculated, and the tail entity vector of the preset knowledge graph is extracted through a multi-layer perceptron to obtain the loss function of the knowledge graph embedding. Finally, the recommendation model is trained through the recommendation task loss function and the loss function of the knowledge graph embedding to obtain the final recommendation task model, solving the technical problem that existing recommendation methods based on knowledge graphs mostly ignore the relative importance between the recommendation task and the knowledge graph task and cannot capture users' preferences more precisely, resulting in low accuracy of the recommendation algorithm.
[0153] In addition, a factorization machine and a deep neural network model are used to extract the low-order feature combinations and high-order feature combinations corresponding to the user feature vector and the item feature vector, solving the technical problem that existing technologies often focus on the learning of explicit feature combinations, while those implicit feature combinations that cannot be captured may contain potentially useful information, and losing this information may limit the model's ability to mine deep domain features, thus affecting the overall performance of the recommendation system.
[0154] Such as Figure 4 , the performance degradation during the transmission process from the low layer to the high layer between items and entities is alleviated through the mutual information capture module. In addition, the feature-aware learning module captures low-order and high-order feature information through the implicit combined features between users and items, thereby improving the recommendation performance. Experimental comparisons with other state-of-the-art methods show that this invention has better prediction ability than other methods, and the newly designed module has a positive impact on the model performance.
[0155] For the proposed mutual information capture module, it can be described from two perspectives: From the perspective of the recommendation task, the inputs are user and item vectors. The user will extract its latent features through a multi-layer perceptron neural network, and the item is input into the cross-compression unit. From another perspective, it will interact with the knowledge graph embedding task; From the perspective of the knowledge graph embedding task, the inputs are head entity vector and relation vector. The relation will also extract its latent features through a multi-layer perceptron, and the head entity is input into the cross-compression unit together with the item in the recommendation task. The user vector, item vector, head entity vector, and relation vector are all obtained after information purification. To make them pay more attention to the parts that are more important for the recommendation task, the multi-head attention mechanism is used to learn the weight distribution of the vectors after mapping and feature interaction. This is a common practice in the attention mechanism because it can adaptively learn the different importance between the recommendation task and the knowledge embedding task.
[0156] Regarding the proposed feature-aware learning module, it is further analyzed from two key perspectives. In the knowledge graph embedding task, the mutual information capture module combines the processed head entity vector and relation vector, then uses a multi-layer perceptron for link prediction, and performs an inner product operation on the prediction result and the actual feature vector to obtain a scoring function for training the knowledge graph embedding task; For the final recommendation goal, it concatenates the user and item vectors after the mutual information capture module, and then inputs them into the deep factorization machine in the feature-aware learning module to capture the low-order and high-order implicit feature interactions between the user and the item. Finally, a scoring function is obtained through the final recommendation prediction result and the true recommendation result. This scoring function will be jointly trained with the knowledge graph embedding task to achieve knowledge enhancement.
[0157] The present invention uses three publicly available datasets to experiment on the proposed invention:
[0158] MovieLens-1M dataset: It contains 1,000,209 anonymous ratings (rating range from 1 to 5) of approximately 3,900 movies by 6,040 users who joined MovieLens.
[0159] Book-Crossing: Book recommendation data for recommending books based on user preferences, containing 278,858 users (anonymous, but with demographic information), providing 1,149,780 ratings (ratings ranging from 1 to 10) for approximately 271,379 books.
[0160] Last.FM: A user listening sequence dataset, containing play information of 1,892 users for 17,632 artists.
[0161] The present invention divides each data set into three parts: a training set, an evaluation set, and a test set in a ratio of 6:2:2. For click-through rate (CTR) prediction, the area under the ROC curve (AUC) and accuracy (ACC) will be used to test the user-item pair matching rate, and the specific results are shown in Table 1.
[0162] Table 1 Experimental Results of CTR Click-Through Rate Prediction
[0163]
[0164] The above is a detailed description of the specific implementation manner of the present invention in combination with the accompanying drawings. This is only a preferred solution of the present invention, but the present invention is not limited to the above implementation manner. Various changes can be made without departing from the gist of the present invention within the knowledge scope of ordinary technical personnel in the relevant technical field.
[0165] Another embodiment of the present invention provides a recommendation device based on a knowledge graph, as Figure 2 shown. The device includes:
[0166] A cross-compression module 21, configured to calculate an item vector associated with user behavior and an entity vector of a preset knowledge graph through a preset cross-compression algorithm, and obtain a corresponding item and entity vector pair;
[0167] A multi-head attention module 22, configured to input a pre-obtained user and relationship vector pair and the item and entity vector pair into a preset multi-head attention model, and calculate and output a user feature vector and an item feature vector corresponding to user behavior;
[0168] A task loss function module 23, configured to extract a low-order feature combination and a high-order feature combination corresponding to the user feature vector and the item feature vector through a factorization machine and a deep neural network model, and obtain a recommendation prediction function, and calculate a corresponding recommendation task loss function;
[0169] A loss function module 24 for knowledge graph embedding, configured to extract a tail entity vector of the preset knowledge graph through a multi-layer perceptron, and obtain a loss function for knowledge graph embedding;
[0170] A training module 25, configured to train a recommendation model through the recommendation task loss function and the loss function for knowledge graph embedding, and obtain a final recommendation task model.
[0171] The recommendation device based on the knowledge graph provided in this embodiment calculates the item vector associated with the user behavior and the entity vector of the preset knowledge graph through a preset cross-compression algorithm, obtains the corresponding item and entity vector pair, and then inputs the pre-obtained user and relationship vector pair and the item and entity vector pair into the preset multi-head attention model to calculate and output the user feature vector and item feature vector corresponding to the user behavior. Then, a factorization machine and a deep neural network model are used to extract the low-order feature combination and high-order feature combination corresponding to the user feature vector and the item feature vector, and a recommendation prediction function is obtained. The corresponding recommendation task loss function is calculated, and the tail entity vector of the preset knowledge graph is extracted through a multi-layer perceptron to obtain the loss function of the knowledge graph embedding. Finally, the recommendation model is trained through the recommendation task loss function and the loss function of the knowledge graph embedding to obtain the final recommendation task model, which solves the technical problem that existing recommendation methods based on knowledge graphs mostly ignore the relative importance between the recommendation task and the knowledge graph task and cannot capture the user's preferences more precisely, resulting in low accuracy of the recommendation algorithm.
[0172] In addition, a factorization machine and a deep neural network model are used to extract the low-order feature combination and high-order feature combination corresponding to the user feature vector and the item feature vector, which solves the technical problem that existing technologies often focus on the learning of explicit feature combinations, while those implicit feature combinations that cannot be captured may contain potentially useful information, and the loss of this information may limit the model's ability to mine deep domain features, thus affecting the overall performance of the recommendation system.
[0173] Another embodiment of the present invention provides a recommendation device based on a knowledge graph, as Figure 3 shown. The device 10 includes:
[0174] One or more processors 110 and a memory 120. Figure 3 Taking one processor 110 as an example for introduction, the processor 110 and the memory 120 can be connected through a bus or other means. Figure 3 Taking the connection through the bus as an example.
[0175] The processor 110 is used to complete various control logics of the device 10, and it can be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), a single-chip microcomputer, an ARM (Acorn RISC Machine), or other programmable logic devices, discrete gate or transistor logic, discrete hardware components, or any combination of these components. Additionally, the processor 110 can also be any conventional processor, microprocessor, or state machine. The processor 110 can also be implemented as a combination of computing devices, for example, a combination of a DSP and a microprocessor, multiple microprocessors, one or more microprocessors combined with a DSP and / or any other such configuration.
[0176] The memory 120, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules, such as the program instructions corresponding to the knowledge-graph-based recommendation method in the embodiments of the present invention. The processor 110 executes various functional applications and data processing of the device 10 by running the non-volatile software programs, instructions, and units stored in the memory 120, that is, implements the knowledge-graph-based recommendation method in the above method embodiments.
[0177] The memory 120 can include a program storage area and a data storage area. Among them, the program storage area can store an operating system and application programs required for at least one function; the data storage area can store data created according to the use of the device 10, etc. In addition, the memory 120 can include high-speed random-access memory and can also include non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, or other non-volatile solid-state storage devices. In some embodiments, the memory 120 optionally includes a memory remotely set relative to the processor 110, and these remote memories can be connected to the device 10 through a network. Examples of the above networks include but are not limited to the Internet, an enterprise intranet, a local area network, a mobile communication network, and combinations thereof.
[0178] One or more units are stored in the memory 120 and, when executed by one or more processors 110, implement the following steps:
[0179] Calculate the item vector associated with the user behavior and the entity vector of the preset knowledge graph through a preset cross-compression algorithm to obtain the corresponding item and entity vector pair;
[0180] Input the pre-obtained user and relationship vector pair and the item and entity vector pair into a preset multi-head attention model to calculate and output the user feature vector and item feature vector corresponding to the user behavior;
[0181] Extract low-order feature combinations and high-order feature combinations corresponding to the user feature vector and the item feature vector through a factorization machine and a deep neural network model, obtain a recommendation prediction function, and calculate a corresponding recommendation task loss function;
[0182] Extract the tail entity vector of the preset knowledge graph through a multi-layer perceptron, and obtain a loss function for knowledge graph embedding;
[0183] Train a recommendation model through the recommendation task loss function and the knowledge graph embedding loss function to obtain a final recommendation task model.
[0184] An embodiment of the present invention provides a non-volatile computer-readable storage medium. The computer-readable storage medium stores computer-executable instructions. When the computer-executable instructions are executed by one or more processors, the steps of S101 to S105 described above are implemented.
[0185] By way of example, non-volatile storage media can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) as an external cache memory. By way of illustration and not limitation, RAM can be obtained in many forms such as synchronous RAM (SRAM), dynamic RAM, (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), Synchlink DRAM (SLDRAM), and direct Rambus (Rambus) RAM (DRRAM). The memory components or memories of the operating environment disclosed herein are intended to include one or more of these and / or any other suitable types of memories.
[0186] Of course, those of ordinary skill in the art can understand that all or part of the processes of implementing the above method embodiments can be completed by instructing relevant hardware (such as a processor, a controller, etc.) through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the above method embodiments. The storage medium can be a memory, a magnetic disk, a floppy disk, a flash memory, an optical memory, etc.
[0187] Compared with the prior art, the present invention calculates the item vector associated with the user behavior and the entity vector of the pre-set knowledge graph through a pre-set cross-compression algorithm, obtains the corresponding item and entity vector pairs, and then inputs the pre-obtained user and relationship vector pairs and the item and entity vector pairs into the pre-set multi-head attention model to calculate and output the user feature vector and the item feature vector corresponding to the user behavior. Then, a factorization machine and a deep neural network model are used to extract the low-order feature combination and the high-order feature combination corresponding to the user feature vector and the item feature vector, and a recommendation prediction function is obtained, and the corresponding recommendation task loss function is calculated. In addition, the tail entity vector of the pre-set knowledge graph is extracted through a multi-layer perceptron, and the loss function of the knowledge graph embedding is obtained. Finally, the recommendation model is trained through the recommendation task loss function and the knowledge graph embedding loss function to obtain the final recommendation task model, solving the technical problem that existing recommendation methods based on knowledge graphs mostly ignore the relative importance between the recommendation task and the knowledge graph task, and cannot capture the user's preferences more precisely, resulting in low accuracy of the recommendation algorithm.
[0188] In addition, by using a factorization machine and a deep neural network model to extract the low-order feature combination and the high-order feature combination corresponding to the user feature vector and the item feature vector, the technical problem that existing technologies often focus on the learning of explicit feature combinations, while those implicit feature combinations that cannot be captured may contain potentially useful information, and the loss of this information may limit the model's ability to mine deep domain features, thus affecting the overall performance of the recommendation system, is solved.
Claims
1. A recommendation method based on a knowledge graph, characterized in that It includes: Calculating the item vectors associated with user behavior and the entity vectors of a pre-set knowledge graph through a pre-set cross-compression algorithm, and obtaining the corresponding item and entity vector pairs; Inputting the pre-obtained user and relationship vector pairs and the item and entity vector pairs into a pre-set multi-head attention model, and calculating and outputting the user feature vector and item feature vector corresponding to user behavior; Extracting the low-order feature combinations and high-order feature combinations corresponding to the user feature vector and the item feature vector through a factorization machine and a deep neural network model, and obtaining a recommendation prediction function, and calculating the corresponding recommendation task loss function; Extracting the tail entity vector of the pre-set knowledge graph through a multi-layer perceptron, and obtaining the loss function of knowledge graph embedding; Training a recommendation model through the recommendation task loss function and the knowledge graph embedding loss function, and obtaining a final recommendation task model.
2. The recommendation method based on a knowledge graph according to claim 1, wherein Calculating the item vectors associated with user behavior and the entity vectors of a pre-set knowledge graph through a pre-set cross-compression algorithm, and obtaining the corresponding item and entity vector pairs, including: Calculating the feature interaction matrix of the item vectors associated with user behavior and the entity vectors of the pre-set knowledge graph through a cross-feature algorithm; Projecting the feature interaction matrix into the next-layer feature space for interaction matrix compression processing, and obtaining the corresponding item and entity vector pairs.
3. The recommendation method based on a knowledge graph according to claim 1, wherein After the step of inputting the pre-obtained user and relationship vector pairs and the item and entity vector pairs into a pre-set multi-head attention model, and calculating and outputting the user feature vector and item feature vector corresponding to user behavior, it further includes: Outputting the user feature vector and the item feature vector of each layer through a feed-forward network for the user feature vector and the item feature vector, and performing normalization processing.
4. The recommendation method based on a knowledge graph according to claim 3, wherein The step of extracting the low-order feature combinations and high-order feature combinations corresponding to the user feature vector and the item feature vector through a factorization machine and a deep neural network model, and obtaining a recommendation prediction function, and calculating the corresponding recommendation task loss function, includes: Extracting the low-order feature combinations corresponding to the user feature vector and the item feature vector through a factorization machine; Extracting the high-order feature combinations corresponding to the user feature vector and the item feature vector through a deep neural network model; Performing non-linear transformation processing on the low-order feature combinations and the high-order feature combinations, obtaining a recommendation prediction function, and calculating the corresponding recommendation task loss function.
5. The recommendation method based on a knowledge graph according to claim 1, wherein The step of extracting the tail entity vector of the pre-set knowledge graph through a multi-layer perceptron, and obtaining the loss function of knowledge graph embedding, includes: Extracting the head entity vector and relationship vector of the pre-set knowledge graph; Extracting the tail entity vector of the pre-set knowledge graph through the multi-layer perceptron; Calculating the head entity vector, relationship vector and the tail entity vector through a similarity function, and obtaining the loss function of knowledge graph embedding.
6. The recommendation method based on a knowledge graph according to claim 1, wherein After the step of extracting the tail entity vector of the pre-set knowledge graph through a multi-layer perceptron, and obtaining the loss function of knowledge graph embedding, it further includes: Calculating the regularization loss function of the recommendation model.
7. The recommendation method based on a knowledge graph according to claim 6, wherein Training a recommendation model through the recommendation task loss function and the loss function of the knowledge graph embedding to obtain a final recommendation task model, including: Training a recommendation model through the recommendation task loss function, the loss function of the knowledge graph embedding, and the regularization loss function to obtain a final recommendation task model.
8. A recommendation device based on a knowledge graph, characterized in that Including: A cross-compression module for calculating an item vector associated with user behavior and an entity vector of a preset knowledge graph through a preset cross-compression algorithm to obtain a corresponding item and entity vector pair; A multi-head attention module for inputting a pre-obtained user and relationship vector pair and the item and entity vector pair into a preset multi-head attention model to calculate and output a user feature vector and an item feature vector corresponding to user behavior; A task loss function module for extracting low-order feature combinations and high-order feature combinations corresponding to the user feature vector and the item feature vector through a factorization machine and a deep neural network model, obtaining a recommendation prediction function, and calculating a corresponding recommendation task loss function; A loss function module for knowledge graph embedding for extracting the tail entity vector of the preset knowledge graph through a multi-layer perceptron to obtain a loss function for knowledge graph embedding; A training module for training a recommendation model through the recommendation task loss function and the loss function of the knowledge graph embedding to obtain a final recommendation task model.
9. A recommendation device based on a knowledge graph, characterized in that, The device includes at least one processor; and, A memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the knowledge graph-based recommendation method according to any one of claims 1-7.
10. A non-volatile computer-readable storage medium, characterized in that, The non-volatile computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by one or more processors, the one or more processors can execute the knowledge graph-based recommendation method according to any one of claims 1-7.