Personalized recommendation method based on knowledge graph
By using the knowledge graph and node interaction mechanism in personalized recommendation, the recommendation problem in the existing technology is solved in the case of sparse interaction between users and projects, and the personalized recommendation effect with high accuracy and reliability is achieved.
Patent Information
- Application Number
- CN202210151759.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-02-18
- Publication Date
- 2024-12-06
- Estimated Expiration
- 2042-02-18
AI Technical Summary
The existing personalized recommendation methods perform poorly in sparse situations with small number of interactions between users and projects, and cannot effectively model users' attributes and preferences, resulting in poor reliability and practicality of recommendations.
Using a knowledge graph-based method, by obtaining user data information, aggregating user-item interaction graph and item knowledge graph are constructed, embedded vector representation is generated, and message aggregation is used using node interaction and attention mechanisms to obtain the feature representation of users and items, and calculate it. Recommendation probability, realize personalized recommendation.
It improves the reliability and practicality of recommendations, can effectively capture high-order relationships and feature interaction information between users and items, and significantly improves the accuracy of recommendations.
Smart Images

Figure CN114461927B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of computers, and specifically relates to a personalized recommendation method based on knowledge graphs. Background Art
[0002] With the development of economic technology and the advent of the information age, personalized recommendation technology has been widely used in people's production and life, bringing endless convenience to people's production and life. With the development of information technology and the Internet, people have gradually moved from an era of information scarcity to an era of information overload. It is difficult for consumers to find information of interest from a large amount of information (items), and for information producers to make their information stand out and get attention. The task of the recommendation method is to connect users and information (items). At the same time, another problem that the recommendation method needs to solve is to explore user behavior and find users' personalized needs, so as to accurately recommend products to users who need them, and help users find products that they are interested in but difficult to find.
[0003] Today's personalized recommendation methods generally use collaborative filtering to make recommendations. Collaborative filtering methods have good effectiveness and universality, but they cannot model auxiliary information, such as item attributes, user preferences, etc. Therefore, they perform poorly in sparse situations where the number of user and item interactions is small. This makes existing personalized recommendation methods less reliable and less practical. Summary of the invention
[0004] The purpose of the present invention is to provide a personalized recommendation method based on knowledge graph with high reliability, good practicality and high accuracy.
[0005] The personalized recommendation method based on knowledge graph provided by the present invention comprises the following steps:
[0006] S1. Obtain user data information;
[0007] S2. Construct a knowledge graph based on the user data information obtained in step S1;
[0008] S3. Encode the entity nodes of the knowledge graph constructed in step S2 and generate an embedding vector representation for each entity and relationship in the graph;
[0009] S4. Based on the embedding vector representation generated in step S3, message aggregation is performed based on node interaction and attention mechanism to obtain the feature representation of the user and the feature representation of the item;
[0010] S5. Based on the feature representation of the user and the feature representation of the item obtained in step S4, the probability of each item being recommended to the user is calculated, thereby completing personalized recommendations based on the knowledge graph.
[0011] Step S2 constructs a knowledge graph based on the user data information obtained in step S1, specifically by fusing the user-item interaction graph and the item knowledge graph into a collaborative knowledge graph.
[0012] The construction of the knowledge graph according to the user data information obtained in step S1 specifically includes the following steps:
[0013] Extract item knowledge as knowledge graph data; then filter entities with frequencies lower than a set value and retain relations that appear in at least N triples; use 10-core, 20-core, and 30-core settings at the same time to ensure that each item has at least 10 interaction nodes, 20 interaction nodes, and 30 interaction nodes in the knowledge graph; N is a set positive integer;
[0014] For the user-item interaction graph, the explicit feedback is converted into implicit feedback: the item will be marked as 1, indicating that the user has given a positive evaluation to the item; the positive evaluation threshold is 4, and a set of uninteracted items marked as 0 is sampled for each user;
[0015] Use the knowledge graph KGP tool; and use the KGP tool to detect the dataset format: if the dataset format is a CSV format file, continue with the subsequent steps; if the dataset format is a JSON format file, convert the JSON format file to a CSV format file and continue with the subsequent steps;
[0016] Use KGP tool to clean the data to remove duplicate values and null values in the data set;
[0017] The user enters the name of the relationship through the number in the dataset and assigns the head and tail of the triple of the knowledge graph; the KGP tool is used to extract the selected data from the number in the dataset and construct it as a triple named after the relationship;
[0018] After the user completes the triple construction, the KGP tool is used to extract the triples and reconstruct them into a CSV file, while assigning an index value to each entity;
[0019] Finally, the constructed knowledge graph is completed.
[0020] Step S3 encodes the entity nodes of the knowledge graph constructed in step S2, and generates an embedded vector representation for each entity and relationship in the graph. Specifically, the entity nodes of the knowledge graph constructed in step S2 are encoded, and the TransR method is used to generate an embedded vector representation for each entity and relationship in the graph.
[0021] Step S4, based on the embedding vector representation generated in step S3, performs message aggregation based on node interaction and attention mechanism, thereby obtaining the feature representation of the user and the feature representation of the item, which specifically includes the following steps:
[0022] A. For any central node h in the knowledge graph G, let N(h) be the set of neighboring nodes of h;
[0023] B. Perform weighted summation on the node feature vectors in the set N(h), and iteratively aggregate the interaction information between the nodes in the set N(h) into the feature representation of the central node h, thereby obtaining the linear aggregation and feature interaction message aggregation of the central node h;
[0024] C. Integrate the linear aggregation of the central node h and the feature interaction message aggregation to obtain the feature representation of the central node h;
[0025] D. Repeat steps A to C to finally obtain the feature representations of all users and all items.
[0026] The step B of iteratively aggregating the interaction information between the nodes in the set N(h) into the feature representation of the central node h, thereby obtaining the linear aggregation and feature interaction message aggregation of the central node h, specifically includes the following steps:
[0027] B1. Use the following formula to calculate the linear aggregation LA(h) of the central node h:
[0028]
[0029] Where α(h,r,t) is the attention coefficient in the attention mechanism, which is used to represent the message passing weight of the neighbor node t on the relationship r; is the generated embedding vector of entity t. The superscript number 0 indicates that the neighbor information of any order is not aggregated. It is the embedding vector of t itself.
[0030] B2. The characteristic interaction message aggregation BA(h) of the central node h is calculated using the following formula:
[0031]
[0032] Where C is the combination operator in the permutation and combination; d(h) is the set including the set N(h) and the central node h; t1 and t2 are the two selected node combinations; Generate an embedding vector for entity t1; Generate an embedding vector for entity t2.
[0033] In step C, the linear aggregation of the central node h and the feature interaction message aggregation are integrated to obtain the feature representation of the central node h. Specifically, the feature representation of the central node h is calculated using the following formula:
[0034]
[0035] Where LA(h) is the linear aggregation of the central node h; BA(h) is the feature interaction message aggregation of the central node h; a is the set weighting parameter.
[0036] Step S5 calculates the probability of each item being recommended to the user based on the feature representation of the user and the feature representation of the item obtained in step S4, thereby completing personalized recommendation based on the knowledge graph, which specifically includes the following steps:
[0037] (1) Feature representation of user u obtained in step S4 and the feature representation of item i The inner product operation is used to calculate the probability of item i being recommended to user u; is the generated embedding vector of entity u, and the superscript j indicates that the j-order neighbor information is aggregated; is the generated embedding vector of entity i, and the superscript j indicates that the j-order neighbor information is aggregated;
[0038] (2) Repeat step (1) to calculate the probability of all items being recommended to user u, and sort the obtained probability values, select the k items with the highest ranking and recommend them to user u, thereby completing personalized recommendation based on the knowledge graph.
[0039] The knowledge graph-based personalized recommendation method provided by the present invention integrates the recommendation method based on collaborative filtering and the knowledge graph into a unified recommendation framework, and designs an end-to-end collaborative knowledge graph recommendation model. The model overcomes the disadvantage of the independence of user-item interaction records and can obtain collaborative information of users based on project attributes. Moreover, the method of the present invention is based on the graph attention network, designs a feature interaction aggregation method, and combines the original neighbor node aggregation method to recursively aggregate the feature interaction information and linear weighted information of neighbor nodes. This method of explicitly encoding the node interaction relationship and high-order relationship in the graph enables the model to capture the rich semantics and high-order connectivity based on feature interaction between nodes in the collaborative knowledge graph. Therefore, the method of the present invention has high reliability, good practicality and high accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Figure 1 The figure is a schematic diagram of the method flow of the present invention.
[0041] Figure 2The figure is a schematic diagram of information collection and feature interactive collection of the method of the present invention. DETAILED DESCRIPTION
[0042] like Figure 1 The method flow diagram of the method of the present invention is shown as follows: The personalized recommendation method based on knowledge graph provided by the present invention comprises the following steps:
[0043] S1. Obtain user data information;
[0044] S2. Construct a knowledge graph based on the user data information obtained in step S1; specifically, merge the user-item interaction graph and the item knowledge graph into a collaborative knowledge graph; specifically, the following steps are included:
[0045] In addition to extracting the interaction between items, the method of the present invention also extracts item knowledge (such as the subject matter, director, and starring in the movie data set) as knowledge graph data; then filters entities with a frequency lower than a set value, and retains relations that appear in at least N triples; uses 10-core, 20-core, and 30-core settings at the same time, thereby ensuring that each item has at least 10 interaction nodes, 20 interaction nodes, and 30 interaction nodes in the knowledge graph; N is a set positive integer;
[0046] In the rating dataset, it is a bipartite graph of user-item interaction; the rating star ranges from 0 to 5, where 5 is the best and 0 is the worst; from the rating star, we can directly understand the degree of user's like or dislike of the item; however, the actual data behavior is implicit feedback, which is more complex and important; therefore, for the user-item interaction graph, the explicit feedback is converted into implicit feedback: the item will be marked as 1, indicating that the user has given a positive rating to the item; the positive rating threshold is 4, and a set marked as 0 that has not been interacted with is sampled for each user;
[0047] Use the knowledge graph KGP tool; and use the KGP tool to detect the dataset format: if the dataset format is a CSV format file, continue with the subsequent steps; if the dataset format is a JSON format file, convert the JSON format file to a CSV format file and continue with the subsequent steps;
[0048] Use KGP tool to clean the data to remove duplicate values and null values in the data set;
[0049] The user enters the name of the relationship through the number in the dataset and assigns the head and tail of the triple of the knowledge graph; the KGP tool is used to extract the selected data from the number in the dataset and construct it as a triple named after the relationship;
[0050] After the user completes the triple construction, the KGP tool is used to extract the triples and reconstruct them into a CSV file, while assigning an index value to each entity;
[0051] Finally, the constructed knowledge graph is completed;
[0052] S3. Encode the entity nodes of the knowledge graph constructed in step S2, and generate an embedded vector representation for each entity and relationship in the graph; specifically, encode the entity nodes of the knowledge graph constructed in step S2, and use the TransR method to generate an embedded vector representation for each entity and relationship in the graph;
[0053] The purpose of this step is to encode the structural information of the constructed knowledge graph G, generate an embedding vector in a low-dimensional continuous space for each entity and relationship in the graph, and try to keep the structural information of the graph; the mainstream method of knowledge graph embedding is the translation distance model based on TransE and its variants, which uses a distance-based scoring function; the main translation distance models include TransE, TransH, TransR, etc., and the present invention uses the TransR method to generate embedding vectors; because it is necessary to consider that the same entity should have different semantics in different relationships, by additionally introducing the relational space, when calculating the distance between two entities, consideration is achieved in a specific relational space; the generated representation vector has two main functions: injecting the structural information of the knowledge graph into the model, providing rich auxiliary information for downstream recommendation tasks; in the attention mechanism, the similarity of the head and tail entities of the corresponding triplet in a specific relationship r can be calculated through the embedding vectors of entities and relationships, so that the proportion of information aggregated to the central node h in subsequent steps can be controlled;
[0054] S4. Based on the embedding vector representation generated in step S3, message aggregation is performed based on node interaction and attention mechanism to obtain the feature representation of the user and the feature representation of the item; specifically, the steps include:
[0055] A. For any central node h in the knowledge graph G, let N(h) be the set of neighboring nodes of h;
[0056] B. Perform weighted summation on the node feature vectors in the set N(h), and iteratively aggregate the interaction information between the nodes in the set N(h) into the feature representation of the central node h, thereby obtaining the linear aggregation and feature interaction message aggregation of the central node h; specifically, the steps include:
[0057] B1. Use the following formula to calculate the linear aggregation LA(h) of the central node h:
[0058]
[0059] Where α(h,r,t) is the attention coefficient in the attention mechanism, which is used to represent the message passing weight of the neighbor node t on the relationship r; is the generated embedding vector of entity t. The superscript number 0 indicates that the neighbor information of any order is not aggregated. It is the embedding vector of t itself.
[0060] B2. The characteristic interaction message aggregation BA(h) of the central node h is calculated using the following formula:
[0061]
[0062] Where C is the combination operator in the permutation and combination; d(h) is the set including the set N(h) and the central node h; t1 and t2 are the two selected node combinations; Generate an embedding vector for entity t1; Generate an embedding vector for entity t2;
[0063] C. Integrate the linear aggregation of the central node h and the feature interaction message aggregation to obtain the feature representation of the central node h; specifically, the feature representation of the central node h is calculated using the following formula:
[0064]
[0065] Where LA(h) is the linear aggregation of the central node h; BA(h) is the aggregation of the characteristic interaction messages of the central node h; a is the set weighting parameter;
[0066] D. Repeat steps A to C to finally obtain the feature representations of all users and all items;
[0067] by Figure 2 For example: take i3 as the central node, then N(i3) = {e1, e3, u5}, d(i3) = 3; based on the constructed knowledge graph G, for each target node h, the weighted sum of the node feature vectors in N(h) and the mutual information between the nodes in N(h) are iteratively aggregated into the feature representation of the central node h, so as to capture the high-order connectivity between h and its neighbors and the feature interaction information between neighbors; therefore, this part is the message aggregation between neighbor nodes on the graph, and the aggregation process mainly includes two aspects: linear aggregation of neighbor nodes to the central node; and aggregation of feature interaction information between neighbor nodes to the central node.
[0068] The collection methods are linear collection and bilinear collection. The linear collection part performs linear addition on the three nodes in N(i3), and the aggregated information is recorded as Among them, α1~α3 are coefficients calculated according to the attention mechanism, which are used to control the amount of information propagated from h's neighbor nodes to the central node h on the relationship r;
[0069] The bilinear collection part collects the feature interaction information of the four nodes. The feature interaction here is mathematically defined as the dot product operation of two feature vectors. The aggregated information of this part is recorded as Coefficient This is because there are 6 possible combinations of any two of the four nodes in N(i3); the final step of message aggregation is to integrate the above two types of information and record the aggregated neighbor information as After obtaining the aggregated part of the neighbor node information, and Perform another aggregation operation to obtain the representation of node i3 after aggregating its first-order neighbors. This process is performed simultaneously on all nodes in the knowledge graph G. When the target node i3 aggregates the first-order neighbor information, At the same time, the three neighbor nodes in N(i3) also aggregate the information of their respective first-order neighbors;
[0070] S5. Based on the feature representation of the user and the feature representation of the item obtained in step S4, the probability of each item being recommended to the user is calculated, thereby completing the personalized recommendation based on the knowledge graph; specifically, the steps include:
[0071] (1) The feature representation of user u obtained in step S4 and the feature representation of item i The inner product operation is used to calculate the probability of item i being recommended to user u; is the generated embedding vector of entity u, and the superscript j indicates that the j-order neighbor information is aggregated; is the generated embedding vector of entity i, and the superscript j indicates that the j-order neighbor information is aggregated;
[0072] In specific implementation, the inner product operation is
[0073] (2) Repeat step (1) to calculate the probability of all items being recommended to user u, and sort the obtained probability values, select the k items with the highest ranking and recommend them to user u, thereby completing personalized recommendation based on the knowledge graph.
Claims
1. A personalized recommendation method based on knowledge graph, comprising the following steps: S1. Obtain user data information; S2. Construct a knowledge graph based on the user data information obtained in step S1; S3. Encode the entity nodes of the knowledge graph constructed in step S2 and generate an embedding vector representation for each entity and relationship in the graph; S4. Based on the embedding vector representation generated in step S3, message aggregation is performed based on node interaction and attention mechanism to obtain the feature representation of the user and the feature representation of the item; specifically, the steps include: A. For any central node h in the knowledge graph G, let N(h) be the set of neighboring nodes of h; B. Perform weighted summation on the node feature vectors in the set N(h), and iteratively aggregate the interaction information between the nodes in the set N(h) into the feature representation of the central node h, thereby obtaining the linear aggregation and feature interaction message aggregation of the central node h; specifically, the steps include: B1. Use the following formula to calculate the linear aggregation LA(h) of the central node h: Where α(h,r,t) is the attention coefficient in the attention mechanism, which is used to represent the message passing weight of neighbor node t on relationship r; is the generated embedding vector of entity t. The superscript number 0 indicates that the neighbor information of any order is not aggregated. B2. The characteristic interaction message aggregation BA(h) of the central node h is calculated using the following formula: Where C is the combination operator in the permutation and combination; d(h) is the set including the set N(h) and the central node h; t1 and t2 are the two selected node combinations; Generate an embedding vector for entity t1; Generate an embedding vector for entity t2; C. Integrate the linear aggregation of the central node h and the feature interaction message aggregation to obtain the feature representation of the central node h; Specifically, the characteristic representation of the central node h is calculated using the following formula: Where LA(h) is the linear aggregation of the central node h; BA(h) is the aggregation of the characteristic interaction messages of the central node h; a is the set weighting parameter; D. Repeat steps A to C to finally obtain the feature representations of all users and all items; S5. Based on the feature representation of the user and the feature representation of the item obtained in step S4, the probability of each item being recommended to the user is calculated, thereby completing personalized recommendations based on the knowledge graph.
2. According to the personalized recommendation method based on knowledge graph according to claim 1, Features Step S2 constructs a knowledge graph based on the user data information obtained in step S1, specifically by fusing the user-item interaction graph and the item knowledge graph into a collaborative knowledge graph.
3. According to the personalized recommendation method based on knowledge graph according to claim 2, Features The construction of the knowledge graph according to the user data information obtained in step S1 specifically includes the following steps: Extract item knowledge as knowledge graph data; then filter entities with frequencies lower than a set value and retain relations that appear in at least N triples; use 10-core, 20-core, and 30-core settings at the same time to ensure that each item has at least 10 interaction nodes, 20 interaction nodes, and 30 interaction nodes in the knowledge graph; N is a set positive integer; For the user-item interaction graph, the explicit feedback is converted into implicit feedback: the item will be marked as 1, indicating that the user has given a positive evaluation to the item; the positive evaluation threshold is 4, and a set of uninteracted items marked as 0 is sampled for each user; Use the knowledge graph KGP tool; and use the KGP tool to detect the dataset format: if the dataset format is a CSV format file, continue with the subsequent steps; if the dataset format is a JSON format file, convert the JSON format file to a CSV format file and continue with the subsequent steps; Use KGP tool to clean the data to remove duplicate values and null values in the data set; The user enters the name of the relationship through the number in the dataset and assigns the head and tail of the triple of the knowledge graph; the KGP tool is used to extract the selected data from the number in the dataset and construct it as a triple named after the relationship; After the user completes the triple construction, the KGP tool is used to extract the triples and reconstruct them into a CSV file, while assigning an index value to each entity; Finally, the constructed knowledge graph is completed.
4. According to the personalized recommendation method based on knowledge graph according to claim 2, Features Step S3 encodes the entity nodes of the knowledge graph constructed in step S2, and generates an embedded vector representation for each entity and relationship in the graph. Specifically, the entity nodes of the knowledge graph constructed in step S2 are encoded, and the TransR method is used to generate an embedded vector representation for each entity and relationship in the graph.
5. The personalized recommendation method based on knowledge graph according to claim 1, Features Step S5 calculates the probability of each item being recommended to the user based on the feature representation of the user and the feature representation of the item obtained in step S4, thereby completing personalized recommendation based on the knowledge graph, which specifically includes the following steps: (1) The feature representation of user u obtained in step S4 and the feature representation of item i The inner product operation is used to calculate the probability of item i being recommended to user u; is the generated embedding vector of entity u, and the superscript j indicates that the j-order neighbor information is aggregated; is the generated embedding vector of entity i, and the superscript j indicates that the j-order neighbor information is aggregated; (2) Repeat step (1) to calculate the probability of all items being recommended to user u, and sort the obtained probability values, select the k items with the highest ranking and recommend them to user u, thereby completing personalized recommendation based on the knowledge graph.
