Recommendation method and system based on knowledge tree prompt and article multivariate relation modeling
By constructing an extended knowledge graph and generating natural language prompts based on knowledge tree hints and multi-item relationship modeling, and utilizing a large language model and hypergraph convolutional network, the cold start and semantic understanding problems in traditional recommendation methods are solved, and more accurate and personalized next basket recommendations are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SUN YAT SEN UNIV
- Filing Date
- 2026-01-12
- Publication Date
- 2026-05-08
AI Technical Summary
Traditional next-basket recommendation methods struggle to effectively handle cold-start and long-tail products, and large language models have limited semantic understanding of products in vertical domains, resulting in recommendation results that favor popular products and lack diversity and accuracy.
Based on knowledge tree prompts and multi-item relationship modeling, this method constructs an extended knowledge graph, dynamically builds a knowledge tree, generates natural language prompts, and extracts multi-item relationship representations using a large language model and a hypergraph convolutional network. It then combines these with a weighted fusion of the user's historical purchase frequency to generate the item prediction results for the next basket.
It significantly improves the accuracy and interpretability of recommendations, better understands the semantics of items in vertical fields, captures complex combination patterns of multiple items, responds to users' stable interests and diverse needs, and achieves personalized next basket recommendations.
Smart Images

Figure CN121998732A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of intelligent recommendation technology, and more specifically, to a recommendation method and system based on knowledge tree prompts and multi-item relationship modeling. Background Technology
[0002] With the rapid development of e-commerce platforms, recommendation systems have become a key technology connecting users and products. Their core objective is to predict users' future purchasing interests based on their historical behavioral data. In real-world shopping scenarios, users often tend to purchase multiple items in a single transaction to satisfy diverse needs. This behavioral pattern has given rise to the "next basket recommendation" task, whose goal is no longer to predict individual items, but rather to predict a set of items a user is likely to purchase next.
[0003] However, traditional next-basket recommendation methods rely on item IDs for collaborative filtering modeling, which struggles to effectively handle cold-start and long-tail products. This leads to biased recommendations towards popular items, impacting the diversity and fairness of the recommendations. Furthermore, existing methods often model based on binary relationships between items, while real-world shopping scenarios involve complex multi-faceted relationships between products, such as bundled purchases and contextualized combinations. Relying solely on binary relationships fails to capture these multi-layered and multi-dimensional collaborative effects. Moreover, large language models have been introduced into recommendation systems to enhance semantic understanding. However, in vertical domains, many product names fall outside the vocabulary and have not been pre-trained with large models. This limits the model's understanding of these products, making it prone to "illusions" or erroneous inferences, thus affecting recommendation accuracy.
[0004] To address these challenges, existing research has begun exploring methods combining knowledge graphs and large-scale models to enhance the understanding of product semantics and to model complex relationships between products using graph structures. However, how to effectively integrate knowledge-guided reasoning with large-scale model inference, and how to dynamically model collaborative relationships among multiple items, remain key issues that urgently need to be addressed in current next-basket recommendation systems. Summary of the Invention
[0005] To address the aforementioned technical issues, this invention proposes a recommendation method and system based on knowledge tree prompts and multi-item relationship modeling. This method deeply integrates domain knowledge, models multi-item relationships, and adapts to the semantic understanding needs of vertical domains, thereby improving the accuracy, interpretability, and practicality of next basket recommendations.
[0006] The first aspect of this invention provides a recommendation method based on knowledge tree hints and multi-dimensional relationship modeling of items, comprising the following steps: An initial knowledge graph is constructed based on the item attribute information. On the basis of the initial knowledge graph, the baskets purchased by the user in the past and the inclusion relationship between the baskets and the items are added as new entities and relationships to form an expanded knowledge graph. Based on the user's historical purchase basket sequence, a knowledge tree is dynamically constructed from the expanded knowledge graph. The knowledge tree is then traversed in a breadth-first manner to extract the triple structure, and knowledge tree prompts in natural language form are generated based on a preset prompt template. The user's historical basket sequence and knowledge tree prompts are input into the large language model, and the embedding representation of the last token output by the model is extracted as a sequence representation that integrates semantic information. Based on the similarity between items, an item hypergraph is dynamically constructed, and a hypergraph convolutional network is used in the hypergraph to extract multivariate relationship representations of items. Based on the user's historical purchase frequency of items, the sequence representation and the multivariate relationship representation of items are weighted and fused through a frequency-aware gating unit to generate the prediction result of the user's next basket of items.
[0007] In this solution, an initial knowledge graph is constructed based on item attribute information. Then, based on this initial knowledge graph, the user's historical purchases of baskets and the inclusion relationships between baskets and items are added as new entities and relationships, forming an expanded knowledge graph, including: An initial knowledge graph is constructed using item entities and item attribute entities as nodes and the association between items and attributes as edges. In the initial knowledge graph, item entities represent recommended goods or services, and item attribute entities represent the characteristics, categories, or tags of items. Obtain the user's historical purchase information, define each purchase of the user as a basket entity, assign a unique identifier to each basket entity, add the basket entity to the initial knowledge graph, construct the inclusion relationship edge from the basket entity to each item entity contained in the basket, and generate basket-item association; In the initial knowledge graph, an expanded knowledge graph with a three-layer structure of basket entity, item entity, and item attribute entity is generated based on the newly added basket entity and containment relationship edges.
[0008] In this scheme, a knowledge tree is dynamically constructed from the expanded knowledge graph based on the user's historical purchase basket sequence. A breadth-first traversal is then performed on the knowledge tree to extract the triplet structure, including: Map each basket in the user's historical purchase basket sequence to the corresponding basket entity node in the expanded knowledge graph, and use each basket entity node as the root node of the knowledge tree; Starting from the root node, a cluster search is performed in the expanded knowledge graph. During the search process, a comprehensive scoring function is constructed by integrating association strength, information novelty and relevance to user sequences. At each layer expansion, the N optimal paths with the highest scores are retained according to the comprehensive scoring function. When the search depth reaches a preset threshold or the path score is lower than a preset threshold, the search stops, the path set starting from the root node is obtained, and a dynamic knowledge tree is constructed with the basket entity as the root, the item entities contained in the basket as the intermediate layer, and the attribute entities associated with the items as the leaf nodes. Perform a breadth-first traversal on each dynamic knowledge tree, recording the head entity, relation, and tail entity corresponding to each edge in sequence during the traversal, and generating a sequence of triples arranged in traversal order.
[0009] In this solution, for the triplet sequence, a knowledge tree prompt in natural language form is generated based on a preset prompt template, including: The triple sequence is hierarchically labeled, and different levels are distinguished according to the type of the head entity in the triple. Within the same level, the triples are sorted according to the predefined relation priority to generate a structured list of triples. Based on the relation type in the triple, the corresponding natural language sentence template is matched from the preset prompt template library, and the head entity, relation and tail entity in the triple are filled into the corresponding slots of the selected template to generate a knowledge tree prompt in natural language form. The knowledge tree prompts corresponding to each basket in the user's historical purchase basket sequence are arranged and spliced in order of purchase time, and time-series correlation words are inserted between different knowledge tree prompts to form a serialized knowledge narrative text; Redundancy detection and merging are performed on the generated knowledge tree prompts, and the prompt text is intelligently pruned according to the context length limit of the large language model to generate the final knowledge tree prompts.
[0010] In this scheme, the user's historical basket sequence and knowledge tree prompts are input into a large language model. The embedding representation of the last token output by the model is extracted as a sequence representation that integrates semantic information, including: The list of items in each historical basket in the user's historical basket sequence is formatted into a natural language description sentence, and the description sentence is combined with the corresponding knowledge tree prompt to generate a description-knowledge block; The description-knowledge blocks are arranged sequentially according to the purchase time, and task guidance statements and semantic representation extraction instructions are added at the beginning and end respectively to form a structured combined input text; The combined input text is converted into a token sequence and input into a large language model. The large language model performs contextual understanding and information fusion on the description-knowledge block based on the task guidance statement and delimiter, and extracts instructions according to the semantic representation, and performs semantic summarization and compression on all input information. Obtain the high-dimensional context-aware embedding vector generated by the large language model for the last token in the input sequence, and use it as the sequence representation output that integrates user historical behavior patterns and item domain knowledge.
[0011] In this scheme, an item hypergraph is dynamically constructed based on the similarity between items. A hypergraph convolutional network is then used within the hypergraph to extract multivariate relationship representations of the items, including: Based on the initial representation of the items, a hybrid expert network is used to calculate the similarity score between any two items from a predefined dimension. The similarity scores of each expert network are dynamically fused to generate an item similarity matrix. A preset similarity scoring threshold is set. For a target item, item pairs that exceed the preset similarity scoring threshold are filtered from the item similarity matrix to form a candidate item set corresponding to the target item. Each candidate item set is treated as a hyperedge, and all items in the set are treated as nodes connected by the hyperedge. A hypergraph structure is initially constructed. Redundancy removal and merging operations are performed on the hyperedges in the hypergraph structure to generate a dynamic item hypergraph that represents the multi-dimensional collaborative relationships between items. Perform hypergraph convolution operations on the dynamic item hypergraph. By stacking multiple layers of hypergraph convolutional networks, the item nodes aggregate information from their neighboring nodes, and the node representation output by the last layer of the hypergraph convolutional network is used as the multivariate relation representation of the item.
[0012] In this scheme, based on the user's historical purchase frequency of items, a frequency-aware gating unit is used to weightedly fuse sequential representations and multivariate relationship representations of items to generate a prediction result for the user's next basket of items, including: Extract the number of times a user has purchased each item in history, normalize the data, obtain the frequency value of the user's repurchase tendency for the item, and construct the user's frequency vector based on the frequency values of all items. The user's sequence representation and the frequency vector are input into a gated neural network. The gated neural network calculates a corresponding gate value for each item. A gate value close to 1 indicates a greater reliance on the user's long-term preferences, while a gate value close to 0 indicates a greater reliance on the multi-dimensional collaborative relationships between items. The user's sequence representation is transformed into an interaction score knowledge value between the user and the item through a projection network, which serves as the basic preference score. The gating value is used as a weight to perform a weighted summation of the basic preference score and the score after linear mapping of the multivariate relationship representation of the item, so as to obtain the final predicted score of the item. Calculate the final predicted score for all items, sort them according to the scores, select the top K items with the highest scores based on the sorting results, and output them as the predicted results for the user's next basket.
[0013] The second aspect of the present invention provides a recommendation system based on knowledge tree prompts and multi-item relationship modeling, the system comprising: a knowledge graph construction and expansion module, a knowledge tree prompt construction module, a large model sequence encoding module, an item hypergraph construction module, a multi-item relationship encoding module, and a frequency-aware gating unit module; The knowledge graph construction and expansion module constructs an initial knowledge graph based on item attribute information. On the basis of the initial knowledge graph, the baskets purchased by the user in the past and the inclusion relationship between the baskets and the items are added as new entities and relationships to form an expanded knowledge graph. The knowledge tree prompting construction module dynamically constructs a knowledge tree from the expanded knowledge graph based on the user's historical purchase basket sequence, performs a breadth-first traversal of the knowledge tree, extracts the triple structure, and generates knowledge tree prompts in natural language form based on a preset prompt template. The large model sequence encoding module receives the user's historical basket sequence and knowledge tree prompts, and extracts the embedded representation of the last token output by the model as a sequence representation that integrates semantic information. The item hypergraph construction module dynamically constructs a hypergraph structure connecting items based on the basic representation of items and calculates multidimensional similarity to generate the item hypergraph. The multi-item relationship encoding module uses a hypergraph convolutional network to extract multi-item relationship representations of items in the hypergraph, and obtains the multi-item collaborative pattern in the next basket recommendation scenario; The frequency-aware gating unit module, based on the user's historical purchase frequency of items, uses the frequency-aware gating unit to perform weighted fusion of sequence representation and multivariate relationship representation of items to generate the prediction result of the user's next basket of items.
[0014] Compared with the prior art, the beneficial effects of the present invention are as follows: This invention dynamically constructs a knowledge tree from an expanded knowledge graph and generates structured natural language prompts to guide a large language model to understand items in a vertical domain. Without increasing the number of parameters in the large model, it effectively injects domain knowledge, significantly improves the model's ability to accurately understand the semantics of items, fundamentally alleviates the "illusion" phenomenon of recommendations caused by insufficient semantic understanding, and enhances the interpretability of recommendations.
[0015] By using a hybrid expert network to measure item similarity from multiple dimensions and dynamically constructing an item hypergraph to represent the diverse collaborative relationships between items, and leveraging a hypergraph convolutional network for high-order information propagation, we can effectively capture the complex combination patterns of multiple items involved in a user's purchase, thus better reflecting real-world consumption scenarios and improving the ability to predict the next purchase.
[0016] The design incorporates frequency-aware gating units that fuse sequential representations reflecting long-term user preferences with multivariate relationship representations reflecting synergistic relationships between items. Based on the user's historical purchase frequency, the weights of these two information sources are dynamically adjusted to adaptively model user repurchase habits and contextual exploration behaviors. This allows the system to not only respond to stable user interests but also flexibly adapt to diverse combined purchase needs, ultimately achieving more accurate and personalized "next basket" recommendations. Attached Figure Description
[0017] To more clearly illustrate the technical solutions in the embodiments or examples of the present invention, the drawings used in the embodiments or examples will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained according to these drawings without creative effort.
[0018] Figure 1 A flowchart is shown for a recommendation method based on knowledge tree hints and multi-item relationship modeling; Figure 2 The flowchart illustrates the process of constructing a knowledge tree and performing a breadth-first traversal to extract the triple structure. Figure 3 A flowchart is shown for extracting multivariate relation representations of items from a hypergraph; Figure 4 A block diagram of a recommendation system based on knowledge tree prompts and multi-item relationship modeling is shown. Detailed Implementation
[0019] To better understand the above-mentioned objectives, features, and advantages of the present invention, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. It should be noted that, unless otherwise specified, the embodiments and features described in these embodiments can be combined with each other.
[0020] Many specific details are set forth in the following description in order to provide a full understanding of the invention. However, the invention may also be practiced in other ways different from those described herein, and therefore the scope of protection of the invention is not limited to the specific embodiments disclosed below.
[0021] like Figure 1As shown, this embodiment provides a recommendation method based on knowledge tree hints and multi-item relationship modeling, including: An initial knowledge graph is constructed based on the item attribute information. On the basis of the initial knowledge graph, the baskets purchased by the user in the past and the inclusion relationship between the baskets and the items are added as new entities and relationships to form an expanded knowledge graph. Based on the user's historical purchase basket sequence, a knowledge tree is dynamically constructed from the expanded knowledge graph. The knowledge tree is then traversed in a breadth-first manner to extract the triple structure, and knowledge tree prompts in natural language form are generated based on a preset prompt template. The user's historical basket sequence and knowledge tree prompts are input into the large language model, and the embedding representation of the last token output by the model is extracted as a sequence representation that integrates semantic information. Based on the similarity between items, an item hypergraph is dynamically constructed, and a hypergraph convolutional network is used in the hypergraph to extract multivariate relationship representations of items. Based on the user's historical purchase frequency of items, the sequence representation and the multivariate relationship representation of items are weighted and fused through a frequency-aware gating unit to generate the prediction result of the user's next basket of items.
[0022] It should be noted that an initial knowledge graph is constructed using item entities and item attribute entities as nodes, and the relationships between items and attributes as edges. This initial knowledge graph serves as the system's foundational static knowledge base. In this initial knowledge graph, item entities represent recommendable goods or services, and item attribute entities represent the characteristics, categories, or tags of items. Relationships between items and attributes are established, and these relationships can be one-to-many or many-to-many.
[0023] By extracting user historical purchase information from data sources such as product databases using information extraction techniques, each user purchase is defined as a "basket entity," and a unique identifier, such as a timestamp combined with a user ID, is assigned to each basket entity. These basket entities are added to the initial knowledge graph, constructing containment edges from the basket entities to the individual item entities within each basket, generating basket-item associations. Adding baskets to the knowledge graph provides a structural foundation for retrieving higher-order combination patterns such as combined purchases. When two items are contained in the same or one basket, the items are not directly connected in the extended knowledge graph, but are associated through a common basket parent node, allowing the system to infer item combinations using graph algorithms. In the initial knowledge graph, an extended knowledge graph with a three-layer structure of basket entities, item entities, and item attribute entities is generated based on the newly added basket entities and containment edges. Here, basket entities represent user consumption behavior units, item entities represent recommendation targets, and item attribute entities describe item characteristics.
[0024] It should be noted that, as Figure 2As shown, each basket in the user's historical purchase basket sequence is mapped to the corresponding basket entity node in the expanded knowledge graph, and each basket entity node is used as the root node of the knowledge tree. The user's consumption behavior is mapped as the starting point of knowledge exploration, so that the generated knowledge tree has the representation of user behavior patterns, ensuring that the generated knowledge is closely integrated with the user's real consumption scenario.
[0025] Starting from the root node, a bundle search is performed in the expanded knowledge graph to conduct guided and efficient graph exploration. The expanded knowledge graph expands layer by layer outward along relation edges. During the search process, a comprehensive scoring function is constructed by integrating association strength, information novelty, and relevance to the user sequence. At each layer of expansion, the N optimal paths with the highest scores are retained based on the comprehensive scoring function, where association strength is the weight of the relation in the knowledge graph. Information novelty is calculated by comparing the embedding of the candidate entity with the average cosine similarity of all entity embeddings already included in the knowledge tree. The novelty score is negatively correlated with the average similarity, and this indicator favors nodes with significant differences from the explored paths. While constructing the knowledge tree, a sequence list of the user's historical sequence (excluding the currently searched knowledge tree) is obtained through a large model. This list serves as a pre-learned semantic representation for each entity in the knowledge graph. The cosine similarity between the candidate entity's representation and the user sequence representation is calculated as the relevance to the user sequence. This relevance to the user sequence indicator is used to favor nodes with implicit associations with other baskets or items in the user's history.
[0026] When the search depth reaches a preset threshold or the path score is lower than a preset threshold, the search stops. The set of paths starting from the root node is obtained and constructed as a dynamic knowledge tree with the basket entity as the root, the items contained in the basket as the intermediate layer, and the attribute entities associated with the items as the leaf nodes. A breadth-first traversal is performed on each dynamic knowledge tree, starting from the root node (basket), first visiting all child nodes (items), and then visiting the next level node (attribute). During the traversal, the head entity, relation, and tail entity corresponding to each edge are recorded in sequence, generating a sequence of triples arranged in traversal order.
[0027] It should be noted that after obtaining the triple sequence through breadth-first traversal, the triple sequence undergoes structured preprocessing. The triple sequence is hierarchically labeled, categorized into different levels based on the type of the head entity within the triple, and sorted within the same level according to predefined relation priorities, generating a structured list of triples. Preferably, core, general, and stable relations are placed first, while secondary, specific, and variable relations are placed later.
[0028] Based on the relation type in the triples, corresponding natural language sentence templates are matched from a pre-set prompt template library. Each template corresponds to one type or class of relations and consists of a fixed sentence structure and fillable slots. The head entity, relation, and tail entity in the triples are filled into the corresponding slots of the selected templates. Intelligent entity linking is performed during template filling. The first appearance of an entity uses its full name. When the same entity appears again in subsequent sentences, it is referred to using pronouns or abbreviations according to the context to avoid language repetition and redundancy, generating knowledge tree prompts in natural language form. The knowledge tree prompts corresponding to each basket in the user's historical purchase basket sequence are arranged and spliced according to the purchase time order, and temporal correlation words are inserted between different knowledge tree prompts to form a serialized knowledge narrative text. Redundancy information is detected and merged in the generated knowledge tree prompts. Based on the context length limit of the large language model, priority is given to retaining recent baskets, item attributes with higher relevance to the current prediction target, and core relation information with higher frequency of occurrence. The prompt text is intelligently pruned to generate the final knowledge tree prompt.
[0029] It should be noted that the list of items in each historical basket in the user's historical basket sequence is formatted into short natural language descriptive sentences, transforming the complex list structure into descriptions that conform to natural language habits. These descriptive sentences are then combined with the corresponding knowledge tree prompts to generate description-knowledge blocks, creating a narrative input structure that tightly integrates facts and explanations, helping the model establish a deep connection between the two.
[0030] The description-knowledge blocks are arranged sequentially according to purchase time, and task guidance statements (e.g., "You are a professional shopping preference analysis assistant, skilled at summarizing consumption patterns and interests from users' purchase history and detailed product descriptions. Please carefully read the following annotated purchase records and extract key user preference representations from them.") and semantic representation extraction instructions (e.g., "Please generate a dense semantic representation vector that can summarize all the above purchase history and product information") are added at the beginning and end to form a structured combined input text. The combined input text is converted into a token sequence and input into a large language model. The large language model performs contextual understanding and information fusion on the description-knowledge blocks based on the task guidance statements and delimiters, and performs semantic summarization and compression on all input information according to the semantic representation extraction instructions. The high-dimensional context-aware embedding vector generated by the large language model for the last token in the input sequence is obtained as the sequence representation output that integrates user historical behavior patterns and item domain knowledge.
[0031] It should be noted that, as Figure 3As shown, based on the initial representation of items in the extended knowledge graph, a hybrid expert network is used to calculate the similarity score between any two items from predefined dimensions. Each expert is a learnable linear transformation matrix that examines and compares items from a specific perspective or aspect. The similarity scores from each expert network are dynamically fused to generate an item similarity matrix. Preferably, a lightweight gating network is introduced to assign different weights to the similarity scores of different experts according to the current context to be modeled. The final item pair similarity is obtained by weighted summation. A preset similarity score threshold is set. For the target item, item pairs exceeding the preset similarity score threshold are selected from the item similarity matrix to form a candidate item set corresponding to the target item. Each candidate item set is used as a hyperedge, and all items in the set are used as nodes connected by the hyperedge, initially constructing a hypergraph structure. The hyperedge represents a core item and all items that are highly related to it in multiple dimensions. Redundancy removal and merging operations are performed on the hyperedges in the hypergraph structure to generate a dynamic item hypergraph representing the multi-dimensional collaborative relationships between items. The adjacency matrix of the hypergraph is defined as: ; in Represents the hypergraph adjacency matrix The Middle Okay, number Column elements, Represents items Similarity between them Indicates the object With all other items Sort the similarity sets and take the top ones. The set of items corresponding to the maximum similarity.
[0032] Hypergraph convolution operations are performed on the dynamic item hypergraph. Information is passed along the path of point-hyperedge-point. By stacking multiple layers of hypergraph convolutional networks, item nodes aggregate and update information from their neighbors. Through the stacking of multiple layers of hypergraph convolution, the final representation of an item incorporates information from directly related items and other items indirectly related through shared hyperedges. The node representation output by the last layer of the hypergraph convolutional network serves as the multivariate relation representation of the item. The hypergraph convolutional network, in which the first layer... The formula for layer convolution is: ; in Indicates the first The representation matrix of all items after convolution. Indicates the first The representation matrix output by the convolutional layer. Indicates the first The learnable parameter matrix of the layer, Representing nodes respectively and super-edge The degree, Represents the adjacency matrix of a hypergraph. Indicates matrix transpose. This represents a diagonal matrix.
[0033] It should be noted that the historical purchase counts of each user for each item are extracted and normalized to obtain the frequency value of the user's repurchase tendency for each item. A user frequency vector is then constructed based on the frequency values of all items. ; ,in Indicates user Purchase items The frequency of purchases; for items that a user has never purchased, the frequency value can be set to 0 or a very small value.
[0034] The user's sequence representation and the frequency vector are input into a gated neural network. The gating unit determines, when predicting the next basket, the extent to which the prediction should rely on the user's long-term stable preferences for each item, or the extent to which it should rely on the item's position and synergistic effects within the current multi-faceted relationship network. The gated neural network calculates a corresponding gating value for each item. A gating value close to 1 indicates a greater reliance on the user's long-term preferences, as the user has a clear need for the item. A gating value close to 0 indicates a greater reliance on multi-faceted synergistic relationships between items. For items purchased infrequently or for novelty items, the purchase motivation is more driven by matching, context, or exploratory behavior.
[0035] For each candidate item, the user's sequence representation is transformed into an interaction score knowledge value between the user and the item through a projection network, which serves as the basic preference score. The gating value is used as a weight to perform a weighted summation of the basic preference score and the score obtained by linear mapping of the multivariate relationship representation of the item, thus obtaining the final predicted score of the item. ; , This indicates that the gated neural network is for items. The generated gate value, This represents the user's basic preference score for items calculated from the user's sequence representation. Represents a learnable linear transformation matrix. Represents items The representation of multiple relationships.
[0036] The system calculates the final predicted score for all items, sorts them according to the scores, and selects the top K items with the highest scores as the predicted results for the user's next basket, which are then output. Furthermore, based on the sorting, the system considers the differences between the multi-faceted relationship representations of the items to avoid recommending overly homogeneous items, thereby increasing the coverage and practicality of the basket.
[0037] like Figure 4 As shown, the second embodiment of the present invention provides a recommendation system based on knowledge tree prompts and multi-item relationship modeling. The system includes: a knowledge graph construction and expansion module, a knowledge tree prompt construction module, a large model sequence encoding module, an item hypergraph construction module, a multi-item relationship encoding module, and a frequency-aware gating unit module. The knowledge graph construction and expansion module constructs an initial knowledge graph based on item attribute information. On the basis of the initial knowledge graph, the baskets purchased by the user in the past and the inclusion relationship between the baskets and the items are added as new entities and relationships to form an expanded knowledge graph. The knowledge tree prompting construction module dynamically constructs a knowledge tree from the expanded knowledge graph based on the user's historical purchase basket sequence, performs a breadth-first traversal of the knowledge tree, extracts the triple structure, and generates knowledge tree prompts in natural language form based on a preset prompt template. The large model sequence encoding module receives the user's historical basket sequence and knowledge tree prompts, and extracts the embedded representation of the last token output by the model as a sequence representation that integrates semantic information. The item hypergraph construction module dynamically constructs a hypergraph structure connecting items based on the basic representation of items and calculates multidimensional similarity to generate the item hypergraph. The multi-item relationship encoding module uses a hypergraph convolutional network to extract multi-item relationship representations of items in the hypergraph, and obtains the multi-item collaborative pattern in the next basket recommendation scenario; The frequency-aware gating unit module, based on the user's historical purchase frequency of items, uses the frequency-aware gating unit to perform weighted fusion of sequence representation and multivariate relationship representation of items to generate the prediction result of the user's next basket of items.
[0038] A third embodiment of the present invention provides a computer-readable storage medium, which includes a recommendation method program based on knowledge tree hints and multi-item relationship modeling. When the recommendation method program based on knowledge tree hints and multi-item relationship modeling is executed by a processor, it implements the steps of the recommendation method based on knowledge tree hints and multi-item relationship modeling.
[0039] In the several embodiments provided in this application, it should be understood that the disclosed methods and systems can be implemented in other ways. The system embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods, such as: multiple units or components can be combined, or integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the various components shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, and can be electrical, mechanical, or other forms. Furthermore, in the various embodiments of the present invention, all functional units can be integrated into one processing unit, or each unit can be a separate unit, or two or more units can be integrated into one unit; the integrated unit can be implemented in hardware or in the form of hardware plus software functional units.
[0040] Those skilled in the art will understand that all or part of the steps of the above method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps of the above method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0041] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in the present invention should be included within the scope of protection of the present invention.
Claims
1. A recommendation method based on knowledge tree prompts and multi-item relationship modeling, characterized in that, Includes the following steps: An initial knowledge graph is constructed based on the item attribute information. On the basis of the initial knowledge graph, the baskets purchased by the user in the past and the inclusion relationship between the baskets and the items are added as new entities and relationships to form an expanded knowledge graph. Based on the user's historical purchase basket sequence, a knowledge tree is dynamically constructed from the expanded knowledge graph. The knowledge tree is then traversed in a breadth-first manner to extract the triple structure, and knowledge tree prompts in natural language form are generated based on a preset prompt template. The user's historical basket sequence and knowledge tree prompts are input into the large language model, and the embedding representation of the last token output by the model is extracted as a sequence representation that integrates semantic information. Based on the similarity between items, an item hypergraph is dynamically constructed, and a hypergraph convolutional network is used in the hypergraph to extract multivariate relationship representations of items. Based on the user's historical purchase frequency of items, the sequence representation and the multivariate relationship representation of items are weighted and fused through a frequency-aware gating unit to generate the prediction result of the user's next basket of items.
2. The recommendation method based on knowledge tree prompts and multi-item relationship modeling according to claim 1, characterized in that, An initial knowledge graph is constructed based on item attribute information. Then, based on this initial knowledge graph, the user's historical purchases of baskets and the containment relationships between baskets and items are added as new entities and relationships, forming an expanded knowledge graph, including: An initial knowledge graph is constructed using item entities and item attribute entities as nodes and the association between items and attributes as edges. In the initial knowledge graph, item entities represent recommended goods or services, and item attribute entities represent the characteristics, categories, or tags of items. Obtain the user's historical purchase information, define each purchase of the user as a basket entity, assign a unique identifier to each basket entity, add the basket entity to the initial knowledge graph, construct the inclusion relationship edge from the basket entity to each item entity contained in the basket, and generate basket-item association; In the initial knowledge graph, an expanded knowledge graph with a three-layer structure of basket entity, item entity, and item attribute entity is generated based on the newly added basket entity and containment relationship edges.
3. The recommendation method based on knowledge tree prompts and multi-item relationship modeling according to claim 1, characterized in that, Based on the user's historical purchase basket sequence, a knowledge tree is dynamically constructed from the expanded knowledge graph. A breadth-first traversal is performed on the knowledge tree to extract the triplet structure, including: Map each basket in the user's historical purchase basket sequence to the corresponding basket entity node in the expanded knowledge graph, and use each basket entity node as the root node of the knowledge tree; Starting from the root node, a cluster search is performed in the expanded knowledge graph. During the search process, a comprehensive scoring function is constructed by integrating association strength, information novelty and relevance to user sequences. At each layer expansion, the N optimal paths with the highest scores are retained according to the comprehensive scoring function. When the search depth reaches a preset threshold or the path score is lower than a preset threshold, the search stops, the path set starting from the root node is obtained, and a dynamic knowledge tree is constructed with the basket entity as the root, the item entities contained in the basket as the intermediate layer, and the attribute entities associated with the items as the leaf nodes. Perform a breadth-first traversal on each dynamic knowledge tree, recording the head entity, relation, and tail entity corresponding to each edge in sequence during the traversal, and generating a sequence of triples arranged in traversal order.
4. The recommendation method based on knowledge tree prompts and multi-item relationship modeling according to claim 3, characterized in that, For the triple sequence, a knowledge tree prompt in natural language form is generated based on a preset prompt template, including: The triple sequence is hierarchically labeled, and different levels are distinguished according to the type of the head entity in the triple. Within the same level, the triples are sorted according to the predefined relation priority to generate a structured list of triples. Based on the relation type in the triple, the corresponding natural language sentence template is matched from the preset prompt template library, and the head entity, relation and tail entity in the triple are filled into the corresponding slots of the selected template to generate a knowledge tree prompt in natural language form. The knowledge tree prompts corresponding to each basket in the user's historical purchase basket sequence are arranged and spliced in order of purchase time, and time-series correlation words are inserted between different knowledge tree prompts to form a serialized knowledge narrative text; Redundancy detection and merging are performed on the generated knowledge tree prompts, and the prompt text is intelligently pruned according to the context length limit of the large language model to generate the final knowledge tree prompts.
5. The recommendation method based on knowledge tree prompts and multi-item relationship modeling according to claim 1, characterized in that, The user's historical basket sequence and knowledge tree hints are input into a large language model. The embedding representation of the last token output by the model is extracted as a sequence representation that incorporates semantic information, including: The list of items in each historical basket in the user's historical basket sequence is formatted into a natural language description sentence, and the description sentence is combined with the corresponding knowledge tree prompt to generate a description-knowledge block; The description-knowledge blocks are arranged sequentially according to the purchase time, and task guidance statements and semantic representation extraction instructions are added at the beginning and end respectively to form a structured combined input text; The combined input text is converted into a token sequence and input into a large language model. The large language model performs contextual understanding and information fusion on the description-knowledge block based on the task guidance statement and delimiter, and extracts instructions according to the semantic representation, and performs semantic summarization and compression on all input information. Obtain the high-dimensional context-aware embedding vector generated by the large language model for the last token in the input sequence, and use it as the sequence representation output that integrates user historical behavior patterns and item domain knowledge.
6. The recommendation method based on knowledge tree prompts and multi-item relationship modeling according to claim 1, characterized in that, A hypergraph is dynamically constructed based on the similarity between items. A hypergraph convolutional network is then used to extract multivariate relationship representations of the items, including: Based on the initial representation of the items, a hybrid expert network is used to calculate the similarity score between any two items from a predefined dimension. The similarity scores of each expert network are dynamically fused to generate an item similarity matrix. A preset similarity scoring threshold is set. For a target item, item pairs that exceed the preset similarity scoring threshold are filtered from the item similarity matrix to form a candidate item set corresponding to the target item. Each candidate item set is treated as a hyperedge, and all items in the set are treated as nodes connected by the hyperedge. A hypergraph structure is initially constructed. Redundancy removal and merging operations are performed on the hyperedges in the hypergraph structure to generate a dynamic item hypergraph that represents the multi-dimensional collaborative relationships between items. Perform hypergraph convolution operations on the dynamic item hypergraph. By stacking multiple layers of hypergraph convolutional networks, the item nodes aggregate information from their neighboring nodes, and the node representation output by the last layer of the hypergraph convolutional network is used as the multivariate relation representation of the item.
7. The recommendation method based on knowledge tree prompts and multi-item relationship modeling according to claim 1, characterized in that, Based on the user's historical purchase frequency of items, a frequency-aware gating unit is used to weightedly fuse sequential representations and multivariate relationship representations of items to generate a prediction result for the user's next basket of items, including: Extract the number of times a user has purchased each item in history, normalize the data, obtain the frequency value of the user's repurchase tendency for the item, and construct the user's frequency vector based on the frequency values of all items. The user's sequence representation and the frequency vector are input into a gated neural network. The gated neural network calculates a corresponding gate value for each item. A gate value close to 1 indicates a greater reliance on the user's long-term preferences, while a gate value close to 0 indicates a greater reliance on the multi-dimensional collaborative relationships between items. The user's sequence representation is transformed into an interaction score knowledge value between the user and the item through a projection network, which serves as the basic preference score. The gating value is used as a weight to perform a weighted summation of the basic preference score and the score after linear mapping of the multivariate relationship representation of the item, so as to obtain the final predicted score of the item. Calculate the final predicted score for all items, sort them according to the scores, select the top K items with the highest scores based on the sorting results, and output them as the predicted results for the user's next basket.
8. A recommendation system based on knowledge tree prompts and multi-item relationship modeling, characterized in that, For implementing the recommendation method based on knowledge tree prompts and multi-item relationship modeling as described in any one of claims 1-7, the system includes: a knowledge graph construction and expansion module, a knowledge tree prompt construction module, a large model sequence encoding module, an item hypergraph construction module, a multi-item relationship encoding module, and a frequency-aware gating unit module; The knowledge graph construction and expansion module constructs an initial knowledge graph based on item attribute information. On the basis of the initial knowledge graph, the baskets purchased by the user in the past and the inclusion relationship between the baskets and the items are added as new entities and relationships to form an expanded knowledge graph. The knowledge tree prompting construction module dynamically constructs a knowledge tree from the expanded knowledge graph based on the user's historical purchase basket sequence, performs a breadth-first traversal of the knowledge tree, extracts the triple structure, and generates knowledge tree prompts in natural language form based on a preset prompt template. The large model sequence encoding module receives the user's historical basket sequence and knowledge tree prompts, and extracts the embedded representation of the last token output by the model as a sequence representation that integrates semantic information. The item hypergraph construction module dynamically constructs a hypergraph structure connecting items based on the basic representation of items and calculates multidimensional similarity to generate the item hypergraph. The multi-item relationship encoding module uses a hypergraph convolutional network to extract multi-item relationship representations of items in the hypergraph, and obtains the multi-item collaborative pattern in the next basket recommendation scenario; The frequency-aware gating unit module, based on the user's historical purchase frequency of items, uses the frequency-aware gating unit to perform weighted fusion of sequence representation and multivariate relationship representation of items to generate the prediction result of the user's next basket of items.