An item recommendation method, device, and storage medium
By constructing an interactive matrix and item vector training item recommendation model, the problem of poor recommendation results caused by sparse interaction between users and items in the prior art is solved, and higher recommendation accuracy and robustness are achieved.
Patent Information
- Application Number
- CN202210110843.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-29
- Publication Date
- 2025-07-22
- Estimated Expiration
- 2042-01-29
AI Technical Summary
The existing recommendation system has sparse interactions between users and items and few positive samples, resulting in poor model recommendation effects, and negative sampling introduces noise, affecting the model training effect.
By constructing the interaction matrix and item vector of the positive sample data set, training the item recommendation model, avoiding negative sampling, and using the encoder and predictor for model training to obtain item recommendation results.
Improves the accuracy and robustness of the recommendation, avoids training collapse and noise interference, and enhances the recommendation effect.
Smart Images

Figure CN114491266B_ABST
Abstract
Description
Technical Field
[0001] The present invention mainly relates to the technical field of data analysis, and particularly relates to an item recommendation method, device, and storage medium. Background Art
[0002] Currently, mainstream recommendation systems capture user preferences based on the interaction records between users and items, and thus recommend to users. However, the interactions between users and all items are very sparse, with few positive samples. On the other hand, items without interactions are often regarded as negative samples, and a lot of noise is introduced through negative sampling, resulting in poor recommendation effects of existing models. Summary of the Invention
[0003] The technical problem to be solved by the present invention is to provide an item recommendation method, device, and storage medium in view of the deficiencies of the prior art.
[0004] The technical solution of the present invention for solving the above technical problem is as follows: An item recommendation method includes the following steps:
[0005] Import a positive sample data set, construct an interaction matrix for the positive sample data set to obtain an interaction matrix and multiple item vectors;
[0006] Construct a training model, and train the training model according to the interaction matrix and the multiple item vectors to obtain an item recommendation model;
[0007] Import the data to be recommended, input the data to be recommended into the item recommendation model, and obtain an item recommendation result according to the item recommendation model.
[0008] Another technical solution of the present invention for solving the above technical problem is as follows: An item recommendation device includes:
[0009] A matrix construction module, configured to import a positive sample data set, construct an interaction matrix for the positive sample data set to obtain an interaction matrix and multiple item vectors;
[0010] A model training module, configured to construct a training model, and train the training model according to the interaction matrix and the multiple item vectors to obtain an item recommendation model;
[0011] An item recommendation result obtaining module, configured to import the data to be recommended, input the data to be recommended into the item recommendation model, and obtain an item recommendation result according to the item recommendation model.
[0012] Another technical solution for the present invention to solve the above technical problems is as follows: An item recommendation device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the item recommendation method as described above is implemented.
[0013] Another technical solution for the present invention to solve the above technical problems is as follows: A computer-readable storage medium stores a computer program. When the computer program is executed by a processor, the item recommendation method as described above is implemented.
[0014] The beneficial effects of the present invention are: By constructing an interaction matrix from a positive sample data set, an interaction matrix and multiple item vectors are obtained. The training model is trained using the interaction matrix and multiple item vectors to obtain an item recommendation model. The data to be recommended is input into the item recommendation model, and the item recommendation result is obtained according to the item recommendation model. There is no need for traditional negative sampling, which avoids the noise interference brought by the sampling process and also avoids the problem of training collapse during model training, improving the accuracy and robustness of the recommendation. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] Figure 1 It is a schematic flowchart of an item recommendation method provided by an embodiment of the present invention;
[0016] Figure 2 It is a block diagram of a module of an item recommendation device provided by an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0017] The principles and features of the present invention are described below with reference to the accompanying drawings. The examples given are only for explaining the present invention and are not intended to limit the scope of the present invention.
[0018] Figure 1 It is a schematic flowchart of an item recommendation method provided by an embodiment of the present invention.
[0019] As Figure 1 shown, an item recommendation method includes the following steps:
[0020] Import a positive sample data set, construct an interaction matrix for the positive sample data set to obtain an interaction matrix and multiple item vectors;
[0021] Construct a training model, and train the training model according to the interaction matrix and multiple item vectors to obtain an item recommendation model;
[0022] Import the data to be recommended, input the data to be recommended into the item recommendation model, and obtain the item recommendation result according to the item recommendation model.
[0023] It should be understood that the best items are selected for recommendation through the trained vector representations.
[0024] In the above embodiments, an interaction matrix and multiple item vectors are obtained by constructing an interaction matrix for the positive sample dataset. The item recommendation model is trained through the interaction matrix and multiple item vectors. The data to be recommended is input into the item recommendation model, and the item recommendation result is obtained according to the item recommendation model. There is no need for traditional negative sampling, which avoids the noise interference brought by the sampling process and also avoids the problem of training collapse during model training, improving the accuracy and robustness of the recommendation.
[0025] Optionally, as an embodiment of the present invention, the positive sample dataset includes multiple positive sample data. The process of constructing an interaction matrix for the positive sample dataset to obtain an interaction matrix and multiple item vectors includes:
[0026] Randomly initialize multiple positive sample data to obtain multiple item vectors corresponding to each user;
[0027] Construct an original interaction matrix through multiple positive sample data and replace the parameters of the original interaction matrix according to a preset ratio to obtain a replaced interaction matrix.
[0028] It should be understood that the random initialization is to represent a random vector as a user or an item, and each number of the vector is randomly generated, just like randomly obtaining a number within 100.
[0029] It should be understood that the random initialization can be implemented through the Xavier function, that is, use Xavier to initialize the embedding vector.
[0030] It should be understood that the positive sample dataset D is defined as D = {(u, i)|u ∈ U, i ∈ I}, and there is an interaction between user u and item i in the dataset.
[0031] Specifically, from the positive sample dataset D, an interaction matrix A1 (i.e., the original interaction matrix) is constructed. If there is an interaction between u and item i, the corresponding value in the matrix (i.e., the original interaction matrix) is 1, and if there is no interaction, the corresponding value is 0.
[0032] It should be understood that the 1 values in the interaction matrix A (i.e., the original interaction matrix) are modified to 0 according to the ratio (i.e., the preset ratio) to obtain A2 (i.e., the replaced interaction matrix).
[0033] It should be understood that the preset ratio refers to the ratio of the total number of elements in the original interaction matrix. For example, if there are 100 '1's in the original interaction matrix, then 10% of them are changed from '1' to '0'. In the above embodiment, multiple item vectors are randomly initialized from multiple positive sample data, the original interaction matrix is constructed through the multiple positive sample data, and the parameters of the original interaction matrix are replaced according to the preset ratio to obtain the replaced interaction matrix. The strategy of obtaining negative samples by mainstream negative sampling is abandoned, and the positive samples are enhanced, thus enhancing the recommendation effect and robustness.
[0034] Optionally, as an embodiment of the present invention, the training model includes an encoder and a predictor. The process of constructing the training model and training the training model according to the interaction matrix and the multiple item vectors to obtain the item recommendation model includes:
[0035] S21: Respectively encode and analyze the original interaction matrix and the replaced interaction matrix through the encoder and multiple item vectors corresponding to each user, to obtain a first user vector corresponding to each user and a second user vector corresponding to each user;
[0036] S22: Respectively map each of the first user vectors and the multiple item vectors corresponding to each user through the predictor, to obtain a user prediction vector corresponding to each user and multiple item prediction vectors corresponding to each user;
[0037] S23: Perform loss analysis on all item vectors, all first user vectors, all second user vectors, all user prediction vectors, and all item prediction vectors, to obtain the item recommendation model.
[0038] It should be understood that the encoder is defined to obtain vector representations by enhancing data, the predictor is defined to perform non-linear transformation on the vector representations, and a contrastive learning objective function is defined for training.
[0039] In the above embodiment, the item recommendation model is obtained by training the training model through the interaction matrix and multiple item vectors. The predictor avoids the problem of training collapse, alleviates the problem brought by data sparsity, and enhances the recommendation effect and robustness.
[0040] Optionally, as an embodiment of the present invention, the process of step S21 includes:
[0041] Calculate the first user vector corresponding to each user through the first formula respectively for the multiple item vectors corresponding to each user and the original interaction matrix, and the first formula is:
[0042]
[0043] Among them,
[0044] Among them, is the first user vector, β u,i is the importance of item i for user u in the original interaction matrix, d i is the sum of the corresponding column of item i in the original interaction matrix, d u is the sum of the corresponding row of user u in the original interaction matrix, is the set of all items i that have interacted with user u, e i is the item vector;
[0045] By using the second formula to calculate the second user vector for the multiple item vectors corresponding to each of the users and the updated interaction matrix respectively, the second user vectors corresponding to each of the users are obtained. The second formula is:
[0046]
[0047] Among them,
[0048] Among them, is the second user vector, β′ u,i is the importance of item i for user u in the updated interaction matrix, d′ i is the sum of the corresponding column of item i in the updated interaction matrix, d′ u is the sum of the corresponding row of user u in the updated interaction matrix, is the set of all items i that have interacted with user u, e i is the item vector.
[0049] Specifically, the user vector E u is encoded from the item vector e i The derivation formula is as follows:
[0050]
[0051] Among them, is the set of all positive sample items i that have interacted with a certain user u, β u,i is the importance of item i for user u; d i is the sum of the corresponding column of item i in the interaction matrix; d u is the sum of the corresponding row of user u in the interaction matrix; and through two different interaction matrices A1 (i.e., the original interaction matrix) and A2 (i.e., the updated interaction matrix), different vector representations (i.e., the first user vector) and (i.e., the second user vector).
[0052] In the above embodiments, the first user vector and the second user vector are obtained by encoding and analyzing the original interaction matrix and the replaced interaction matrix through the encoder and the item vector respectively, providing basic data for subsequent data processing and improving the accuracy and robustness of the recommendation.
[0053] Optionally, as an embodiment of the present invention, the predictor includes a fully connected layer neural network, and the process of step S22 includes:
[0054] Based on the fully connected layer neural network, map each of the first user vectors to obtain a user prediction vector corresponding to each user;
[0055] Based on the fully connected layer neural network, map multiple item vectors corresponding to each user to obtain multiple item prediction vectors corresponding to each user.
[0056] It should be understood that the fully connected layer neural network is defined as the predictor P.
[0057] It should be understood that the user vector (i.e., the first user vector) passes through the predictor P to obtain the user prediction vector P u , and the item vector e i passes through the predictor P to obtain the item prediction vector P i .
[0058] In the above embodiments, based on the fully connected layer neural network, the first user vector mapping of each first user vector is performed to obtain the user prediction vector, and based on the fully connected layer neural network, the item vector mapping of multiple item vectors is performed to obtain multiple item prediction vectors. The predictor avoids the training collapse problem, alleviates the problem caused by data sparsity, and enhances the recommendation effect and robustness of the recommendation system.
[0059] Optionally, as an embodiment of the present invention, the process of step S23 includes:
[0060] Calculate the loss value for all item vectors, all first user vectors, all second user vectors, all user prediction vectors, and all item prediction vectors through the third formula to obtain the loss value. The third formula is:
[0061]
[0062] where Loss is the loss value, cos() is the cosine similarity function, P u is the user prediction vector, e i is the item vector, Pi is the item prediction vector, is the first user vector, is the second user vector;
[0063] Judge whether the loss value is greater than or equal to a preset threshold. If so, use the training model as the item recommendation model; if not, update the parameters of the encoder and the predictor according to the loss value, and return to step S21.
[0064] It should be understood that the vector similarity between the user and the positive sample i tends to be higher, and different representations of the same user tend to be similar. To avoid the problem of contrast learning training collapse, the objective function is defined as follows:
[0065]
[0066] where the function cos(a, b) is the cosine similarity function, a participates in gradient update, and b does not participate in gradient update; and the model is trained by the forward and backward propagation training methods.
[0067] In the above embodiments, the item recommendation model is obtained through the loss analysis of all item vectors, all first user vectors, all second user vectors, all user prediction vectors, and all item prediction vectors, avoiding the problem of contrast learning training collapse, and improving the accuracy and robustness of the recommendation.
[0068] Figure 2 This is the module block diagram of an item recommendation device provided by an embodiment of the present invention.
[0069] Optionally, as another embodiment of the present invention, as Figure 2 shown, an item recommendation device includes:
[0070] A matrix construction module, configured to import a positive sample data set, construct an interaction matrix for the positive sample data set, and obtain an interaction matrix and a plurality of item vectors;
[0071] A model training module, configured to construct a training model, and train the training model according to the interaction matrix and the plurality of item vectors to obtain an item recommendation model;
[0072] An item recommendation result obtaining module, configured to import data to be recommended, input the data to be recommended into the item recommendation model, and obtain an item recommendation result according to the item recommendation model.
[0073] Optionally, as an embodiment of the present invention, the positive sample data set includes a plurality of positive sample data, and the matrix construction module is specifically configured to:
[0074] Randomly initialize the multiple positive sample data to obtain multiple item vectors corresponding to each user;
[0075] Construct an original interaction matrix through the multiple positive sample data, and replace the parameters of the original interaction matrix according to a preset ratio to obtain a replaced interaction matrix.
[0076] Optionally, another embodiment of the present invention provides an item recommendation device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the item recommendation method described above is implemented. The device can be a computer or the like.
[0077] Optionally, another embodiment of the present invention provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the item recommendation method described above.
[0078] It should be noted that in this article, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not expressly listed, or also includes elements inherent to such process, method, article or device.
[0079] Those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working processes of the above-described device and unit can refer to the corresponding processes in the foregoing method embodiments, and will not be elaborated herein.
[0080] In several embodiments provided by the present application, it should be understood that the disclosed device and method can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of units is only a logical function division, and there can be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed.
[0081] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place, or may be distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiments of the present invention.
[0082] In addition, each functional unit in various embodiments of the present invention may be integrated into a processing unit, may exist physically alone for each unit, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of a software functional unit.
[0083] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it may be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, may be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods in various embodiments of the present invention. The foregoing storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), magnetic disks, or optical discs that can store program codes.
[0084] The above are only the preferred embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present invention shall be included in the protection scope of the present invention.
Claims
1. An item recommendation method, characterized in that, It includes the following steps: Import the positive sample dataset, construct an interaction matrix for the positive sample dataset to obtain the interaction matrix and multiple item vectors; Construct a training model, and train the training model according to the interaction matrix and the multiple item vectors to obtain an item recommendation model; Import the data to be recommended, input the data to be recommended into the item recommendation model, and obtain an item recommendation result according to the item recommendation model; The positive sample dataset includes multiple positive sample data, and the process of constructing an interaction matrix for the positive sample dataset to obtain the interaction matrix and multiple item vectors includes: Randomly initialize the multiple positive sample data to obtain multiple item vectors corresponding to each user; Construct an original interaction matrix through the multiple positive sample data, and replace the parameters of the original interaction matrix according to a preset ratio to obtain a replaced interaction matrix; The training model includes an encoder and a predictor, and the process of constructing the training model and training the training model according to the interaction matrix and the multiple item vectors to obtain an item recommendation model includes: S21: Respectively perform encoding analysis on the original interaction matrix and the replaced interaction matrix through the encoder and the multiple item vectors corresponding to each user to obtain a first user vector corresponding to each user and a second user vector corresponding to each user; S22: Respectively map each of the first user vectors and the multiple item vectors corresponding to each user through the predictor to obtain a user prediction vector corresponding to each user and multiple item prediction vectors corresponding to each user; S23: Perform loss analysis on all item vectors, all first user vectors, all second user vectors, all user prediction vectors, and all item prediction vectors to obtain an item recommendation model.
2. The article recommendation method according to claim 1, wherein The process of step S21 includes: Calculate the first user vector for the multiple item vectors corresponding to each user and the original interaction matrix respectively through the first formula to obtain the first user vector corresponding to each user, and the first formula is: Among them, Among them, is the first user vector, and β u,i is the importance of item i to user u in the original interaction matrix, and d i is the sum of the corresponding column of item i in the original interaction matrix, and d u is the sum of the corresponding row of user u in the original interaction matrix, is the set of all items i that have interacted with user u, and e i is the item vector; Calculate the second user vector for the multiple item vectors corresponding to each user and the replaced interaction matrix respectively through the second formula to obtain the second user vector corresponding to each user, and the second formula is: Among them, Among them, is the second user vector, β′ u,i is the importance of item i for user u in the interaction matrix after replacement, d′ i is the sum of the column corresponding to item i in the interaction matrix after replacement, d′ u is the sum of the row corresponding to user u in the interaction matrix after replacement, is the set of all items i that have interacted with user u, e i is the item vector.
3. The article recommendation method according to claim 1, characterized in that The predictor includes a fully connected layer neural network, and the process of step S22 includes: Map the first user vectors respectively based on the fully connected layer neural network to obtain user prediction vectors corresponding to each user; Map the multiple item vectors corresponding to each user respectively based on the fully connected layer neural network to obtain multiple item prediction vectors corresponding to each user.
4. The article recommendation method according to claim 1, characterized in that The process of step S23 includes: Calculate the loss value for all item vectors, all first user vectors, all second user vectors, all user prediction vectors, and all item prediction vectors through the third formula to obtain the loss value, and the third formula is: Among them, Loss is the loss value, cos() is the cosine similarity function, P u is the user prediction vector, e i is the item vector, P i is the item prediction vector, is the first user vector, is the second user vector; Determine whether the loss value is greater than or equal to a preset threshold. If so, use the training model as an item recommendation model; if not, update the parameters of the encoder and the predictor according to the loss value, and return to step S21.
5. An item recommendation device, characterized in that, Including: A matrix construction module, configured to import a positive sample data set, construct an interaction matrix for the positive sample data set, and obtain an interaction matrix and a plurality of item vectors. A model training module, configured to construct a training model, and train the training model according to the interaction matrix and the plurality of item vectors to obtain an item recommendation model. An item recommendation result obtaining module, configured to import data to be recommended, input the data to be recommended into the item recommendation model, and obtain an item recommendation result according to the item recommendation model. The positive sample data set includes a plurality of positive sample data, and the matrix construction module is specifically configured to: Randomly initialize the plurality of positive sample data to obtain a plurality of item vectors corresponding to each user. Construct an original interaction matrix through the plurality of positive sample data, and replace the parameters of the original interaction matrix according to a preset ratio to obtain a replaced interaction matrix. The training model includes an encoder and a predictor, and the model training module is specifically configured to: S21: Perform encoding analysis on the original interaction matrix and the replaced interaction matrix respectively through the encoder and the plurality of item vectors corresponding to each user to obtain a first user vector corresponding to each user and a second user vector corresponding to each user. S22: Map each of the first user vectors and the plurality of item vectors corresponding to each user through the predictor to obtain a user prediction vector corresponding to each user and a plurality of item prediction vectors corresponding to each user. S23: Perform loss analysis on all the item vectors, all the first user vectors, all the second user vectors, all the user prediction vectors, and all the item prediction vectors to obtain an item recommendation model.
6. An item recommendation system, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that When the processor executes the computer program, the item recommendation method according to any one of claims 1 to 4 is implemented.
7. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, the item recommendation method according to any one of claims 1 to 4 is implemented.
Citation Information
Patent Citations
Commodity recommendation method, system and device
CN111815415A
Sequence recommendation model training and application method and device, equipment and storage medium
CN113592593A