Recommendation model training methods, recommendation methods, devices, media and equipment
By optimizing the training process of the recommendation model through clustering and pruning of feature data pairs, the imbalance problem caused by long-tail distribution is solved, the model's learning effect on low-frequency samples is improved, and the discrimination ability of the recommendation model is enhanced.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-07
- Publication Date
- 2026-03-10
AI Technical Summary
Existing recommendation models suffer from imbalance due to the long-tail distribution in the training sample set, resulting in insufficient training of low-frequency samples and thus insufficient ability of the recommendation model to distinguish low-frequency features.
Clustering techniques are used to cluster feature vectors in the training samples into clusters. The first loss function is used to optimize the distance loss from the feature vectors to the cluster centers. Temperature hyperparameter adjustment is combined to enhance training on low-frequency samples. Pruned feature data pairs are used to construct the loss function to improve the model's learning efficiency.
This improved the learning frequency and sufficiency of the recommendation model for low-frequency samples, enhanced the model's ability to distinguish low-frequency features, and improved the overall performance of the recommendation model.
Smart Images

Figure CN114595787B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of this disclosure relate to the field of artificial intelligence data processing technology, and more specifically, the embodiments of this disclosure relate to training methods, recommendation methods, apparatus, media and devices for recommendation models. Background Technology
[0002] This section is intended to provide background or context for the embodiments of this disclosure set forth in the claims, and the description herein is not acknowledged as prior art simply because it is included in this section.
[0003] With the continuous development of machine learning, major internet platforms widely adopt machine learning-based recommendation models to provide content recommendation services to users. Machine learning-based recommendation models need to be trained in advance using training data to learn user preferences. Therefore, the more training data available for various scenarios, the stronger the recommendation model's ability to distinguish between different situations and make accurate recommendations.
[0004] However, due to the long-tail effect, the distribution of samples in the training sample set is unbalanced, so low-frequency samples cannot be fully trained, resulting in inaccurate feature representations of the training samples in the prediction model. Summary of the Invention
[0005] In this context, embodiments of the present disclosure provide methods for training recommendation models, recommendation methods, apparatus, media, and devices.
[0006] According to a first aspect of this disclosure, a method for training a recommendation model is provided, comprising: acquiring a set of training samples, the training samples including: first object feature data of a first object, second object feature data of a second object, and labels identifying the training samples as positive or negative samples; inputting the set of training samples into a recommendation model, and performing a training process including: mapping a first feature vector based on the first object feature data of the input current training samples, and mapping a second feature vector based on the second object feature data of the current training samples; clustering at least one first object cluster based on each obtained first feature vector, and clustering at least one second cluster based on each obtained second feature vector; updating the recommendation model based on a loss calculated by a first loss function; wherein the loss calculated by the first loss function includes: a first loss part and a second loss part; the first loss part is obtained based on a first distance between the cluster centers of the second cluster to which the first feature vector and the second feature vector belong in the current training samples; the second loss part is obtained based on a second distance between the cluster centers of the first object cluster to which the second feature vector and the first feature vector belong in the current training samples.
[0007] According to a second aspect of this disclosure, a recommendation method is provided, comprising: acquiring first feature data of at least one first object and second feature data of a plurality of second objects; inputting the first feature data and the second feature data into a recommendation model to obtain a similarity between the at least one first object and the plurality of second objects; and ranking the plurality of second objects based on the similarity for recommendation to the first object; wherein the recommendation model is trained by the training method described in any one of the first aspects.
[0008] According to a third aspect of this disclosure, a training apparatus for a recommendation model is provided, comprising: a training sample acquisition module for acquiring a set of training samples, the training samples including: first object feature data of a first object, second object feature data of a second object, and labels identifying the training samples as positive or negative samples; and a model training module for inputting the set of training samples into a recommendation model and performing a training process including: mapping a first feature vector based on the input first object feature data, and mapping a second feature vector based on the input second object feature data; clustering at least one first object cluster based on the obtained first feature vectors, and clustering at least one second cluster based on the obtained second feature vectors; and updating the recommendation model based on a loss calculated by a first loss function; wherein the loss calculated by the first loss function includes: a first loss portion and a second loss portion; the first loss portion is obtained based on a first distance between the cluster centers of the second cluster to which the first feature vector and the second feature vector belong in the current training sample; and the second loss portion is obtained based on a second distance between the cluster centers of the first object cluster to which the second feature vector and the first feature vector belong in the current training sample.
[0009] According to a fourth aspect of this disclosure, a recommendation apparatus is provided, comprising: a feature acquisition module for acquiring first feature data of at least one first object and second feature data of a plurality of second objects; an input module for inputting the first feature data and the second feature data into a recommendation model to obtain a similarity between the at least one first object and the plurality of second objects; and a ranking module for ranking the plurality of second objects based on the similarity for recommendation to the first object; wherein the recommendation model is trained by a training method as described in any of the first aspects.
[0010] According to a fifth aspect of this disclosure, a storage medium is provided having a computer program stored thereon, characterized in that the computer program, when executed by a processor, implements: the training method described in any one of the first aspects; or the recommended method described in any one of the second aspects.
[0011] According to a sixth aspect of this disclosure, an electronic device is provided, comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to execute: the training method of any one of the first aspects; or the recommended method of any one of the second aspects via executing the executable instructions.
[0012] The recommendation model training method, recommendation method, apparatus, medium, and device provided in this disclosure, during training, obtains at least one first object cluster by clustering based on a set of first feature vectors corresponding to a first object, and obtains at least one second cluster by clustering based on a set of second feature vectors corresponding to a second object; the recommendation model is updated based on the loss calculated by a first loss function; the calculated loss includes: a first loss part and a second loss part; the first loss part is obtained based on a first distance between the cluster centers of the first feature vector and the second feature vector in the current training sample; the second loss part is obtained based on a second distance between the second feature vector and the cluster center of the first object cluster to which the first feature vector belongs in the current training sample. By clustering the features of two objects separately, and replacing the optimization of similarity loss in related technologies with optimizing the distance from the feature vector of one object to the corresponding cluster center of the other object, low-frequency samples can also be fully trained, thus solving the problems of related technologies. Attached Figure Description
[0013] The above and other objects, features, and advantages of this disclosure will become readily apparent from the following detailed description of exemplary embodiments, taken in conjunction with the accompanying drawings. Several embodiments of this disclosure are illustrated in the drawings by way of example and not limitation, in which:
[0014] Figure 1 A flowchart illustrating a training method for a recommendation model according to an embodiment of this disclosure is shown.
[0015] Figure 2 This illustration shows a schematic diagram of the principle of calculating loss using a first loss function based on the recommendation model architecture in an application example of this disclosure.
[0016] Figure 3 This illustration shows a schematic diagram of the principle of calculating loss using a second loss function based on the recommendation model architecture in an application example of this disclosure.
[0017] Figure 4 A schematic diagram of the training method for the recommendation model in yet another embodiment of this disclosure is shown.
[0018] Figure 5 A schematic diagram illustrating the flow of a training method for a recommendation model in another embodiment of this disclosure is shown.
[0019] Figure 6A flowchart illustrating a recommended method in one embodiment of this disclosure is shown.
[0020] Figure 7 A schematic diagram of the modular architecture of a training apparatus for a recommended model in one embodiment of this disclosure is shown.
[0021] Figure 8 A schematic diagram of the modular architecture of a recommended apparatus according to an embodiment of this disclosure is shown.
[0022] Figure 9 A schematic diagram of a storage medium according to an embodiment of the present disclosure is shown.
[0023] Figure 10 A schematic diagram of the structure of an electronic device according to an embodiment of the present disclosure is shown.
[0024] In the accompanying drawings, the same or corresponding reference numerals indicate the same or corresponding parts. Detailed Implementation
[0025] The principles and spirit of this disclosure will now be described with reference to several exemplary embodiments. It should be understood that these embodiments are given merely to enable those skilled in the art to better understand and implement this disclosure, and are not intended to limit the scope of this disclosure in any way. Rather, these embodiments are provided to make this disclosure more thorough and complete, and to fully convey the scope of this disclosure to those skilled in the art.
[0026] Those skilled in the art will recognize that embodiments of this disclosure can be implemented as a system, apparatus, device, method, or computer program product. Therefore, this disclosure can be specifically implemented in the following forms: entirely hardware, entirely software (including firmware, resident software, microcode, etc.), or a combination of hardware and software.
[0027] According to embodiments of this disclosure, methods, apparatus, media, devices, and platforms for calculating and training creative ability information are provided.
[0028] In this document, any number of elements in the accompanying figures is for illustrative purposes and not for limitation, and any naming is for distinction only and has no limiting meaning.
[0029] The principles and spirit of this disclosure are explained in detail below with reference to several representative embodiments.
[0030] The data involved in this disclosure may be data authorized by the user or fully authorized by all parties, and the implementation methods / executives of this disclosure may be combined with each other. Invention Overview
[0032] First, the definitions of terms that may be used in this disclosure will be stated in advance to facilitate subsequent understanding of the specification:
[0033] Accuracy This refers to the prediction results of the recommendation model. It indicates how many samples predicted as positive are actually true positive samples. There are two possibilities for a positive prediction: one is predicting a positive sample as a true positive (TP), and the other is predicting a negative sample as a false positive (FP).
[0034] Recall rate This refers to the original sample; it indicates how many positive examples in the sample were correctly predicted. There are two possibilities: one is to predict the original positive class as positive (TP), and the other is to predict the original positive class as negative (FN). That is:
[0035] TP, FP, FN, precision, and recall are all evaluation metrics for models.
[0036] InfonCE A common loss function in contrastive learning is shown in the following formula: loss q As shown, its optimization objective is easily seen from its numerator and denominator. The numerator emphasizes positive examples, aiming for them to be as close as possible, while the denominator emphasizes negative samples, aiming for them to be as far away as possible. InfonCE can drive positive examples to be closer and negative samples to be farther away in the projection space, which is a typical abstract contrastive learning system, where τ is the temperature hyperparameter.
[0037]
[0038] The biggest difference between contrastive learning and metric learning lies in whether the training data is constructed in a self-supervised manner. Specifically, in contrastive learning, the positive and negative samples are automatically constructed according to certain rules, rather than using manually labeled data (i.e., a supervised approach). In the image domain, positive examples in contrastive learning are typically generated by performing two different transformations on an image, creating two different views of that image. The corresponding negative samples are usually obtained automatically by randomly selecting a batch of other images.
[0039] In other words, the positive and negative values of samples are relative, not absolute. For example, in metric learning, a user's interaction with a material is a positive sample, while a user's lack of interaction with a material is a negative sample. Similarly, in contrastive learning, if an image is a positive example, its different views are still positive examples for each other, while in a batch, all other images besides the positive image can be considered negative samples for that image. Therefore, although multiple negative samples may be described later, these negative samples do not necessarily have a mutually negative relationship.
[0040] hard negative samples : refers to proposals that are easily predicted as positive samples by the network, i.e., false positives. Training with hard negative samples significantly improves the network's classification performance.
[0041] easy negative samples Proposals that are easily predicted as negative samples: A large number of easy negative samples will cause the model's overall learning direction to go astray, resulting in ineffective learning.
[0042] Long-tail distribution: such as Figure 1 In a cumulative distribution function, the distribution of a random variable X is said to be a long-tailed distribution when the following conditions are met. Assume that for all t>0:
[0043]
[0044] This is equivalent to
[0045]
[0046] The principle behind recommendation models is to predict the probability (e.g., similarity) of a user's action towards an item (e.g., clicking), and then recommend items to the user based on the probability. The input to a recommendation model consists of the features of both the user and the item, and the training samples used for training are also constructed using these user and item features.
[0047] Understandably, the distribution of different types of training samples in the training sample set will affect the predictive ability of the trained recommendation model. Taking the type of negative samples as an example, if the training sample set contains a large number of easily identifiable easy negative samples (i.e., high-frequency samples), while the number of hard negative samples (i.e., low-frequency samples) that are easily identified as positive samples is extremely small, the recommendation model will be trained frequently by easy negative samples. The effect of easy negative feature data on updating the recommendation model will quickly weaken, resulting in a lot of ineffective training. Meanwhile, the low-frequency hard negative samples cannot provide sufficient training for the recommendation model, leading to a deficiency in the model's ability to distinguish hard negative samples. In a recommendation scenario, positive samples can be related content of recommended items that the user clicked, while negative samples can be related content of recommended items that the user did not click.
[0048] This imbalance is actually caused by the long-tailed distribution of the training samples, and it is unavoidable.
[0049] Currently, related technologies primarily focus on increasing the number of negative samples, failing to specifically address the issue of recommendation models not being able to fully learn the low-frequency features corresponding to low-frequency feature data due to long-tail distribution. Therefore, the training sample set used for recommendation models contains a large number of easy negative samples and a small number of hard negative samples. Consequently, the recommendation model will fully learn the high-frequency features related to easy negative samples but cannot fully learn the low-frequency features related to hard negative samples.
[0050] Therefore, how to improve the imbalanced distribution of training samples in order to enhance the performance of recommendation models has become a pressing technical problem in the industry.
[0051] In view of this, the embodiments of this disclosure can provide training methods, recommendation methods, apparatus, media and devices for recommendation models to solve the above problems.
[0052] Exemplary method embodiments
[0053] refer to Figure 1 The diagram shown illustrates a flowchart of a training method for a recommendation model in one embodiment of this disclosure.
[0054] exist Figure 1 The training method for the recommendation model includes:
[0055] Step S101: Obtain a set of training samples, the training samples including: first object feature data of a first object, second object feature data of a second object, and labels that identify whether the training samples are positive or negative samples.
[0056] For example, the group can refer to a batch, with each batch having the same number of training samples. The first object can be a user, and the second object can be an item. In a media recommendation scenario, the item includes, but is not limited to, one of the following: media; broadcaster; text content, etc. For example, the media can include one or a combination of music, music playlists, images, pictures, etc. The text content includes news, updates, comments, etc.
[0057] Step S102: Input the set of training samples into the recommendation model and execute the training process.
[0058] The training process is run within the recommendation model and specifically includes:
[0059] S1021: A first feature vector is obtained by mapping the first object feature data based on the input of the current training sample, and a second feature vector is obtained by mapping the second object feature data based on the current training sample;
[0060] S1022: At least one first object cluster is obtained by clustering based on each of the obtained first feature vectors, and at least one second cluster is obtained by clustering based on each of the obtained second feature vectors.
[0061] S1023: Update the recommendation model based on the loss calculated by the first loss function.
[0062] The loss calculated by the first loss function includes: a first loss part and a second loss part; the first loss part is obtained based on the first distance between the cluster centers of the second cluster to which the first feature vector and the second feature vector belong in the current training sample; the second loss part is obtained based on the second distance between the cluster centers of the first object cluster to which the second feature vector and the first feature vector belong in the current training sample.
[0063] Clustering groups similar training samples together to form clusters. The training samples are clustered into clusters, each corresponding to a user / material category. Then, a first loss function is used to optimize the loss on the distance between the feature vector of one object and the cluster centers of another object, replacing the loss from optimizing feature vector similarity in related techniques. This transforms the original one-to-one relationship with feature vectors into a one-to-many relationship, where one feature vector corresponds to one cluster center. The cluster center is calculated based on the combined feature vectors within the cluster. This "many" approach increases the frequency of low-frequency feature calculations, allowing the recommendation model to more fully learn the low-frequency features of users and materials.
[0064] In some embodiments, the clustering calculation method may be, for example, the K-means clustering algorithm, or other clustering methods such as hierarchical clustering.
[0065] The training process for each round is explained in detail. Each training sample can be represented as {a, b, x}, where a corresponds to the feature data of user a, b corresponds to the feature data of item b, and x is the label, indicating whether the sample is positive or negative, i.e., whether a has an action on b, which can be represented by, for example, "0" or "1". Training samples in a batch are input into the recommendation model one by one. User feature data and item feature data are mapped to obtain User feature vectors and item feature vectors. In each training round of the recommendation model, a training sample is input, and the clusters are combined with the input training sample and the previously formed clusters to perform clustering calculations for this round to update the clusters. This then calculates the loss for this round and uses it to update the parameters of the recommendation model for this round. In possible examples, clustering may only occur within a group (within a batch) and not across batches. For example, if a batch size is 8, then the number of embeddings used for clustering in 8 training rounds ranges from 1 to 8. In the next training epoch, the first training sample of the next batch is input into the recommendation model for training, and intra-group clustering of the embedding corresponding to the next batch is performed, and so on. Intra-group clustering is beneficial for implementing online recommendation models.
[0066] Figure 2 This illustration shows a schematic diagram of the principle of calculating loss using a first loss function based on the recommendation model architecture in an application example of this disclosure.
[0067] exist Figure 2 In the example, the recommendation model is exemplarily shown as a dual-tower model. The recommendation model has two parallel towers that map the input first object feature data (User feature data) and second object feature data (item feature data) to obtain feature vectors, namely a first feature vector (User Embedding) and a second feature vector (item Embedding). Then, a first loss component is calculated for the second cluster center of the second cluster to which the first feature vector and the second feature vector belong, and a second loss component is calculated for the first cluster center of the first object cluster to which the second feature vector and the first feature vector belong. Finally, the first and second loss components are combined to obtain the loss calculated by the first loss function. In a possible example, the first tower of the recommendation model includes a first feature vector processing layer and a first deep neural network, and the second tower includes a second feature vector processing layer and a second deep neural network.
[0068] Step 1021, which maps the first feature data of the first object based on the input to obtain a first feature vector, and maps the second feature data of the second object based on the input to obtain a second feature vector, specifically includes:
[0069] The first feature processing layer processes the first feature data into feature vectors to obtain a first preliminary feature vector, and the second feature processing layer processes the second feature data into feature vectors to obtain a second preliminary feature vector. In possible examples, the first and second feature processing may include feature encoding, feature vectorization, and pooling processing, etc. The pooling processing may be max-pooling and mean-pooling to process the User feature data and item feature data into Feature Embeddings as preliminary feature vectors.
[0070] The first object feature vector, i.e., the current User Embedding, is obtained through a first deep neural network based on the first preliminary feature vector. The second object feature vector, i.e., the current item Embedding, is obtained through a second deep neural network based on the second preliminary feature vector. In a possible example, the first and second deep neural networks can be implemented as DNNs, including an input layer, at least one hidden layer, and an output layer. The layers can be fully connected, meaning that any neuron in the i-th layer is connected to any neuron in the (i+1)-th layer. Each neuron in a layer takes the outputs of the neurons connected to the previous layer as input and calculates its output based on the weighted sum of these inputs (which may also include bias).
[0071] Furthermore, clustering is performed based on the current and previously obtained User Embeddings to obtain User clusters; clustering is also performed based on the current and previously obtained Item Embeddings to obtain Item clusters. The first loss component is formed by calculating the first distance between the current User Embedding and the center of the first cluster of the Item Embedding's Item cluster, and the second loss component is formed by calculating the second distance between the current Item Embedding and the center of the second cluster of the Item Embedding's User cluster. The loss calculated by the first loss function is the sum of the first and second loss components, which can be used to update the parameters of the recommendation model.
[0072] For example, the first loss function can be expressed as shown in equation (1):
[0073] l(z t q s )+l(z s q t (1)
[0074] Where t corresponds to User and s corresponds to item; l(z t qs ) represents the first loss portion; l(z) t q s ) indicates the second loss portion; z t Let z represent the first feature vector (i.e., the User feature vector). s q represents the second feature vector (i.e., the item feature vector); t q is the first center representation vector of the first cluster center of the first object class cluster to which the first feature vector belongs. s The second center representation vector represents the second cluster center of the second cluster to which the second feature vector belongs.
[0075] In some embodiments, the first spacing is obtained based on the similarity between the first feature vector and the second cluster center, and the second spacing is obtained based on the similarity between the second feature vector and the first cluster center. The similarity calculation function includes an adjustable temperature hyperparameter to control the impact of negative samples with different recognition difficulties on the loss calculated by the first loss function. In a possible example, the similarity calculation between the first feature vector and the second cluster center includes: calculating a first similarity metric based on the first feature vector and the second cluster center with which the similarity is to be calculated, combined with the temperature hyperparameter; and calculating a second similarity metric based on the first feature vector and other second cluster centers, combined with the temperature hyperparameter; and obtaining the similarity based on the ratio between the first similarity metric and the second similarity metric.
[0076] The first part of the loss l(z) t q s Let's take l(z) as an example to illustrate the above principle. t q s That is, to calculate the first spacing, the specific calculation formula can be exemplarily expressed as the following formula (2):
[0077]
[0078] In this case, it is assumed that K-means is pre-divided into K clusters, where k represents the k-th cluster.
[0079] That is, the similarity between the first feature vector and the second cluster center, expressed in the formula as the similarity between the k-th cluster center and the t-th User on the item side. The first similarity metric value, c is the second similarity metric. k The current feature vector representing the cluster center of the second cluster to which the second feature vector of the current input training sample belongs, i.e., the second cluster center to which the similarity is to be calculated, c k′ This represents other second-type cluster centers besides the one in question. T represents the matrix transpose.
[0080] The similarity calculation function includes an adjustable temperature hyperparameter to control the impact of negative samples with varying recognition difficulties on the loss calculated by the first loss function. τ is the temperature hyperparameter. It's understandable that the numerator emphasizes positive samples, aiming for the feature vectors mapped by positive samples to be as close as possible to each other; the denominator emphasizes negative samples, aiming for the feature vectors mapped by positive and negative samples to be as far apart as possible. By introducing τ into the first loss function, its value can be adjusted. For example, decreasing the value of τ can focus the loss on hard samples, thus increasing the similarity distance between positive samples and hard negative samples; furthermore, increasing the number of negative samples can also contribute to the effective learning of hard negative samples, even with more easy negative samples in the training samples.
[0081] By using the first loss function based on the distance between the feature vector of one object and the center of the corresponding cluster of another object, the learning frequency of the corresponding features of low-frequency hard negative samples has been improved to a certain extent. Furthermore, combined with the focus on the corresponding features of low-frequency hard negative samples brought about by τ, the recommendation model can further improve the sufficiency of learning the features of low-frequency negative samples.
[0082] based on Figure 2 As can be seen, the recommendation model can update parameters based on backpropagation of loss gradient descent. Therefore, the first loss function needs to be able to propagate the loss to the first deep neural network and the second deep neural network.
[0083] In some embodiments, a parameter matrix can be designed to map each first feature vector to the cluster center of its respective cluster, and this parameter matrix can be used to realize loss propagation in backpropagation.
[0084] In a specific example, K points C2 = {c1, c2, ..., c3} are randomly selected. K} As the cluster centers of each second-class cluster on the item side, c1~c K Let Z1 be the initial vector of the cluster center, and then, as shown in equation (1), map the first eigenvector set Z1 = {z1, z2, ..., z...}. T Each first eigenvector z1~z in} T Let Q1 = {q1,q2,...,q} T In calculations, z1 can be mapped to c1 via q1, ... via q K Corresponding to z T Mapping to C T For example, if z1~z is calculated T With c1, c2, ..., c KClustering is determined by similarity. For example, to determine if z1 and z3 belong to the same cluster as c1, a mapping relationship from z1 to c1 can be formed by, for example, z1q1 = c1, and a mapping relationship from z3 to c1 can be formed by, for example, z3 * q3 = c1. For example, c1 ~ c K If it can be a d-dimensional vector, then the C2 dimension is...<d,K> ;z1~z T It can be a d-dimensional vector, and T can be the size of a batch, then the dimension of Z1 is...<d,T> ;q1~q T It can be a K-dimensional vector, and the dimension of Q1 is...<K,T> Q1 updates parameters based on backpropagation of the loss and can propagate the loss back to the input layer to update the parameters of deep neural networks, etc.
[0085] Ideally, the similarity between a User and the second cluster center of the cluster to which the User belongs is 1, and the similarity between the User and the second cluster centers of other second clusters is 0.
[0086] It is understandable that the second loss component l(z) s q t The calculation principle of ) is the same as that of l(z) above. t q s The objects are the same, only the objects have changed. Therefore, based on the principle of the first loss part above, such as the principle of reference formula (2), the calculation method of the second loss part can be obtained. Among them, the second distance is obtained based on the similarity between the second feature vector and the center of the first cluster. The second loss part includes the similarity between the second feature vector and the center of the first cluster. Its calculation method includes: calculating the third similarity measure value based on the second feature vector and the center of the first cluster to be calculated, combined with the temperature hyperparameter, and calculating the fourth similarity measure value based on the second feature vector and other centers of the first cluster, combined with the temperature hyperparameter; and obtaining the similarity based on the ratio between the third similarity measure value and the fourth similarity measure value. Corresponding to the above examples of C2, Z1, Q1, l(z s q t The calculation also includes C1, Z2, and Q2. The loss is backpropagated through Q2 to update the model parameters.
[0087] To illustrate the above process more clearly, a specific example will be used.
[0088] Suppose we construct four training samples regarding user A's views of items 01, 02, 03, and 04, where A viewed item 03 but not items 01, 02, or 04. These four training samples are represented as {A feature data, item 01 feature data, 0}, {A feature data, item 02 feature data, 0}, {A feature data, item 03 feature data, 1}, and {A feature data, item 04 feature data, 0}. In a possible example, item 01 might be a song, whose feature data includes the title "xx" and the number of times it has been played (1000).
[0089] Input these four training samples one by one into the recommendation model, for example Figure 2 The recommendation model shown goes through a first feature mapping layer and a second feature mapping layer. The two feature data in each training sample are encoded in two separate paths to obtain FeatureEmbedding, which is then further mapped by a DNN to User Embedding and ItemEmbedding.
[0090] Cluster the existing UserEmbedding set and ItemEmbedding set respectively, setting K=2 for both, to form 2 User clusters and 2 Item clusters.
[0091] Let's continue with the example of calculating the first loss. We randomly generate C = {x1, x2}, where x1 and x2 are the initial cluster centers of two item clusters. We then calculate four item embeddings: V 01 V 02 V 03 V 04 Calculate the distances d to x1 and x2 respectively, and compare their magnitudes to achieve clustering.
[0092] In this example, it is assumed that the comparison between the calculated distances between each item embedding to x1 and x2 satisfies the following:
[0093] d(V 01 x1) <d(V 02 (x2)
[0094] d(V 02 x1) <d(V 02 (x2)
[0095] d(V 03 x1) <d(V 03 (x2)
[0096] d(V 04 (x2) <d(V 04 x1)
[0097] It can be seen that V 01V 02 V 03 They are clustered into one class, with cluster center x1; V 04 They cluster into one class, with the cluster center being x2.
[0098] Let Q = {q1, q2, q3, ... q} batch_size In this example, q1~q batch_size Both are vectors with dimension d = 2. If a batch has 4 training samples, then batch_size = 4.
[0099] V through vector Q 01 V 02 V 03 V 04 Mapping to C, we get:
[0100] V 01 q1 = x1;
[0101] V 02 q2 = x1;
[0102] V 03 q3 = x1;
[0103] V 04 q4 = x2.
[0104] Clustering effectively transforms the relationships between user and material features represented by the training samples {A feature data, material 01 feature data, 0}, {A feature data, material 02 feature data, 0}, {A feature data, material 03 feature data, 1}, and {A feature data, material 04 feature data, 0} into the overall relationship between users and each type of material: {A feature vector, x1 feature vector, 0}, {A feature vector, x1 feature vector, 0}, {A feature vector, x1 feature vector, 1}, and {A feature data, x2 feature vector, 0}. It is evident that the x1 feature vector appears three times, which is equivalent to the material 01, material 02, and material 03 feature data appearing three times as a whole, effectively improving the sufficiency of training the recommendation model with low-frequency samples.
[0105] Furthermore, for example, based on the principle of updating cluster centers using the K-means clustering algorithm, in each training epoch of the recommendation model, the cluster centers C are updated according to the mean values of the feature vectors in the same cluster during the training epoch; that is, x1 and x2 are updated. As x1 and x2 are updated, q1 to q4 are also updated, thus backpropagating the loss.
[0106] Additionally, in some embodiments, cropping can be performed on each training sample in the training sample set to obtain multiple cropped samples of each training sample from different views. These cropped samples are mutually positive, as are the cropped samples and the original training samples, because they belong to different views of the same training sample. This can improve the training sufficiency of the recommendation model using low-frequency samples in the training sample set. Optionally, each training sample can form a pair of cropped feature data, called a cropped feature data pair, and a loss function can be constructed to measure the similarity between the cropped feature data pairs, allowing the recommendation model to learn to recognize that the cropped feature data are mutually positive. In some embodiments, the cropping process includes randomly cropping the values of at least one dimension of the first object feature data and the second object feature data, such as randomly discarding values in certain dimensions of the first and second feature data.
[0107] Specifically, a first cropped feature data pair can be obtained by performing cropping processing on the first object feature data in the training samples, and a second cropped feature data pair can be obtained by performing cropping processing on at least the second object feature data in the training samples. That is, a User cropped feature data pair is generated for each User feature data of the input positive sample, and an item cropped feature data pair is generated for each item feature data of the positive sample.
[0108] Furthermore, the generated User clipping feature data pairs and item clipping feature data pairs can be input into the User-side and item-side stacks of the recommendation model, respectively, and their corresponding losses can be calculated using the second loss function to update the parameters of the recommendation model.
[0109] The second loss function can be exemplarily expressed as the following equation (3):
[0110]
[0111] in, Measured for the third loss component and Losses between and Based on the first eigenvector z t Two positive examples obtained from random cropping; This is the fourth part of the loss. and Based on the second eigenvector z s Two positive examples obtained from random cropping.
[0112] For example, a training sample contains User feature data User1 and item feature data item1, along with a label (0 or 1). The User feature data is input into the recommendation model to generate UserEmbedding. The User feature data is then randomly pruned twice to obtain User-pruned feature data pairs, containing User1' and User1'. Inputting User1' and User1' into the generated feature vector pairs UserEmbedding1' and UserEmbedding1' is then performed. Calculate the loss between User Embedding1' and UserEmbedding1". Similarly, it can be done through... Calculate the corresponding loss for item1. This can be achieved using the InformCE function.
[0113] like Figure 3 As shown, a schematic diagram illustrates the principle of calculating loss using a second loss function based on the recommendation model architecture in an application example of this disclosure.
[0114] The recommendation model in the diagram could be as follows: Figure 2 The dual-tower model shown uses networks connected by double arrows that actually share parameters (such as sharing first object feature data and second object feature data), representing one of the two towers. Training samples are input into this recommendation model. The first object feature data generates a first feature vector in the first tower, and the second object feature data generates a second feature vector in the second tower. The first object feature data, after being pruned, generates two pruned feature data points: first pruned feature data 1 and first pruned feature data 2. These are then input into the first tower to obtain first pruned vector 1 and first pruned vector 2, respectively. A third loss component is calculated between these two pruned feature vectors. Similarly, the second object feature data, after being pruned, generates second pruned feature data 1 and second pruned feature data 2. These two pruned feature vectors are then input into the second tower to obtain second pruned vector 1 and second pruned vector 2, respectively. A fourth loss component is calculated between these two pruned feature vectors. Based on the second loss function, the third and fourth loss components are combined to obtain the loss calculated by the second loss function, which is used to update the parameters of the recommendation model. In other embodiments, the generated feature vectors may be pruned twice to obtain pruned vector pairs; however, compared to pruned feature data, the pruned feature data is processed in the tower because the pruned parts are padded with zeros for calculation, which is more efficient than the calculation of complete feature data.
[0115] In some embodiments, the second loss function and the first loss function can be combined into a third loss function, and the losses calculated by them can be integrated to jointly update the parameters of the recommendation model.
[0116] For example, in equation (4), the third loss function L(z) is calculated. t , z s ):
[0117]
[0118] Therefore, it is possible to Figure 4 The diagram shown illustrates a flowchart of a training method for a recommendation model according to another embodiment of this disclosure. Figure 1 Compared to the previous embodiment, the difference in this embodiment is that the first loss function and the second loss function are used together to train the recommendation model.
[0119] exist Figure 4 The process includes:
[0120] Step S401: Obtain a set of training samples, the training samples including: first object feature data of a first object, second object feature data of a second object, and labels that identify whether the training samples are positive or negative samples;
[0121] Step S402: Perform cropping processing on the first object feature data in the training samples to obtain a first cropped feature data pair, and perform cropping processing on the second object feature data in the training samples to obtain a second cropped feature data pair;
[0122] Step S403: Input the set of training samples, and the first and second cropping feature data pairs of each training sample into the recommendation model, and perform the training process including:
[0123] Step S4031: Obtain a first feature vector by mapping the first object feature data of the current training sample, and obtain a second feature vector by mapping the second object feature data of the current training sample; obtain a first cropping vector pair by mapping the first cropping feature data pair of the current training sample, and obtain a second cropping vector pair by mapping the second cropping feature data pair of the current training sample.
[0124] Step S4032: Based on the obtained first feature vectors, at least one first object cluster is obtained by clustering, and based on the obtained second feature vectors, at least one second cluster is obtained;
[0125] Step S4033: Update the recommendation model based on the loss calculated jointly by the first loss function and the second loss function.
[0126] The loss calculated by the first loss function includes: a first loss part and a second loss part; the first loss part is obtained based on the first distance between the cluster centers of the second cluster to which the first feature vector and the second feature vector belong in the current training sample; the second loss part is obtained based on the second distance between the cluster centers of the second feature vector and the first object cluster to which the first feature vector belongs in the current training sample; the loss calculated by the second loss function includes: a third loss part between the clipped feature vectors in the first clipped feature vector pair; and a fourth loss part between the clipped feature vectors in the second clipped feature vector pair.
[0127] In other embodiments, the loss can be calculated sequentially based on the first loss function and the second loss function, and the recommendation model can be updated accordingly. For example, when a current training sample is input into the recommendation model, the loss is first calculated using the first loss function corresponding to the output of the current training sample in the recommendation model, and the recommendation model parameters are updated. Then, the loss is calculated using the second loss function corresponding to the various pruning feature data of the current training sample in the output of the recommendation model, and the recommendation model parameters are updated again. Alternatively, the recommendation model parameters can be updated first using the second loss function, and then updated using the first loss function. The choice can be made based on balancing the precision and recall of the recommendation model.
[0128] Figure 5 A schematic diagram of the training method for the recommendation model in yet another embodiment of this disclosure is shown.
[0129] exist Figure 5 The example demonstrates the process of updating model parameters by first using the first loss function and then using the second loss function. Figure 1 Compared to the previous embodiment, the difference in this embodiment lies in the fact that the recommendation model is trained using the first loss function and the second loss function sequentially.
[0130] exist Figure 5 The process includes:
[0131] Step S501: Obtain a set of training samples, the training samples including: first object feature data of a first object, second object feature data of a second object, and labels that identify whether the training samples are positive or negative samples;
[0132] Step S502: Perform cropping processing on the first object feature data in the training samples to obtain a first cropped feature data pair, and perform cropping processing on the second object feature data in the training samples to obtain a second cropped feature data pair;
[0133] Step S503: Input the set of training samples, and the first and second cropping feature data pairs of each training sample into the recommendation model, and perform the training process including:
[0134] Step S5031: Obtain a first feature vector by mapping the first object feature data based on the input of the current training sample, and obtain a second feature vector by mapping the second object feature data based on the current training sample;
[0135] Step S5032: Based on the obtained first feature vectors, at least one first object cluster is obtained by clustering, and based on the obtained second feature vectors, at least one second cluster is obtained;
[0136] Step S5033: Update the recommendation model based on the loss calculated by the first loss function;
[0137] Step S5034: Obtain a first cropping vector pair by mapping the first cropping feature data pair based on the current training sample, and obtain a second cropping vector pair by mapping the second cropping feature data pair based on the current training sample;
[0138] Step S5035: Update the recommendation model based on the loss calculated by the second loss function.
[0139] like Figure 6 The diagram shown illustrates a flowchart of a recommended method in one embodiment of this disclosure.
[0140] The recommendation method can be based on a training method (e.g., as described in the embodiments of this disclosure) Figure 1 Figure 4 Figure 5 The recommendation model trained by the model was used to complete the task.
[0141] exist Figure 6 The recommendation method includes:
[0142] Step S601: Obtain first feature data of at least one first object and second feature data of multiple second objects.
[0143] In some embodiments, the first object includes a first user, and the second object includes a second user or a media object.
[0144] Step S602: Input the first feature data and the second feature data into the recommendation model to obtain the similarity between the at least one first object and the plurality of second objects.
[0145] Specifically, the recommendation model can obtain a first feature vector based on the first object feature data of the input current training sample, and obtain a second feature vector based on the second object feature data of the current training sample, and can obtain the similarity by taking the inner product of the first feature vector and the second feature vector.
[0146] Step S603: Sort the plurality of second objects based on the similarity for recommendation to the first object.
[0147] The recommendation model trained by the training method in this embodiment can be applied to scenarios such as recommendation retrieval and coarse ranking. The recommendation process can include content retrieval, coarse ranking, fine ranking, and re-ranking, each of which is a step.
[0148] Additionally, in some embodiments, the recommendation method further includes outputting the first feature vector and / or the second feature vector. The first and second feature vectors can be used as inputs or intermediate vectors for other models, such as the generated User Embedding and / or item Embedding as feature vectors used in ranking, for example. Similarly, in other search scenarios, such as ad search, User Embedding and / or item Embedding can also be used as feature vectors in the model.
[0149] The recommendation model trained by the training method described in the previous embodiments learns low-frequency features to a greater extent, thereby making the generated embeddings more reliable. Consequently, the related recall and ranking results will be more reliable, and the item recommendations will be more accurate.
[0150] Exemplary device embodiments
[0151] After introducing the exemplary method implementations of this disclosure, the following references are made. Figure 7 The training apparatus 700 for the recommended model of the exemplary embodiments of this disclosure will be described.
[0152] Since the various functional modules or sub-modules of the training device 700 for the recommended model in this embodiment are in the same principle as the corresponding steps or sub-steps of the training method in the above exemplary method embodiments, the specific implementation in this embodiment can refer to the previous content, and the same technical content will not be repeated.
[0153] like Figure 7As shown, in one embodiment of this disclosure, a training device 700 for a recommendation model includes: a training sample acquisition module 701, used to acquire a set of training samples, the training samples including: first object feature data of a first object, second object feature data of a second object, and labels identifying the training samples as positive or negative samples; and a model training module 702, used to input the set of training samples into a recommendation model, and perform a training process including: mapping a first feature vector based on the input first object feature data, and mapping a second feature vector based on the input second object feature data; clustering at least one first object cluster based on each obtained first feature vector, and clustering at least one second cluster based on each obtained second feature vector; and updating the recommendation model based on the loss calculated by a first loss function; wherein the loss calculated by the first loss function includes: a first loss part and a second loss part; the first loss part is obtained based on a first distance between the cluster centers of the first feature vector and the second feature vector in the current training sample; and the second loss part is obtained based on a second distance between the second feature vector and the cluster centers of the first object cluster in the current training sample.
[0154] In some embodiments, the training device 700 further includes: a pruning module, configured to perform pruning processing on first object feature data in the training samples to obtain a first pruning feature data pair, and perform pruning processing on at least second object feature data in the training samples to obtain a second pruning feature data pair, before inputting the set of training samples to the recommendation model.
[0155] In some embodiments, the model training module 702 inputs the set of training samples to the recommendation model, and the training process further includes: inputting the first cropped feature data pair and the second cropped feature data pair to the recommendation model, and the training process includes: mapping the first cropped feature data pair based on the current training sample to obtain a first cropped vector pair, and mapping the second cropped feature data pair based on the current training sample to obtain a second cropped vector pair; updating the recommendation model based on the loss jointly calculated by the first loss function and the second loss function; or, calculating the loss sequentially based on the first loss function and the second loss function and updating the recommendation model respectively; wherein the loss calculated by the second loss function includes: a third loss portion between cropped feature vectors in the first cropped feature vector pair; and a fourth loss portion between cropped feature vectors in the second cropped feature vector pair.
[0156] In some embodiments, the cropping process includes randomly cropping the value of at least one dimension of the first object feature data and the second object feature data.
[0157] In some embodiments, the first spacing is obtained based on the similarity between the first feature vector and the center of the second cluster, and the second spacing is obtained based on the similarity between the second feature vector and the center of the first cluster; the similarity calculation function includes an adjustable temperature hyperparameter to control the impact of negative samples with different recognition difficulties on the loss calculated by the first loss function.
[0158] In some embodiments, the similarity calculation method between the first feature vector and the second cluster center includes: calculating a first similarity metric based on the first feature vector and the second cluster center whose similarity is to be calculated, combined with a temperature hyperparameter; and calculating a second similarity metric based on the first feature vector and other second cluster centers, combined with a temperature hyperparameter; and obtaining a similarity based on the ratio between the first similarity metric and the second similarity metric. The similarity calculation method between the second feature vector and the first cluster center includes: calculating a third similarity metric based on the second feature vector and the first cluster center whose similarity is to be calculated, combined with a temperature hyperparameter; and calculating a fourth similarity metric based on the second feature vector and other first cluster centers, combined with a temperature hyperparameter; and obtaining a similarity based on the ratio between the third similarity metric and the fourth similarity metric.
[0159] In some embodiments, the model training module 702 is further configured to perform updates to the first object cluster and the second cluster in each training round of the recommendation model.
[0160] In some embodiments, the recommendation model includes a first feature vector processing layer, a first deep neural network, a second feature vector processing layer, and a second deep neural network; the process of mapping the first feature vector based on the input first object feature data and the second feature vector based on the input second object feature data includes: performing feature vector processing on the first feature data through the first feature processing layer to obtain a first preliminary feature vector, performing feature vector processing on the second feature data through the second feature processing layer to obtain a second preliminary feature vector; obtaining the first object feature vector based on the first preliminary feature vector through the first deep neural network, and obtaining the second object feature vector based on the second preliminary feature vector through the second deep neural network.
[0161] refer to Figure 8 A recommended apparatus 800 according to an exemplary embodiment of the present disclosure will be described.
[0162] Since the various functional modules or sub-modules of the recommendation device 800 in this embodiment are in the same principle as the corresponding steps or sub-steps of the recommendation method in the above exemplary method embodiments, the specific implementation in this embodiment can refer to the previous content, and the same technical content will not be repeated.
[0163] like Figure 8 As shown, in one embodiment of this disclosure, a recommendation device 800 includes: a feature acquisition module 801, configured to acquire first feature data of at least one first object and second feature data of a plurality of second objects; an input module 802, configured to input the first feature data and the second feature data into a recommendation model to obtain the similarity between the at least one first object and the plurality of second objects; and a ranking module 803, configured to rank the plurality of second objects based on the similarity for recommendation to the first object; wherein the recommendation model is trained by the training method as described in the previous embodiments.
[0164] In some embodiments, the recommendation model obtains a first feature vector based on a first object feature data mapping of the input current training sample, and obtains a second feature vector based on a second object feature data mapping of the current training sample; the recommendation model also outputs the first feature vector and / or the second feature vector.
[0165] In some embodiments, the first object includes a first user, and the second object includes a second user or a media object.
[0166] Exemplary storage media
[0167] After introducing the methods and apparatus of exemplary embodiments of the present disclosure, the storage medium of exemplary embodiments of the present disclosure will now be described with reference to FIG9.
[0168] refer to Figure 9 As shown, a storage medium 900 according to an embodiment of the present disclosure is described. This medium may contain program code and can run on a device, such as a server, to execute the various steps and sub-steps in the above-described method embodiments of the present disclosure. In this document, a readable storage medium can 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.
[0169] The program code may take the form of any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of readable storage media (a non-exhaustive list) include: an electrical connection having one or more wires, a portable disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0170] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, carrying readable program code. Such propagated data signals may take various 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, capable of sending, propagating, or transmitting programs for use by or in conjunction with an instruction execution system, apparatus, or device.
[0171] The program code contained on the readable medium may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.
[0172] Program code for performing the operations of this disclosure can be written in any combination of one or more programming languages, including object-oriented programming languages such as Java and C++, and conventional procedural programming languages such as C or similar languages. The program code can execute entirely on the user's computing device, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).
[0173] Exemplary electronic devices
[0174] Having described the storage medium of exemplary embodiments of this disclosure, the following references are made. Figure 10 An electronic device according to an exemplary embodiment of the present disclosure will be described.
[0175] Figure 10 The electronic device 1000 shown is merely an example and should not be construed as limiting the functionality or scope of use of the embodiments disclosed herein. The electronic device 1000 can be implemented in servers, etc.
[0176] like Figure 10 As shown, the electronic device 1000 is manifested in the form of a general-purpose computing device. The components of the electronic device 1000 may include, but are not limited to: at least one processing unit 1010, at least one storage unit 1020, and a bus 1030 connecting different system components (including storage unit 1020 and processing unit 1010).
[0177] The storage unit stores program code, which can be executed by the processing unit 1010 to perform the steps and sub-steps of the method described in the above embodiments of this disclosure. For example, the processing unit 1010 can perform, for instance, the following steps: Figure 1 , Figure 3 or Figure 6 The steps in the embodiments, etc.
[0178] In some embodiments, storage unit 1020 may include volatile storage units, such as random access memory (RAM) 10201 and / or cache storage unit 10202, and may further include read-only memory (ROM) 10203.
[0179] In some embodiments, the storage unit 1020 may also include a program / utility 10204 having a set (at least one) of program modules 10205, such program modules 10205 including but not limited to: an operating system, one or more applications, other program modules, and program data, each or some combination of these examples may include an implementation of a network environment.
[0180] In some embodiments, bus 1030 may include a data bus, an address bus, and a control bus.
[0181] In some embodiments, the electronic device 1000 can also communicate with one or more external devices 1100 (e.g., keyboards, pointing devices, Bluetooth devices, etc.) via the input / output (I / O) interface 1050. Optionally, the electronic device 1000 also includes a display unit 1040 connected to the input / output (I / O) interface 1050 for display purposes. Furthermore, the electronic device 1000 can also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via a network adapter 1060. As shown, the network adapter 1060 communicates with other modules of the electronic device 1000 via a bus 1030. It should be understood that, although not shown in the figures, other hardware and / or software modules can be used in conjunction with the electronic device 1000, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0182] It should be noted that although several modules or sub-modules, such as training devices and recommendation devices, are mentioned in the detailed description above, this division is merely exemplary and not mandatory. In fact, according to embodiments of this disclosure, the features and functions of two or more units / modules described above can be embodied in one unit / module. Conversely, the features and functions of one unit / module described above can be further divided and embodied by multiple units / modules.
[0183] Furthermore, although the operations of the methods disclosed herein are described in a specific order in the accompanying drawings, this does not require or imply that these operations must be performed in that specific order, or that all of the operations shown must be performed to achieve the desired result. Additionally or alternatively, certain steps may be omitted, multiple steps may be combined into one step, and / or one step may be broken down into multiple steps.
[0184] While the principles of this disclosure have been described with reference to several specific embodiments, it should be understood that this disclosure is not limited to the disclosed specific embodiments, and the division of aspects does not imply that features in these aspects cannot be combined for benefit; such division is merely for convenience of expression. This disclosure is intended to cover various modifications and equivalent arrangements included within the spirit and scope of the appended claims.
Claims
1. A method for training a recommendation model, characterized in that, The application is applied to a media recommendation scenario, including: obtaining a set of training samples, the training samples including: first object feature data of a first object, second object feature data of a second object, and a label identifying the training sample as a positive sample or a negative sample; the first object is a user, and the second object is a material, which includes but is not limited to any one of the following: media; anchor; text content; inputting the set of training samples into a recommendation model, and performing a training process including: mapping the first object feature data of the input current training sample to obtain a first feature vector, and mapping the second object feature data of the current training sample to obtain a second feature vector; clustering each obtained first feature vector to obtain at least one first object cluster, and clustering each obtained second feature vector to obtain at least one second object cluster; the first object cluster is a category of the user, and the second object cluster is a category of the material; updating the recommendation model based on the loss calculated by the first loss function; wherein the loss calculated by the first loss function includes: a first loss part and a second loss part; the first loss part is obtained based on a first distance between the first feature vector and the second feature vector in the current training sample and the cluster center of the second object cluster; and the second loss part is obtained based on a second distance between the second feature vector and the cluster center of the first object cluster of the first feature vector in the current training sample.
2. The training method of claim 1, wherein, Before the inputting the set of training samples into the recommendation model, further including: performing clipping processing on the first object feature data in the training sample to obtain a first clipped feature data pair, and performing clipping processing on the second object feature data in the training sample to obtain a second clipped feature data pair.
3. The training method of claim 2, wherein, Further including: inputting the first clipped feature data pair and the second clipped feature data pair into the recommendation model, and performing a training process including: mapping the first clipped feature data pair of the current training sample to obtain a first clipped feature vector pair, and mapping the second clipped feature data pair of the current training sample to obtain a second clipped feature vector pair; updating the recommendation model based on the loss calculated by the first loss function and the second loss function; or, sequentially calculating the loss by the first loss function and the second loss function and updating the recommendation model respectively; wherein the loss calculated by the second loss function includes: a third loss part between the clipped feature vectors in the first clipped feature vector pair; and a fourth loss part between the clipped feature vectors in the second clipped feature vector pair.
4. The training method of claim 2, wherein, The clipping processing includes randomly clipping the value of at least one dimension in the first object feature data and the second object feature data.
5. The training method of claim 1, wherein, The first distance is obtained according to the similarity between the first feature vector and the second cluster center, and the second distance is obtained according to the similarity between the second feature vector and the first cluster center; The calculation function of the similarity includes an adjustable temperature hyperparameter for controlling the influence of the loss calculated by the first loss function on different identification difficulties of the negative sample.
6. The training method of claim 5, wherein, The similarity calculation between the first feature vector and the second cluster center of the second type comprises: calculating a first similarity value according to the first feature vector and the second cluster center of the second type to be calculated, and combining the temperature hyperparameter, and calculating a second similarity value according to the first feature vector and other second cluster centers of the second type, and combining the temperature hyperparameter; and obtaining the similarity based on the ratio between the first similarity value and the second similarity value; The similarity calculation between the second feature vector and the first cluster center of the first type comprises: calculating a third similarity value according to the second feature vector and the first cluster center of the first type to be calculated, and combining the temperature hyperparameter, and calculating a fourth similarity value according to the second feature vector and other first cluster centers of the first type, and combining the temperature hyperparameter; and obtaining the similarity based on the ratio between the third similarity value and the fourth similarity value.
7. The training method of claim 1, wherein Further comprising: In each training round of the recommendation model, the update of the first is performed.
8. The training method of claim 1, wherein, The recommendation model comprises a first feature vector processing layer, a first deep neural network, a second feature vector processing layer, and a second deep neural network; the first feature vector is obtained based on the input first object feature data, and the second feature vector is obtained based on the input second object feature data, comprising: The first feature data is processed by the first feature processing layer to obtain a first preliminary feature vector, and the second feature data is processed by the second feature processing layer to obtain a second preliminary feature vector; The first object feature vector is obtained based on the first preliminary feature vector by the first deep neural network, and the second object feature vector is obtained based on the second preliminary feature vector by the second deep neural network.
9. A recommendation method characterized by comprising: Comprising: Obtaining first feature data of at least one first object and second feature data of a plurality of second objects; Inputting the first feature data and the second feature data into a recommendation model to obtain the similarity between the at least one first object and the plurality of second objects; Based on the similarity, the plurality of second objects are sorted for recommendation to the first object; The recommendation model is trained by the training method of any one of claims 1 to 8.
10. The recommendation method of claim 9, wherein, The recommendation model maps the first feature vector based on the input first object feature data of the current training sample, and maps the second feature vector based on the second object feature data of the current training sample; the recommendation method further comprises: Outputting the first feature vector and / or the second feature vector.
11. A training device for a recommendation model, characterized in that, Applied to a media recommendation scenario, comprising: A training sample acquisition module is configured to acquire a group of training samples, wherein the training samples comprise: first object feature data of a first object, second object feature data of a second object, and a label identifying whether the training sample is a positive sample or a negative sample; the first object is a user, and the second object is a material, which includes but is not limited to any one of the following: media; anchor; text content; The model training module is configured to input the set of training samples into the recommendation model and perform a training process, including: obtaining a first feature vector based on the input first object feature data mapping, and obtaining a second feature vector based on the input second object feature data mapping; clustering each obtained first feature vector to obtain at least one first object cluster, and clustering each obtained second feature vector to obtain at least one second object cluster; the first object cluster is a category of a user, and the second object cluster is a category of a material; updating the recommendation model based on a loss calculated by a first loss function; wherein the loss calculated by the first loss function includes a first loss part and a second loss part; the first loss part is obtained based on a first distance between the first feature vector and the second feature vector in the current training sample and the cluster center of the second cluster; and the second loss part is obtained based on a second distance between the second feature vector and the cluster center of the first object cluster to which the first feature vector belongs.
12. The training device of claim 11, wherein, Further comprising: The clipping module is configured to perform clipping processing on the first object feature data in the training sample to obtain a first clipped feature data pair, and perform clipping processing on the second object feature data in the training sample to obtain a second clipped feature data pair.
13. The exercise device of claim 12, wherein, The model training module is configured to input the set of training samples into the recommendation model and perform a training process, including: The model training module is configured to input the set of training samples into the recommendation model and perform a training process, including: The model training module is configured to input the set of training samples into the recommendation model and perform a training process, including: The model training module is configured to input the set of training samples into the recommendation model and perform a training process, including: The model training module is configured to input the set of training samples into the recommendation model and perform a training process, including:
14. The exercise device of claim 12, wherein, The model training module is configured to input the set of training samples into the recommendation model and perform a training process, including:
15. The exercise device of claim 11, wherein, The model training module is configured to input the set of training samples into the recommendation model and perform a training process, including: The clipping processing includes randomly clipping the value of at least one dimension of the first object feature data and the second object feature data. The first distance is obtained according to the similarity between the first feature vector and the second cluster center, and the second distance is obtained according to the similarity between the second feature vector and the first cluster center; The calculation function of the similarity includes an adjustable temperature hyperparameter for controlling the influence of the loss calculated by the first loss function on different negative samples with different recognition difficulties.
16. The exercise device of claim 15, wherein, The similarity calculation between the first feature vector and the second cluster center of the second type comprises: calculating a first similarity value according to the first feature vector and the second cluster center of the second type to be calculated in combination with a temperature hyperparameter, and calculating a second similarity value according to the first feature vector and other second cluster centers of the second type in combination with the temperature hyperparameter; and obtaining the similarity based on the ratio between the first similarity value and the second similarity value. The similarity calculation between the second feature vector and the first cluster center of the first type comprises: calculating a third similarity value according to the second feature vector and the first cluster center of the first type to be calculated in combination with a temperature hyperparameter, and calculating a fourth similarity value according to the second feature vector and other first cluster centers of the first type in combination with the temperature hyperparameter; and obtaining the similarity based on the ratio between the third similarity value and the fourth similarity value.
17. The exercise device of claim 11, wherein, The model training module is further configured to perform the update on the first in each training round of the recommendation model.
18. The exercise device of claim 11, wherein, The recommendation model comprises a first feature vector processing layer, a first deep neural network, a second feature vector processing layer, and a second deep neural network; the first feature vector is obtained based on the input first object feature data, and the second feature vector is obtained based on the input second object feature data, comprising: performing feature vector processing on the first feature data through the first feature processing layer to obtain a first preliminary feature vector, and performing feature vector processing on the second feature data through the second feature processing layer to obtain a second preliminary feature vector; obtaining the first object feature vector based on the first preliminary feature vector through the first deep neural network, and obtaining the second object feature vector based on the second preliminary feature vector through the second deep neural network.
19. A recommendation apparatus characterized by comprising: Comprising: a feature acquisition module configured to acquire first feature data of at least one first object and second feature data of a plurality of second objects; an input module configured to input the first feature data and the second feature data to a recommendation model to obtain a similarity between the at least one first object and the plurality of second objects; a sorting module configured to sort the plurality of second objects based on the similarity for recommendation to the first object; wherein the recommendation model is trained by the training method of any one of claims 1 to 8.
20. The recommendation device of claim 19, wherein, The recommendation model maps the first feature vector based on the input first object feature data of the current training sample, and maps the second feature vector based on the second object feature data of the current training sample; and the recommendation model further outputs the first feature vector and / or the second feature vector.
21. A storage medium having stored thereon a computer program, characterized in that The computer program is executed by the processor to implement: the training method of any one of claims 1 to 8; or the recommendation method of any one of claims 9 to 10.
22. An electronic device, comprising: Comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to execute the training method of any one of claims 1 to 8; or the recommendation method of any one of claims 9 to 10 via execution of the executable instructions. the training method of any one of claims 1 to 8; or the recommendation method of any one of claims 9 to 10.
Citation Information
Patent Citations
Information intelligent recommendation method based on deep clustering
CN112417289A
Push model training method and device, data push method and device and storage medium
CN113033090A