Training method of recommendation model, recommendation model, and storage medium
By constructing loss functions and distillation loss functions to train the recommendation model, the Matthew effect is resolved, the accuracy of the recommendation system is improved, and the recommendation results are ensured to better reflect the user's true interests.
Patent Information
- Application Number
- CN202310933234.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-27
- Publication Date
- 2026-01-13
- Estimated Expiration
- 2043-07-27
AI Technical Summary
Existing recommendation systems are prone to the Matthew effect, where popular items become more popular and unpopular items become even less popular, resulting in low recommendation accuracy and difficulty in reflecting users' true interests.
By acquiring the original training set and the unbiased training set, loss functions and distillation loss functions are constructed using the initial recommendation model and the unbiased recommendation model, and the target recommendation model is trained to ensure that the predicted scores output by the recommendation model better reflect the user's true interests.
It effectively solves the Matthew effect, improves the accuracy of the recommendation system, and makes the recommendation model more reflective of users' true interests.
Smart Images

Figure CN116956040B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of Internet technology, and in particular to a training method for a recommendation model, a recommendation model, and a storage medium. Background Technology
[0002] Existing recommendation systems are widely used in various online services to help users discover items of interest, such as videos, music, and books, more quickly. However, current recommendation systems suffer from exposure bias: popular items receive more exposure and thus a greater learning weight from the system, making it more likely to recommend them in subsequent recommendations. Conversely, less popular items receive less exposure and thus a smaller learning weight, making them less likely to be recommended in subsequent recommendations. This can easily lead to a Matthew effect: popular items become more popular, and less popular items become less popular.
[0003] Existing methods to address the Matthew effect involve using a popularity-based weighting approach. This reduces the learning weight of frequently featured items and increases the learning weight of less frequently featured items, thus suppressing popular items and increasing recommendation diversity. However, recommendation systems based on this approach, by simply reducing the number of frequently featured items and recommending more less frequently featured items, fail to reflect users' true interests, resulting in low recommendation accuracy. Summary of the Invention
[0004] This application provides a training method, a recommendation model, and a storage medium for a recommendation model. While addressing the Matthew effect, the samples recommended by this model are more likely to reflect the user's true interests, thus improving recommendation accuracy.
[0005] This application provides a method for training a recommendation model, including:
[0006] Obtain the original training set, the unbiased training set, and the initial recommendation model. The original training set includes samples recommended by the recommendation system, and the unbiased training set includes samples randomly selected from the candidate recommendation samples of the recommendation system. The initial recommendation model is used to predict the probability that the input sample will be fully viewed by the user.
[0007] Obtain the original training set and the sample labels in the unbiased training set indicating whether the user has fully viewed the samples;
[0008] The samples in the unbiased training set are weighted, and the samples in the original training set are weighted based on the probability that the samples in the original training set belong to the unbiased training set.
[0009] The first sample in the weighted original training set and the first sample in the weighted unbiased training set are input into the initial recommendation model. The first loss function is constructed based on the first prediction score output by the initial recommendation model, the sample label of the first sample, and the sample weight of the first sample.
[0010] The second sample in the unbiased training set is input into the unbiased recommendation model, and a second loss function is constructed based on the second predicted score output by the unbiased recommendation model and the sample label of the second sample; wherein, the unbiased recommendation model is used to predict the probability that the input sample will be fully viewed by the user;
[0011] Based on the first predicted score and the second predicted score, a distillation loss function of the unbiased recommendation model on the initial recommendation model is constructed;
[0012] When the first loss function, the second loss function, and the distillation loss function all converge, the initial recommendation model training is considered complete, and the target recommendation model is obtained.
[0013] Furthermore, the weighting of the samples in the original training set based on the probability that the samples in the original training set belong to the unbiased training set includes:
[0014] A binary classification model is trained using the original training set, the unbiased training set, and the true labels of the samples in the training set. The true label of the sample is the label indicating whether the sample belongs to the unbiased training set. The binary classification model is used to predict the probability that the input sample belongs to the unbiased training set.
[0015] The original training set samples are input into the trained binary classification model, and the output is the probability that the sample belongs to the unbiased training set.
[0016] The weights of the samples in the original training set are set to be proportional to the probabilities, so as to weight the samples in the original training set.
[0017] Furthermore, the step of training a binary classification model using the original training set, the unbiased training set, and the true labels of the samples in the training set includes:
[0018] Input the original training set and the user features, sample features and sample labels corresponding to the samples in the unbiased training set into the initial binary classification discriminant model;
[0019] Based on the probability that a sample belongs to the unbiased training set output by the initial binary classification model, and the true label of the sample, a binary cross-entropy is constructed.
[0020] When the binary cross-entropy converges, it is determined that the initial binary classification discriminant model training is complete, and the binary classification discriminant model is obtained.
[0021] Furthermore, the initial recommendation model includes: a binary classification recommendation model;
[0022] The step of inputting the weighted original training set and the first sample from the weighted unbiased training set into the initial recommendation model, and constructing the first loss function based on the first predicted score output by the initial recommendation model, the sample label of the first sample, and the sample weight of the first sample includes:
[0023] Input the weighted original training set and the user features and sample features of the first sample in the weighted unbiased training set into the binary classification recommendation model;
[0024] A binary cross-entropy is constructed based on the first predicted score output by the binary classification recommendation model, the sample label of the first sample, and the sample weight of the first sample.
[0025] The binary cross-entropy is used as the first loss function.
[0026] Furthermore, the unbiased recommendation model is a binary classification prediction model;
[0027] The step of inputting the second sample from the unbiased training set into the unbiased recommendation model, and constructing the second loss function based on the second predicted score output by the unbiased recommendation model and the sample label of the second sample includes:
[0028] Input the user features and sample features of the second sample in the unbiased training set into the binary classification prediction model;
[0029] A binary cross-entropy is constructed based on the second predicted score output by the binary classification prediction model and the sample label of the second sample;
[0030] The binary cross-entropy is used as the second loss function.
[0031] Furthermore, the step of constructing the distillation loss function of the unbiased recommendation model for the initial recommendation model based on the first predicted score and the second predicted score includes:
[0032] Obtain the first predicted score obtained by inputting the same sample into the initial recommendation model, and the second predicted score obtained by inputting the same sample into the unbiased recommendation model;
[0033] Based on the first and second predicted scores corresponding to the same sample, the second predicted score is used as the sample label to construct a binary cross-entropy so that the unbiased recommendation model distills the initial recommendation model.
[0034] The binary cross-entropy is used as the distillation loss function.
[0035] Furthermore, the step of determining that the initial recommendation model training is complete when the first loss function, the second loss function, and the distillation loss function all converge includes:
[0036] Obtain the sum of the first loss function, the second loss function, and the distillation loss function;
[0037] When the sum of the sums tends to stabilize, it is determined that the initial recommendation model training is complete.
[0038] This application embodiment also provides a recommendation model, which is trained according to the above-described recommendation model training method, and is used to input candidate recommendation samples and rank the candidate recommendation samples according to the prediction scores output by the recommendation model.
[0039] This application also provides an electronic device, including:
[0040] Central processing unit, memory, and input / output interfaces;
[0041] The memory is either a short-term storage memory or a persistent storage memory;
[0042] The central processing unit is configured to communicate with the memory and execute instructions in the memory to perform the methods described above.
[0043] This application also provides a computer-readable storage medium including instructions that, when executed on a computer, cause the computer to perform the method described above.
[0044] As can be seen from the above technical solutions, the embodiments of this application have the following advantages:
[0045] This application embodiment includes: obtaining an original training set, an unbiased training set, and an initial recommendation model, wherein the original training set includes samples recommended by the recommendation system, the unbiased training set includes samples randomly selected from the candidate recommendation samples of the recommendation system, and the initial recommendation model is used to predict the probability that an input sample is fully viewed by a user; obtaining sample labels for whether samples in the original training set and the unbiased training set are fully viewed by a user; weighting the samples in the unbiased training set, and further weighting the samples in the original training set based on the probability that a sample in the original training set belongs to the unbiased training set; and inputting the weighted original training set and the first sample in the weighted unbiased training set into the initial recommendation model. The initial recommendation model is trained by distilling the prediction scores of the unbiased model (trained on an unbiased training set) onto the unbiased recommendation model. A first loss function is constructed based on the first predicted score, the sample label, and the sample weight of the first sample. A second loss function is constructed based on the second predicted score and the sample label of the second sample. The unbiased recommendation model is used to predict the probability that an input sample will be fully viewed by the user. A distillation loss function is then constructed to approximate the unbiased recommendation model's predictions. When all three loss functions converge, the initial recommendation model is considered trained, and the target recommendation model is obtained. In this embodiment, the prediction scores of the unbiased model trained on the unbiased training set are used to distill the recommendation model, making the prediction distribution of the recommendation model's output close to an unbiased distribution. This effectively solves the Matthew effect. Furthermore, by constructing the loss function based on the probability that a sample output by the recommendation model will be fully viewed by the user, the recommendation model is trained to learn the sample features of samples fully viewed by the user. After training, the prediction scores output by the recommendation model better reflect the user's true interests, thus improving recommendation accuracy while addressing the Matthew effect. Attached Figure Description
[0046] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments recorded in this application. For those skilled in the art, other drawings can be obtained based on these drawings.
[0047] Figure 1 This is a communication network architecture diagram disclosed in an embodiment of this application;
[0048] Figure 2 This is a diagram illustrating the training process of a recommendation model disclosed in an embodiment of this application.
[0049] Figure 3 This is a diagram illustrating the training process of another recommended model disclosed in an embodiment of this application;
[0050] Figure 4This is a schematic diagram of a binary classification discrimination model disclosed in an embodiment of this application;
[0051] Figure 5 This is a schematic diagram of a model distillation disclosed in an embodiment of this application;
[0052] Figure 6 This is a schematic diagram of a training device for a recommendation model disclosed in an embodiment of this application;
[0053] Figure 7 This is a schematic diagram of an electronic device disclosed in an embodiment of this application. Detailed Implementation
[0054] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present application.
[0055] In the description of the embodiments of this application, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are only for the convenience of describing the embodiments of this application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on the embodiments of this application.
[0056] In the description of the embodiments of this application, it should be noted that, unless otherwise explicitly specified and limited, the terms "installation," "connection," and "linking" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection of two components. Those skilled in the art can understand the specific meaning of the above terms in the embodiments of this application based on the specific circumstances.
[0057] Existing online services that recommend samples to users, such as Figure 1As shown, the recommender system 101 can recommend multiple samples from the candidate pool to the user's display 102 for browsing. The display 102 can be a mobile phone or computer, etc., without specific limitations. The recommender system 101 can be connected to one or more displays 102, without specific limitations. The samples can be music, videos, or books, etc., without specific limitations. Currently, in most recommender systems 101, popular samples have a higher exposure frequency and a higher learning weight, leading to a tendency to recommend popular samples in subsequent recommendations. Conversely, unpopular samples have a lower exposure frequency and a lower learning weight, making them less likely to be recommended in subsequent recommendations, thus easily leading to the Matthew effect. Existing methods to address the Matthew effect involve using a popularity-based weighting method, reducing the learning weight of popular samples and increasing the learning weight of unpopular items with lower exposure frequency to suppress popular items and increase recommendation diversity. However, existing solutions, when recommending items, simply reduce the recommendation of popular samples with higher exposure frequency and recommend more unpopular samples with lower exposure frequency. The recommended samples are difficult to reflect the user's true interests, resulting in low recommendation accuracy. Therefore, this application provides a method for training a recommendation model that, while addressing the Matthew effect, allows the recommended samples to better reflect users' true interests, thus improving recommendation accuracy. Figure 2 As shown, this specifically includes steps 201 to 206.
[0058] 201. Obtain the original training set, the unbiased training set, and the initial recommendation model.
[0059] In this embodiment, an original training set, an unbiased training set, and an initial recommendation model can be obtained. The original training set includes samples recommended by the recommendation system; that is, the samples in the original training set are those recommended to the user by the recommendation system. Generally, the candidate pool of the recommendation system contains multiple candidate recommendation samples. When recommending samples to the user, the recommendation system generally prioritizes recommending popular samples, meaning that most samples in the original training set are popular samples. The unbiased training set includes samples randomly selected from the candidate recommendation samples of the recommendation system. It can be understood that each randomly selected sample has an equal probability of being selected; that is, the unbiased training set includes samples randomly recommended to the user. The original training set and the unbiased training set are used to train the initial recommendation model. To make the training set more consistent with the user's browsing habits, random samples with a small probability of appearing during browsing generally will not cause the user to interrupt browsing. Therefore, the number of samples in the unbiased training set is generally less than the number of samples in the original training set. The unbiased training set plus the original training set constitutes the total training set, which can account for one percent or two percent of the total training set; the specific percentage is not limited here.
[0060] This initial recommendation model is used to predict the probability that an input sample will be fully viewed by a user. This sample can be music or video, and being fully viewed means either listening to the music completely or watching the video completely; no specific limitation is made here. Furthermore, being fully viewed can also mean that the portion viewed by the user constitutes a large portion of the total sample, such as three-quarters or four-fifths; no specific limitation is made here. This initial recommendation model is pre-trained on samples that have been fully viewed by users. It can pre-learn the sample features of these fully viewed samples. When a sample is input into the initial recommendation model, its sample features are compared with the pre-learned sample features, and the corresponding prediction score is output. This prediction score is the probability that the sample has been fully viewed by the user.
[0061] In this embodiment, the labels of samples in the original training set and unbiased training set that have been fully viewed by the user can also be obtained. If a sample has been fully viewed by the user, the sample label is 1; otherwise, the sample label is 0. These labels can be obtained through user feedback or manually set, without specific limitations here, but user feedback is preferred. It is understood that the samples in the original training set are generally popular samples, which appear prominently in the recommendation system's ranking, allowing for user feedback on browsing information and the corresponding user browsing labels. The unbiased training set consists of randomly selected samples, some of which may be less popular, appearing later in the recommendation system's ranking and making it difficult to obtain user feedback on browsing information. In this case, samples from the unbiased training set can be randomly inserted into the recommendation positions corresponding to the original training set to improve the ranking of the unbiased training set samples and obtain user feedback on browsing information, thus obtaining the corresponding user browsing labels.
[0062] 202. Weight the original training set and the unbiased training set.
[0063] After obtaining the original training set and the unbiased training set, they can be weighted. The unbiased training set samples can be weighted based on hyperparameters, where hyperparameters are set as weights for the samples in the unbiased training set. These hyperparameters can be parameters obtained experimentally and are related to model tuning, aiming to improve training performance and accelerate convergence. When weighting the samples in the original training set, to make the distribution of the original training set approximate that of the unbiased training set, the samples in the original training set can be weighted based on the probability that a sample belongs to the unbiased training set. The higher the probability that a sample belongs to the unbiased training set, the greater its weight; the lower the probability, the smaller its weight. When the probability of a sample belonging to the unbiased training set is zero, its weight is also zero, meaning that samples from this original training set will not be used to train the recommendation model. By weighting the samples in the original training set based on the probability that the samples belong to the unbiased training set, the original dataset can be corrected. Even if the probability of a sample being selected in the original dataset approaches the probability of random selection, the Matthew effect can be effectively mitigated when using the original training set to train the recommendation model.
[0064] 203. Input the weighted original training set and the weighted unbiased training set into the initial recommendation model to construct the first loss function.
[0065] After weighting the original training set and the unbiased training set, the weighted original training set and the weighted unbiased training set can be used to train the initial recommendation model. Specifically, the weighted original training set and the weighted unbiased training set are input into the initial recommendation model to construct the first loss function. The first sample from the weighted original training set and the weighted unbiased training set are input into the initial recommendation model. The initial recommendation model predicts the probability that the input sample will be fully viewed by the user and outputs the corresponding first prediction score. The first loss function is constructed based on the first prediction score output by the initial recommendation model, the sample label of the first sample, and the sample weight of the first sample. The first loss function for that sample can be the difference between the sample label and the first prediction score of the first sample multiplied by the sample weight of the first sample. The sample label can be understood as the true label, i.e., the true label of whether the sample was fully viewed by the user. If yes, the true label is 1; if no, the true label is 0. In other words, the first loss function is constructed by determining the relative situation between the output first prediction score and the true label.
[0066] It is understandable that the training of the initial recommendation model is iterative. In each iteration, the samples of the training set are input into the initial recommendation model, and the first predicted score of the output corresponding to the iteration process can be obtained. It is also understandable that the samples input into the initial recommendation model in each iteration process are different, that is, the first predicted score of the output of each iteration is also different, and the first loss function obtained is also different.
[0067] 204. Input the unbiased training set into the unbiased recommendation model to construct the second loss function.
[0068] In this embodiment, unbiased training, i.e., training an unbiased recommendation model, can be used. Specifically, the unbiased training set is input into the unbiased recommendation model to construct a second loss function. The second sample from the unbiased training set is input into the unbiased recommendation model, and the second loss function is constructed based on the second predicted score output by the unbiased recommendation model and the sample label of the second sample. The unbiased recommendation model is used to predict the probability that the input sample will be fully viewed by the user. It is understood that the training process of this unbiased recommendation model is also iterative, and the second loss function obtained in each iteration is different. This second loss function can be obtained from the difference between the sample's true label and the corresponding second predicted score. The sample label represents whether the sample has been fully viewed by the user, and the second predicted score represents the probability that the sample has been fully viewed by the user. That is, the closer the output second predicted score is to the sample label, the smaller the second loss function; the further the output second predicted score is from the sample label, the larger the second loss function.
[0069] 205. Based on the second predicted score output by the unbiased recommendation model, construct the distillation loss function of the unbiased recommendation model on the basis of the initial recommendation model.
[0070] To make the predicted scores output by the recommendation model approximate an unbiased distribution, a distillation loss function for the unbiased recommendation model over the initial recommendation model can be constructed based on the second predicted score output by the unbiased recommendation model. Specifically, the distillation loss function can be constructed based on the first predicted score output by the initial recommendation model and the second predicted score output by the unbiased recommendation model; that is, the mean squared error between the first and second predicted scores is used as the distillation loss function to distill the initial recommendation model. When predicting the same sample, the first predicted score output by the initial model will be closer to the predicted score output by the unbiased recommendation model, effectively avoiding the Matthew effect, even if the training of the initial recommendation model is approximately based on randomly selected samples.
[0071] 206. When the first loss function, the second loss function, and the distillation loss function all converge, the training is complete and the target recommendation model is obtained.
[0072] During training, when the first loss function, the second loss function, and the distillation loss function all converge, the initial recommendation model can be considered successfully trained, and the target recommendation model is obtained. It's understandable that multiple first loss functions, multiple second loss functions, and multiple distillation loss functions can be obtained during training. Convergence is determined when the first loss function, the second loss function, and the distillation loss function stabilize within a certain range. Specifically, convergence can be determined when the loss function is less than a preset threshold. This preset threshold can be understood as 0.4 or 0.5 when the loss function is represented using JS divergence; the specific value is not limited here.
[0073] As can be seen, the embodiments of this application include: obtaining an original training set, an unbiased training set, and an initial recommendation model; weighting the samples in the unbiased training set, and further weighting the samples in the original training set based on the probability that a sample in the original training set belongs to the unbiased training set; inputting the weighted original training set and the weighted unbiased training set into the initial recommendation model, and constructing a first loss function based on the first prediction score output by the initial recommendation model and the weight of the sample; inputting the unbiased training set into the unbiased recommendation model, and constructing a second loss function based on the second prediction score output by the unbiased recommendation model; constructing a distillation loss function of the unbiased recommendation model on the initial recommendation model based on the first prediction score and the second prediction score; when the first loss function, the second loss function, and the distillation loss function all converge, it is determined that the initial recommendation model training is complete, and the target recommendation model is obtained. In this embodiment, the prediction score output by the unbiased model trained on the unbiased training set is used to distill the recommendation model, making the prediction distribution output by the recommendation model close to the unbiased distribution, which effectively solves the Matthew effect. Furthermore, a first loss function is constructed based on the probability that the sample output by the recommendation model is fully viewed by the user, and the recommendation model is trained to learn the features of the sample fully viewed by the user. After training, the prediction score output by the recommendation model can better reflect the user's true interests, that is, the accuracy of recommendation is improved while solving the Matthew effect.
[0074] Furthermore, the training process of the recommendation model will be described in detail below, such as... Figure 3 As shown, it specifically includes steps 301 to 306.
[0075] 301. Obtain the original training set, the unbiased training set, and the initial recommendation model.
[0076] It is understandable that step 301 is similar to step 201 above, and will not be described in detail here.
[0077] 302. Input the samples from the original training set into the trained binary classification model, and determine the weights of the samples in the original training set based on the predicted scores of the samples output by the model that belong to the unbiased training set.
[0078] In this embodiment of the application, when weighting the original training set, the samples of the original training set can be input into the trained binary classification model, and the weight of the samples in the original training set can be determined according to the prediction score of the model output that the samples belong to the unbiased training set. In essence, weighting the samples in the original training set based on the probability that a sample belongs to the unbiased training set can be achieved by training a binary classification model using the original training set, the unbiased training set, and the true labels of the samples in the training set. The true label of a sample indicates whether it belongs to the unbiased training set. The binary classification model predicts the probability that an input sample belongs to the unbiased training set; that is, it distinguishes whether a sample in the original training set is unbiased (random flow). If it is not unbiased, it is considered a biased sample. The samples from the original training set are input into the trained binary classification model, and the output is the probability that a sample belongs to the unbiased training set, i.e., the predicted score k. The predicted score is 1 if the sample belongs to the unbiased training set and 0 if it does not. The weights of the samples in the original training set are proportional to their probabilities, thus weighting the samples in the original training set. Therefore, based on the predicted score k of the binary classification model, the original training set s can be classified accordingly. t Weighted w t , making the original training set s t The distribution is close to the unbiased training set s c The unbiased distribution can also be applied to the unbiased training set s c Weighted w c , where w t =log(1+α·k),w c =β, where α and β are hyperparameters. That is, the higher the predicted score, the greater the weight of the samples in the original training set.
[0079] Furthermore, binary classification discriminant models such as Figure 4 As shown in the figure, MLP is a multilayer perceptron, and predict is the prediction result. The binary classification discriminant model is trained using the original training set, the unbiased training set, and the real labels of the samples in the training set. This includes inputting the user features, sample features, and sample labels (user feedback) corresponding to the samples in the original training set and the unbiased training set into the initial binary classification discriminant model. Among them, the user features can be the user's age or the user's gender, which is not limited here; the sample features can be the sample type. When the sample is music, the sample features can be the music type, such as symphony or rock; the sample labels are the sample labels of the samples that have been fully viewed by the user.
[0080] Next, based on the probability that a sample belongs to the unbiased training set (i.e., the predicted score output by the initial binary classification model) and the true label of the sample, a binary cross-entropy is constructed; the binary cross-entropy is:
[0081]
[0082] At this time, y p Let w be the predicted score output by the initial binary classification model, w be the weight in the binary cross-entropy (set to 1), and y be the true label of the sample. The true label can be the label indicating whether the sample belongs to the unbiased training set (input by the user). If it does, the true label is 1; otherwise, it is 0. When the binary cross-entropy converges, the initial binary classification model is considered to have been successfully trained, and the binary classification model is obtained.
[0083] 303. Input the weighted original training set and the weighted unbiased training set into the binary classification recommendation model to construct the binary cross-entropy, and use the binary cross-entropy as the first loss function.
[0084] After weighting the original training set and the unbiased training set, the weighted original training set and the weighted unbiased training set are used to train an initial recommendation model. The initial recommendation model includes a binary classification recommendation model, meaning the weighted original training set and the weighted unbiased training set can be input into the binary classification recommendation model to construct a binary cross-entropy, which is used as the first loss function. Specifically, user features and sample features of preset samples from the weighted original training set and the weighted unbiased training set can be input into the binary classification recommendation model, allowing the model to learn the features corresponding to samples fully viewed by the user. Here, the preset sample is any sample from the weighted original training set and the weighted unbiased training set. The binary classification model is used to distinguish whether a sample has been fully viewed by the user, and when a sample is input into the binary classification recommendation model, the model can predict the probability that the sample has been fully viewed by the user. Based on the first predicted score output by the binary classification recommendation model and the weights of the preset samples, a binary cross-entropy is constructed. This binary cross-entropy is:
[0085]
[0086] At this time, y p The first predicted score output by the binary classification recommendation model is w, where w is the preset weight of the sample and y is the true label of the sample. The true label of the sample is whether the user has fully viewed the sample; if yes, it is 1, otherwise it is 0. The binary cross-entropy is used as the first loss function.
[0087] 304. Input the unbiased training set into the binary classification prediction model to construct the binary cross-entropy, and use the binary cross-entropy as the second loss function.
[0088] Furthermore, an unbiased recommendation model can be trained using an unbiased training set. This involves training the model with randomly selected samples, allowing it to learn the features corresponding to samples fully viewed by the user within the randomly selected samples. This unbiased recommendation model includes a binary classification prediction model, where the unbiased training set is input into the binary classification prediction model to construct a binary cross-entropy, which is then used as the second loss function. Specifically, user features and sample features from pre-defined samples in the unbiased training set can be input into the binary classification prediction model; the binary cross-entropy is then constructed based on the second prediction score output by the binary classification prediction model.
[0089]
[0090] At this time, y p The second predicted score is the output of the binary classification prediction model, w is the weight of the preset sample in the unbiased training set, set to 1, and y is the true label of the sample. The true label of the sample is whether the user has fully viewed the sample. If yes, it is 1, otherwise it is 0. The binary cross-entropy is used as the second loss function.
[0091] 305. Construct a distillation loss function based on the first recommendation score output by the binary classification recommendation model and the second recommendation score output by the binary classification prediction model for the same sample.
[0092] After obtaining the first recommendation score output by the binary classification recommendation model and the second recommendation score output by the binary classification prediction model, the same sample can be selected based on both scores to construct a distillation loss function. For example... Figure 5 As shown, the first predicted score obtained by inputting the same sample into the initial recommendation model (binary classification recommendation model) and the second predicted score obtained by inputting the same sample into the unbiased recommendation model (binary classification prediction model) can be obtained. It can be understood that when training the unbiased recommendation model, the training set input into the unbiased recommendation model is the unbiased training set, meaning the same sample is an unbiased sample. The training set of the initial recommendation model includes the original training set and the unbiased training set. Since the unbiased training set is a randomly selected sample, this random sample may be a sample from the original training set. Sample features can be used for comparison to determine if they are the same sample. The first predicted score corresponding to the same sample is used as the model prediction, and the second predicted score corresponding to the same sample is used as the true label. The unbiased recommendation model is distilled using the binary cross-entropy of the initial recommendation model; this binary cross-entropy l dist =l(y left ,y right ,1), y left y is the first predicted score corresponding to the same sample. right The second predicted score is the same as the second predicted score for the same sample; the binary cross-entropy is used as the distillation loss function.
[0093] 306. When the sum of the first loss function, the second loss function, and the distillation loss function converges, the training is complete and the target recommendation model is obtained.
[0094] The initial recommendation model's training completion can be determined based on the first loss function, the second loss function, and the distillation loss function. Specifically, the sum of the first, second, and distillation loss functions can be obtained. When this sum converges, meaning it stabilizes, the initial recommendation model is considered to have completed training. It can be understood that when the sum of the three loss functions converges, the unbiased recommendation model is also considered to have completed training.
[0095] This application also provides a recommendation model, which is trained using the recommendation model training method described above. The recommendation model is used to input candidate recommendation samples and rank them according to the predicted scores output by the model. It is understood that when an online service recommends samples to users, the user features and sample features of the candidate recommendation samples can be input into the trained recommendation model. The recommendation model outputs the predicted scores corresponding to the samples, and the recommendation order of the candidate samples is ranked according to the predicted scores; the higher the predicted score, the higher the recommendation order of the sample, and the lower the predicted score, the lower the recommendation order of the sample.
[0096] This application also provides a training device for a recommendation model, such as... Figure 6 As shown, it includes:
[0097] The acquisition unit 601 is used to acquire the original training set, the unbiased training set, and the initial recommendation model. The original training set includes samples recommended by the recommendation system, and the unbiased training set includes samples randomly selected from the candidate recommendation samples of the recommendation system. The initial recommendation model is used to predict the probability that the input sample will be fully viewed by the user.
[0098] Weighting unit 602 is used to weight the samples in the unbiased training set, and to weight the samples in the original training set based on the probability that the samples in the original training set belong to the unbiased training set.
[0099] The first construction unit 603 is used to input the weighted original training set and the weighted unbiased training set into the initial recommendation model, and construct a first loss function based on the first prediction score output by the initial recommendation model and the weight of the sample.
[0100] The second construction unit 604 is used to input the unbiased training set into the unbiased recommendation model and construct a second loss function based on the second prediction score output by the unbiased recommendation model; wherein, the unbiased recommendation model is used to predict the probability that the input sample is fully viewed by the user;
[0101] The third construction unit 605 is used to construct the distillation loss function of the unbiased recommendation model on the initial recommendation model based on the first prediction score and the second prediction score.
[0102] The determining unit 606 is used to determine that the initial recommendation model training is complete and the target recommendation model is obtained when the first loss function, the second loss function and the distillation loss function all converge.
[0103] This application also provides an electronic device 700, such as... Figure 7 As shown, the image generation apparatus 700 of this application embodiment may include one or more central processing units (CPUs) 701 and a memory 702, wherein the memory 702 stores one or more applications or data.
[0104] The memory 702 can be volatile or persistent storage. The program stored in the memory 702 can include one or more modules, each module including a series of instruction operations on the electronic device. Furthermore, the central processing unit 701 can be configured to communicate with the memory 702 and execute the series of instruction operations stored in the memory 702 on the electronic device 700.
[0105] Electronic device 700 may also include one or more power supplies 705, one or more wired or wireless network interfaces 704, one or more input / output interfaces 703, and / or one or more operating systems, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, etc.
[0106] The central processing unit 701 can perform the operations performed in any of the aforementioned specific method embodiments, which will not be described in detail here.
[0107] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0108] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection between apparatuses or units through some interfaces, and may be electrical, mechanical, or other forms.
[0109] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0110] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0111] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
Claims
1. A method for training a recommendation model, characterized in that, include: Obtain the original training set, the unbiased training set, and the initial recommendation model. The original training set includes samples recommended by the recommendation system, and the unbiased training set includes samples randomly selected from the candidate recommendation samples of the recommendation system. The initial recommendation model is used to predict the probability that the input sample will be fully viewed by the user. Obtain the sample labels of the original training set and the samples in the unbiased training set. The sample labels are used to indicate whether the samples have been fully viewed by the user. The samples in the unbiased training set are weighted, and the samples in the original training set are weighted based on the probability that the samples in the original training set belong to the unbiased training set. The first sample in the weighted original training set and the first sample in the weighted unbiased training set are input into the initial recommendation model. The first loss function is constructed based on the first prediction score output by the initial recommendation model, the sample label of the first sample, and the sample weight of the first sample. The second sample in the unbiased training set is input into the unbiased recommendation model, and a second loss function is constructed based on the second predicted score output by the unbiased recommendation model and the sample label of the second sample; wherein, the unbiased recommendation model is used to predict the probability that the input sample will be fully viewed by the user; Based on the first predicted score and the second predicted score, a distillation loss function of the unbiased recommendation model on the initial recommendation model is constructed; When the first loss function, the second loss function, and the distillation loss function all converge, the initial recommendation model training is considered complete, and the target recommendation model is obtained.
2. The training method according to claim 1, characterized in that, The weighting of the samples in the original training set based on the probability that the samples in the original training set belong to the unbiased training set includes: A binary classification model is trained using the original training set, the unbiased training set, and the true labels of the samples in the training set. The true labels of the samples are used to indicate whether the samples belong to the unbiased training set, and the binary classification model is used to predict the probability that the input sample belongs to the unbiased training set. The original training set samples are input into the trained binary classification model, and the output is the probability that the sample belongs to the unbiased training set. The weights of the samples in the original training set are set to be proportional to the probabilities, so as to weight the samples in the original training set.
3. The training method according to claim 2, characterized in that, The step of training a binary classification model using the original training set, the unbiased training set, and the true labels of the samples in the training set includes: Input the original training set and the user features, sample features and sample labels corresponding to the samples in the unbiased training set into the initial binary classification discriminant model; Based on the probability that a sample belongs to the unbiased training set output by the initial binary classification model, and the true label of the sample, a binary cross-entropy is constructed. When the binary cross-entropy converges, it is determined that the initial binary classification discriminant model training is complete, and the binary classification discriminant model is obtained.
4. The training method according to claim 1, characterized in that, The initial recommendation model includes: a binary classification recommendation model; The step of inputting the weighted original training set and the first sample from the weighted unbiased training set into the initial recommendation model, and constructing the first loss function based on the first predicted score output by the initial recommendation model, the sample label of the first sample, and the sample weight of the first sample includes: Input the weighted original training set and the user features and sample features of the first sample in the weighted unbiased training set into the binary classification recommendation model; A binary cross-entropy is constructed based on the first predicted score output by the binary classification recommendation model, the sample label of the first sample, and the sample weight of the first sample. The binary cross-entropy is used as the first loss function.
5. The training method according to claim 1, characterized in that, The unbiased recommendation model is a binary classification prediction model; The step of inputting the second sample from the unbiased training set into the unbiased recommendation model, and constructing the second loss function based on the second predicted score output by the unbiased recommendation model and the sample label of the second sample includes: Input the user features and sample features of the second sample in the unbiased training set into the binary classification prediction model; A binary cross-entropy is constructed based on the second predicted score output by the binary classification prediction model and the sample label of the second sample; The binary cross-entropy is used as the second loss function.
6. The training method according to claim 1, characterized in that, The step of constructing the distillation loss function of the unbiased recommendation model on the initial recommendation model based on the first prediction score and the second prediction score includes: Obtain the first predicted score obtained by inputting the same sample into the initial recommendation model, and the second predicted score obtained by inputting the same sample into the unbiased recommendation model; Based on the first and second prediction scores corresponding to the same sample, a binary cross-entropy is constructed so that the unbiased recommendation model distills the initial recommendation model. The binary cross-entropy is used as the distillation loss function.
7. The training method according to claim 1, characterized in that, The step of determining that the initial recommendation model training is complete when the first loss function, the second loss function, and the distillation loss function all converge includes: Obtain the sum of the first loss function, the second loss function, and the distillation loss function; When the sum of the sums tends to stabilize, it is determined that the initial recommendation model training is complete.
8. A recommendation model, characterized in that, The recommendation model is trained by the training method of the recommendation model according to any one of claims 1 to 7, and the recommendation model is used to input candidate recommendation samples and rank the candidate recommendation samples according to the prediction scores output by the recommendation model.
9. An electronic device, characterized in that, include: Central processing unit, memory, and input / output interfaces; The memory is either a short-term storage memory or a persistent storage memory; The central processing unit is configured to communicate with the memory and execute instructions in the memory to perform the method of any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, Includes instructions that, when executed on a computer, cause the computer to perform the method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Recommendation model training method, recommendation method, device, and computer-readable medium
CN113508378A
Recommendation method, training method of recommendation model and related device
CN114661999A