A Personalized Search and Recommendation Method Based on Knowledge Forest and User Preferences
By constructing a knowledge forest and a personalized search recommendation method based on user preferences, and utilizing knowledge pattern trees and graph embedding technology, the problems of entity ambiguity and staticity in knowledge graphs are solved, thereby improving the accuracy and efficiency of information and optimizing the search and reasoning process.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- NORTHEASTERN UNIV CHINA
- Filing Date
- 2024-07-10
- Publication Date
- 2026-05-26
AI Technical Summary
Existing knowledge graphs suffer from insufficient semantic richness, difficulty in capturing complexity, and outdated knowledge due to static nature in entity and relation representations. Furthermore, existing search and recommendation algorithms have high computational complexity, rely on large amounts of labeled data, and have poor generalization ability.
A personalized search and recommendation method based on knowledge forest and user preferences is adopted. By constructing a knowledge pattern tree, extracting entity relationships and using graph embedding techniques, a directed weighted tree structure is designed. The knowledge forest is constructed using user historical information, each entity is assigned a different weight, the information flow path is optimized, and a personalized recommendation list is generated through similarity calculation.
It effectively solves the problem of entity ambiguity, achieves accuracy and consistency of information, optimizes the reasoning and search process, improves accuracy and efficiency, and ensures intuitive and clear hierarchical relationships of information and rapid identification of key information.
Smart Images

