A fast collaborative filtering method based on hash metric learning
By employing a fast collaborative filtering method based on hash metric learning, user and item features are mapped to a hash encoding space, solving the problems of inaccurate capture of user preference information and overfitting in existing recommendation systems, and achieving higher accuracy and faster online recommendations.
Patent Information
- Application Number
- CN202210431989.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-22
- Publication Date
- 2026-01-27
- Estimated Expiration
- 2042-04-22
AI Technical Summary
Existing matrix factorization-based recommendation systems suffer from problems such as not satisfying the triangle inequality when capturing user preference information, making it difficult to accurately capture user preference information. Furthermore, they are prone to overfitting when user-item interaction data is sparse, and existing metric learning methods cannot effectively utilize the relationship between positive and negative samples.
A fast collaborative filtering method based on hash metric learning is adopted. By constructing a hash model, user and item features are mapped to the hash-encoded Hamming space. The method optimizes user and item features and generates a recommendation list by optimizing the objective function and loss function, including triple loss and pair ranking loss.
It improves the accuracy and real-time performance of recommendations, and can extract more personalized user preference information, outperforming existing implicit recommendation models.
Smart Images

Figure CN114861048B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of collaborative filtering technology, specifically relating to a fast collaborative filtering method based on hash metric learning. Background Technology
[0002] With the continuous development and popularization of internet technology and the arrival of the big data era, a vast amount of information resources are generated online every moment. Users can obtain a large amount of information through various channels, such as text, images, music, and videos, to find information that meets their needs. This massive amount of information brings people immense convenience, but it makes it difficult to quickly extract the information they want, making the acquisition of valuable information extremely difficult. Therefore, solving this "information overload" problem has become paramount, and the emergence of recommendation systems has alleviated this problem. Users typically use search engines to obtain the information they want; however, this method only achieves good results when the user's goals and needs are precisely defined. Recommendation systems, on the other hand, can analyze users' historical behavior, uncover their interests and preferences, and help users discover their implicit needs, thereby effectively filtering information and providing personalized recommendations.
[0003] Recommender systems are divided into two main categories based on the different types of information they utilize: (1) explicit models that utilize diverse and rich information such as user interaction information, user information, item information, and comment information; and (2) implicit modeling methods that utilize only user and item interaction information. Explicit models have achieved great success in online recommender systems, but due to the difficulty and high cost of obtaining user information, item information, and comment information, how to model using only implicit information remains one of the hot topics in recommender systems today.
[0004] Generally, there are two methods for estimating user preference differences based on implicit feedback: 1) Recommender systems based on learning to rank (LTR), including pair-wise LTR and list-wise LTR. 2) Recommender systems based on metric learning.
[0005] In pair-wise LTR-based recommender systems, Bayesian Personalized Ranking (BPR) and its variants are representative, proposed to accelerate convergence when item popularity exhibits a long-tailed distribution.
[0006] In list-wise LTR recommendation methods, CoFi-Rank is a representative example, which optimizes the ranking in an objective way, inspired by the idea of Maximum Marginal Matrix Factorization (MMMF). Meanwhile, Yue et al. proposed ListCF, whose important advantage lies in its ability to reduce the computational complexity of the training and prediction processes while achieving the same or better ranking performance as previous memory-based ranking-oriented CF algorithms.
[0007] Ranking-based recommendations can learn the distinguishable features of users for items through pair-wise LTR and list-wise LTR loss functions, thereby learning the differences in user preferences for items. However, their frameworks are based on the idea of matrix factorization, but because they do not satisfy the triangle inequality, they cannot accurately capture user preference information.
[0008] To address the limitations of MF-based methods, metric learning methods that satisfy the triangle inequality have been introduced into recommender systems. These methods project users and items into a low-dimensional metric space where user preferences are estimated by the distance between items. Collaborative Metric Learning (CML) first integrates metric learning into the recommender system, which determines the relative preferences of users for two items through a Triple Hinge Loss. CML can provide more accurate recommendations than BPR. However, CML has two limitations: (1) CML does not consider the relationship between positive and negative items, which hinders the capture of more information on the differences in positive and negative item preferences. (2) CML assumes that all users and items share the same fixed boundary m, which is not suitable for personalized recommendations.
[0009] To address the aforementioned issues, latent relational metric learning (LRML) incorporates memory networks to introduce additional preference discrepancies to learn the relationships between users and items. Symmetric metric learning with adaptive margin (SML), which considers positive and negative sample relationships, provides an adaptive margin learning method for different users and items, but it is prone to overfitting when user-item interaction data is very sparse. However, using absolute geometric distance to estimate user preferences for items with different within-class variances is inappropriate because absolute geometric distance is easily affected by the data class distribution and cannot learn the differences in user preferences for items across different classes. Summary of the Invention
[0010] To address the aforementioned problems, this invention proposes a fast collaborative filtering method based on hash metric learning.
[0011] The technical solution of this invention is: a fast collaborative filtering method based on hash metric learning, comprising the following steps:
[0012] S1: Collect user data and user ratings of items, and perform data cleaning and data segmentation;
[0013] S2: Initialize parameters for user data and rating data after data cleaning and data segmentation;
[0014] S3: Construct a hash model;
[0015] S4: Perform feature optimization on user data features and rating data features;
[0016] S5: Based on the feature optimization results, use the user data and rating data after parameter initialization to iteratively train the hash model until convergence, obtain the user's interest value for the item, and generate a recommendation list.
[0017] Furthermore, in step S1, the specific method for data cleaning is as follows: filter user data and rating data with an interaction quantity greater than a set interaction threshold, and filter user data and rating data containing missing values.
[0018] The specific method for data segmentation is as follows: the data is segmented according to a set ratio, and in the rating data, the rating data for items that users have rated is set to 1, and the rating data for items that users have not rated is set to 0.
[0019] Furthermore, in step S2, the specific method for parameter initialization is as follows: the user data features and rating data features are randomly initialized with a normal distribution using 0 as the mean and 0.5 as the variance.
[0020] Furthermore, in step S3, the optimization objective function of the hash model... The expression is:
[0021]
[0022] Where U represents the hash characteristics of all users, and V represents the hash characteristics of all items. This represents the loss function for pairwise sorting. This represents the loss function for metric learning. This represents a hyperparameter that measures the importance of the two loss functions.
[0023] Furthermore, in step S4, the objective function for optimizing user data features is:
[0024]
[0025] Among them, u iC represents the hash characteristics of user i. i Let d represent a d*d dimensional constant matrix, where d i Let represent a d-dimensional constant vector, where d represents the dimension of the constant vector and the constant matrix;
[0026] The objective function for optimizing the rating data is:
[0027]
[0028] Among them, v j C represents the d-dimensional hash feature of an item. j Let d represent a d*d dimensional constant matrix, where d j Let represent a d-dimensional constant vector.
[0029] Further, in step S5, the user data and rating data after parameter initialization are used as the initial values for iterative training. The hash model is iteratively trained according to the feature optimization results until convergence, obtaining the feature matrix of the user data and rating data. The inner product operation is performed on the feature matrix to obtain the user's interest value for the item, and a recommendation list is generated based on the user's interest value for the item. The formula for calculating the inner product operation is as follows: In the formula, r represents the predicted score, u i Represents the user's hash characteristics, v j Represents the hash characteristics of an item.
[0030] The beneficial effects of this invention are:
[0031] (1) The fast collaborative filtering method proposed in this invention uses scale-invariant angle boundaries for different data clusters. By optimizing the target, negative samples will also be pushed away from both users and positive samples, which can extract users' personalized preference information to a greater extent, thereby improving the accuracy of recommendations.
[0032] (2) This invention maps the modeled user and item features into a hash-encoded Hamming space, significantly improving the real-time performance of online recommendations. The recommendation effectiveness of this invention is superior to the state-of-the-art (SOTA) models commonly found in implicit recommendations, and it also significantly improves the speed of online recommendations. Attached Figure Description
[0033] Figure 1 A flowchart for a fast collaborative filtering method;
[0034] Figure 2 A schematic diagram illustrating the triplet loss in the objective function. Detailed Implementation
[0035] The embodiments of the present invention will be further described below with reference to the accompanying drawings.
[0036] like Figure 1 As shown, this invention provides a fast collaborative filtering method based on hash metric learning, comprising the following steps:
[0037] S1: Collect user data and user ratings of items, and perform data cleaning and data segmentation;
[0038] S2: Initialize parameters for user data and rating data after data cleaning and data segmentation;
[0039] S3: Construct a hash model;
[0040] S4: Perform feature optimization on user data features and rating data features;
[0041] S5: Based on the feature optimization results, use the user data and rating data after parameter initialization to iteratively train the hash model until convergence, obtain the user's interest value for the item, and generate a recommendation list.
[0042] In this embodiment of the invention, the specific method for data cleaning in step S1 is as follows: filter user data and rating data with a number of interactions greater than a set interaction threshold, and filter user data and rating data containing missing values.
[0043] The specific method for data segmentation is as follows: Data is divided according to a set ratio, and in the rating data, ratings that users have rated items are set to 1, while ratings that users have not rated items are set to 0. Data cleaning and segmentation can prevent data from being too sparse, which could hinder recommendations.
[0044] The dataset is divided in an 8:2 ratio, specifically based on each user's interaction. Since this is an exploration of implicit recommendations, all ratings are set to 1, and those without ratings are set to 0.
[0045] In this embodiment of the invention, the specific method for parameter initialization in step S2 is as follows: User data features and rating data features are randomly initialized using a normal distribution with a mean of 0 and a variance of 0.5. First, the feature vectors of users and items are k-dimensional. Generally, the hash feature of user i is represented by u. i Represents u i The corresponding positive sample item features are represented by v j Indicates that the characteristics of negative sample items are represented by v. k express.
[0046] In this embodiment of the invention, in step S3, the optimization objective function of the hash model... The expression is:
[0047]
[0048] Where U represents the hash characteristics of all users, and V represents the hash characteristics of all items. This represents the loss function for pairwise sorting. This represents the loss function for metric learning. This represents a hyperparameter that measures the importance of the two loss functions.
[0049] The objective function consists of two parts:
[0050] 1) Triple hinge loss derived from a boundary condition with invariant angles. Based on the fundamental geometric theorem of triangles, the angle opposite the smaller side is the smaller angle. The objective is to make angle ikj the smallest angle. However, directly optimizing this objective has a problem: point k might be too close to point j (i.e., positive and negative samples), which clearly contradicts the initial goal. Therefore, an alternative method is sought to make j move away from k and closer to i, specifically as follows... Figure 2 As shown in the diagram, a circle is constructed with points i and j as diameters, resulting in a new direct triangle Δko′. This ensures that k and j′ are the longest sides, thus avoiding the aforementioned problem. An upper bound β is established on the diagonal α to seek an upper bound unaffected by the intra-class scale. The hinge loss is defined as follows:
[0051]
[0052] in
[0053] 2) Pairwise ranking loss introduced to uncover more user preference information.
[0054] The loss function is defined by the following formula:
[0055]
[0056] Finally, by combining hinge loss and pairwise ranking loss, the optimization objective is as follows:
[0057]
[0058] Thus, a solution for real-number features based on angular metric learning was successfully established.
[0059] In this embodiment of the invention, step S4 further considers establishing the features in a binary Hamming space to accelerate online recommendation. Setting values greater than 0 in the real number features to 1 and values less than 0 to -1 completes the feature initialization of the Hash binary features. Because binary optimization cannot directly calculate partial derivatives, the optimization formulas for key parameters are introduced first. The objective function for optimizing user data features is:
[0060]
[0061] Among them, u i C represents the hash characteristics of user i. i Let d represent a d*d dimensional constant matrix, where d i Let represent a d-dimensional constant vector, where d represents the dimension of the constant vector and the constant matrix;
[0062] By passing an unrelated item to u i The above problem can be transformed into a quadratic problem in two variables, which can then be solved and u updated. i Similarly, the objective function for optimizing the scoring data is:
[0063]
[0064] Among them, v j C represents the d-dimensional hash feature of an item. j Let d represent a d*d dimensional constant matrix, where d j Let represent a d-dimensional constant vector.
[0065] In this embodiment of the invention, in step S5, the user data and rating data after parameter initialization are used as the initial values for iterative training. The hash model is iteratively trained according to the result of feature optimization until convergence, obtaining the feature matrix of user data and rating data. The inner product operation is performed on the feature matrix to obtain the user's interest value for the item, and a recommendation list is generated based on the user's interest value for the item. The formula for calculating the inner product operation is as follows: In the formula, r represents the predicted score, u i Represents the user's hash characteristics, v j Represents the hash characteristics of an item.
[0066] The beneficial effects of this invention are as follows:
[0067] (1) The fast collaborative filtering method proposed in this invention uses scale-invariant angle boundaries for different data clusters. By optimizing the target, negative samples will also be pushed away from both users and positive samples, which can extract users' personalized preference information to a greater extent, thereby improving the accuracy of recommendations.
[0068] (2) This invention maps the modeled user and item features into a hash-encoded Hamming space, significantly improving the real-time performance of online recommendations. The recommendation effectiveness of this invention is superior to the state-of-the-art (SOTA) models commonly found in implicit recommendations, and it also significantly improves the speed of online recommendations.
[0069] Those skilled in the art will recognize that the embodiments described herein are intended to help the reader understand the principles of the invention, and should be understood that the scope of protection of the invention is not limited to such specific statements and embodiments. Those skilled in the art can make various other specific modifications and combinations based on the technical teachings disclosed in this invention without departing from the spirit of the invention, and these modifications and combinations are still within the scope of protection of this invention.
Claims
1. A fast collaborative filtering method based on hash metric learning, characterized in that, Includes the following steps: S1: Collect user data and user ratings of items, and perform data cleaning and data segmentation; In step S1, the specific method for data cleaning is as follows: filter user data and rating data with an interaction quantity greater than a set interaction threshold, and filter user data and rating data containing missing values. The specific method for data segmentation is as follows: the data is segmented according to a set ratio, and in the rating data, the rating data that the user has rated the item is set to 1, and the rating data that the user has not rated the item is set to 0. S2: Initialize parameters for user data and rating data after data cleaning and data segmentation; In step S2, the specific method for parameter initialization is as follows: the user data features and rating data features are randomly initialized with a normal distribution using 0 as the mean and 0.5 as the variance; S3: Construct a hash model; Optimization objective function of hash model The expression is: in , , , in, Represents the hash characteristics of all users. Represents the hash characteristics of all items. This represents the loss function for pairwise sorting. This represents the loss function for metric learning. Indicates hyperparameters; S4: Perform feature optimization on user data features and rating data features; The objective function for optimizing user data features is: in, Indicates user i hash characteristics, Represent a d * d A constant matrix of dimension, Represent a d A constant vector of dimension, d The dimension of constant vectors and constant matrices; The objective function for optimizing the rating data is: in, Representing items d Dimensional hash features Represent a d * d A constant matrix of dimension, Represent a d A constant vector of dimension; S5: Based on the feature optimization results, use the user data and rating data after parameter initialization to iteratively train the hash model until convergence, obtain the user's interest value for the item, and generate a recommendation list.
2. The fast collaborative filtering method based on hash metric learning according to claim 1, characterized in that, In step S5, the user data and rating data after parameter initialization are used as the initial values for iterative training. The hash model is iteratively trained according to the feature optimization results until convergence, obtaining the feature matrix of the user data and rating data. The inner product operation is performed on the feature matrix to obtain the user's interest value for the items, and a recommendation list is generated based on the user's interest value for the items. The formula for calculating the inner product operation is as follows: In the formula, Indicates the predicted score. Represents the user's hash characteristics, Represents the hash characteristics of an item.