A recommendation method based on multi-view hierarchical index tree coding and large language model
Patent Information
- Application Number
- CN202611157300.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-31
- Publication Date
- 2026-10-20
AI Technical Summary
[0005]因此现有推荐方法存在推荐精度较差的问题
[0055]本发明的有益效果如下:本发明提供的一种基于多视⻆层次索引树编码与大语言模型的推荐方法推荐精度较好。
Smart Images

Figure FT_1
Abstract
Description
Technical Field
[0001] This invention relates to the field of information retrieval, specifically to a recommendation method based on multi-view hierarchical index tree encoding and a large language model. Background Technology
[0002] Recommendation systems are one of the core competitive advantages of e-commerce platforms. By analyzing user behavior data through recommendation methods, recommendation systems can uncover user preferences and purchasing habits, recommend products that match users' preferences, improve user experience, promote user purchasing behavior, and also promote cross-selling and bundled sales, thereby increasing user purchase conversion rates and boosting the sales volume of e-commerce platforms.
[0003] The most commonly used recommendation method is implicit collaborative filtering, which models user preferences solely based on implicit user interaction records, without requiring users to actively provide explicit ratings or reviews. Implicit interactions include purchasing, clicking, browsing, favoriting, and adding to cart. However, implicit collaborative filtering suffers from the problem of positive and negative signal asymmetry. It can only observe positive user interactions but cannot directly obtain negative feedback signals (such as what users dislike). In real-world recommendation scenarios, the number of products is usually far greater than the number of products that users have interacted with, and the density of the interaction matrix is often less than 0.2%. Therefore, the interaction state of most user-product pairs is unknown, resulting in a huge gap between the number of positive and negative samples.
[0004] Therefore, the Bayesian Personalized Ranking (BPR) framework is used to address the problem of asymmetric positive and negative signals. This framework uses a negative sampling strategy to select a subset of items that the user has not interacted with as negative samples, which are then used to construct paired training data with positive samples. The model is optimized by maximizing the preference difference between positive and negative samples. However, a user's lack of interaction with a particular item could stem from a lack of interest or from a genuine liking for the item but not yet having encountered it. The latter, known as spurious negative samples, can suppress the user's true preferences and impair recommendation accuracy when used for training.
[0005] Therefore, existing recommendation methods suffer from poor recommendation accuracy. Summary of the Invention
[0006] The technical problem to be solved by the present invention is to overcome the shortcomings of the prior art and provide a recommendation method with better recommendation accuracy based on multi-view hierarchical index tree encoding and large language model.
[0007] To address the aforementioned technical problems, this invention provides a recommendation method based on multi-view hierarchical index tree encoding and a large language model, comprising:
[0008] S1. Based on the user-product interaction data, construct user sets, product sets, user-product interaction datasets, positive sample sets for each user, and multiple sets of users who have interacted with each product. Construct a collaborative similarity matrix based on the multiple sets of users who have interacted with each product. Construct a spectral embedding matrix based on the collaborative similarity matrix. Construct a high-order proximity matrix based on the collaborative similarity matrix.
[0009] S2. After constructing a collaborative tree structure based on the collaborative similarity matrix, a latent semantic tree based on the spectral embedding matrix, and a high-order neighbor tree based on the high-order neighbor matrix, a three-tree path code is generated for each product; the three-tree path code includes collaborative tree path code, latent semantic tree path code, and high-order neighbor tree path code.
[0010] S3. Construct candidate sets for each user based on multiple sets of users who have interacted with each product. Construct large language model prompts based on the three-tree path codes of each candidate product in each user's candidate set. Obtain confidence-weighted false negative sample sets for each user based on the large language model prompts. Use the confidence-weighted false negative sample sets for each user to augment the training set, thus obtaining the augmented training set.
[0011] S4. Construct a hard negative sample set for each user based on the candidate set and the confidence-weighted false negative sample set for each user. Calculate the comprehensive score of each user, each positive sample, and each hard negative sample in each round of training based on the hard negative sample set of each user to select the optimal hard negative sample.
[0012] S5. Based on the enhanced training set and the selected optimal hard negative sample, calculate the BPR loss for each user, each positive sample, and each hard negative sample to obtain the trained recommendation model.
[0013] S6. Using the trained recommendation model, calculate the preference ratings for all uninteracted items for each user based on the new interaction data, and obtain the recommendation list for each user.
[0014] As a further improvement of the present invention: step S1 includes:
[0015] S101. Collect user-product interaction data to construct user sets, product sets, user-product interaction datasets, positive sample sets for each user, and multiple user sets that have interacted with each product;
[0016] The interaction data consists of user-product interaction logs;
[0017] S102. Measure the collaborative similarity between products based on the set of users who have interacted with each product, and construct a collaborative similarity matrix;
[0018] S103. Construct a normalized graph Laplacian matrix based on the collaborative similarity matrix, and perform eigenvalue decomposition on the normalized graph Laplacian matrix to obtain the spectral embedding matrix;
[0019] S104. Construct a random walk transition matrix based on the collaborative similarity matrix and the degree matrix, and generate a high-order neighbor matrix based on the random walk transition matrix.
[0020] Preferably, step S101 includes:
[0021] S1011. Extract all users from the user-product interaction logs to construct a user set;
[0022] S1012. Extract all products from the user-product interaction logs to construct a product set;
[0023] S1013. Extract users and products that have interacted from the user-product interaction logs to form user-product interaction pairs, and construct a user-product interaction dataset using all user-product interaction pairs.
[0024] S1014. Extract the positive sample set for each user from the user-product interaction log;
[0025] S1015. Extract multiple sets of users who have interacted with each product from the user-product interaction log.
[0026] Preferably, step S103 includes:
[0027] S1031. Calculate the degree matrix based on the collaborative similarity matrix;
[0028] S1032. Calculate the inverse square root of the degree matrix based on the degree matrix;
[0029] S1033. Calculate the normalized graph Laplacian matrix based on the degree matrix and the inverse square root of the degree matrix;
[0030] S1034. Perform eigenvalue decomposition on the normalized graph Laplacian matrix, solve the characteristic equation to obtain multiple eigenvectors, and construct a spectral embedding matrix based on the multiple eigenvectors.
[0031] As a further improvement of the present invention: step S2 includes:
[0032] S201. Use top-down recursion. -means clustering constructs a collaborative structure tree based on the collaborative similarity matrix;
[0033] S202. Use top-down recursion. -means clustering constructs a latent semantic tree based on the spectral embedding matrix;
[0034] S203. Use top-down recursion. -means clustering constructs a higher-order neighbor tree based on a higher-order neighbor matrix;
[0035] S204. Construct the three-tree path code triplet for each product based on the three-tree path code of each product.
[0036] As a further improvement of the present invention: step S3 includes:
[0037] S301. Construct a candidate set for each user based on the product set and the product set that each user has already interacted with;
[0038] S302. Construct a large language model prompt based on the three-tree path encoding of each candidate product;
[0039] S303. Based on the output of the large language model corresponding to all candidate items in each user's candidate set, obtain the confidence-weighted false negative sample set for each user, and calculate the training weights according to the confidence.
[0040] S304. Add the false negative samples from the confidence-weighted false negative sample set of all users to the positive sample set to enhance the training set, thus obtaining the enhanced training dataset.
[0041] Preferably, step S301 includes:
[0042] S3011. Remove the products that the user has interacted with from all products to obtain a set of products that have not been interacted with;
[0043] S3012. Calculate the preference score for each user and each non-interacted item in the user's set of non-interacted items using the existing recommendation model;
[0044] S3013. Sort the preference scores of each user and each user's set of uninteracted products in descending order, and select the 20 products with the highest preference scores as the candidate set; if there are fewer than 20 uninteracted products, select the uninteracted products with preference scores higher than 0.7 to form the candidate set.
[0045] Preferably, step S302 includes:
[0046] S3021. Instructions for constructing a system based on the three-tree path coding of each candidate product;
[0047] S3022. Construct text prompts based on the three-tree path encoding of each candidate product;
[0048] S3023. Input the system commands and text prompts into the large language model, and the large language model will obtain the large language model prompts after reasoning and analysis.
[0049] As a further improvement of the present invention: step S4 includes:
[0050] S401. Remove the items that are judged as false negative samples from the candidate set to obtain a hard negative sample set consisting of multiple true negative samples with the highest training value.
[0051] S402. Calculate the preference score of each candidate item in the hard negative sample set and normalize it on the hard negative sample set to obtain the normalized preference score of each candidate item.
[0052] S403. Calculate the normalized LCP similarity of each tree structure;
[0053] S404. Based on the normalized preference scores of each user and each hard negative sample on each user's hard negative sample set and the normalized LCP similarity of each tree, a multi-view scoring function is constructed to calculate the comprehensive score of each user, each positive sample and each hard negative sample in each round of training.
[0054] S405. Select the highest combined score of each user, each positive sample, and each hard negative sample in each round of training as the optimal hard negative sample.
[0055] The beneficial effects of the present invention are as follows: The recommendation method based on multi-view hierarchical index tree encoding and large language model provided by the present invention has good recommendation accuracy.
[0056] S1 constructs a collaborative similarity matrix, a spectral embedding matrix, and a higher-order proximity matrix to provide a data foundation for subsequent multi-view tree coding, thus realizing the structured information preparation required for three-view complementary enhancement. S2 constructs a collaborative structure tree based on the collaborative similarity matrix, a latent semantic tree based on the spectral embedding matrix, and a higher-order proximity tree based on the higher-order proximity matrix, and generates three-tree path codes for each product, realizing the transformation of interaction patterns into hierarchical paths that LLM can understand without product text descriptions and three-view complementary enhancement.
[0057] S3 constructs a large language model prompt based on the three-tree path encoding of each product, and uses the confidence score output by LLM to weight false negative samples, thus achieving accurate false negative sample identification with confidence weighting, without the need for fine-tuning LLM, reducing training noise caused by judgment uncertainty.
[0058] S4 achieves progressive training through course learning by dynamically adjusting the preference rating weights during training rounds and selecting the best hard negative samples from the candidate set by combining a multi-view rating function, thus avoiding unstable negative sample quality caused by model bias in the early stages of training.
[0059] This results in a well-trained recommendation model with good recommendation accuracy, thus making the method more accurate in recommending recommendations. Attached Figure Description
[0060] Figure 1 This is a schematic diagram of the principle of the present invention. Detailed Implementation
[0061] The specific embodiments of the present invention will be described in further detail below with reference to the accompanying drawings.
[0062] Definitions of relevant terms used in this invention:
[0063] Tree: A hierarchical data structure containing multiple elements, each of which is a node; the root node is the node located at the top of the tree; if a node A is connected to a node B below it, then A is the parent node of B, and B is the child node of A. A parent node can have multiple child nodes; a node without child nodes is a leaf node; the sequence of nodes traversed from the root node to a specific node is a path; an edge is a line connecting two nodes; the number of edges on the path from the root node to a node is the depth, and all nodes with the same depth belong to the same level, with the root node located at level 0;
[0064] like Figure 1 As shown, this invention provides a recommendation method based on multi-view hierarchical index tree encoding and a large language model:
[0065] S1. Collect user-product interaction data, and construct user set, product set, user-product interaction dataset, positive sample set of each user, and multiple user sets that have interacted with each product based on the user-product interaction data. Construct a collaborative similarity matrix based on the multiple user sets that have interacted with each product, construct a spectral embedding matrix based on the collaborative similarity matrix, and construct a high-order neighbor matrix based on the collaborative similarity matrix through random walk.
[0066] S101. Collect user-product interaction data to construct user sets, product sets, user-product interaction datasets, positive sample sets for each user, and multiple user sets that have interacted with each product;
[0067] Interactions include purchasing, clicking, browsing, adding to favorites, or adding to cart;
[0068] The interaction data consists of user-product interaction logs; in the example, it is the purchase records of sports and outdoor products on the Amazon platform from the Amazon-Sports dataset.
[0069] S1011. Extract all users from the user-product interaction logs to construct a user set. ;
[0070] , For the first One user; Index for users; Total number of users;
[0071] S1012. Extract all products from the user-product interaction logs to construct a product set I. ;
[0072] , For the first One product; It serves as both a product index and a row index for the collaborative similarity matrix; The total number of goods;
[0073] S1013. Extract users and products that have interacted from the user-product interaction logs to form user-product interaction pairs, and construct a user-product interaction dataset using all user-product interaction pairs. ;
[0074] Indicates the first The user and the first The first product has interaction, that is, the... User - Number One product interaction pair;
[0075] S1014. Extract the positive sample set for each user from the user-product interaction log;
[0076] No. The positive sample set of each user is represented as: That is, the first The set of products that a user has interacted with; positive samples are the products that have been interacted with. ;
[0077] For example, the set of items that the 5th user has interacted with is represented as , That is, the 5th user purchased the 12th, 45th, 78th, and 203rd items, a total of four items;
[0078] S1015. Extract multiple sets of users who have interacted with each product from the user-product interaction log;
[0079] With the The set of users who have interacted with a product is represented as follows: ;
[0080] Add a new product index , , It is also the column index of the collaborative similarity matrix; it will be related to the first... The set of users who have interacted with a product is represented as follows: ;
[0081] S102. Measure the collaborative similarity between products based on the set of users who have interacted with each product, and construct a collaborative similarity matrix. , ,in, Both the number of rows and the number of columns are A real matrix;
[0082] The Middle Line 1 Column elements Indicates the first The product and the first The collaborative similarity of each product, with a value range of [value range missing]. ; The calculation formula is:
[0083] ,
[0084] In the formula, The cardinality symbol for a set; Intersection symbol; The union symbol;
[0085] Furthermore, the collaborative similarity between the two products is symmetrical, that is... ;when hour, That is, each product has a collaborative similarity of 1 with itself;
[0086] ,
[0087] For example, , That is, a total of 5 users, namely the 1st user, the 3rd user, the 5th user, the 8th user, and the 12th user, purchased the 12th item;
[0088] , That is, the 2nd user, the 3rd user, the 5th user, the 9th user, the 15th user, and the 20th user, a total of 6 users, purchased the 45th item.
[0089] , Then the collaborative similarity between the 12th and 45th items is... ;
[0090] S103. Constructing a normalized graph Laplacian matrix based on the collaborative similarity matrix. The spectral embedding matrix is obtained by performing eigenvalue decomposition on the normalized graph Laplacian matrix. ;
[0091] S1031. Calculate the degree matrix based on the collaborative similarity matrix. , The size is a diagonal matrix;
[0092] Degree matrix Line 1 Column elements The calculation formula is: ;
[0093] when hour, Indicates the first The sum of the collaborative similarity between a product and all products is used to reflect the popularity of the product.
[0094] S1032. Calculate the inverse square root of the degree matrix based on the degree matrix. , It is a diagonal matrix;
[0095] The first square root of the inverse of the degree matrix Line 1 Column elements The calculation formula is:
[0096] ;
[0097] S1033. Calculate the normalized graph Laplacian matrix based on the degree matrix and the inverse square root of the degree matrix. , It is a symmetric matrix with dimension . ;
[0098] The calculation formula is:
[0099] ,
[0100] In the formula, for The identity matrix has 1s on the diagonal and 0s on the rest; The term is an intermediate matrix;
[0101] Normalized graph Laplace matrix Line 1 The elements of the column are ;
[0102] when hour, for The diagonal element, the reaction The degree of connection between an individual product and other products, The larger the value, the more it indicates the first The closer the connection between a product and other products, the smaller the value indicates that the first product is more closely connected to the second product. The fewer connections a product has with other products, the better. The more independent each product is;
[0103] The middle matrix Line 1 Column elements The calculation formula is:
[0104] ;
[0105] This assumes Demonstrating with small-scale examples, because There are four items in total. Considered the first item in the demonstration, Consider it the second product in the demonstration, Considered the third product in the demonstration, It is considered the fourth item in this demonstration and substituted into the calculation;
[0106] but ,
[0107] ,
[0108] ,
[0109] ,
[0110] ,
[0111] ;
[0112] , ,
[0113] , ,
[0114] ;
[0115] The element in the 1st row and 2nd column of the middle matrix:
[0116] ,
[0117] Continuing to calculate all elements of the intermediate matrix, we get:
[0118] ;
[0119] ;
[0120] S1034. Perform eigenvalue decomposition on the normalized graph Laplacian matrix, solve the characteristic equation to obtain multiple eigenvectors, and construct a system based on these eigenvectors. spectral embedding matrix ;
[0121] for Symmetric matrix In this regard, there exist orthogonal matrices. With diagonal matrix Make:
[0122] ,
[0123] ,
[0124] In the formula, This is a shorthand operator for diagonal matrices; For the first The eigenvalues of a row are scalars, which are solutions to the characteristic equation and are used to reflect the connectivity of the graph. The smaller the value, the more smoothly the corresponding eigenvector changes on the graph, capturing the global structure. A value close to 0 indicates that the graph is nearly connected in that direction.
[0125] ,
[0126] In the formula, For the first The eigenvectors corresponding to the eigenvalues of a row have a size of Its elements are the coordinates of each commodity on the structural pattern; the eigenvectors corresponding to the eigenvalues of each row are orthogonal and represent different structural patterns respectively.
[0127] The characteristic equation is: ;
[0128] (1) Let the matrix Solve for the case where the determinant is equal to zero. ,get The eigenvalues are represented as:
[0129] ,
[0130] In the formula, This refers to matrix determinant operations, used here to construct the characteristic polynomial and solve the characteristic equation.
[0131] (2) Solve the homogeneous equation for each eigenvalue (i.e., the eigenvectors corresponding to each eigenvalue);
[0132] The homogeneous equation is: ;
[0133] (3) After arranging all eigenvalues from smallest to largest, select the smallest one. The eigenvectors corresponding to the non-zero eigenvalues are arranged in ascending order of eigenvalues, and multiple eigenvectors are used as columns to form a series. ;
[0134] The calculation formula is:
[0135] ,
[0136] In the formula, To select the smallest The eigenvectors corresponding to the non-zero eigenvalues are arranged in ascending order of eigenvalues to form a matrix; As an embedded dimension, it can be set , Much less than the total number of goods;
[0137] S104. Construct a random walk transition matrix based on the collaborative similarity matrix and the degree matrix. Generate higher-order neighbor matrix ;
[0138] The calculation formula is: ,
[0139] In the formula, The inverse of the similarity matrix is used to perform row normalization on the similarity matrix to obtain the transition probabilities;
[0140] The first random walk transition matrix Line 1 The elements of a column are represented as ;
[0141] The dimension is , The calculation formula is:
[0142] ,
[0143] In the formula, The walk attenuation coefficient controls the retention probability at each walk step; a larger value indicates a greater indirect relationship between the capture distance and the walk's distance. It can be set as follows: ; For the step count index, , This represents the total number of steps taken. The wander attenuation coefficient Power; For the transition matrix Power of;
[0144] In the higher-order neighbor matrix, the first Line 1 The elements of a column are represented as The diagonal element is the largest because the first element is the largest. The probability of a product returning to itself is the highest. and Reaction number The product and the first The strength of the indirect association between two products through intermediate products; the higher the value of the off-diagonal element, the more it indicates that the two products are not only directly similar, but can also reach each other through intermediate products;
[0145] S2. After constructing a collaborative tree structure based on the collaborative similarity matrix, a latent semantic tree based on the spectral embedding matrix, and a high-order neighbor tree based on the high-order neighbor matrix, a three-tree path code is generated for each product; the three-tree path code includes collaborative tree path code, latent semantic tree path code, and high-order neighbor tree path code.
[0146] S201. Use top-down recursion. -means clustering constructs a collaborative structure tree based on the collaborative similarity matrix;
[0147] S2011. Use the collaborative similarity matrix as input;
[0148] S2012. Settings The number of clusters in -means clustering is , It is also a collaborative branching factor in the collaborative tree structure, which can be set as follows: Based on the behavioral features of the collaborative similarity matrix, the products are divided into categories. Clusters, Each cluster is the result of the first-level clustering, and each cluster is a child node of the root node;
[0149] S20121. Extracting the first step of the collaborative similarity matrix. OK As the first Collaborative feature vectors of individual products Complete feature extraction; Encoded the first Collaborative similarity relationship between a product and all other products;
[0150] ;
[0151] S20122. Randomly select from all items in the item set. Each product is used as the initial collaborative cluster center to achieve the initialization of the cluster center;
[0152] The initial set of co-cluster centers is represented as:
[0153] ,
[0154] In the formula, An index for clusters in collaborative clustering; For the first Each co-cluster center is a vector;
[0155] S20123. Calculate the Euclidean distance from each product to each co-cluster center, and assign each product to the nearest cluster to achieve iterative allocation;
[0156] No. The item to the first Euclidean distance between co-cluster centers The calculation formula is:
[0157]
[0158] In the formula, It is an L2 norm; For the first The first collaborative clustering center One component;
[0159] No. The cluster number to which each product belongs during the collaborative clustering process. The calculation formula is:
[0160] ,
[0161] In the formula, To find the expression that minimizes value;
[0162] S20124. For each cluster, update its co-cluster center to the mean of all product feature vectors within that cluster;
[0163] The updated version Collaborative clustering centers The calculation formula is:
[0164]
[0165] In the formula, For the first A collaborative cluster, where the elements of the cluster are goods;
[0166] S20125. Repeat S20123~S20124 until the cluster centers no longer change or the maximum number of iterations is reached, to obtain the first-level clustering results;
[0167] The maximum number of iterations can be set to 100.
[0168] S2013. Starting from the first-level clustering results, determine whether the total number of items in each cluster of each level of clustering results is greater than the capacity of the collaborative leaf nodes. If it is greater than, then keep With the value unchanged, perform S2012 on clusters where the total number of items is greater than the capacity of the collaborative leaf nodes to obtain the clustering results of the next layer. Repeat the above process until the total number of items in each cluster of the next layer is less than or equal to the value of the clustering results. , can be set ;
[0169] For example, the results of the first-level clustering include , , , , There are 2200 items, all belonging to team sports equipment; There are 2,000 items, all belonging to the category of fitness training equipment; There are 2,150 items, all belonging to outdoor sports products; There are 2089 items, belonging to sportswear accessories;
[0170] After judgment, clustering is performed. For the 0th co-cluster cluster, the th Clusters, The second-level clustering results include , , , ; There are 580 items, all belonging to ball sports; There are 520 items, all of which are protective gear; There are 550 items, which belong to training aids; There are 550 items, all belonging to team sportswear;
[0171] S2014. Calculate the collaborative structure tree path code for each product based on the collaborative structure tree;
[0172] No. Collaborative structure tree path encoding for each product The calculation formula is:
[0173] ,
[0174] In the formula, For the path in the collaborative structure tree The node identifier of a layer is a non-negative integer, and different child nodes under the same parent node have different numbers; This is the index of the layer number in the collaborative structure tree path. , The depth of the collaborative structure tree, i.e., the length of the path, depends on and , ;
[0175] For example, the collaborative structure tree path encoding for the 12th item is: ,but , represents the root node (i.e., all products in the product set). This indicates that the first-level clustering result for the 12th item is... , Representative team sports equipment; This indicates that the first-level clustering result for the 12th item is... , Representing ball sports, Represents a leaf node.
[0176] S202. Use top-down recursion. -means clustering constructs a latent semantic tree based on the spectral embedding matrix;
[0177] S2021. Use the spectral embedding matrix as input;
[0178] S2022. Settings The number of clusters in -means clustering is , It is also a latent semantic branching factor of the latent semantic tree, which can be set as follows: Using the characteristics of each behavior in the spectral embedding matrix, all products in the product set are divided into... Clusters, Each cluster represents the result of the first-level clustering.
[0179] S20221. Extracting the first spectral embedding matrix OK As the first Latent semantic feature vector of each product ;
[0180] ;
[0181] In the formula, For the column index of the spectral embedding matrix; The first spectral embedding matrix Line number Column elements;
[0182] S20222. Randomly select from all items in the item set. Each product serves as an initial potential semantic cluster center;
[0183] The initial set of latent semantic cluster centers is represented as follows:
[0184] ,
[0185] In the formula, An index for clusters of latent semantic clustering; For the first Each potential semantic cluster center is a vector;
[0186] S20223. Calculate the Euclidean distance from each item to each potential semantic cluster center, and assign each item to the cluster with the closest distance;
[0187] No. The item to the first Euclidean distance between cluster centers The calculation formula is:
[0188] ,
[0189] In the formula, For the first The first latent semantic cluster center One component;
[0190] No. The cluster number to which each product belongs during the latent semantic clustering process. The calculation formula is:
[0191] ,
[0192] In the formula, To find the expression that minimizes ;
[0193] S20224. For each cluster, update its latent semantic cluster center to the mean of all product feature vectors within that cluster;
[0194] The updated version Potential semantic cluster centers The calculation formula is:
[0195]
[0196] In the formula, For the first Clusters of potential semantic clusters;
[0197] S20225. Repeat S20223~S20224 until the cluster centers no longer change or the maximum number of iterations is reached, to obtain the first-level clustering results;
[0198] The maximum number of iterations can be set to 100.
[0199] S2023. Starting from the first-level clustering results, determine whether the total number of items in each cluster of each level of clustering results is greater than the capacity of the latent semantic leaf nodes. If it is greater than, then keep With the value unchanged, perform S2022 on clusters where the total number of items is greater than the capacity of the latent semantic leaf nodes to obtain the clustering results of the next layer. Repeat the above process until the total number of items in each cluster of the next layer is less than or equal to the value of the clustering results. , can be set ;
[0200] S2024. Calculate the latent semantic tree path code for each product based on the latent semantic tree;
[0201] No. The formula for calculating the latent semantic tree path encoding of a product is:
[0202] ,
[0203] In the formula, For the first in the path The node identifier of the layer is a non-negative integer; This is an index of the level in the latent semantic tree path. , The depth of the latent semantic tree;
[0204] S203. Use top-down recursion. -means clustering constructs a higher-order neighbor tree based on a higher-order neighbor matrix;
[0205] S2031. Use the higher-order neighbor matrix as input;
[0206] S2032. Settings The number of clusters in -means clustering is , It is also a higher-order branching factor in a higher-order neighbor tree, which can be set as follows: Using the characteristics of each behavior in the spectral embedding matrix, all products in the product set are divided into... Clusters, Each cluster represents the result of the first-level clustering.
[0207] S20321. Extracting the first high-order neighbor matrix OK As the first High-order feature vector of each product ;
[0208] ;
[0209] S20322. Randomly select from all items in the item set. Each product serves as the initial high-order cluster center;
[0210] The initial set of higher-order cluster centers is represented as:
[0211] ,
[0212] In the formula, For indexes of clusters in higher-order clustering; For the first A high-order cluster center;
[0213] S20323. Calculate the Euclidean distance from each product to each higher-order cluster center, and assign each product to the cluster with the closest distance;
[0214] No. The item to the first Euclidean distance of the high-order cluster centers The calculation formula is:
[0215] ,
[0216] In the formula, For the first The first high-order cluster center One component;
[0217] No. The cluster number to which each product belongs during the high-order clustering process. The calculation formula is:
[0218] ,
[0219] In the formula, Take the expression that minimizes the value. ;
[0220] S20324. For each cluster, update its higher-order cluster centers to the mean of all product feature vectors within that cluster;
[0221] The updated version High-order cluster centers The calculation formula is:
[0222]
[0223] In the formula, For the first A cluster of higher-order clusters;
[0224] S20325. Repeat S20323~S20324 until the cluster centers no longer change or the maximum number of iterations is reached to obtain the first-level clustering results;
[0225] The maximum number of iterations can be set to 100.
[0226] S2033. Starting from the first-level clustering results, determine whether the total number of items in each cluster of each level of clustering results is greater than the capacity of the higher-order leaf nodes. If it is greater than, then keep With the value unchanged, perform S2032 on clusters where the total number of items is greater than the capacity of the higher-order leaf nodes to obtain the clustering results of the next layer. Repeat the above process until the total number of items in each cluster of the next layer is less than or equal to the value of the next layer clustering results. , can be set ;
[0227] S2034. Calculate the higher-order neighbor tree path code for each product based on the higher-order neighbor tree;
[0228] No. High-order nearest neighbor tree path encoding of each product The calculation formula is:
[0229] ,
[0230] In the formula, The path in the higher-order neighbor tree is the first Layer node identifiers; This is an index of the level in the path of a higher-order neighbor tree. , The depth of the higher-order neighbor tree;
[0231] S204. Construct the three-tree path code triplet for each product based on the three-tree path code of each product;
[0232] No. The triplet representation of the three-tree path encoding of a product is as follows: ;
[0233] S3. Construct candidate sets for each user based on multiple sets of users who have interacted with each product. Construct large language model (LLM) prompts based on the three-tree path codes of each candidate product in each user's candidate set. Obtain confidence-weighted false negative sample sets for each user based on the LLM prompts. Use the confidence-weighted false negative sample sets for each user to augment the training set, thus obtaining the augmented training set.
[0234] S301. Construct a candidate set for each user based on the product set and the product set that each user has already interacted with;
[0235] S3011. Remove the products that the user has interacted with from all products to obtain a set of products that have not been interacted with;
[0236] No. A collection of uninteractive items for a single user The calculation formula is:
[0237] ,
[0238] In the formula, This is the set difference operator;
[0239] ;
[0240] For example, , ;
[0241] S3012. Use the existing recommendation model to calculate the preference score of each user and each non-interactive item in the user's non-interactive item set. The preference score ranges from [0 to 1]. The higher the preference score, the higher the user's preference for the non-interactive item is considered by the existing recommendation model.
[0242] Existing recommendation models include matrix factorization models, etc.
[0243] No. The user and the first The first in the user's collection of uninteracted items Preference ratings for products that have not been interacted with The calculation formula is:
[0244] ,
[0245] In the formula, For the first The index of the uninteractive items in the set of uninteractive items for each user. , For the first The total number of uninteracted items in a user's set of uninteracted items; For the first The embedding vectors of each user are obtained through pre-training. ; For the first The embedding vectors of non-interactive products are obtained through pre-training. ;
[0246] S3013. Sort the preference scores of each user and each user's set of non-interactive products in descending order, and select the 20 products with the highest preference scores as the candidate set; if there are fewer than 20 non-interactive products, select the non-interactive products with preference scores higher than 0.7 to form the candidate set.
[0247] No. The candidate set for each user is represented as follows: ;
[0248] S302. Construct a large language model prompt based on the three-tree path encoding of each candidate product;
[0249] S3021. Instructions for constructing a system based on the three-tree path encoding of each candidate product. The system instructions include task description, hierarchical latent semantic interpretation of the three-tree path encoding, classification judgment criteria, and confidence output format requirements, which are predefined fixed texts.
[0250] For the first The index of candidate items in the candidate set for each user. , For the first The total number of candidate items in the candidate set for each user;
[0251] S3022. Construct a text prompt based on the three-tree path code of each candidate product. The text prompt contains the three-tree path code information of the user's interacted products and candidate products.
[0252] No. The user and the first Text prompts for candidate products The calculation formula is:
[0253] ,
[0254] In the formula, For the first The index of the interacted products in the set of interacted products for each user. , The total number of interacted items in the set of interacted items for the u-th user;
[0255] The item is the first The set of three-tree path codes for all products interacted with by a user is traversed. The path codes for each product are collected to obtain the data. The item is the first The three-tree path encoding triples of each candidate product are used as product information to be judged.
[0256] S3023. Input the system commands and text prompts into the large language model. After reasoning and analysis, the large language model prompts are obtained, which are the outputs of the large language model.
[0257] No. The user and the first The large language model output of each candidate product The calculation formula is:
[0258] ,
[0259] In the formula, For LLM to the first The user and the first The predicted label for the candidate product is essentially a prediction of the first candidate product. The candidate product is for the first The determination of whether an individual user is a false negative sample Values or , These are false negative samples. These are true negative samples; For LLM to the first The user and the first The confidence level of the predicted labels for each candidate product. The higher the value, the more certain the LLM is about the predicted label. It can be obtained by parsing the logits output of the LLM or by requiring the LLM to explicitly output the confidence score. This is the inference function for a large language model, which can be an Llama3-8b model.
[0260] S303. Based on the output of the large language model corresponding to all candidate items in each user's candidate set, obtain the confidence-weighted false negative sample set for each user, so as to identify all false negative samples from each user's candidate set and calculate the training weights according to the confidence.
[0261] No. Confidence-weighted false negative sample set for each user The calculation formula is:
[0262] ,
[0263] In the formula, This is a false negative sample identification function, implemented by a large language model. The input is a set of users and candidate items, and the output is a subset of false negative samples and their confidence weights. For the first The first user's Training weights for each false negative sample; For each item-weighted pair, there are elements of the confidence-weighted spurious negative sample set.
[0264] The calculation formula is:
[0265] ,
[0266] In the formula, The confidence threshold can be set as follows: False negative samples with a confidence level below the confidence threshold have their training weights reset to zero and are not added to the training set to avoid introducing noise from low-confidence judgments.
[0267] S304. Add the false negative samples from the confidence-weighted false negative sample set of all users to the positive sample set to augment the training set, resulting in the augmented training dataset. This expands the positive samples and alleviates the negative sampling bias problem in the recommendation system;
[0268] The calculation formula is:
[0269] ,
[0270] In the formula, This is the training set portion of the user-product interaction dataset;
[0271] S4. Construct a hard negative sample set for each user based on the candidate set and the confidence-weighted false negative sample set for each user. Calculate the comprehensive score of each user, each positive sample, and each hard negative sample in each round of training based on the hard negative sample set of each user to select the optimal hard negative sample.
[0272] S401. Remove the items that are judged as false negative samples from the candidate set to obtain a hard negative sample set consisting of multiple true negative samples with the highest training value.
[0273] No. The hard negative sample set of each user is represented as follows: ;
[0274] S402. Calculate the preference score of each candidate item in the hard negative sample set and normalize it on the hard negative sample set to obtain the normalized preference score of each candidate item.
[0275] Normalization is performed as a minimum-maximum normalization.
[0276] In the Normalized on the hard negative sample set of each user The user and the first Preference scores for each hard negative sample The calculation formula is:
[0277] ,
[0278] In the formula, For the first Index of hard negative samples in the hard negative sample set for each user , For the first The total number of hard negative samples in the hard negative sample set of each user; For the first The user and the first The preference score for each hard negative sample is a scalar. In the first Min-max normalization on the hard negative sample set of n users is used to transform the nth user into the nth user. The user and the first Preference scores for each hard negative sample are mapped to ; To distinguish from The Index of hard negative samples in the hard negative sample set for each user; In the first The minimum value of the preference scores of each user and each hard negative sample in the hard negative sample set of each user; In the first The maximum value of each user's preference rating with each hard negative sample in the hard negative sample set of each user; The item is the first The range of preference ratings between each user and each hard negative sample in the hard negative sample set of each user;
[0279] S403. Calculate the normalized LCP (Normalized Longest Common Prefix) similarity of each tree structure to define the hierarchical similarity measure between products;
[0280] No. The positive sample and the first Between hard negative samples Tree-normalized LCP similarity The range of values is 1 indicates that the paths are exactly the same, and 0 indicates that there is no common prefix. The calculation formula is:
[0281] ,
[0282] In the formula, For tree structure category index, , The tree structure category is collaborative structure. The tree structure category represents latent semantics. The tree structure category is represented by higher-order neighbor; For the first The index of positive samples in the positive sample set of each user. M is the first The total number of positive samples in the positive sample set of each user; The length of the subsequence, i.e., the number of node identifiers to be taken, is a variable; For the first A number of positive samples Tree path encoding before A subsequence composed of node identifiers; For the first One hard negative sample Tree path encoding before A subsequence composed of node identifiers; For the first A number of positive samples Tree path encoding; For the first One hard negative sample Tree path encoding;
[0283] The term is the length of the longest common prefix, i.e., satisfying the first... The largest number of nodes with all identifiers equal value;
[0284] S404. Based on the normalized preference scores of each user and each hard negative sample on each user's hard negative sample set and the normalized LCP similarity of each tree, a multi-view scoring function is constructed to calculate the comprehensive score of each user, each positive sample, and each hard negative sample in each round of training. The multi-view scoring function integrates preference prediction and three-tree LCP similarity, and dynamically adjusts the scoring weight through a course learning strategy. The course learning strategy is to focus on easily distinguishable negative samples in the early stage of training, and gradually increase the sampling ratio and scoring weight of hard negative samples as training progresses, so as to achieve a gradual increase in difficulty.
[0285] No. In the first round of training The user, the The positive sample and the first positive sample The combined score of each hard negative sample The larger the value, the more it indicates the first... The higher the quality of a hard negative sample, the better. The calculation formula is:
[0286] ,
[0287] In the formula, For each training round, start counting from 1; The course learning weight function controls the contribution of the model's preference score to gradually increase with each training round; For the similarity weights of the collaborative structure tree, we can set... ; For the similarity weights in the latent semantic tree, we can set... ; For the similarity weights of a higher-order neighbor tree, we can set... ;
[0288] The calculation formula is:
[0289] ,
[0290] In the formula, As the initial value for the preference rating weights, we can set... In the early stages of training, the weight of preference scores is reduced to avoid scoring bias before the model has converged. The final value of the preference rating weight can be set as follows: The preference score weights are restored to their full extent during the later stages of training. The preset number of rounds can be set. Within this number of rounds from Growth to ;
[0291] S405. Select the highest combined score of each user, each positive sample, and each hard negative sample in each round of training as the optimal hard negative sample. ;
[0292] The calculation formula is:
[0293] ;
[0294] S406. In order to enhance the representation capability of hard negative samples, the Mixup strategy is adopted to interpolate and generate enhanced embeddings of each hard negative sample in the embedding space;
[0295] No. Augmented embeddings of hard negative samples The dimension is , can be set , The calculation formula is:
[0296] ,
[0297] In the formula, For Mixup interpolation coefficients, from a uniform distribution Random sampling is performed, with each training batch sampling independently, so that the augmentation embedding is randomly interpolated between positive and negative samples; For the first The embedding vectors of n positive samples, with dimension n It is learned from the recommendation model; For the first The embedding vectors of each hard negative sample are learned by the recommendation model;
[0298] S5. Based on the enhanced training set and the selected optimal hard negative sample, calculate the BPR loss for each user, each positive sample, and each hard negative sample to obtain the trained recommendation model.
[0299] S501. Calculate the BPR loss for each user, each positive sample, and each hard negative sample to obtain the trained recommendation model;
[0300] No. The user, the The positive sample and the first positive sample BPR loss for each hard negative sample The calculation formula is:
[0301] ,
[0302] In the formula, For the first A positive sample score; For the first The scores of hard negative samples are close to the scores of positive samples; The Sigmoid activation function is used to activate the th... The positive sample score and the first The difference between the scores of each hard negative sample is mapped to the interval (0,1);
[0303] S502. Perform iterative optimization after the first round of training is completed;
[0304] The iterative optimization involves keeping the collaborative tree structure unchanged after each training round, reconstructing the latent semantic tree and higher-order neighbor tree using the updated model embedding, generating updated three-tree path codes for each product, and re-executing S3 based on the updated three-tree path codes for each product to obtain an updated augmented training set. Since the clustering affiliation of some products may change, the judgment results and confidence of LLM are adjusted accordingly. S501 is executed based on the updated augmented training set until the model converges.
[0305] Model convergence occurs when the change in the validation set NDCG@20 is less than the preset convergence threshold or the maximum number of iterations is reached after two consecutive rounds of optimization. The preset convergence threshold can be set to 0.001 and the maximum number of iterations can be set to 3.
[0306] S6. Using the trained recommendation model, calculate the preference ratings for all uninteracted items for each user based on the new interaction data, and obtain the recommendation list for each user.
[0307] The recommended list includes all of the user's uninterrupted products, sorted in descending order of the user's preference rating for all uninterrupted products.
[0308] For example, the top ten uninterrupted items in the recommendation list of the fifth user mentioned above are shown in Table 1:
[0309] Table 1
[0310] 1 33 0.95 2 301 0.93 3 1200 0.91 4 89 0.89 5 56 0.87 6 412 0.85 7 678 0.83 8 112 0.81 9 834 0.79 10 456 0.77
Claims
1. A recommendation method based on multi-view hierarchical index tree encoding and a large language model, characterized in that, include: S1. Based on the user-product interaction data, construct user sets, product sets, user-product interaction datasets, positive sample sets for each user, and multiple sets of users who have interacted with each product. Construct a collaborative similarity matrix based on the multiple sets of users who have interacted with each product. Construct a spectral embedding matrix based on the collaborative similarity matrix. Construct a high-order proximity matrix based on the collaborative similarity matrix. S2. After constructing a collaborative structure tree based on the collaborative similarity matrix, a latent semantic tree based on the spectral embedding matrix, and a high-order neighbor tree based on the high-order neighbor matrix, a three-tree path code is generated for each product. Three-tree path coding includes collaborative tree path coding, latent semantic tree path coding, and higher-order neighbor tree path coding; S3. Construct candidate sets for each user based on multiple sets of users who have interacted with each product. Construct large language model prompts based on the three-tree path codes of each candidate product in each user's candidate set. Obtain confidence-weighted false negative sample sets for each user based on the large language model prompts. Use the confidence-weighted false negative sample sets for each user to augment the training set, thus obtaining the augmented training set. S4. Construct a hard negative sample set for each user based on the candidate set and the confidence-weighted false negative sample set for each user. Calculate the comprehensive score of each user, each positive sample, and each hard negative sample in each round of training based on the hard negative sample set of each user to select the optimal hard negative sample. S5. Based on the enhanced training set and the selected optimal hard negative sample, calculate the BPR loss for each user, each positive sample, and each hard negative sample to obtain the trained recommendation model. S6. Using the trained recommendation model, calculate the preference ratings for all uninteracted items for each user based on the new interaction data, and obtain the recommendation list for each user.
2. The recommendation method based on multi-view hierarchical index tree encoding and a large language model according to claim 1, characterized in that, The steps in S1 include: S101. Collect user-product interaction data to construct user sets, product sets, user-product interaction datasets, positive sample sets for each user, and multiple user sets that have interacted with each product; The interaction data consists of user-product interaction logs; S102. Measure the collaborative similarity between products based on the set of users who have interacted with each product, and construct a collaborative similarity matrix; S103. Construct a normalized graph Laplacian matrix based on the collaborative similarity matrix, and perform eigenvalue decomposition on the normalized graph Laplacian matrix to obtain the spectral embedding matrix; S104. Construct a random walk transition matrix based on the collaborative similarity matrix and the degree matrix, and generate a high-order neighbor matrix based on the random walk transition matrix.
3. The recommendation method based on multi-view hierarchical index tree encoding and a large language model according to claim 2, characterized in that, The steps in S101 include: S1011. Extract all users from the user-product interaction logs to construct a user set; S1012. Extract all products from the user-product interaction logs to construct a product set; S1013. Extract users and products that have interacted from the user-product interaction logs to form user-product interaction pairs, and construct a user-product interaction dataset using all user-product interaction pairs. S1014. Extract the positive sample set for each user from the user-product interaction log; S1015. Extract multiple sets of users who have interacted with each product from the user-product interaction log.
4. The recommendation method based on multi-view hierarchical index tree encoding and a large language model according to claim 2, characterized in that, The steps in S103 include: S1031. Calculate the degree matrix based on the collaborative similarity matrix; S1032. Calculate the inverse square root of the degree matrix based on the degree matrix; S1033. Calculate the normalized graph Laplacian matrix based on the degree matrix and the inverse square root of the degree matrix; S1034. Perform eigenvalue decomposition on the normalized graph Laplacian matrix, solve the characteristic equation to obtain multiple eigenvectors, and construct a spectral embedding matrix based on the multiple eigenvectors.
5. The recommendation method based on multi-view hierarchical index tree encoding and a large language model according to claim 1, characterized in that, Step S2 includes: S201. Use top-down recursion. -means clustering constructs a collaborative structure tree based on the collaborative similarity matrix; S202. Use top-down recursion. -means clustering constructs a latent semantic tree based on the spectral embedding matrix; S203. Use top-down recursion. -means clustering constructs a higher-order neighbor tree based on a higher-order neighbor matrix; S204. Construct the three-tree path code triplet for each product based on the three-tree path code of each product.
6. The recommendation method based on multi-view hierarchical index tree encoding and a large language model according to claim 1, characterized in that, The steps in S3 include: S301. Construct a candidate set for each user based on the product set and the product set that each user has already interacted with; S302. Construct a large language model prompt based on the three-tree path encoding of each candidate product; S303. Based on the output of the large language model corresponding to all candidate items in each user's candidate set, obtain the confidence-weighted false negative sample set for each user, and calculate the training weights according to the confidence. S304. Add the false negative samples from the confidence-weighted false negative sample set of all users to the positive sample set to enhance the training set, thus obtaining the enhanced training dataset.
7. The recommendation method based on multi-view hierarchical index tree encoding and a large language model according to claim 6, characterized in that, The steps in S301 include: S3011. Remove the products that the user has interacted with from all products to obtain a set of products that have not been interacted with; S3012. Calculate the preference score for each user and each non-interacted item in the user's set of non-interacted items using the existing recommendation model; S3013. Sort the preference scores of each user and each user's set of uninteracted products in descending order, and select the 20 products with the highest preference scores as the candidate set; if there are fewer than 20 uninteracted products, select the uninteracted products with preference scores higher than 0.7 to form the candidate set.
8. The recommendation method based on multi-view hierarchical index tree encoding and large language model according to claim 6, characterized in that, The steps in S302 include: S3021. Instructions for constructing a system based on the three-tree path coding of each candidate product; S3022. Construct text prompts based on the three-tree path encoding of each candidate product; S3023. Input the system commands and text prompts into the large language model, and the large language model will obtain the large language model prompts after reasoning and analysis.
9. The recommendation method based on multi-view hierarchical index tree encoding and large language model according to claim 1, characterized in that, The steps in S4 include: S401. Remove the items that are judged as false negative samples from the candidate set to obtain a hard negative sample set consisting of multiple true negative samples with the highest training value. S402. Calculate the preference score of each candidate item in the hard negative sample set and normalize it on the hard negative sample set to obtain the normalized preference score of each candidate item. S403. Calculate the normalized LCP similarity of each tree structure; S404. Based on the normalized preference scores of each user and each hard negative sample on each user's hard negative sample set and the normalized LCP similarity of each tree, a multi-view scoring function is constructed to calculate the comprehensive score of each user, each positive sample and each hard negative sample in each round of training. S405. Select the highest combined score of each user, each positive sample, and each hard negative sample in each round of training as the optimal hard negative sample.