A training method, device, electronic device and storage medium for a recommendation model
By adopting adaptive gradient smoothing strategy and SMOAdaGrad algorithm in the multimedia resource recommendation model, different gradient smoothing factors are set for negative samples and positive samples, which solves the problem of recommendation inaccuracy caused by the small number of negative samples, and improves the robustness and accuracy of the model.
Patent Information
- Application Number
- CN202210766023.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-30
- Publication Date
- 2025-08-26
- Estimated Expiration
- 2042-06-30
AI Technical Summary
In the existing multimedia resource recommendation model, the recommendation results are inaccurate due to the small number of negative samples, especially in cold start, data attribution and data reporting delay scenarios, and the recommendation results are inaccurate.
Adaptive gradient smoothing strategy is adopted to optimize the parameter matrix of the recommended model by setting different gradient smoothing factors for negative and positive samples during the training process, and smoothing the sparse features using the SMOAdaGrad algorithm to improve the robustness of the model.
In the case of small negative samples, the accuracy of the recommended model can be improved, the distrust problem caused by sparse samples can be solved, and the computing resource overhead can be increased and the training speed can be improved.
Smart Images

Figure CN115062166B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of multimedia resource recommendation, and in particular to a training method, device, electronic device and storage medium for a recommendation model. Background Art
[0002] In the field of multimedia resource recommendation technology, current recommendation models, whether based on shallow or deep networks, theoretically discover data patterns by fitting data distributions. However, in real-world scenarios, data sparsity across different dimensions often creates uncertainty, leading to inaccurate recommendations. Summary of the Invention
[0003] The embodiments of the present application provide a training method, device, electronic device and storage medium for a recommendation model, which are used to solve the problem of inaccurate recommendations caused by a small number of negative samples in the related art.
[0004] In a first aspect, an embodiment of the present application provides a method for training a recommendation model, comprising:
[0005] Acquire multiple training samples, wherein the type of any training sample is a negative sample or a positive sample;
[0006] Input any training sample into the recommendation model to obtain the predicted value;
[0007] updating the parameters of the parameter matrix of the recommendation model in each dimension according to the gradient smoothing strategy corresponding to the sample type of the training sample, the predicted value, and the label of the training sample;
[0008] When the recommendation model reaches a convergence condition, training is stopped to obtain a final recommendation model, which is used to recommend multimedia resources.
[0009] In a second aspect, an embodiment of the present application provides a training device for a recommendation model, comprising:
[0010] An acquisition module is used to acquire multiple training samples, wherein the type of any training sample is a negative sample or a positive sample;
[0011] The prediction module is used to input any training sample into the recommendation model to obtain the predicted value;
[0012] An updating module, configured to update the parameters of the parameter matrix of the recommendation model in each dimension according to the gradient smoothing strategy corresponding to the sample type of the training sample, the predicted value, and the label of the training sample;
[0013] The stopping module is used to stop training when the recommendation model reaches a convergence condition to obtain a final recommendation model, and the final recommendation model is used to recommend multimedia resources.
[0014] In a third aspect, an embodiment of the present application provides an electronic device, comprising: at least one processor, and a memory communicatively connected to the at least one processor, wherein:
[0015] The memory stores a computer program that can be executed by at least one processor. The computer program is executed by the at least one processor so that the at least one processor can perform the above-mentioned training method of the recommendation model.
[0016] In a fourth aspect, an embodiment of the present application provides a storage medium. When the computer program in the storage medium is executed by a processor of an electronic device, the electronic device can execute the above-mentioned training method of the recommendation model.
[0017] In an embodiment of the present application, a plurality of training samples are obtained, wherein the type of any training sample is a negative sample or a positive sample, the training sample is input into the recommendation model to obtain a predicted value, and the parameters of the parameter matrix of the recommendation model in each dimension are updated according to the gradient smoothing strategy corresponding to the sample type of the training sample, the predicted value and the label of the training sample. When the recommendation model reaches the convergence condition, the training is stopped to obtain the final recommendation model, which is used to recommend multimedia resources. In this way, different gradient smoothing strategies are set for negative samples and positive samples, which is conducive to the recommendation model to make predictions and recommendations based on the more realistic distribution of positive and negative samples in each dimension, so that when the number of negative samples is small, relatively accurate predictions and recommendations can still be made, solving the problem of distrust caused by sample sparsity. In addition, this solution does not require additional data processing of the samples and will not increase the overall number of samples, so it can also save computing resources and improve the training speed of the recommendation model. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0019] Figure 1 A flowchart of a training method for a recommendation model provided in an embodiment of the present application;
[0020] Figure 2 A schematic diagram of a training process of a recommendation model provided in an embodiment of the present application;
[0021] Figure 3 A flowchart of another method for training a recommendation model provided in an embodiment of the present application;
[0022] Figure 4 A flowchart of updating parameters of a parameter matrix of a recommendation model in each dimension provided in an embodiment of the present application;
[0023] Figure 5 A flowchart of another embodiment of the present application for updating parameters of a parameter matrix of a recommendation model in each dimension;
[0024] Figure 6 A flowchart for recommending multimedia resources provided in an embodiment of the present application;
[0025] Figure 7 A schematic diagram of the structure of a training device for a recommendation model provided in an embodiment of the present application;
[0026] Figure 8 A schematic diagram of the hardware structure of an electronic device for implementing a training method for a recommendation model provided in an embodiment of the present application. DETAILED DESCRIPTION
[0027] In order to solve the problem of inaccurate recommendations caused by a small number of negative samples in the related art, the embodiments of the present application provide a training method, device, electronic device and storage medium for a recommendation model.
[0028] It should be noted that, in the description of this application, words such as "first" and "second" are only used for the purpose of distinguishing the description, and cannot be understood as indicating or implying relative importance, nor can they be understood as indicating or implying order.
[0029] The preferred embodiments of the present application are described below in conjunction with the drawings in the specification. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present application and are not used to limit the present application. In addition, the embodiments and features in the embodiments of the present application can be combined with each other if there is no conflict.
[0030] To facilitate understanding of this application, the technical terms involved in this application are:
[0031] Features, an important concept in machine learning, are the key to distinguishing things. For example, in the field of recommendation, important features include gender, age, region, interests, level, etc.
[0032] Dimension has multiple meanings in machine learning. For personalized recommendations, dimension refers to the space between features after preprocessing and expressing them as machine learning vectors. For example, gender features like male and female represent dimensions. Another example is age features like those born in the 1980s, 1990s, and 2000s, which are discretized dimensions.
[0033] Gradient represents the directional derivative of a function at a point. When the maximum gradient is obtained along a direction, it indicates that the function changes fastest and at the largest rate of change along that direction at that point.
[0034] Click-Through-Rate (CTR) is an important indicator for measuring advertising effectiveness in the Internet field. Click-through rate = (actual number of clicks / number of impressions) × 100%.
[0035] Click Value Rate (CVR) is an important metric for measuring advertising effectiveness in the internet industry. It refers to the ratio of completed conversions to the total number of clicks within a statistical period. Conversion rate = (number of conversions / number of clicks) × 100%.
[0036] Smoothing is a prediction method that takes a weighted average of actual and predicted data to make the prediction closer to the actual situation. In recommendation systems, smoothing generally involves artificially adding penalty data to the denominator of CTR and CVR to make the statistical results more reliable.
[0037] One Hot is a machine learning feature preprocessing method used to express discrete features. For example, if the gender feature takes three discrete values: male, female, and unknown, male can be identified by 100, female can be identified by 010, and unknown can be identified by 001.
[0038] Spark is a fast, general, scalable, and open-source big data analytics engine. Compared to Hadoop, Spark uses full-memory computing and has faster computing speeds.
[0039] Tensorflow, an open source machine learning framework, is widely used in industrial production, such as personalized recommendations.
[0040] High-dimensional space refers to a space whose spatial dimension is higher than the specified dimension. In high-dimensional space, features can be expressed as high-dimensional features. Since high-dimensional features are generally sparse, high-dimensional features can also be called sparse features.
[0041] Low-dimensional space, relative to the concept of high-dimensional space, refers to a space whose spatial dimension is not higher than the specified dimension. In low-dimensional space, features can be expressed as low-dimensional features. Since low-dimensional features are generally dense, low-dimensional features can also be called dense features.
[0042] Currently, in the field of multimedia resource recommendation, inaccurate recommendations are common in scenarios such as cold start, data attribution, and data reporting delays. Among them, cold start refers to the situation where new content such as songs, products, and advertisements have not appeared before or have appeared only a few times before, which leads to incorrect scoring by the recommendation model. Data attribution means that positive samples need to find corresponding negative samples. For example, in an e-commerce scenario, users add items to the shopping cart as positive samples, and it is necessary to attribute the exposure scenarios corresponding to the items added to the shopping cart, such as "Guess you like it" and "Bought again and again." Since it is not easy to find the corresponding negative samples for positive samples, it will also lead to overestimation of the recommendation model scores. Data reporting delay refers to the delay in reporting log data due to the design of the embedding point, large data, and network limitations. The positive samples have been returned, but the negative sample data is delayed, which leads to overestimation of the recommendation model scores.
[0043] The common characteristics of the above scenarios are the small number of negative samples and abnormal overall sample distribution. Fitting the distribution according to normal model training will cause the recommendation model to overestimate the score and the recommendation results to be inaccurate.
[0044] To address this issue, related technologies process training samples using resampling. Taking song recommendations as an example, song samples that are clicked but played for less than a given duration are considered negative samples, while song samples that are clicked and played for at least a given duration are considered positive samples. After uniformly resampling from the overall negative samples and adding them to the training samples, the number of newly added negative samples in each dimension is proportionally increased, as shown in Table 1.
[0045] Table 1
[0046]
[0047] Among them, the real smooth play is the number of positive samples, click is the number of negative samples, and β is a pre-determined hyperparameter, such as β = 100.
[0048] Analysis shows that this resampling method can generally address the inaccurate recommendation issues caused by a small and unreliable number of negative samples, but the overall resampling will be evenly distributed across all dimensions. However, in reality, the distribution and degree of smoothing of the original data vary across dimensions. For example, the dimension of pre-2000 years smoothed from 10% to 5.3%, and the dimension of males crossing pre-2000 years smoothed from 50% to 25%. The overall smoothing is sufficient, but the smoothing in the finer dimensions is insufficient. Thus, after the recommendation model fits the data distribution, the CVR recommendation result for song A among males crossing pre-2000 years may be much higher than that for song B. However, due to the small number of males crossing pre-2000 years samples, this recommendation result is also inaccurate.
[0049] In view of this, the embodiment of the present application proposes to add adaptive parameter smoothing in the model training stage, so that the recommendation model is not subject to the interference caused by abnormal sample distribution, thereby improving the robustness of the recommendation model.
[0050] The following is a general introduction to the sample iteration process in the model training phase.
[0051] Generally, a batch of training samples can be obtained in advance. After training begins, all training samples are scanned and randomly shuffled to change the distribution of positive and negative samples in these training samples. Then, based on the order of the shuffled training samples, the recommendation model is iterated using each training sample one by one. After all the training samples in this scan are iterated, all training samples are scanned again, and the above process is repeated until the recommendation model reaches the convergence condition, at which point training is stopped. Among them, one iteration refers to the process of inputting one training sample into the recommendation model for prediction. Convergence conditions include reaching the set number of scans and the total loss value being less than the set value.
[0052] The training samples obtained from different scans are the same, but the distribution of positive and negative samples in different batches of training samples after random shuffling is different. For recommendation models, the number of iterations refers to the number of times the training samples are input. That is, the number of iterations is cumulative across multiple scans. For example, if a batch of 100 training samples is scanned 10 times, then a total of 1000 iterations are performed.
[0053] In addition, it should be noted that although each feature can have multiple dimensions, the dimensions of different features are numbered sequentially.
[0054] During model training, the gradient optimization algorithm for updating the parameters in the parameter matrix of the recommendation model is very important. Several gradient optimization algorithms are introduced below.
[0055] The Stochastic Gradient Descent (SGD) algorithm is an iterative method for solving optimization problems and is widely used in recommendation model training. Its basic principle is to use the recommendation model to predict each training sample after obtaining a batch of training samples. The error loss between the predicted value and the true value is calculated, and the gradient is calculated. Then, the parameters in the parameter matrix are updated based on the gradient and the learning rate. This process is repeated until convergence conditions are reached. The entire process is as follows:
[0056] Randomly initialize the parameter matrix w of the recommendation model and give an initial learning rate η;
[0057] Repeat the following process until the convergence condition of the recommendation model is reached:
[0058] Before iterating on any batch of training samples, the training samples in this batch are randomly shuffled.
[0059] Using the training samples x in this batch i After the tth iteration of the recommendation model,
[0060] Calculating gradients
[0061] Update parameter w t+1 :=w t -ηg t ,
[0062] Among them, g t represents the model gradient after the tth iteration, w t represents the parameter matrix at the tth iteration, w t+1 Represents the parameter matrix at the t+1th iteration.
[0063] It's not hard to see that the SGD algorithm's learning rate η is constant, so all parameters have the same update step size. However, in practice, due to data sparsity and uneven feature filling, the update frequencies of different parameters actually vary greatly.
[0064] To this end, algorithms that optimize the SGD algorithm have emerged, such as the Adaptive Gradient (AdaGrad) algorithm. The core idea of the AdaGrad algorithm is to adjust different learning rates for the parameters in different dimensions of the parameter matrix w, updating frequently changing parameters with smaller step sizes and sparse parameters with larger step sizes. The entire process is as follows:
[0065] Randomly initialize the parameter matrix w of the recommendation model and give an initial learning rate η;
[0066] Repeat the following process until the convergence condition of the recommendation model is reached:
[0067] Before iterating on any batch of training samples, the training samples in this batch are randomly shuffled.
[0068] Using the training samples x in this batch i After the tth iteration of the recommendation model,
[0069] Calculating gradients
[0070] Calculate the cumulative gradient of the jth dimension
[0071] Update the j-th dimension parameter
[0072] Among them, g t represents the model gradient after the tth iteration, w t represents the parameter matrix at the tth iteration, represents the model gradient on the jth dimension after the τth iteration, w t+1 Represents the parameter matrix at the t+1th iteration.
[0073] It is not difficult to find that the AdaGrad algorithm accumulates the gradients corresponding to the parameters in each dimension. For dimensions that are updated frequently, the larger the cumulative gradient value, the smaller the update step size.
[0074] The embodiment of the present application provides a Smooth Adaptive Gradient (SMOAdaGrad) algorithm for sparse feature smoothing based on the AdaGrad algorithm. The core idea of the SMOAdaGrad algorithm is to use different learning rates η for the parameters of the parameter matrix w in different dimensions, and to calculate the smoothing factor s corresponding to the parameters in the jth dimension. j , smoothing operations are performed on untrusted dimensions in the training samples. The whole process is as follows:
[0075] Randomly initialize the parameter matrix w of the recommendation model and give an initial learning rate η;
[0076] Repeat the following process until the convergence condition of the recommendation model is reached:
[0077] Before iterating on any batch of training samples, the training samples in this batch are randomly shuffled.
[0078] Calculate the smoothing factor for the j-th dimension:
[0079] Among them, β is a hyperparameter indicating how many samples are confident, n j is the number of negative samples in the j-th dimension.
[0080] Using the training samples x in this batch i After the tth iteration of the recommendation model,
[0081] Compute the gradient:
[0082] Calculate the cumulative gradient of the j-th dimension:
[0083] Update the parameters of the j-th dimension:
[0084] If x i is a negative sample, then
[0085] If xi is a positive sample, then
[0086] Among them, g t represents the model gradient after the tth iteration, w t represents the parameter matrix at the tth iteration, represents the model gradient on the jth dimension after the τth iteration, w t+1 Represents the parameter matrix at the t+1th iteration.
[0087] Before the iteration, the SMOAdaGrad algorithm calculates the smoothing factor s for each dimension. j , which means that for dimensions with fewer negative samples, a larger smoothing factor is set because of its disbelief. When iterating over negative samples, a larger smoothing factor is applied to the corresponding parameters. In the following example, there are 10 negative samples of clicks on the dimension before 00 on song A, and the smoothing factor s j It is 11. Intuitively, each negative sample is used as 11 negative samples, so that the weight of this dimension reaches 10+100=110; 1000 click negative samples on song B, smoothing factor s j It is 1.1.
[0088]
[0089] When using the SMOAdaGrad algorithm, the model training process is as follows Figure 1 As shown, the following steps are included.
[0090] In step 101, the training samples are preprocessed to obtain features of the training samples.
[0091] For example, the values of each training sample in each dimension are mapped to a high-dimensional feature space to obtain the sparse features of the training sample, and the sparse features of the training sample are mapped to a low-dimensional feature space to obtain the dense features of the training sample, and the dense features are used as the features of the training sample.
[0092] In step 102, the parameter matrix w and the learning rate η are randomly initialized.
[0093] In step 103, the smoothing factor s of the parameter matrix in each dimension is obtained. j .
[0094] For example, according to the formula Calculate the smoothing factor s of the parameter matrix in the jth dimension j , where β is a hyperparameter indicating how many samples are confident, n j is the number of negative samples in the j-th dimension.
[0095] For example, according to the smoothing factor s on the jth dimensionj The rule that is negatively correlated with the number of negative samples in the j-th dimension, and the smoothing factor s in the j-th dimension is manually set j .
[0096] In step 104, the kth batch of training samples is scanned and obtained.
[0097] In step 105, the kth batch of training samples is randomly shuffled.
[0098] In step 106, the i-th training sample x in the k-th batch of training samples is used. i , perform the t-th iteration of the recommendation model.
[0099] In step 107, the gradient is calculated
[0100] In step 108, the cumulative gradient of the j-th dimension is calculated
[0101] In step 109, determine x i Is it a negative sample? If so, go to step 110; if not, go to step 111.
[0102] In step 110,
[0103] In step 111,
[0104] In step 112 , it is determined whether the recommendation model has reached the convergence condition. If so, the process proceeds to step 113 ; otherwise, the process proceeds to step 114 .
[0105] In step 113, the training is completed and the final recommendation model is obtained.
[0106] In step 114, determine x i Is it the last training sample in the kth batch of training samples? If not, go to step 115; if so, go to step 116.
[0107] In step 115 , i is updated to i+1, t is updated to t+1, and the process returns to step 106 .
[0108] In step 116 , k is updated to k+1, t is updated to t+1, and the process returns to step 104 .
[0109] In the above embodiment, a smoothing factor is added during the iterative update of the parameters. As a variation, the smoothing factor can also be smoothed on the samples in advance. The whole process is as follows:
[0110] Randomly initialize the parameter matrix w of the recommendation model and give an initial learning rate η;
[0111] Repeat the following process until the convergence condition of the recommendation model is reached:
[0112] Before iterating on any batch of training samples, the training samples in this batch are randomly shuffled.
[0113] Calculate the smoothing factor for the j-th dimension:
[0114] Among them, β is a hyperparameter indicating how many samples are confident, n j is the number of negative samples in the j-th dimension.
[0115] Using the training samples x in this batch i After the tth iteration of the recommendation model,
[0116] Compute the gradient:
[0117] If x i is a negative sample, then
[0118] If x i is a positive sample, then
[0119] Calculate the cumulative gradient of the j-th dimension:
[0120] Update the parameters of the j-th dimension:
[0121] Among them, g t represents the model gradient after the tth iteration, w t represents the parameter matrix at the tth iteration, represents the model gradient on the jth dimension after the τth iteration, w t+1 Represents the parameter matrix at the t+1th iteration.
[0122] In addition, the method of the embodiment of the present application is also applicable to the same type of algorithms of the AdaGrad algorithm, such as the Adaptive Learning Rate Method (AdaDelta) algorithm, the Adaptive Momentum (Adam) algorithm, etc., among which Adam is an integration of AdaGrad and momentum optimization methods.
[0123] Taking the AdaDelta algorithm as an example, the AdaDelta algorithm improves on the AdaGrad algorithm in gradient calculation. The AdaDelta algorithm sums the gradients within a window, rather than accumulating them continuously. For example, the accumulated historical gradient information is multiplied by a decay coefficient ρ, and then the square of the current gradient is added using (1-ρ) as the weighting coefficient. The whole process is as follows:
[0124] Randomly initialize the parameter matrix w of the recommendation model and give an initial learning rate η;
[0125] Repeat the following process until the convergence condition of the recommendation model is reached:
[0126] Calculate the smoothing factor for the j-th dimension:
[0127] Among them, β is a hyperparameter indicating how many samples are confident, n j is the number of negative samples in the j-th dimension.
[0128] Before iterating on any batch of training samples, the training samples in this batch are randomly shuffled.
[0129] Using the training samples x in this batch i After the tth iteration of the recommendation model,
[0130] Calculating gradients
[0131] calculate
[0132] Update the j-th dimension parameter
[0133] Among them, g t represents the model gradient after the tth iteration, w t represents the parameter matrix at the tth iteration, represents the model gradient on the jth dimension after the τth iteration, w t+1 represents the parameter matrix at the t+1th iteration, ∈ is a predetermined hyperparameter.
[0134] After applying the smoothing idea of this application to the AdaDelta algorithm, the whole process is as follows:
[0135] Randomly initialize the parameter matrix w of the recommendation model and give an initial learning rate η;
[0136] Repeat the following process until the convergence condition of the recommendation model is reached:
[0137] Before iterating on any batch of training samples, the training samples in this batch are randomly shuffled.
[0138] Using the training samples x in this batch i After the tth iteration of the recommendation model,
[0139] Calculating gradients
[0140] calculate
[0141] Update the parameters of the j-th dimension:
[0142] If x i is a negative sample, then
[0143] If x i is a positive sample, then
[0144] Among them, g t represents the model gradient after the tth iteration, w t represents the parameter matrix at the tth iteration, represents the model gradient on the jth dimension after the τth iteration, w t+1 represents the parameter matrix at the t+1th iteration, ∈ is a predetermined hyperparameter.
[0145] The solution of the embodiment of the present application can be applied to optimize recommendation models in the fields of song recommendation, e-commerce recommendation, short video recommendation, advertising recommendation, news recommendation, etc. The following describes the solution of the embodiment of the present application by taking the optimization of the Deep Neural Networks (DNN) model (a form of recommendation model) for song recommendation as an example.
[0146] See also Figure 2 In the song scenario, the complete personalized recommendation model training is divided into the following five steps:
[0147] Step 1. Collect training samples.
[0148] This stage primarily involves collecting the raw exposure, click, and play behavior data required for personalized recommendation models. Generally, recommendation models in the recommendation field include click-through rate (CTR) models and conversion rate (CVR) models. In the click-through rate (CTR) model, click samples are positive samples, while exposure samples are negative samples. In the conversion rate (CVR) model, play samples are positive samples, while click samples are negative samples. To better characterize the samples, user profile data and song profile data can also be collected. User profile data includes information such as age, gender, region, interests, and favorites, while song profile data includes information such as the song's style, artist, rating, and popularity.
[0149] Generally, sample data includes user ID user_id, song ID song_id, and label label corresponding to the song ID. By associating user user_id with user portrait data, and song song_id with song portrait data, a usable training sample can be formed.
[0150] Step 2: Feature mapping to high-dimensional space.
[0151] Generally, continuous features can be discretized into multiple dimensions first. For example, age features can be discretized into dimensions of 70s, 80s, 90s, and 00s, and interest features can be discretized into dimensions of strong interest, weak interest, and medium interest. Then, each dimension is mapped to a high-dimensional space using a hashing algorithm. Figure 2 , data on all dimensions are mapped to the high-dimensional space. For example, the number of the male dimension mapped to the high-dimensional space is 9827394712313.
[0152] In this way, all dimensions are expressed in the form of int64 numbers in high-dimensional space. The purely numerically expressed features can be conveniently stored in engines such as Spark, and can accelerate statistical calculations to quickly calculate smoothing factors. It may also reduce feature conflicts in online learning environments.
[0153] Then, one-hot encoding can be performed on each dimension in the high-dimensional space. In this way, through high-dimensional mapping and one-hot feature expression, each training sample is represented as a sparse 0 / 1 variable.
[0154] Step 3. Calculate the smoothing factor of the parameter matrix in each dimension.
[0155] By using computing engines such as Spark, a single scan operation on the training samples can be performed to count the number of positive and negative samples in each dimension.
[0156] See also Figure 2 , in the male dimension 9827394712313, there are 3 training samples in total, namely 1, 3 and 4. Among them, the 3rd and 4th training samples are negative samples, and the 1st training sample is a positive sample. Then n 982739412313 =2, assuming the hyperparameter β = 100, then Therefore, the smoothing factor of the male dimension 9827394712313 is 51. Similarly, the smoothing factors of other dimensions can be calculated.
[0157] Step 4: Map high-dimensional space to low-dimensional space.
[0158] In deep learning computation frameworks like TensorFlow, input data is typically stored and computed in matrices, which cannot handle the high-dimensional sparse space of int64. To address this, the sparse int64 feature space obtained in Step 2 can be mapped to the dense int32 feature space to reduce the spatial size and the feature dimensionality of the input DNN model. For example, using a HashMap, the int64 feature dimensions can be numbered sequentially starting from 1. For example, the dimension representing people born after 2000 can be mapped to 1, the dimension representing people born after 2000 can be mapped to 2, and so on.
[0159] Step 5. Optimize the DNN model using the SMO AdaGrad algorithm.
[0160] Just follow the steps of the SMOAdaGrad algorithm to complete the iteration and calculation of the model.
[0161] Generally, one training sample is input each time for training, such as Figure 2 The first training sample in [1] has the following features: male, born after 2000, from Guangdong, interested in electronic music, and interested in classical music. The label is a positive sample: 1. The feature data is mapped to int64 using a hash algorithm, and then to int32 using a hash map. The 32-dimensional feature is then input into the DNN model. After obtaining the predicted value output by the DNN model, such as the recommendation probability, the loss value is determined based on the predicted value and the label of the training sample. If the loss value is not less than the given value, if the label of the training sample is 0, the matrix parameters in each dimension are multiplied by a smoothing factor. If the label of the training sample is 1, no smoothing factor is multiplied. This process is repeated until the convergence conditions of the DNN model are determined to be met. Training is then stopped to obtain the final recommendation model.
[0162] This embodiment of the application proposes a recommendation algorithm suitable for use with a small number of negative samples. This algorithm can address inaccurate recommendations caused by content cold starts, lack of data attribution, and delayed data reporting. This algorithm is applied during the model training phase and does not require resampling of training samples, thus minimizing computational overhead.
[0163] The following describes the training method of the recommendation model according to the embodiment of the present application with reference to a flowchart.
[0164] Figure 3 A flowchart of a method for training a recommendation model provided in an embodiment of the present application includes the following steps.
[0165] In step 31, a plurality of training samples are obtained, and the type of any training sample is a negative sample or a positive sample.
[0166] Generally speaking, recommendation models in the recommendation field include click-through rate (CTR) models and conversion rate (CVR) models. In the click-through rate (CTR) model, clicked samples are positive samples, and exposed samples are negative samples. In the conversion rate (CVR) model, played samples are positive samples, and clicked samples are negative samples.
[0167] In step 32, any training sample is input into the recommendation model to obtain a predicted value.
[0168] Generally, any training sample contains data of an account and multiple multimedia resources. The predicted value may be the probability of recommending each multimedia resource to the account, or may be information indicating which multimedia resources are recommended to the account.
[0169] In specific implementation, the values of any training sample in each dimension can be mapped to the first feature space (corresponding to the above-mentioned high-dimensional space) to obtain the sparse features of the training sample, and the sparse features of the training sample can be mapped to the second feature space (corresponding to the above-mentioned low-dimensional space) to obtain the dense features of the training sample. The dense features of the training sample are used as the features of the training sample, wherein the dimension of the second feature space is lower than that of the first feature space. Afterwards, the features of the training sample are input into the recommendation model to obtain the predicted value.
[0170] In this way, mapping to high-dimensional space first and then mapping from high-dimensional space to low-dimensional space is beneficial to avoid hash collisions during mapping, thereby reducing the probability of prediction errors.
[0171] In step 33, the parameters of the parameter matrix of the recommendation model in each dimension are updated according to the gradient smoothing strategy corresponding to the sample type of the training sample, the predicted value and the label of the training sample.
[0172] In some embodiments, the Figure 4 The process shown updates the parameters of the parameter matrix of the recommendation model in each dimension, including the following steps.
[0173] In step 331a, a loss value is determined based on the predicted value and the label.
[0174] In step 332a, when the loss value is not less than a given value, the type of the training sample is determined.
[0175] In step 333a, when the type of the training sample is a negative sample, smoothing processing is performed on the parameters of the parameter matrix of the recommendation model in each dimension.
[0176] In step 334a, when the type of the training sample is a positive sample, the parameters of the parameter matrix of the recommendation model in each dimension are processed in a non-smoothing manner.
[0177] In this way, different parameter update strategies are used for positive samples and negative samples to process the parameters of the parameter matrix of the recommendation model in each dimension, which is conducive to the recommendation model to combine the more realistic positive and negative sample distribution in each dimension to make recommendation predictions, so that more reliable predictions and recommendations can still be made when the number of negative samples is small.
[0178] In some embodiments, the Figure 5 The process shown updates the parameters of the parameter matrix of the recommendation model in each dimension, including the following steps.
[0179] In step 331b, the loss value is determined based on the predicted value and the label.
[0180] In step 332b, when the loss value is not less than a given value, the type of the training sample is determined, and the model gradient is calculated based on the characteristics of the training sample and the current parameter matrix.
[0181] For example, according to the formula Calculate the training sample x i Model gradient after the tth iteration of the recommendation model.
[0182] In step 333b, when the type of the training sample is a negative sample, a predetermined smoothing factor of any dimension is obtained, and the current parameters of the parameter matrix in the dimension are updated according to the current parameters of the parameter matrix in the dimension, the preset learning rate, the model gradient and the smoothing factor.
[0183] In specific implementation, the number of negative samples of all training samples in any dimension can be counted, and then the smoothing factor of the dimension can be calculated based on the pre-set hyperparameters and the number of negative samples. For example, according to the formula Calculate the smoothing factor s of the jth dimension j , where β is a hyperparameter indicating how many samples are confident, n j is the number of negative samples in the j-th dimension.
[0184] In practical applications, when improving different gradient optimization algorithms, more factors can be considered when updating the current parameters of the parameter matrix in each dimension. For example, when improving the AdaGrad algorithm, the cumulative gradient G in each dimension can also be considered. j,j When improving the AdaDelta algorithm, the weighted average result E[g 2 ] t , hyperparameters∈.
[0185] In this way, the parameters of the parameter matrix of the recommendation model in each dimension are smoothed, and the confidence of the negative samples is improved to improve the recommendation accuracy of the recommendation model for negative samples.
[0186] In step 334b, when the type of the training sample is a positive sample, the current parameters of the parameter matrix in any dimension are updated according to the current parameters of the parameter matrix in that dimension, a preset learning rate and a model gradient.
[0187] Similarly, when improving different gradient optimization algorithms, more factors can be considered when updating the current parameters of the parameter matrix in each dimension. For example, when improving the AdaGrad algorithm, the cumulative gradient G in each dimension can also be considered. j,j When improving the AdaDelta algorithm, the weighted average result E[g 2 ] t , hyperparameters∈.
[0188] In this way, the parameters of the parameter matrix of the recommendation model in each dimension are processed in a non-smoothing manner, which is equivalent to not changing the recommendation effect of the recommendation model on the positive samples.
[0189] In step 34, when the recommendation model reaches the convergence condition, the training is stopped to obtain the final recommendation model, which is used to recommend multimedia resources.
[0190] Among them, convergence conditions include the number of scans reaching the set number, the total loss value being less than the set value, etc., and multimedia resources include audio, video, text, images, etc.
[0191] Subsequently, the final recommendation model can be used to recommend multimedia resources. Figure 6 A flowchart for recommending multimedia resources provided in an embodiment of the present application includes the following steps:
[0192] In step 61, user portrait data, user operation data, and resource portrait data of candidate multimedia resources corresponding to the current account are obtained.
[0193] Among them, user portrait data includes information such as age, gender, region, interests, favorites, etc.; user operation data includes operations such as clicks, browsing, watching, and purchasing; taking multimedia resources as songs as an example, resource portrait data includes song style, artist, level, etc.; taking multimedia resources as commodities as an example, resource portrait data includes commodity category, commodity price, year of listing, etc.; taking multimedia resources as videos as an example, resource portrait data includes video size, video style, uploader, etc.
[0194] In step 62, the user portrait data, user operation data and resource portrait data are fused to obtain recommended reference data.
[0195] Among them, fusion includes splicing user portrait data, user operation data and resource portrait data in a certain order.
[0196] In step 63 , the values of the recommended data in each dimension are mapped to the first feature space to obtain sparse features of the recommended reference data.
[0197] The first feature space corresponds to the above-mentioned high-dimensional space, and the sparse features of the recommended reference data can be expressed as a 64-bit 0 / 1 string.
[0198] In step 64 , the sparse features of the recommended reference data are mapped to the second feature space to obtain dense features of the recommended reference data. The dense features of the recommended reference data are used as features of the recommended reference data. The dimension of the second feature space is lower than that of the first feature space.
[0199] The second feature space corresponds to the above-mentioned low-dimensional space, and the dense features of the recommended reference data can be expressed as a 32-bit character string.
[0200] In step 65 , the features of the recommended reference data are input into the final recommendation model to obtain a recommended value.
[0201] The recommendation value may be the recommendation probability of each candidate multimedia resource.
[0202] In step 66 , multimedia resources among the candidate multimedia resources are recommended to the account according to the recommendation value.
[0203] Assuming that the recommendation value is the recommendation probability of each candidate multimedia resource, and assuming that the recommendation rule is that the recommendation probability is higher than a given probability, multimedia resources with a recommendation probability higher than the given probability among the candidate multimedia resources may be recommended to the account.
[0204] Based on the same technical concept, an embodiment of the present application also provides a training device for a recommendation model. The principle of solving the problem by the training device for the recommendation model is similar to that of the training method for the recommendation model mentioned above. Therefore, the implementation of the training device for the recommendation model can refer to the implementation of the training method for the recommendation model, and the repeated parts will not be repeated.
[0205] Figure 7 A structural diagram of a training device for a recommendation model provided in an embodiment of the present application includes an acquisition module 71, a prediction module 72, an update module 73, and a stop module 74.
[0206] An acquisition module 71 is configured to acquire a plurality of training samples, wherein the type of any training sample is a negative sample or a positive sample;
[0207] Prediction module 72, used to input any training sample into the recommendation model to obtain a predicted value;
[0208] An updating module 73 is configured to update the parameters of the parameter matrix of the recommendation model in each dimension according to the gradient smoothing strategy corresponding to the sample type of the training sample, the predicted value, and the label of the training sample;
[0209] The stopping module 74 is used to stop training when the recommendation model reaches a convergence condition to obtain a final recommendation model, and the final recommendation model is used to recommend multimedia resources.
[0210] In some embodiments, the update module 73 includes:
[0211] a loss determining unit 731, configured to determine a loss value based on the predicted value and the label;
[0212] a type determining unit 732, configured to determine the type of the training sample when the loss value is not less than a given value;
[0213] A first updating unit 733 is configured to smooth the parameters of the parameter matrix of the recommendation model in each dimension when the type of the training sample is a negative sample;
[0214] The second updating unit 734 is configured to process the parameters of the parameter matrix of the recommendation model in each dimension in a non-smoothing manner when the type of the training sample is a positive sample.
[0215] In some embodiments, the update module 73 further includes:
[0216] A gradient calculation unit 735 is used to calculate the model gradient according to the characteristics of the training sample and the current parameter matrix;
[0217] The first updating unit 733 is specifically configured to obtain a predetermined smoothing factor of any dimension; update the current parameters of the parameter matrix in the dimension according to the current parameters of the parameter matrix in the dimension, a preset learning rate, the model gradient, and the smoothing factor;
[0218] The second updating unit 734 is specifically configured to update the current parameters of the parameter matrix in the dimension according to the current parameters of the parameter matrix in the dimension, the learning rate, and the model gradient.
[0219] In some embodiments, the smoothing factor of the dimension is determined according to the following:
[0220] Count the number of negative samples of all training samples in the dimension;
[0221] The smoothing factor of the dimension is calculated based on the preset hyperparameters and the number of negative samples.
[0222] In some embodiments, the prediction module 72 is specifically configured to:
[0223] Preprocessing the training samples to obtain features of the training samples;
[0224] Inputting the features of the training samples into the recommendation model to obtain the predicted value;
[0225] The training samples are preprocessed according to the following steps:
[0226] Mapping the values of the training samples in each dimension to a first feature space to obtain sparse features of the training samples;
[0227] Map the sparse features of the training sample to the second feature space to obtain the dense features of the training sample, and use the dense features of the training sample as the features of the training sample. The dimension of the second feature space is lower than that of the first feature space.
[0228] In some embodiments, a recommendation module 75 is further included for:
[0229] After obtaining the final recommendation model, obtain the user profile data, user operation data, and resource profile data of the candidate multimedia resources corresponding to the current account;
[0230] fusing the user portrait data, the user operation data, and the resource portrait data to obtain recommended reference data;
[0231] Mapping the values of the recommended data in each dimension to a first feature space to obtain sparse features of the recommended reference data;
[0232] Mapping the sparse features of the recommended reference data to a second feature space to obtain dense features of the recommended reference data, and using the dense features of the recommended reference data as features of the recommended reference data, wherein the dimension of the second feature space is lower than that of the first feature space;
[0233] Inputting the features of the recommendation reference data into the final recommendation model to obtain a recommendation value;
[0234] Recommending multimedia resources from the candidate multimedia resources to the account according to the recommendation value.
[0235] The division of modules in the embodiments of the present application is schematic and is only a logical function division. There may be other division methods in actual implementation. In addition, the functional modules in the embodiments of the present application may be integrated into one processor, or may exist physically separately, or two or more modules may be integrated into one module. The coupling between the modules can be achieved through some interfaces, which are usually electrical communication interfaces, but it is not ruled out that they may be mechanical interfaces or other forms of interfaces. Therefore, the modules described as separate components may or may not be physically separated, and may be located in one place or distributed to different locations of the same or different devices. The above-mentioned integrated modules can be implemented in the form of hardware or in the form of software functional modules.
[0236] After introducing the training method and apparatus of the recommendation model according to the exemplary embodiment of the present application, next, an electronic device according to another exemplary embodiment of the present application is introduced.
[0237] Refer to the following Figure 8 The electronic device 130 implemented according to this embodiment of the present application is described. Figure 8 The electronic device 130 shown is merely an example and should not limit the functions and scope of use of the embodiments of the present application.
[0238] like Figure 8 As shown, the electronic device 130 is a general electronic device. Components of the electronic device 130 may include, but are not limited to, the at least one processor 131, the at least one memory 132, and a bus 133 connecting different system components (including the memory 132 and the processor 131).
[0239] Bus 133 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, and a processor or local bus using any of a variety of bus architectures.
[0240] The memory 132 may include a readable medium in the form of a volatile memory, such as a random access memory (RAM) 1321 and / or a cache memory 1322 , and may further include a read-only memory (ROM) 1323 .
[0241] The memory 132 may also include a program / utility 1325 having a set (at least one) of program modules 1324, such program modules 1324 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.
[0242] The electronic device 130 may also communicate with one or more external devices 134 (e.g., a keyboard, pointing device, etc.), one or more devices that enable a user to interact with the electronic device 130, and / or any device that enables the electronic device 130 to communicate with one or more other electronic devices (e.g., a router, a modem, etc.). Such communication may occur via an input / output (I / O) interface 135. Furthermore, the electronic device 130 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network such as the Internet) via a network adapter 136. As shown, the network adapter 136 communicates with other modules of the electronic device 130 via a bus 133. It should be understood that, although not shown, other hardware and / or software modules may be used in conjunction with the electronic device 130, including but not limited to microcode, device drivers, redundant processors, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0243] In an exemplary embodiment, a storage medium is also provided. When a computer program in the storage medium is executed by a processor of an electronic device, the electronic device can perform the above-mentioned recommendation model training method. Optionally, the storage medium can be a non-transitory computer-readable storage medium, for example, the non-transitory computer-readable storage medium can be a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, optical data storage device, etc.
[0244] In an exemplary embodiment, the electronic device of the present application may include at least one processor and a memory communicatively connected to the at least one processor, wherein the memory stores a computer program executable by the at least one processor, and when the computer program is executed by the at least one processor, the at least one processor may execute the steps of the training method of any recommendation model provided in the embodiments of the present application.
[0245] In an exemplary embodiment, a computer program product is further provided. When the computer program product is executed by an electronic device, the electronic device can implement any exemplary method provided in this application.
[0246] Furthermore, the computer program product may employ any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or component, or any combination thereof. More specific examples (a non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, RAM, ROM, an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof.
[0247] In the embodiments of the present application, the program product for training the recommendation model may be a CD-ROM and include program code, and may be run on a computing device. However, the program product of the present application is not limited thereto. In this document, a readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
[0248] A readable signal medium may include a data signal transmitted in baseband or as part of a carrier wave, which carries readable program code. Such a transmitted data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium that can transmit, propagate, or transfer a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0249] The program code contained on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, radio frequency (RF), etc., or any suitable combination of the foregoing.
[0250] The program code for performing the operations of the present application can be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., and conventional procedural programming languages such as "C" or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, such as a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (e.g., via the Internet using an Internet service provider).
[0251] It should be noted that although several units or subunits of the device are mentioned in the detailed description above, this division is merely exemplary and not mandatory. In fact, depending on the embodiment of the application, the features and functions of two or more units described above can be embodied in a single unit. Conversely, the features and functions of a single unit described above can be further divided and embodied by multiple units.
[0252] Furthermore, although the operations of the method of the present application are described in a particular order in the accompanying drawings, this does not require or imply that the operations must be performed in this particular order, or that all illustrated operations must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps.
[0253] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0254] The present application is described with reference to the flowcharts and / or block diagrams of the methods, apparatus (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the steps in the flowchart and / or block diagram. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0255] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0256] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0257] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present application.
[0258] Obviously, those skilled in the art may make various changes and modifications to this application without departing from the spirit and scope of this application. Thus, if these modifications and variations of this application fall within the scope of the claims of this application and their equivalents, this application is intended to include these modifications and variations.
Claims
1. A training method for a recommendation model, characterized in that: include: Acquire multiple training samples, wherein the type of any training sample is a negative sample or a positive sample; Input any training sample into the recommendation model to obtain the predicted value; Determining a loss value based on the predicted value and the label of the training sample; When the loss value is not less than a given value, the parameters of the parameter matrix of the recommendation model in each dimension are updated according to the gradient smoothing strategy corresponding to the sample type of the training sample, wherein when the type of the training sample is a negative sample, the parameters of the parameter matrix of the recommendation model in each dimension are smoothed; When the recommendation model reaches a convergence condition, the training is stopped to obtain a final recommendation model, which is used to recommend multimedia resources.
2. The method according to claim 1, wherein When the type of the training sample is a positive sample, the parameters of the parameter matrix of the recommendation model in each dimension are processed in a non-smoothing manner.
3. The method according to claim 1, wherein Updating the parameters of the parameter matrix of the recommendation model in each dimension also includes: Calculating the model gradient according to the characteristics of the training sample and the current parameter matrix; Smoothing the parameters of the parameter matrix of the recommendation model in each dimension includes: Obtaining a predetermined smoothing factor for any dimension, wherein the fewer the negative samples in the dimension, the larger the smoothing factor of the dimension; Update the current parameters of the parameter matrix in the dimension according to the current parameters of the parameter matrix in the dimension, the preset learning rate, the model gradient and the smoothing factor; Processing the parameters of the parameter matrix of the recommendation model in each dimension in a non-smoothing manner includes: The current parameters of the parameter matrix in the dimension are updated according to the current parameters of the parameter matrix in the dimension, the learning rate, and the model gradient.
4. The method according to claim 3, wherein The smoothing factor for the dimension is determined as follows: Count the number of negative samples of all training samples in the dimension; The smoothing factor of the dimension is calculated based on the preset hyperparameters and the number of negative samples.
5. The method according to claim 1, wherein Input any training sample into the recommendation model to obtain the predicted value, including: Preprocessing the training samples to obtain features of the training samples; Inputting the features of the training samples into the recommendation model to obtain the predicted value; The training samples are preprocessed according to the following steps: Mapping the values of the training samples in each dimension to a first feature space to obtain sparse features of the training samples; The sparse features of the training samples are mapped to a second feature space to obtain dense features of the training samples, and the dense features of the training samples are used as features of the training samples. The dimension of the second feature space is lower than that of the first feature space.
6. The method according to claim 1, wherein After obtaining the final recommendation model, it also includes: Obtain user profile data, user operation data, and resource profile data of candidate multimedia resources corresponding to the current account; fusing the user portrait data, the user operation data, and the resource portrait data to obtain recommended reference data; Mapping the values of the recommended reference data in each dimension to a first feature space to obtain sparse features of the recommended reference data; Mapping the sparse features of the recommended reference data to a second feature space to obtain dense features of the recommended reference data, and using the dense features of the recommended reference data as features of the recommended reference data, wherein the dimension of the second feature space is lower than that of the first feature space; Inputting the features of the recommendation reference data into the final recommendation model to obtain a recommendation value; Recommending multimedia resources from the candidate multimedia resources to the account according to the recommendation value.
7. A training device for a recommendation model, characterized in that: include: An acquisition module is used to acquire multiple training samples, wherein the type of any training sample is a negative sample or a positive sample; The prediction module is used to input any training sample into the recommendation model to obtain the predicted value; an updating module, configured to determine a loss value based on the predicted value and the label of the training sample, and when the loss value is not less than a given value, update the parameters of the parameter matrix of the recommendation model in each dimension according to a gradient smoothing strategy corresponding to the sample type of the training sample, wherein when the type of the training sample is a negative sample, the parameters of the parameter matrix of the recommendation model in each dimension are smoothed; The stopping module is used to stop training when the recommendation model reaches a convergence condition to obtain a final recommendation model, and the final recommendation model is used to recommend multimedia resources.
8. The device according to claim 7, wherein The update module further includes: The second updating unit is configured to process the parameters of the parameter matrix of the recommendation model in each dimension in a non-smoothing manner when the type of the training sample is a positive sample.
9. The device according to claim 7, wherein The update module also includes: A gradient calculation unit, configured to calculate a model gradient based on the characteristics of the training sample and the current parameter matrix; a first updating unit, specifically configured to obtain a predetermined smoothing factor for any dimension, wherein the fewer the negative samples in the dimension, the larger the smoothing factor of the dimension; and update the current parameters of the parameter matrix in the dimension according to the current parameters of the parameter matrix in the dimension, a predetermined learning rate, the model gradient, and the smoothing factor; The second updating unit is specifically configured to update the current parameters of the parameter matrix in the dimension according to the current parameters of the parameter matrix in the dimension, the learning rate, and the model gradient.
10. The device according to claim 9, wherein The smoothing factor for the dimension is determined as follows: Count the number of negative samples of all training samples in the dimension; The smoothing factor of the dimension is calculated based on the preset hyperparameters and the number of negative samples.
11. The device according to claim 7, wherein The prediction module is specifically used for: Preprocessing the training samples to obtain features of the training samples; Inputting the features of the training samples into the recommendation model to obtain the predicted value; The training samples are preprocessed according to the following steps: Mapping the values of the training samples in each dimension to a first feature space to obtain sparse features of the training samples; The sparse features of the training samples are mapped to a second feature space to obtain dense features of the training samples, and the dense features of the training samples are used as features of the training samples. The dimension of the second feature space is lower than that of the first feature space.
12. The device according to claim 7, wherein Also included are recommended modules for: After obtaining the final recommendation model, obtain the user profile data, user operation data, and resource profile data of the candidate multimedia resources corresponding to the current account; fusing the user portrait data, the user operation data, and the resource portrait data to obtain recommended reference data; Mapping the values of the recommended reference data in each dimension to a first feature space to obtain sparse features of the recommended reference data; Mapping the sparse features of the recommended reference data to a second feature space to obtain dense features of the recommended reference data, and using the dense features of the recommended reference data as features of the recommended reference data, wherein the dimension of the second feature space is lower than that of the first feature space; Inputting the features of the recommendation reference data into the final recommendation model to obtain a recommendation value; Recommending multimedia resources from the candidate multimedia resources to the account according to the recommendation value.
13. An electronic device, characterized in that: include: at least one processor, and a memory communicatively coupled to the at least one processor, wherein: The memory stores a computer program executable by the at least one processor. The computer program is executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 6.
14. A storage medium, characterized in that When the computer program in the storage medium is executed by a processor of an electronic device, the electronic device can perform the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Click prediction model training method, object recommendation method, device and program product
CN114637913A