Figure CN118820595B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of recommendation knowledge representation technology and search technology, and in particular to a personalized search recommendation method based on knowledge forest and user preferences. Background Technology
[0002] Knowledge graphs are an important branch of artificial intelligence, a structured semantic knowledge base used to describe concepts and their relationships in the physical world in symbolic form. Their basic building blocks are represented by triples of "entity-relationship-entity," as well as key-value pairs of entities and their associated attributes. Entities are interconnected through relationships, forming a network of knowledge structures. Representing knowledge in a graphical structure, knowledge graphs clearly display the relationships between entities, making knowledge more intuitive and easier to understand. They can capture and express a rich variety of relationships between entities, thus providing more detailed and comprehensive knowledge representation capabilities. The semantic descriptions of entities and relationships in knowledge graphs provide more semantic information, enabling computers to better understand and reason about knowledge, and perform complex reasoning and inferences based on the structured knowledge representation of the knowledge graph. Currently, knowledge graphs are widely used in search engines, intelligent assistants, recommendation systems, intelligent question answering, natural language processing, and data analysis, providing powerful knowledge support and semantic understanding capabilities for various application scenarios.
[0003] Knowledge graphs consist of entity triples forming a complete and vast knowledge network. However, these entity triples present significant problems. First, the representation of entities and relations can sometimes be oversimplified, failing to capture complex semantic information. For example, some relations may be ambiguous, and the relation representation in a knowledge graph may not be able to distinguish between different meanings, resulting in insufficient semantic richness. Second, many relations in the real world have complex structures and semantic meanings, but the triple structure of a knowledge graph sometimes struggles to capture this complexity. For example, some relations may be multiple or recursive, and the simple triple structure of a knowledge graph cannot adequately represent this complexity. While theoretically, the natural language semantic information corresponding to the knowledge represented by the triple can be described using entity pairs and relations, in practical applications, due to the vast amount of information and numerous entities with the same name, the simple triple structure "entity-relation-entity" cannot truly and accurately represent a unique piece of knowledge. This ambiguity creates significant search and reasoning difficulties in practical applications, often requiring substantial additional overhead to resolve the problems caused by this ambiguity. Furthermore, since knowledge is constantly changing and evolving, but knowledge graphs are often static representations, they may fail to reflect the changes and evolution of the real world in a timely manner over time, leading to outdated and inaccurate knowledge.
[0004] Existing knowledge graph search and recommendation algorithms include path-based, embedding-based, rule-based, and graph neural network-based methods. All of these algorithms build upon the graph structure, but this approach has several drawbacks. For example, as the graph size increases, path-based methods experience a significant rise in computational complexity and generate numerous irrelevant paths; embedding-based methods have an inherent disadvantage in terms of semantic information; rule-based methods rely on high-quality rule definitions and exhibit poor generalization ability; and graph neural network-based methods require extensive labeled data for complex model training. Summary of the Invention
[0005] To address the shortcomings of the existing technologies, this invention proposes a personalized search and recommendation method based on knowledge forests and user preferences. The aim is to avoid entity ambiguity by providing a knowledge representation method that facilitates reasoning and searching, thereby improving the application of knowledge representation in the field.
[0006] This invention proposes a personalized search and recommendation method based on knowledge forests and user preferences, comprising:
[0007] Step 1: Collect and preprocess the user history information of several users, and build an attribute set for each user according to user needs;
[0008] Step 2: Construct a knowledge schema tree for each user based on their attribute set;
[0009] Step 3: Use the entity relation extraction algorithm to extract entity relations from the preprocessed user history information of each user, and use the extracted entities and knowledge pattern tree to build a knowledge tree, and then use the knowledge trees of all users to build a knowledge forest.
[0010] Step 4: Use graph embedding technology to assign weights to all edges of each knowledge tree in the knowledge forest to obtain the final knowledge forest and save it to the graph database;
[0011] Step 5: Construct a target user knowledge tree based on the target user's needs. Calculate the similarity between the target user knowledge tree and each knowledge tree in the knowledge forest by calling the knowledge forest in the graph database. Then, use the calculated similarity to generate a personalized recommendation list for the target user.
[0012] The user history information mentioned in step 1 includes: user characteristic information, environmental background information, historical interaction information, and user preference information;
[0013] The preprocessing includes: data cleaning, deduplication, and format standardization;
[0014] The method for constructing the attribute set in step 1 is as follows: For any user, according to user needs, determine several attributes for representing user characteristics, several attributes for representing environmental state, several attributes for representing historical interactions, and several attributes for representing user preferences, and take the set of all attributes as the user's attribute set.
[0015] The method for constructing the knowledge pattern tree in step 2 is as follows: For any user, the root node of the knowledge pattern tree is represented as the user entity of that user. Based on the user's historical information, the user's knowledge pattern tree is divided into four subtrees, namely: user feature subtree, environment state subtree, interaction record subtree, and user preference subtree.
[0016] The root node of the user feature subtree is represented as a user feature. Each attribute in the attribute set used to represent the user feature is used as an edge connecting the root node and the child node in the user feature subtree. The attribute value of each attribute is used as the child node of the user feature subtree.
[0017] The root node of the environment state subtree is represented as the environment state. Each attribute in the attribute set used to represent the environment state is used as an edge connecting the root node and the child node in the environment state subtree. The attribute value of each attribute is used as the child node of the environment state subtree.
[0018] The root node of the interaction record subtree is represented as the historical interaction. Each attribute in the attribute set used to represent the historical interaction is used as an edge connecting the root node and the child node in the interaction record subtree. The attribute value of each attribute is used as the child node of the interaction record subtree.
[0019] The root node of the user preference subtree is represented as the user preference. Each attribute in the attribute set used to represent the user preference is used as an edge connecting the root node and the child node in the user preference subtree. The attribute value of each attribute is used as the child node of the user preference subtree.
[0020] The hierarchical relationship between the child nodes in each subtree is determined by the logical relationship between the attributes corresponding to each child node.
[0021] Step 3 further includes:
[0022] Step 3.1: For any user, use the entity relation extraction algorithm to extract entity relations from the preprocessed user history information, and obtain entities from user feature information, environmental background information, historical interaction information and user preference information respectively;
[0023] Step 3.2: Match the entities extracted from the user feature information with the attributes in the attribute set that represent user features, and use the successfully matched entities as the attribute values of the corresponding attributes; match the entities extracted from the environmental background information with the attributes in the attribute set that represent environmental states, and use the successfully matched entities as the attribute values of the corresponding attributes; match the entities extracted from the historical interaction information with the attributes in the attribute set that represent historical interactions, and use the successfully matched entities as the attribute values of the corresponding attributes; match the entities extracted from the user preference information with the attributes in the attribute set that represent user preferences, and use the successfully matched entities as the attribute values of the corresponding attributes.
[0024] Step 3.3: Use the attribute values obtained in Step 3.2 to assign values to the child nodes of the user's knowledge pattern tree, and use the assigned knowledge pattern tree as the user's knowledge tree;
[0025] Step 3.4: Repeat steps 3.1-3.3 until a knowledge tree is built for each user, and the collection of all knowledge trees is called a knowledge forest;
[0026] Step 4 further includes:
[0027] Step 4.1: For any knowledge tree in the knowledge forest, randomly initialize all nodes in the knowledge tree to generate the embedding vector of each node;
[0028] Step 4.2: For any node v in the knowledge tree, take node v as the starting point and use a random walk algorithm to perform a random walk to obtain several adjacent node pairs; each adjacent node pair consists of node v and one of node v's neighboring nodes u.
[0029] Step 4.3: Calculate the loss function value of each adjacent node pair using the loss function of graph embedding technology, and use it as the similarity between node v and neighbor node u in that adjacent node pair;
[0030] Step 4.4: Calculate the gradient of the loss function with respect to the embedding vector of the neighbor node u using the stochastic gradient descent algorithm, and update the embedding vector of the neighbor node u using this gradient to obtain the updated embedding vector of the neighbor node u.
[0031] Step 4.5: Repeat steps 4.3-4.4 until the preset number of iterations is met or the loss function is minimized, then stop the iteration and obtain the updated embedding vectors of all neighboring nodes of node v;
[0032] Step 4.6: Repeat steps 4.2-4.5 until the updated embedding vectors of all nodes in the knowledge tree are obtained;
[0033] Step 4.7: Calculate the cosine similarity between each pair of adjacent nodes in the knowledge tree using the updated embedding vectors of all nodes in the knowledge tree. Use the sigmoid function to map the cosine similarity between each pair of adjacent nodes to the range [0,1], and use the mapped cosine similarity as the weight of the edge connecting the pair of adjacent nodes to obtain the weighted knowledge tree.
[0034] Step 4.8: Repeat steps 4.1-4.7 until all edges of the knowledge trees in the knowledge forest have been weighted. The set of all weighted knowledge trees is then used as the final knowledge forest and saved to the graph database.
[0035] The loss function described in step 4.3 is expressed as follows:
[0036]
[0037] Where L represents the similarity between node v and its neighbor node u; V is the set of all nodes in the knowledge tree; N(u) is the set of all neighbor nodes of node v; v u v is the embedding vector of neighbor node u; v Let be the embedding vector of node v; σ represents the sigmoid function;
[0038] Step 5 further includes:
[0039] Step 5.1: Obtain the target user's historical information based on the target user's needs and construct a target user knowledge tree;
[0040] Step 5.2: Call the knowledge forest in the graph database. For any knowledge tree in the knowledge forest, use a pre-trained language model to vectorize the knowledge tree and the target user's knowledge tree respectively, and extract all paths in the knowledge tree and the target user's knowledge tree respectively and represent them as vectors.
[0041] Step 5.3: Calculate the cosine similarity between the vector representation of each path in the knowledge tree and the vector representation of each path in the target user's knowledge tree as the similarity score between each path in the knowledge tree and each path in the target user's knowledge tree.
[0042] Step 5.4: Aggregate the similarity scores of all paths in the knowledge tree and all paths in the target user's knowledge tree to obtain the overall similarity between the knowledge tree and the target user's knowledge tree;
[0043] Step 5.5: Repeat steps 5.2-5.4 to obtain the overall similarity between all knowledge trees in the called knowledge forest and the target user's knowledge tree;
[0044] Step 5.6: Sort the overall similarity between the target user's knowledge tree and each knowledge tree in descending order, and select the top K knowledge trees in the sorting results as the similar knowledge trees of the target user;
[0045] Step 5.7: Sequentially obtain the attribute values corresponding to all child nodes in the user preference subtree of the similarity knowledge tree of K target users and use them as the personalized recommendation results for the target users, and generate a personalized recommendation list for the target users;
[0046] The method described in step 5.4 for aggregating the similarity scores of all paths in the knowledge tree with all paths in the target user's knowledge tree is as follows:
[0047]
[0048] Where T1 represents any knowledge tree in the knowledge forest; T2 represents the knowledge tree of the target user; Similarity(T1,T2) represents the overall similarity between T1 and T2; P1 and P2 are the path sets in T1 and T2 respectively; p is the path in P1; q is the path in P2; CosineSimilarity(·) is the cosine similarity function; Weight(p) represents the weight of path p; Weight(q) represents the weight of path q.
[0049] The beneficial effects of adopting the above technical solution are as follows:
[0050] Compared to traditional graph structures, the method of this invention constructs a knowledge tree by designing a directed weighted tree structure, thereby building a knowledge forest that can be used for personalized search and recommendation. In designing the directed weighted tree structure, the method of this invention utilizes the principles of basic tree structure and weight allocation to construct a knowledge tree for each extracted entity. For any extracted entity with the same name, since entities with the same name have different weights in different knowledge trees, the ambiguity caused by entity name duplication is eliminated during reasoning and search, ensuring the accuracy and consistency of information, effectively solving the entity ambiguity problem, and achieving precise information organization.
[0051] The tree structure designed by the method of this invention, namely the knowledge pattern tree, can provide an intuitive and clear hierarchical relationship and clear node connections, making the information flow path clearer, thereby optimizing the reasoning and search process and making the reasoning and search process more orderly.
[0052] The node weight allocation mechanism used in this invention highlights the importance of each node in the knowledge tree, helping the search system and users to quickly identify key information, thereby improving the accuracy and efficiency of reasoning and searching in the decision-making process. Attached Figure Description
[0053] Figure 1 This is a flowchart of a personalized search recommendation method based on knowledge forest and user preferences in this embodiment;
[0054] Figure 2 This is a schematic diagram of the knowledge tree constructed in the movie recommendation system of this embodiment. Detailed Implementation
[0055] To facilitate understanding of this application, specific embodiments of the present invention will be described in further detail below with reference to the accompanying drawings and embodiments. The following embodiments are illustrative of the invention but are not intended to limit its scope. Rather, these embodiments are provided to provide a more thorough and complete understanding of the disclosure of this application.
[0056] This embodiment offers a personalized search and recommendation method based on knowledge forests and user preferences, such as... Figure 1 As shown, the method includes the following steps:
[0057] Step 1: Collect and preprocess the user history information of several users, and build an attribute set for each user according to user needs.
[0058] The user history information includes: user characteristic information, environmental background information, historical interaction information, and user preference information.
[0059] In this embodiment, user historical information can be collected from existing databases, text documents, and knowledge graphs, or it can be collected from the Internet using web crawler technology. The collected user characteristic information, environmental background information, historical interaction information, and user preference information are all textual information. Specifically, user characteristic information reflects the user's personalized characteristics; environmental background information helps understand the user's behavior in specific situations by collecting the user's environmental context; historical interaction information analyzes user behavior by collecting the user's historical interaction records with the search and recommendation system; and user preference information learns user preferences by collecting the user's historical choices.
[0060] The preprocessing includes: data cleaning, deduplication, and format standardization.
[0061] In this implementation, the collected user history information is first cleaned. This involves deleting or repairing errors, missing values, or outliers to ensure data accuracy and completeness; and removing special characters, punctuation marks, and HTML tags to eliminate interference. Data mining and text analysis techniques can be used to automatically identify and correct erroneous data during the cleansing process. Next, the cleaned user history information is deduplicated based on specified unique identifiers or key attributes. Duplicate records are removed to retain unique data instances, ensuring data uniqueness. Finally, the deduplicated user history information is converted into a unified format and structure for easier subsequent processing and analysis. The format standardization process involves standardizing date, time, units, and format information to ensure data consistency and comparability. Unstructured or semi-structured data is then converted into structured data.
[0062] The method for constructing the attribute set is as follows: For any user, according to user needs, determine several attributes for representing user characteristics, several attributes for representing environmental state, several attributes for representing historical interactions, and several attributes for representing user preferences, and take the set of all attributes as the user's attribute set.
[0063] In this implementation, since each entity has a series of attributes describing its characteristics, it is necessary to determine the attributes needed for personalized search recommendations based on user needs. Then, attribute values corresponding to the determined attributes are obtained through entity extraction, thereby completing the construction of the knowledge tree. Taking movie search recommendations as an example, for user A, the user need is to create a movie recommendation list based on the user's historical records and preference information. The attributes needed for movie recommendations are defined according to the user needs, specifically including: determining four attributes—gender, age, region, and language—to represent user characteristics; determining two attributes—geographical location and device information—to represent environmental status; determining four attributes—marked movies, favorited movies, rated movies, and search keywords—to represent historical interactions; and determining one attribute—favorite movies—to represent user preferences. The set of all the above attributes is taken as user A's attribute set.
[0064] Step 2: Build a knowledge pattern tree for each user based on the user's attribute set.
[0065] In this implementation, a knowledge pattern tree is used to define the hierarchical relationships between elements in the knowledge tree within a knowledge forest. A knowledge pattern tree consists of multiple subtrees, each modeling a specific aspect of the user's historical information and determining hierarchical subtree nodes based on that information. The knowledge pattern tree meticulously organizes all attributes in the user's attribute set according to a logical hierarchy, thus forming a comprehensive knowledge representation for that user. When constructing a knowledge tree for a user subsequently, these attribute hierarchies will be specified to reflect each user's unique information and preferences.
[0066] The method for constructing the knowledge pattern tree is as follows: For any user, the root node of the knowledge pattern tree is represented as the user entity of that user. Based on the user's historical information, the user's knowledge pattern tree is divided into four subtrees: user feature subtree, environment state subtree, interaction record subtree, and user preference subtree.
[0067] The root node of the user feature subtree is represented as a user feature. Each attribute in the attribute set used to represent the user feature is used as an edge connecting the root node and the child node in the user feature subtree. The attribute value of each attribute is used as the child node of the user feature subtree.
[0068] The root node of the environment state subtree is represented as the environment state. Each attribute in the attribute set used to represent the environment state is used as an edge connecting the root node and the child node in the environment state subtree. The attribute value of each attribute is used as the child node of the environment state subtree.
[0069] The root node of the interaction record subtree is represented as the historical interaction. Each attribute in the attribute set used to represent the historical interaction is used as an edge connecting the root node and the child node in the interaction record subtree. The attribute value of each attribute is used as the child node of the interaction record subtree.
[0070] The root node of the user preference subtree is represented as the user preference. Each attribute in the attribute set used to represent the user preference is used as an edge connecting the root node and the child node in the user preference subtree. The attribute value of each attribute is used as the child node of the user preference subtree.
[0071] The hierarchical relationship between child nodes in each subtree is determined by the logical relationship between the attributes corresponding to each child node.
[0072] In this implementation, a root node can correspond to multiple child nodes with the same attributes, and this one-to-many structure is called relationship overlap. For example... Figure 2As shown, a knowledge schema tree is constructed for user A. The root node of this knowledge schema tree represents the user entity, i.e., "User A". From the root node, subtrees are divided into user feature subtrees, environment state subtrees, interaction record subtrees, and user preference subtrees. The root node of the user feature subtree is "User Feature". Since the logical relationship between the attributes representing user features in the attribute set is parallel, the user feature subtree includes four parallel child nodes, and the edges between these four child nodes and the root node of the user feature subtree are: "Gender", "Age", "Region", and "Language". The root node of the environment state subtree is "Environment State". Since the logical relationship between the attributes representing environment state in the attribute set is parallel, the user feature subtree includes two parallel child nodes, and the edges between these two child nodes and the root node of the environment state subtree are: "Geographic Location" and "Device Information". The root node of the interaction record subtree is "Historical Interactions". Since the logical relationship between the attributes representing historical interactions in the attribute set is "Marked Movies", "Favorites", etc., the user feature subtree includes these attributes. The relationship between movies and search keywords is parallel, and the rating of tagged movies is the next level below the tagged movies. Therefore, the user feature subtree includes two levels of child nodes. The first level includes three types of child nodes in parallel, and the edges between these three child nodes and the root node of the user feature subtree are "search keywords", "tagged movies", and "favorite movies", respectively. Each child node connected to "tagged movies" has a next-level node that serves as the second-level child node of the user feature subtree, and the edge between the next-level node and the child node connected to "tagged movies" is "tagged movie rating". The root node of the user preference subtree is "user preference". Since the attribute used to represent the user preference subtree in the attribute set is "favorite movies", there is only one type of child node in the user preference subtree, and the edge between this child node and the root node of the user preference subtree is "favorite movies".
[0073] Step 3: Use the entity relation extraction algorithm to extract entity relations from the preprocessed user history information of each user, and use the extracted entities and knowledge pattern tree to build a knowledge tree, and then use the knowledge trees of all users to build a knowledge forest.
[0074] Step 3.1: For any user, use the Universal Information Extraction (UIE) algorithm to extract entity relationships from the preprocessed user history information, and obtain entities from user feature information, environmental background information, historical interaction information and user preference information respectively.
[0075] Step 3.2: Match the entities extracted from the user feature information with the attributes in the attribute set that represent user features, and use the successfully matched entities as the attribute values of the corresponding attributes; match the entities extracted from the environmental background information with the attributes in the attribute set that represent environmental states, and use the successfully matched entities as the attribute values of the corresponding attributes; match the entities extracted from the historical interaction information with the attributes in the attribute set that represent historical interactions, and use the successfully matched entities as the attribute values of the corresponding attributes; match the entities extracted from the user preference information with the attributes in the attribute set that represent user preferences, and use the successfully matched entities as the attribute values of the corresponding attributes.
[0076] Step 3.3: Use the attribute values obtained in Step 3.2 to assign values to the child nodes of the user's knowledge pattern tree, and use the assigned knowledge pattern tree as the user's knowledge tree.
[0077] In this embodiment, natural language processing technology is used, specifically the Entity Relation Extraction (UIE) algorithm, to extract entities from each user's historical information. Each extracted entity is then matched against attributes in an attribute set, and the successfully matched entity is used as the attribute value of the matched attribute. Attribute information is added to the knowledge pattern tree by assigning all attribute values to the child nodes of the knowledge pattern tree, thus completing the construction of the knowledge tree. The predefined set of relations required by the algorithm constitutes the set of subtree nodes in the knowledge pattern tree. The process of extracting entities from each user's historical information using the UIE algorithm is implemented using a pre-trained entity extraction model. Specifically, the entity extraction model learns from labeled triplet samples, where the triplet samples are represented as: entity-relation-entity. All relations of the labeled triplet samples are used as a predefined set of relations, and these relations are represented by edges in the knowledge tree.
[0078] like Figure 2As shown, for user A, the entities extracted from the user feature information include: "female", "30", "Beijing" and "Chinese". The above four entities are matched with the attributes used to represent user features in the attribute set, and the successfully matched entities are used as the attribute values of the corresponding attributes: user A's gender is "female", age is "30", region is "Beijing" and language is "Chinese". The successfully matched attribute values are then assigned to the child nodes of user A's user feature subtree. Similarly, matching entities extracted from environmental background information yields the following results: User A's geographical location is "Shanghai," and their device information is "mobile phone." Matching entities extracted from historical interaction information yields the following results: User A's search keywords are "comedy" and "science fiction," and their tagged movies are "Inception" and "Interstellar," with "Inception" having a rating of "9" and "Interstellar" having a rating of "10." Their favorite movies are "Her" and "Forrest Gump." Matching entities extracted from user preference information yields the following results: User A's favorite movies are "Inception" and "Interstellar."
[0079] Step 3.4: Repeat steps 3.1-3.3 until a knowledge tree is built for each user, and the collection of all knowledge trees is called a knowledge forest.
[0080] Step 4: Use graph embedding technology to assign weights to the edges of each knowledge tree in the knowledge forest to obtain the final knowledge forest and save it to the graph database.
[0081] In this embodiment, the DeepWalk graph embedding technique is used to embed nodes in the knowledge tree into a low-dimensional vector space. This involves mapping nodes in the knowledge tree to vector representations, obtaining the node embedding vectors, and thus capturing the structure and relationships between nodes. Specifically, DeepWalk captures local structural information between nodes by simulating random walks and uses this information to learn the vector representations of the nodes. Weighting aims to add appropriate weights to each edge in the knowledge tree, typically based on the importance of the attributes represented by each edge and the tightness of connections between nodes. Machine learning algorithms are then used to learn and capture the most decisive information, thereby strengthening the representation of key information in the knowledge tree.
[0082] Step 4.1: For any knowledge tree in the knowledge forest, randomly initialize all nodes in the knowledge tree to generate the embedding vector of each node.
[0083] Step 4.2: For any node v in the knowledge tree, take node v as the starting point and use a random walk algorithm to perform a random walk to obtain several adjacent node pairs; the adjacent node pairs consist of node v and one of node v's neighboring nodes u.
[0084] Step 4.3: Based on the loss function of graph embedding technology, calculate the loss function value of each adjacent node pair using the embedding vector of the node as the similarity between node v and neighbor node u in that adjacent node pair.
[0085] The loss function is expressed as:
[0086]
[0087] Where L represents the similarity between node v and its neighbor node u, i.e., the loss value; V is the set of all nodes in the knowledge tree; N(u) is the set of all neighbor nodes of node v; v u v is the embedding vector of neighbor node u; v Let be the embedding vector of node v; σ represents the sigmoid function.
[0088] Step 4.4: Calculate the gradient of the loss function with respect to the embedding vector of the neighbor node u using the stochastic gradient descent algorithm, and update the embedding vector of the neighbor node u using this gradient to obtain the updated embedding vector of the neighbor node u.
[0089] The expression for updating the embedding vector of neighbor node u is:
[0090]
[0091] Where v u ′ Represents the updated embedding vector of neighbor node u; η is the learning rate; This represents the gradient of the loss function with respect to the embedding vector of the neighbor node u.
[0092] Step 4.5: Repeat steps 4.3-4.4 until the preset number of iterations is met or the loss function is minimized, then stop the iteration and obtain the updated embedding vectors of all neighboring nodes of node v.
[0093] In this implementation, DeepWalk aims to minimize the loss function, making frequently occurring adjacent node pairs (positive sample pairs) closer in the vector space, while unrelated adjacent node pairs (negative sample pairs) further apart, thus achieving effective node embedding learning. Node embedding vectors can be learned using optimization algorithms such as stochastic gradient descent, updating the embedding vector of each node in each iteration based on the gradient of the loss function.
[0094] Step 4.6: Repeat steps 4.2-4.5 until the updated embedding vectors of all nodes in the knowledge tree are obtained.
[0095] Step 4.7: Calculate the cosine similarity between each pair of adjacent nodes in the knowledge tree using the updated embedding vectors of all nodes in the knowledge tree. Use the sigmoid function to map the cosine similarity between each pair of adjacent nodes to the range [0,1], and use the mapped cosine similarity as the weight of the edge connecting the pair of adjacent nodes to obtain the weighted knowledge tree.
[0096] In this embodiment, for each pair of adjacent nodes, the cosine similarity between the adjacent nodes is calculated using the embedding vectors of the nodes to represent the similarity between the pair of adjacent nodes. Cosine similarity is a commonly used metric that measures the cosine value of the angle between two vectors.
[0097] In this implementation, all weights within a knowledge tree are divided and mapped using the sigmoid function. The similarity values are mapped to the range [0,1], where a higher cosine similarity indicates a higher similarity between nodes, and thus a higher weight is assigned to the edge; conversely, a lower cosine similarity indicates a lower degree of association between nodes, and thus a lower weight is assigned to the edge.
[0098] Step 4.8: Repeat steps 4.1-4.7 until all edges of the knowledge trees in the knowledge forest have been weighted. The set of all weighted knowledge trees is then used as the final knowledge forest and saved to the graph database.
[0099] In this embodiment, the knowledge forest is stored in the Neo4j graph database for visualization.
[0100] Step 5: Construct a target user knowledge tree based on the target user's needs. Calculate the similarity between the target user knowledge tree and each knowledge tree in the knowledge forest by calling the knowledge forest in the graph database, and use the calculated similarity to generate a personalized recommendation list for the target user.
[0101] Step 5.1: Obtain the target user's historical information based on the target user's needs and construct the target user's knowledge tree.
[0102] In this embodiment, the method for constructing the target user knowledge tree is the same as the method for constructing the knowledge tree in steps 1-3.
[0103] Step 5.2: Call the knowledge forest in the graph database. For any knowledge tree in the knowledge forest, use a pre-trained language model to vectorize the knowledge tree and the target user's knowledge tree respectively, and extract all paths in the knowledge tree and the target user's knowledge tree respectively and represent them as vectors.
[0104] Step 5.3: Calculate the cosine similarity between the vector representation of each path in the knowledge tree and the vector representation of each path in the target user's knowledge tree as the similarity score between each path in the knowledge tree and each path in the target user's knowledge tree.
[0105] Step 5.4: Aggregate the similarity scores of all paths in the knowledge tree and all paths in the target user's knowledge tree to obtain the overall similarity between the knowledge tree and the target user's knowledge tree.
[0106] The method for aggregating the similarity scores of all paths in the knowledge tree with those of all paths in the target user's knowledge tree is as follows:
[0107]
[0108] Where T1 represents any knowledge tree in the knowledge forest; T2 represents the knowledge tree of the target user; Similarity(T1,T2) represents the overall similarity between T1 and T2; P1 and P2 are the path sets in T1 and T2 respectively; p is the path in P1; q is the path in P2; CosineSimilarity(·) is the cosine similarity function; Weight(p) represents the weight of path p; Weight(q) represents the weight of path q.
[0109] Step 5.5: Repeat steps 5.2-5.4 to obtain the overall similarity between all knowledge trees in the called knowledge forest and the target user's knowledge tree.
[0110] In this implementation, personalized recommendations can be made by calculating the overall similarity between the user's knowledge tree and other knowledge trees. First, a pre-trained language model is used to vectorize the knowledge tree, extracting all paths and vectorizing them to obtain their vector representations. Based on this vectorization, path weights are obtained by summing the node weights in the knowledge tree to adjust the path's influence. Then, cosine similarity is used to calculate the similarity between path vectors in the user's knowledge tree and path vectors in other knowledge trees. The system aggregates the similarity scores of all paths to obtain the overall similarity between the user's knowledge tree and other knowledge trees.
[0111] Step 5.6: Sort the overall similarity between the target user's knowledge tree and each knowledge tree in descending order, and select the top K knowledge trees in the sorting results as the target user's similar knowledge trees.
[0112] Step 5.7: Sequentially obtain the attribute values corresponding to all child nodes in the user preference subtree of the similarity knowledge tree of K target users and use them as the personalized recommendation results for the target users, and generate a personalized recommendation list for the target users.
[0113] In this implementation, all knowledge trees in the knowledge forest are ranked based on the aggregated similarity scores, with the knowledge tree with the highest similarity placed at the top. This ranking directly impacts the generation of the recommendation list, as higher similarity means their user preference subtrees are more similar to the target user's user preference subtree. Finally, a personalized recommendation list is generated using the selected knowledge trees' user preference subtrees. Taking movie recommendations as an example, the three knowledge trees with the highest similarity are selected as the target user's similar knowledge trees. The attribute values of the "favorite movies" child nodes in these three knowledge trees are obtained, and a personalized recommendation list for the target user is generated based on the similarity ranking.
[0114] In this implementation, the knowledge forest needs to be updated and maintained regularly, including adding new user history information and knowledge, and correcting errors and inaccuracies to maintain its usability and reliability. The maintenance process aims to ensure that the knowledge forest stays in sync with the latest developments and changes in relevant knowledge within the domain, continuously meeting the needs of users and application scenarios.
[0115] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit them. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features therein. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope defined by the claims of the present invention.
Claims
1. A personalized search and recommendation method based on knowledge forests and user preferences, characterized in that, The method includes the following steps: Step 1: Collect and preprocess the user history information of several users, and build an attribute set for each user according to user needs; Step 2: Construct a knowledge schema tree for each user based on their attribute set; Step 3: Use the entity relation extraction algorithm to extract entity relations from the user history information of each user after preprocessing, and use the extracted entities and knowledge pattern tree to build a knowledge tree, and then use the knowledge trees of all users to build a knowledge forest. Step 3.1: For any user, use the entity relation extraction algorithm to extract entity relations from the preprocessed user history information, and obtain entities from user feature information, environmental background information, historical interaction information and user preference information respectively; Step 3.2: Match the entities extracted from the user feature information with the attributes in the attribute set that represent user features, and use the successfully matched entities as the attribute values of the corresponding attributes; match the entities extracted from the environmental background information with the attributes in the attribute set that represent environmental states, and use the successfully matched entities as the attribute values of the corresponding attributes; match the entities extracted from the historical interaction information with the attributes in the attribute set that represent historical interactions, and use the successfully matched entities as the attribute values of the corresponding attributes. The entities extracted from the user preference information are matched with the attributes in the attribute set that represent user preferences, and the entities that successfully match are used as the attribute values of that attribute. Step 3.3: Use the attribute values obtained in Step 3.2 to assign values to the child nodes of the user's knowledge pattern tree, and use the assigned knowledge pattern tree as the user's knowledge tree; Step 3.4: Repeat steps 3.1-3.3 until a knowledge tree is built for each user, and the collection of all knowledge trees is called a knowledge forest; Step 4: Use graph embedding technology to assign weights to all edges of each knowledge tree in the knowledge forest to obtain the final knowledge forest and save it to the graph database; Step 4.1: For any knowledge tree in the knowledge forest, randomly initialize all nodes in the knowledge tree to generate the embedding vector of each node; Step 4.2: For any node in this knowledge tree , will node Starting from a node, a random walk algorithm is used to perform a random walk, resulting in several pairs of adjacent nodes; these pairs of adjacent nodes are determined by the nodes... and nodes A neighbor node composition; Step 4.3: Calculate the loss function value for each pair of adjacent nodes using the graph embedding technique, and use this value as the node value in that pair of adjacent nodes. and neighboring nodes The similarity between them; Step 4.4: Calculate the loss function with respect to neighboring nodes using the stochastic gradient descent algorithm. The gradient of the embedding vector is calculated, and the neighboring nodes are updated using this gradient. The embedding vector is used to obtain the neighboring nodes. Updated embedding vector; Step 4.5: Repeat steps 4.3-4.4 until the preset number of iterations is met or the loss function is minimized, then stop the iteration and obtain the node. The updated embedding vectors of all neighboring nodes; Step 4.6: Repeat steps 4.2-4.5 until the updated embedding vectors of all nodes in the knowledge tree are obtained; Step 4.7: Calculate the cosine similarity between each pair of adjacent nodes in the knowledge tree using the updated embedding vectors of all nodes in the knowledge tree. Then, use the sigmoid function to map the cosine similarity between each pair of adjacent nodes to... Between them, the mapped cosine similarity is used as the weight of the edge connecting the pair of adjacent nodes to obtain the weighted knowledge tree; Step 4.8: Repeat steps 4.1-4.7 until all edges of the knowledge trees in the knowledge forest have been weighted. The set of all weighted knowledge trees is then used as the final knowledge forest and saved to the graph database. Step 5: Construct a target user knowledge tree based on the target user's needs. Calculate the similarity between the target user knowledge tree and each knowledge tree in the knowledge forest by calling the knowledge forest in the graph database, and use the calculated similarity to generate a personalized recommendation list for the target user.
2. The personalized search and recommendation method based on knowledge forest and user preferences according to claim 1, characterized in that, The user history information mentioned in step 1 includes: user characteristic information, environmental background information, historical interaction information, and user preference information; The preprocessing includes: data cleaning, deduplication, and format standardization.
3. The personalized search and recommendation method based on knowledge forest and user preferences according to claim 2, characterized in that, The method for constructing the attribute set in step 1 is as follows: For any user, according to user needs, determine several attributes for representing user characteristics, several attributes for representing environmental state, several attributes for representing historical interactions, and several attributes for representing user preferences, and take the set of all attributes as the user's attribute set.
4. The personalized search and recommendation method based on knowledge forest and user preferences according to claim 3, characterized in that, The method for constructing the knowledge pattern tree in step 2 is as follows: For any user, the root node of the knowledge pattern tree is represented as the user entity of that user. Based on the user's historical information, the user's knowledge pattern tree is divided into four subtrees, namely: user feature subtree, environment state subtree, interaction record subtree, and user preference subtree. The root node of the user feature subtree is represented as a user feature. Each attribute in the attribute set used to represent the user feature is used as an edge connecting the root node and the child node in the user feature subtree. The attribute value of each attribute is used as the child node of the user feature subtree. The root node of the environment state subtree is represented as the environment state. Each attribute in the attribute set used to represent the environment state is used as an edge connecting the root node and the child node in the environment state subtree. The attribute value of each attribute is used as the child node of the environment state subtree. The root node of the interaction record subtree is represented as the historical interaction. Each attribute in the attribute set used to represent the historical interaction is used as an edge connecting the root node and the child node in the interaction record subtree. The attribute value of each attribute is used as the child node of the interaction record subtree. The root node of the user preference subtree is represented as the user preference. Each attribute in the attribute set used to represent the user preference is used as an edge connecting the root node and the child node in the user preference subtree. The attribute value of each attribute is used as the child node of the user preference subtree. The hierarchical relationship between child nodes in each subtree is determined by the logical relationship between the attributes corresponding to each child node.
5. The personalized search and recommendation method based on knowledge forest and user preferences according to claim 4, characterized in that, The loss function described in step 4.3 is expressed as follows: ; in Represents a node and neighboring nodes The similarity between them; It is the set of all nodes in the knowledge tree; For nodes The set of all neighboring nodes; For neighboring nodes The embedding vector; For nodes The embedding vector; This represents the sigmoid function.
6. The personalized search and recommendation method based on knowledge forest and user preferences according to claim 5, characterized in that, Step 5 further includes: Step 5.1: Obtain the target user's historical information based on the target user's needs and construct a target user knowledge tree; Step 5.2: Call the knowledge forest in the graph database. For any knowledge tree in the knowledge forest, use a pre-trained language model to vectorize the knowledge tree and the target user's knowledge tree respectively, and extract all paths in the knowledge tree and the target user's knowledge tree respectively and represent them as vectors. Step 5.3: Calculate the cosine similarity between the vector representation of each path in the knowledge tree and the vector representation of each path in the target user's knowledge tree as the similarity score between each path in the knowledge tree and each path in the target user's knowledge tree. Step 5.4: Aggregate the similarity scores of all paths in the knowledge tree and all paths in the target user's knowledge tree to obtain the overall similarity between the knowledge tree and the target user's knowledge tree; Step 5.5: Repeat steps 5.2-5.4 to obtain the overall similarity between all knowledge trees in the called knowledge forest and the target user's knowledge tree; Step 5.6: Sort the overall similarity between the target user's knowledge tree and each knowledge tree in descending order, and select the top K knowledge trees in the sorting results as the similar knowledge trees of the target user; Step 5.7: Sequentially obtain the attribute values corresponding to all child nodes in the user preference subtree of the similarity knowledge tree of K target users and use them as the personalized recommendation results for the target users, and generate a personalized recommendation list for the target users.
7. The personalized search and recommendation method based on knowledge forest and user preferences according to claim 6, characterized in that, The method described in step 5.4 for aggregating the similarity scores of all paths in the knowledge tree with all paths in the target user's knowledge tree is as follows: ; in Represents any knowledge tree in a knowledge forest; To represent the knowledge tree of the target user; express and Overall similarity; and They are and The set of paths in; for The path in; for The path in; It is the cosine similarity function; Representing a path The weights; Representing a path The weight.