Model training method, content recommendation method, device, equipment and storage medium
Patent Information
- Application Number
- CN202511420035.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-29
- Publication Date
- 2026-10-27
- Estimated Expiration
- 2045-09-29
AI Technical Summary
[0003]相关技术中,在进行混合推荐时,通常的做法是先对每种类型内容单独推荐,然后单独将不同类型的推荐结果进行融合;由于上述推荐方式需要分类型建模,这样,无论是人力还是硬件资源都是多倍占用,导致推荐成本高昂
[0025]本申请实施例提供一种模型训练方法、内容推荐方法、装置、电子设备和计算机存储介质,所述方法包括:获取多个训练样本,每个训练样本包括样本用户的样本用户特征、样本内容的样本内容特征以及所述样本内容对应的标签,不同训练样本的样本内容的类型不同,所述标签表征所述样本用户是否点击过对应类型的样本内容;使用所述多个训练样本对初始内容推荐模型进行训练,得到推荐损失和对比学习损失;所述初始内容推荐模型用于确定所述样本用户对所述对应类型的样本内容的点击概率;基于所述推荐损失和所述对比学习损失,对所述初始内容推荐模型的参数进行调整,得到训练完成的内容推荐模型。
Smart Images

Figure CN121350306B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of information recommendation technology, and in particular to a model training method, a content recommendation method, an apparatus, an electronic device, and a computer storage medium. Background Technology
[0002] Current recommendation systems can no longer be limited to recommending a single type of content; they often need to recommend and display multiple different types of content in the same scenario. Taking video applications (apps) as an example, the homepage feed needs to mix and recommend various types of content, such as long videos, short videos, live sports broadcasts, and ranking lists. A feed refers to a continuously updated information stream that presents content to the user; in some cases, it is even necessary to integrate content types with a wider range of recommendation scopes, such as mixing and recommending different types of content like videos, music, news, and products.
[0003] In related technologies, when performing hybrid recommendations, the usual practice is to first recommend each type of content separately, and then merge the recommendation results of different types separately. Since the above recommendation method requires categorized modeling, it consumes many times more human and hardware resources, resulting in high recommendation costs. Summary of the Invention
[0004] This application provides a model training method, a content recommendation method, an apparatus, an electronic device, and a computer storage medium.
[0005] The technical solution of this application is implemented as follows:
[0006] This application provides a model training method, the method comprising:
[0007] Multiple training samples are obtained. Each training sample includes the sample user features, the sample content features, and the corresponding tags of the sample content. The sample content of different training samples is of different types, and the tags indicate whether the sample user has clicked on the corresponding type of sample content.
[0008] The initial content recommendation model is trained using the multiple training samples to obtain recommendation loss and contrastive learning loss; the initial content recommendation model is used to determine the click probability of the sample user for the corresponding type of sample content;
[0009] Based on the recommendation loss and the contrastive learning loss, the parameters of the initial content recommendation model are adjusted to obtain the trained content recommendation model.
[0010] This application also provides a content recommendation method, the method comprising:
[0011] Obtain the user characteristics of the current user and the content characteristics of multiple pieces of content to be recommended, as the types of different pieces of content to be recommended are different;
[0012] The trained content recommendation model is used to process the user features and various content features to obtain the click probability of the current user for each piece of content to be recommended; the trained content recommendation model is trained according to the model training method provided by one or more of the aforementioned technical solutions;
[0013] Content recommendations are made to the current user based on the click probability.
[0014] This application also provides a model training apparatus, the apparatus comprising:
[0015] The first acquisition module is used to acquire multiple training samples. Each training sample includes the sample user features of the sample user, the sample content features of the sample content, and the label corresponding to the sample content. The sample content of different training samples is of different types, and the label indicates whether the sample user has clicked on the corresponding type of sample content.
[0016] The training module is used to train the initial content recommendation model using the multiple training samples to obtain the recommendation loss and the contrastive learning loss; the initial content recommendation model is used to determine the click probability of the sample user for the corresponding type of sample content;
[0017] The adjustment module is used to adjust the parameters of the initial content recommendation model based on the recommendation loss and the contrastive learning loss, so as to obtain the trained content recommendation model.
[0018] This application also provides a content recommendation device, the device comprising:
[0019] The second acquisition module is used to acquire the user characteristics of the current user and the content characteristics of multiple content to be recommended. The types of different content to be recommended are different.
[0020] The processing module is used to process the user features and various content features using the trained content recommendation model to obtain the click probability of the current user for each content to be recommended; the trained content recommendation model is trained according to the model training method provided by one or more of the aforementioned technical solutions;
[0021] The recommendation module is used to recommend content to the current user based on the click probability.
[0022] This application provides an electronic device, the device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, it implements the model training method or content recommendation method provided by one or more of the foregoing technical solutions.
[0023] This application provides a computer storage medium storing a computer program; when the computer program is executed, it can implement the model training method or content recommendation method provided by one or more of the aforementioned technical solutions.
[0024] This application provides a computer program product, including a computer program that, when executed by a processor, implements the model training method or content recommendation method provided by one or more of the aforementioned technical solutions.
[0025] This application provides a model training method, a content recommendation method, an apparatus, an electronic device, and a computer storage medium. The method includes: acquiring multiple training samples, each training sample including sample user features, sample content features, and a tag corresponding to the sample content. The sample content of different training samples has different types, and the tag indicates whether the sample user has clicked on sample content of the corresponding type. The method also includes: training an initial content recommendation model using the multiple training samples to obtain a recommendation loss and a contrastive learning loss; using the initial content recommendation model to determine the probability that the sample user clicks on the sample content of the corresponding type; and adjusting the parameters of the initial content recommendation model based on the recommendation loss and the contrastive learning loss to obtain a trained content recommendation model.
[0026] As can be seen from the embodiments of this application, during the model training process, only one initial content recommendation model needs to be trained for different types of sample content. In other words, the entire training process does not require separate training and classification of different types of sample content. This effectively reduces the occupation of human and hardware resources and saves recommendation costs. In addition, since the initial content recommendation model is used to determine the click probability of sample users for different types of sample content, and the click probability can reflect the sample users' preferences for different types of sample content, the initial content recommendation model can merge the recommendation process and the fusion process for different types of content. Compared with the two-stage recommendation method in related technologies that requires separate recommendation and fusion, the separate fusion step is omitted, which can effectively reduce the latency of the recommendation service. Attached Figure Description
[0027] Figure 1 A flowchart illustrating a model training method provided in this application embodiment;
[0028] Figure 2This is a schematic diagram of the structure of an initial content recommendation model provided in an embodiment of this application;
[0029] Figure 3 A flowchart illustrating a content recommendation method provided in an embodiment of this application;
[0030] Figure 4 This is a schematic diagram of the composition structure of the model training device provided in the embodiments of this application;
[0031] Figure 5 A schematic diagram of the composition structure of the content recommendation device provided in the embodiments of this application;
[0032] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0033] The technical solutions in this application will now be clearly and completely described with reference to the accompanying drawings.
[0034] The present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the embodiments provided herein are merely illustrative of the present application and are not intended to limit the present application. Furthermore, the embodiments provided below are some embodiments for implementing the present application, and not all embodiments for implementing the present application. Unless otherwise specified, the technical solutions described in the present application can be implemented in any combination.
[0035] It should be noted that, in this application, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a method or apparatus that includes a list of elements includes not only the elements expressly described, but also other elements not expressly listed, or elements inherent to implementing the method or apparatus. Without further limitations, an element defined by the phrase "comprising a..." does not exclude the presence of other related elements (e.g., steps in the method or units in the apparatus, such as portions of a processor, program, or software, etc.) in the method or apparatus that includes that element.
[0036] For example, the model training method provided in this application includes a series of steps, but the model training method provided in this application is not limited to the steps described herein. Similarly, the model training apparatus provided in this application includes a series of modules, but the model training apparatus provided in this application is not limited to the modules explicitly described herein, but may also include modules that need to be set up for obtaining relevant information or processing based on the information.
[0037] In some embodiments of this application, the model training method can be implemented using a processor in the model training device. The processor can be at least one of the following: Application Specific Integrated Circuit (ASIC), Digital Signal Processor (DSP), Digital Signal Processing Device (DSPD), Programmable Logic Device (PLD), Field Programmable Gate Array (FPGA), CPU, controller, microcontroller, and microprocessor.
[0038] It should be noted that the collection, use, storage, sharing and transfer of user personal information involved in the technical solution of this application all comply with the provisions of relevant laws and regulations, and require notification to users and obtaining their consent or authorization. Where applicable, user personal information has been subjected to de-identification and / or anonymization and / or encryption technical processing.
[0039] In this embodiment, the model training method can be applied to scenarios where multiple different types of content need to be recommended. Here, different types of content may include videos, music, news, products, etc.; scenarios may include content recommendation scenarios in the homepage feed of video apps, etc.
[0040] Figure 1 A flowchart of a model training method provided in an embodiment of this application is shown below. Figure 1 As shown, the method includes the following steps:
[0041] Step 100: Obtain multiple training samples.
[0042] In this embodiment of the application, the model training method can be executed by a model training device, which can be configured in an electronic device.
[0043] Here, each training sample in the multiple training samples may include the sample user features, the sample content features, and the corresponding labels of the sample content.
[0044] It should be noted that the types of sample content are different for different training samples. For example, the type of sample content for one training sample is news, while the type of sample content for another training sample is music.
[0045] In this embodiment of the application, the characteristics of the sample user may include, but are not limited to, the attributes of the sample user's identity document (ID), gender, age, region, occupation, etc.; the characteristics of the sample content may include, but are not limited to, the attributes of the sample content's type, theme, rhythm, quality, and person, etc.; for example, if the sample user u likes a certain kind of music, then the type, theme, rhythm, quality, and person of the sample content may be music, love song, soothing, classic, and lead singer, respectively.
[0046] For example, the label is also called the click label. Each training sample corresponds to one label. The label is used to characterize whether the sample user has clicked on the corresponding type of sample content. Its value can be 0 or 1. Here, 0 can be set to indicate no click and 1 to indicate click. No specific limitation is made here.
[0047] In this embodiment of the application, the method of obtaining multiple training samples is not specifically limited. For example, different types of sample content that each sample user has clicked and has not clicked in the historical time period can be obtained first; then feature extraction is performed on each sample user and different types of sample content to obtain the sample user features of each sample user, the sample content features of each type of sample content, and the corresponding tags; by performing the above processing on multiple sample users, multiple training samples can be obtained.
[0048] Here, the value of the historical time period can be set according to the actual situation. This application embodiment does not make a specific limitation on this. For example, it can be the past month or the past two months.
[0049] Step 101: Train the initial content recommendation model using multiple training samples to obtain the recommendation loss and contrastive learning loss.
[0050] In this embodiment of the application, before performing step 101, an initial video recommendation model can be constructed first. After the model is constructed, multiple training samples are used to train the initial content recommendation model to obtain recommendation loss and contrastive learning loss. The initial content recommendation model is used to determine the click probability of sample users for sample content of the corresponding type.
[0051] For example, Figure 2 This is a schematic diagram of the structure of an initial content recommendation model provided in an embodiment of this application, such as... Figure 2 As shown, the initial content recommendation model may include a multi-layer neural network EN and a matching space E. ps And scoring network layer C.
[0052] Among them, the multi-layer neural network EN is responsible for transforming the original input features, with the purpose of feature crossing and dimensionality reduction; the matching space E psIt can include multiple matching patterns, each of which can be viewed as an attribute feature of different types of sample content in one dimension; that is, different matching patterns correspond to different dimensions. For example, multiple matching patterns may include, but are not limited to, the type, theme, rhythm, quality, characters, title, and image quality of the sample content. The scoring network layer C is used to determine the degree of matching between the sample user and the corresponding type of sample content.
[0053] To facilitate understanding, the following will be combined with Figure 2 The model structure shown illustrates the process of determining the recommendation loss and the contrastive learning loss.
[0054] In some embodiments, training an initial content recommendation model using multiple training samples to obtain recommendation loss and contrastive learning loss may include: performing data augmentation on each training sample to obtain corresponding augmented samples; processing the augmented samples corresponding to each training sample using a multi-layer neural network to obtain associated features; determining the contrastive learning loss based on the associated features and the matching space; processing each training sample using a multi-layer neural network to obtain intermediate features; and determining the recommendation loss based on the intermediate features and the matching space.
[0055] For example, see Figure 2 The initial content recommendation model can consist of two parts: a pattern learning part and a ranking prediction part. The pattern learning part is accomplished through the network structure to the right of the dashed line, and the ranking prediction part is accomplished through the network structure to the left of the dashed line. It should be noted that the inputs on both sides are the same; during model training, the inputs on both sides are the input features of the same training sample, namely the sample user features and the sample content features. These input features of the training sample can be represented as E. in .
[0056] For example, the contrastive learning loss can be determined through the pattern learning part; the pattern learning part can be completed through contrastive learning to accomplish auxiliary tasks; it should be noted that contrastive learning belongs to unsupervised learning, and its core idea is: for the input features E of the same training sample in After two different transformations, with the same network structure as the input, the model is updated by minimizing the difference in the outputs of the two networks. For ease of understanding, the above process is explained in detail below.
[0057] For example, the initial content recommendation model may also include a mask layer, corresponding to Figure 2 In the context of M and ~M, M and ~M refer to the same Mask layer, and the symbol ~ indicates the negation operation. The Mask layer generates a binary mask (0-1 matrix or vector) to mark the parts of the data that need to be kept or ignored. For example, the vector corresponding to the feature to be discarded is set to zero.
[0058] In this embodiment, a Mask layer can be used to augment the data of each training sample to obtain an augmented sample corresponding to each training sample.
[0059] Understandingly, the process of performing two different transformations on the same input to obtain different outputs is called data augmentation. During model training, the model's input is each training sample E. in Given the sample user features and sample content features, the following data augmentation method can be used: Randomly select and retain half of the features from the sample user features, and also randomly select and retain half of the features from the sample content features. Use the retained features as input to the M-side, and use the remaining features as input to the ~M-side. The output of the M-side is E1, and the output of the ~M-side is E2. E1 and E2 are the training samples E... in The corresponding augmented sample, where E1 = E in &M, E2 = E im &~M.
[0060] For example, as can be seen from the above, each training sample corresponds to two augmented samples, namely the first augmented sample and the second augmented sample, which are represented as E1 and E2 respectively.
[0061] Furthermore, after obtaining the augmented sample corresponding to each training sample, a multi-layer neural network layer EN can be used to process the augmented sample corresponding to each training sample to obtain the association features; wherein, the association features characterize the association relationship between the sample user and the sample content of the corresponding type; here, the association features may include the first association features corresponding to the first augmented sample and the second association features corresponding to the second augmented sample.
[0062] In some embodiments, the process of using a multi-layer neural network layer EN to process the augmented sample corresponding to each training sample to obtain associated features may include: using the multi-layer neural network layer EN to perform feature cross processing on the first augmented sample and the second augmented sample respectively to obtain a first cross feature and a second cross feature; and using the multi-layer neural network layer EN to perform dimensionality reduction processing on the first cross feature and the second cross feature respectively to obtain a first associated feature and a second associated feature.
[0063] For example, the multilayer neural network EN first performs feature cross processing on the first enhanced sample E1 and the second enhanced sample E2 to obtain the first cross feature and the second cross feature respectively; then, it performs dimensionality reduction processing on the first cross feature and the second cross feature respectively to obtain the first association feature and the second association feature, which are represented as E respectively. p1 and E p2 At this point, the first associated feature E p1 Second related feature E p2Both can characterize the association between sample users and corresponding types of sample content; assuming that the current training batch has B training samples, then the first association feature E p1 Second related feature E p2 It can be represented as a B*D dimensional matrix.
[0064] For example, as can be seen from the above, the matching space E ps It can include multiple matching patterns, which can be represented as a K*D dimensional matrix, with each row of the matrix corresponding to a matching pattern.
[0065] Here, K refers to the number of matching patterns, also known as the dimension of the matching patterns. Its value can be determined according to the actual situation, and the value range is usually 2000-3000. If the value of K is 2500, it means that the matching space includes 2500 matching patterns of different dimensions. D represents the vector corresponding to each matching pattern. For the convenience of subsequent calculation, the number of columns of this vector can be equal to the number of columns of the training samples. If the current training batch includes B training samples, the input training samples can be represented as a B*D dimensional matrix.
[0066] It should be noted that when the model starts training, K D-dimensional pattern vectors can be initialized first to obtain the matching space, i.e., the matching space E. ps Initially, the values are randomly generated, but they will be continuously optimized as the model is trained.
[0067] Furthermore, after obtaining the first associated feature E p1 Second related feature E p2 Then, based on the first association feature E p1 Second correlation feature E p2 The process of determining the contrastive learning loss based on the matching space may include: calculating the distance between a first association feature and each matching pattern in the matching space to obtain a first matching feature, the first matching feature including a multi-dimensional vector representing the weight of the sample user and the corresponding type of sample content relative to each matching pattern; calculating the distance between a second association feature and each matching pattern in the matching space to obtain a second matching feature; and determining the contrastive learning loss based on the first and second matching features.
[0068] For example, the first association feature E can be calculated using formula (1). p1 Matching space E ps The distance between each matching pattern is used to obtain the first matching feature P1:
[0069] P1=(E p1 *E ps T (1)
[0070] Similarly, the second correlation feature E can be calculated using formula (2). p2 Matching space E ps The distance between each matching pattern is used to obtain the second matching feature P2:
[0071] P2=(E p2 *E ps T (2)
[0072] As can be seen, after the above steps, the relationship between sample users and sample content can be transformed into matching features. Here, taking a single training sample as an example, the first matching feature P1 and the second matching feature P2 are both 1*K dimensional matrices, i.e., multidimensional vectors. Taking B training samples in the current batch as an example, the first matching feature P1 and the second matching feature P2 are both B*K dimensional matrices, i.e., B multidimensional vectors. It should be noted that each multidimensional vector represents the weight of the sample user and the corresponding type of sample content relative to each matching pattern; that is, each column of the multidimensional vector is composed of the weight corresponding to each matching pattern. The first matching feature P1 and the second matching feature P2 can be regarded as another way of representing the relationship between sample users and the corresponding type of sample content. Initially, E was used. p1 and E p2 Characterization.
[0073] Furthermore, after obtaining the first matching feature P1 and the second matching feature P2, the contrastive learning loss can be determined based on these two matching features.
[0074] Understandably, although the first matching feature P1 and the second matching feature P2 are not exactly the same, they come from the same training sample, that is, they are essentially homogeneous. Therefore, the optimization objective of the model can be achieved by minimizing the distance between the first matching feature P1 and the second matching feature P2. In this embodiment, the cross-entropy loss function can be used to measure the distance between the first matching feature P1 and the second matching feature P2. However, the first matching feature P1 and the second matching feature P2 are feature vectors without any constraints. If the cross-entropy loss of the two is directly calculated, it may lead to model collapse. That is, the relationship between all sample users and the corresponding sample content will be concentrated in the same pattern. To avoid the above problem, the SK (Sinkhorn-Knopp) algorithm can be used to make the following changes to the first matching feature P1 and the second matching feature P2, which can be referred to in formulas (3) and (4):
[0075]
[0076] Where B is the number of training samples in the current training batch, K is the number of matching patterns, and ε is a hyperparameter representing the strength of the uniform constraint, which is usually 0.1 and is not specifically limited here.
[0077] For example, referring to formulas (5) and (6), the cross-entropy loss L1 can be constructed using P1 and Q2, and the cross-entropy loss L2 can be constructed using P2 and Q1:
[0078]
[0079] Here, Q1 and Q2 are the values of Q1* and Q2* after three iterations using the SK algorithm, respectively. The SK algorithm is a publicly available algorithm, and the iteration process will not be described in detail in this embodiment. Since Q(Q1 and Q2) and P(P1 and P2) have the same meaning, Q1 and Q2 can be regarded as values after applying the SK algorithm to constrain the uniformity of the sample distribution. P is the value of P after normalization using the softmax function, and can be regarded as a probability distribution; τ is a hyperparameter, and the larger τ is... The smoother the distribution, the more likely the value of τ is to be 0.2, but no specific limit is imposed here.
[0080] For example, after obtaining the cross-entropy loss L1 and cross-entropy loss L2, the two are summed to obtain the contrastive learning loss, which can then be used to train the model. The model includes a matching space, that is, the matching space is learned by contrastive learning in this embodiment. The above is the process of determining the contrastive learning loss. The process of determining the recommendation loss will be explained below.
[0081] In this embodiment, a multi-layer neural network can be used to process each training sample to obtain intermediate features; the recommendation loss is determined based on the intermediate features and the matching space.
[0082] For example, the recommendation loss can be determined through the ranking evaluation section; see [link to relevant documentation]. Figure 2 The ranking evaluation part and the pattern learning part share a multi-layer neural network layer EN, that is, the initial content recommendation model only needs to include one multi-layer neural network layer EN.
[0083] For example, the ranking evaluation part is a ranking prediction model used to complete the main task; its structure corresponds to Figure 2 The network structure to the left of the dashed line can be divided into upper and lower parts. The lower part of the main task shares multiple neural network layers EN with the auxiliary task, and the input features E of the same training sample are also shared. in After processing through multiple layers of a neural network EN, the intermediate feature E is obtained. p .
[0084] It should be noted that the intermediate features E are obtained using a multi-layer neural network EN.p The process is similar to the process of determining the associated features using a multi-layer neural network EN, which also involves feature crossing and dimensionality reduction. To avoid repetition, it will not be described again here.
[0085] Furthermore, it can be based on the intermediate feature E p Matching space E ps The recommendation loss is determined; the process is illustrated below.
[0086] In some embodiments, determining the recommendation loss based on intermediate features and the matching space may include: calculating the distance between the intermediate features and each matching pattern in the matching space to obtain a third matching feature; processing the third matching feature using a scoring network layer to obtain the score corresponding to the training sample; and determining the recommendation loss based on the score and label corresponding to the training sample.
[0087] It should be noted that the process of obtaining the third matching feature by calculating the distance is similar to the process of obtaining the first matching feature P1 or the second matching feature P2 described above. To avoid repetition, it will not be repeated here.
[0088] For example, the third matching feature can be represented as P, and the upper part of the main task is a scoring network layer C. The input is the third matching feature P corresponding to the training sample, and the output is the score corresponding to the training sample. This score can reflect the degree of matching between the sample user and the corresponding type of sample content. This score is used to indicate the probability of the sample user clicking on the corresponding type of sample content. That is, the initial content recommendation model can determine the probability of the sample user clicking on the corresponding type of sample content.
[0089] Next, the recommendation loss L can be calculated based on the output of the scoring network layer, i.e., the score and label of the training sample. m Here, the recommendation loss L is calculated using an industry-standard method. m That's fine; no specific restrictions are set here.
[0090] Furthermore, after obtaining the recommended loss L m Then, based on the recommended loss L m Together with the contrastive learning losses (L1, L2) determined above, the initial content recommendation model is trained to obtain the trained content recommendation model. This process will be explained later.
[0091] Step 102: Based on the recommendation loss and contrastive learning loss, adjust the parameters of the initial content recommendation model to obtain the trained content recommendation model.
[0092] In this embodiment of the application, the recommendation loss L of the initial content recommendation model is obtained according to the above steps. mThe parameters of the initial content recommendation model can be adjusted based on the contrastive learning losses (L1 and L2) to obtain the trained content recommendation model.
[0093] In some embodiments, adjusting the parameters of the initial content recommendation model based on the recommendation loss and the contrastive learning loss may include: weighting the recommendation loss and the contrastive learning loss based on the weight coefficients pre-assigned to the contrastive learning loss to obtain a comprehensive loss; and adjusting the parameters of the initial content recommendation model according to the comprehensive loss.
[0094] Here, the comprehensive loss refers to the total loss obtained by weighted summation of the recommendation loss and the contrastive learning loss. For example, a weight coefficient α can be pre-assigned to the contrastive learning loss. α, also known as a hyperparameter, is responsible for adjusting the weights of the recommendation loss and the contrastive learning loss. Then, the product of the weight coefficient α and the contrastive learning loss is calculated, and the recommendation loss and this product are summed to obtain the comprehensive loss L. The corresponding process can be found in formula (7).
[0095] L = L m +α*(L1+L2) (7)
[0096] Understandably, in order to suit different use cases, the embodiments of this application can adapt to adjust the weight coefficient α, thereby flexibly controlling the training accuracy of the model.
[0097] Furthermore, after obtaining the comprehensive loss, the parameters of the initial content recommendation model can be adjusted using the comprehensive loss until a preset training stopping condition is reached. Here, the training stopping condition could be that the comprehensive loss reaches a preset minimum value, or that the model performance does not significantly improve after a preset number of consecutive adjustments; at this point, the trained content recommendation model can be obtained.
[0098] In this embodiment, the parameters that the model ultimately needs to determine through training include: the network parameters of the multilayer neural network EN, and the matching space E. ps The vector parameters of each matching pattern and the network parameters of the scoring network layer C are included. The overall idea of model training is to learn the matching space E simultaneously. ps On the one hand, the input features are transformed into the matching space E ps The third matching feature P is learned, and a scoring network layer C is learned to process the input and output of the third matching feature P, so as to obtain the degree of matching between each sample user and the corresponding type of sample content.
[0099] As can be seen, in this embodiment, the traditional two-stage multi-type recommendation model of "separation before fusion" is transformed into a single-stage model of ranking and fusion, reducing the latency of the recommendation service. In addition, there is no need for type-specific modeling, saving a lot of training resources and maintenance costs. Furthermore, since the matching pattern is mined based on the sample users' preferences for various types of sample content, the semantics of the matching pattern already contain the sample users' preferences for different types of sample content. Therefore, during the model prediction process, the final output score can accurately reflect the user's preferences for different types of content, thus significantly improving the personalization of the fusion of different types of content.
[0100] Figure 3 This is a flowchart illustrating a content recommendation method provided in an embodiment of this application, such as... Figure 3 As shown, the method includes the following steps:
[0101] Step 200: Obtain the user characteristics of the current user and the content characteristics of multiple pieces of content to be recommended. The types of content to be recommended are different.
[0102] Step 201: Use the trained content recommendation model to process user features and various content features to obtain the current user's click probability for each piece of content to be recommended;
[0103] Step 202: Recommend content to the current user based on the click probability.
[0104] For example, the trained content recommendation model is trained according to the model training method provided in the above embodiments; here, the current user refers to the target user who needs to be recommended different types of content; multiple recommended contents refer to various different types of candidate content that need to be recommended to the current user; for example, they may include short videos, music, news, etc.
[0105] In this embodiment of the application, after obtaining the trained content recommendation model according to steps 100 to 103, the trained content recommendation model is used to process user features and various content features to obtain the click probability of the current user for each content to be recommended. This click probability can reflect the degree of matching between the current user and each content to be recommended.
[0106] Furthermore, after obtaining the click probability of the current user for each piece of content to be recommended, the multiple pieces of content to be recommended can be sorted in descending order of click probability to obtain a sorting result; then, content can be recommended to the current user based on the sorting result. For example, at least one type of content to be recommended that ranks first in the sorting result can be recommended to the current user.
[0107] Understandably, since recommendation results can reflect users' preferences for each recommended item, making recommendations based on these results can improve the accuracy of content recommendations.
[0108] To better illustrate the purpose of this application, further examples are provided based on the above embodiments.
[0109] Figure 4 This is a schematic diagram of the composition structure of the model training device according to an embodiment of this application, as shown below. Figure 4 As shown, the device includes: a first acquisition module 300, a training module 301, and an adjustment module 302, wherein:
[0110] The first acquisition module 300 is used to acquire multiple training samples. Each training sample includes the sample user features, the sample content features, and the corresponding tags of the sample content. The types of sample content in different training samples are different, and the tags indicate whether the sample user has clicked on the corresponding type of sample content.
[0111] Training module 301 is used to train the initial content recommendation model using multiple training samples to obtain recommendation loss and contrastive learning loss; the initial content recommendation model is used to determine the click probability of sample users for sample content of the corresponding type;
[0112] The adjustment module 302 is used to adjust the parameters of the initial content recommendation model based on the recommendation loss and the contrastive learning loss, so as to obtain the trained content recommendation model.
[0113] In some embodiments, the initial content recommendation model includes multiple neural network layers and a matching space; the training module 301 is further configured to:
[0114] Data augmentation is performed on each training sample to obtain the corresponding augmented sample;
[0115] The augmented samples corresponding to each training sample are processed using a multi-layer neural network to obtain association features. These association features characterize the relationship between sample users and corresponding types of sample content.
[0116] Determine the contrastive learning loss based on the associated features and the matching space;
[0117] Each training sample is processed using multiple layers of a neural network to obtain intermediate features;
[0118] The recommendation loss is determined based on intermediate features and the matching space.
[0119] In some embodiments, the augmented samples include a first augmented sample and a second augmented sample, and the association features include a first association feature and a second association feature. The training module 301 is further configured to:
[0120] The first and second enhanced samples are subjected to feature cross processing using a multi-layer neural network to obtain the first cross feature and the second cross feature.
[0121] The first cross feature and the second cross feature are dimensionality reduced by using a multi-layer neural network to obtain the first association feature and the second association feature.
[0122] In some embodiments, the matching space includes multiple matching patterns; the training module 301 is further configured to:
[0123] Calculate the distance between the first association feature and each matching pattern in the matching space to obtain the first matching feature. The first matching feature includes a multi-dimensional vector, which represents the weight of the sample user and the corresponding type of sample content relative to each matching pattern.
[0124] Calculate the distance between the second association feature and each matching pattern in the matching space to obtain the second matching feature;
[0125] The contrastive learning loss is determined based on the first and second matching features.
[0126] In some embodiments, the matching space includes multiple matching patterns, and the initial content recommendation model further includes a scoring network layer; the training module 301 is also used for:
[0127] Calculate the distance between the intermediate feature and each matching pattern in the matching space to obtain the third matching feature;
[0128] The scoring network layer is used to score the third matching feature to obtain the score corresponding to the training sample;
[0129] The recommendation loss is determined based on the scores and labels corresponding to the training samples.
[0130] In some embodiments, the adjustment module 302 is further configured to:
[0131] Based on the weight coefficients pre-assigned to the contrastive learning loss, the recommendation loss and the contrastive learning loss are weighted and summed to obtain the comprehensive loss;
[0132] The parameters of the initial content recommendation model are adjusted based on the comprehensive loss.
[0133] Figure 5 This is a schematic diagram of the composition structure of a content recommendation device according to an embodiment of this application, such as... Figure 5 As shown, the device includes: a second acquisition module 400, a processing module 401, and a recommendation module 402, wherein:
[0134] The second acquisition module 400 is used to acquire the user characteristics of the current user and the content characteristics of multiple content to be recommended, with different types of content to be recommended.
[0135] The processing module 401 is used to process user features and various content features using the trained content recommendation model to obtain the current user's click probability for each piece of content to be recommended; the trained content recommendation model is trained according to the model training method provided by one or more of the aforementioned technical solutions;
[0136] Recommendation module 402 is used to recommend content to the current user based on click probability.
[0137] In practical applications, the first acquisition module 300, training module 301, adjustment module 302, second acquisition module 400, processing module 401 and recommendation module 402 can all be implemented by a processor located in an electronic device. The processor can be at least one of ASIC, DSP, DSPD, PLD, FPGA, CPU, controller, microcontroller and microprocessor.
[0138] Furthermore, in this embodiment, the functional modules can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional module.
[0139] If the integrated unit is implemented as a software functional module and is not sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this embodiment, in essence, or the part that contributes to related technologies, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the method of this embodiment. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0140] Specifically, the computer program instructions corresponding to the model training method and content recommendation method in this embodiment can be stored on storage media such as optical discs, hard disks, and USB flash drives. When the computer program instructions corresponding to the model training method and content recommendation method in the storage media are read or executed by an electronic device, any of the model training method and content recommendation method in the aforementioned embodiments can be implemented.
[0141] Based on the same technical concept as the foregoing embodiments, see Figure 6 It illustrates an electronic device 500 provided in an embodiment of this application, which may include: a memory 501 and a processor 502; wherein,
[0142] Memory 501 is used to store computer programs and data;
[0143] The processor 502 is configured to execute a computer program stored in the memory to implement any of the model training methods or content recommendation methods described in the foregoing embodiments.
[0144] In practical applications, the aforementioned memory 501 can be volatile memory, such as RAM; or non-volatile memory, such as ROM, flash memory, hard disk drive (HDD), or solid-state drive (SSD); or a combination of the above types of memory, and provide instructions and data to the processor 502.
[0145] The processor 502 described above can be at least one of ASIC, DSP, DSPD, PLD, FPGA, CPU, controller, microcontroller, and microprocessor. It is understood that, for different model training devices, the electronic device used to implement the above processor function can also be other types, and this application embodiment does not specifically limit the specific types.
[0146] This application provides a computer program product, including a computer program that, when executed by a processor, implements any of the model training methods or content recommendation methods described in the foregoing embodiments.
[0147] In some embodiments, the functions or modules of the apparatus provided in this application can be used to perform the methods described in the above method embodiments. The specific implementation can be referred to the description of the above method embodiments, and for the sake of brevity, it will not be repeated here.
[0148] The description of the various embodiments above tends to emphasize the differences between the various embodiments. The similarities or similarities between them can be referred to, and for the sake of brevity, they will not be repeated here.
[0149] The methods disclosed in the various method embodiments provided in this application can be arbitrarily combined to obtain new method embodiments without conflict.
[0150] The features disclosed in the various product embodiments provided in this application can be arbitrarily combined without conflict to obtain new product embodiments.
[0151] The features disclosed in the various method or device embodiments provided in this application can be arbitrarily combined without conflict to obtain new method or device embodiments.
[0152] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of hardware embodiments, software embodiments, or embodiments combining software and hardware aspects. Furthermore, this application can take the form of a computer program product implemented on one or more computer-usable storage media (including, but not limited to, disk storage and optical storage) containing computer-usable program code.
[0153] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0154] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0155] The above are merely preferred embodiments of this application and are not intended to limit the scope of protection of this application.
Claims
1. A model training method, characterized in that, The method includes: Multiple training samples are obtained. Each training sample includes the sample user features, the sample content features, and the corresponding tags of the sample content. The sample content of different training samples is of different types, and the tags indicate whether the sample user has clicked on the corresponding type of sample content. The multiple training samples are used to train an initial content recommendation model, which includes a multi-layer neural network, a matching space, and a scoring network layer. The initial content recommendation model is used to determine the click probability of the sample user for the corresponding type of sample content. Data augmentation is performed on each training sample to obtain a corresponding augmented sample; the augmented sample corresponding to each training sample is processed using the multi-layer neural network to obtain association features, which characterize the association relationship between the sample user and the corresponding type of sample content, and the association features include a first association feature and a second association feature; Calculate the distance between the first association feature and each matching pattern in the matching space to obtain the first matching feature, the first matching feature including a multi-dimensional vector, the multi-dimensional vector representing the weight of the sample user and the corresponding type of sample content relative to each matching pattern; calculate the distance between the second association feature and each matching pattern in the matching space to obtain the second matching feature; determine the contrastive learning loss based on the first matching feature and the second matching feature; The multi-layer neural network is used to process each training sample to obtain intermediate features; the distance between the intermediate features and each matching pattern in the matching space is calculated to obtain a third matching feature; the scoring network layer is used to score the third matching feature to obtain the score corresponding to the training sample; the recommendation loss is determined based on the score corresponding to the training sample and the label. Based on the recommendation loss and the contrastive learning loss, the parameters of the initial content recommendation model are adjusted to obtain the trained content recommendation model.
2. The method according to claim 1, characterized in that, The augmented samples include a first augmented sample and a second augmented sample. The process of using the multi-layer neural network to process the augmented samples corresponding to each training sample to obtain associated features includes: The first enhanced sample and the second enhanced sample are subjected to feature cross processing using the multi-layer neural network to obtain the first cross feature and the second cross feature; The first cross feature and the second cross feature are dimensionality reduced using the multi-layer neural network to obtain the first association feature and the second association feature.
3. The method according to claim 1 or 2, characterized in that, The adjustment of the parameters of the initial content recommendation model based on the recommendation loss and the contrastive learning loss includes: Based on the weight coefficients pre-assigned to the contrastive learning loss, the recommendation loss and the contrastive learning loss are weighted and summed to obtain the comprehensive loss; The parameters of the initial content recommendation model are adjusted based on the comprehensive loss.
4. A content recommendation method, characterized in that, The method includes: Obtain the user characteristics of the current user and the content characteristics of multiple pieces of content to be recommended, as different pieces of content to be recommended have different types; The trained content recommendation model is used to process the user features and each content feature to obtain the click probability of the current user for each content to be recommended; the trained content recommendation model is trained by the model training method according to any one of claims 1 to 3. Content recommendations are made to the current user based on the click probability.
5. A model training device, characterized in that, The device includes: The first acquisition module is used to acquire multiple training samples. Each training sample includes the sample user features of the sample user, the sample content features of the sample content, and the label corresponding to the sample content. The sample content of different training samples is of different types, and the label indicates whether the sample user has clicked on the corresponding type of sample content. The multiple training samples are used to train an initial content recommendation model, which includes a multi-layer neural network, a matching space, and a scoring network layer. The initial content recommendation model is used to determine the click probability of the sample user for the corresponding type of sample content. The training module is used to perform data augmentation on each training sample to obtain a corresponding augmented sample; the multi-layer neural network layer is used to process the augmented sample corresponding to each training sample to obtain association features, the association features characterize the association relationship between the sample user and the sample content of the corresponding type, and the association features include a first association feature and a second association feature; Calculate the distance between the first association feature and each matching pattern in the matching space to obtain the first matching feature, the first matching feature including a multi-dimensional vector, the multi-dimensional vector representing the weight of the sample user and the corresponding type of sample content relative to each matching pattern; calculate the distance between the second association feature and each matching pattern in the matching space to obtain the second matching feature; determine the contrastive learning loss based on the first matching feature and the second matching feature; The multi-layer neural network is used to process each training sample to obtain intermediate features; the distance between the intermediate features and each matching pattern in the matching space is calculated to obtain a third matching feature; the scoring network layer is used to score the third matching feature to obtain the score corresponding to the training sample; the recommendation loss is determined based on the score corresponding to the training sample and the label. The adjustment module is used to adjust the parameters of the initial content recommendation model based on the recommendation loss and the contrastive learning loss, so as to obtain the trained content recommendation model.
6. An electronic device, characterized in that, The device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the program, implements the method according to any one of claims 1 to 4.
7. A computer storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the computer program implements the method described in any one of claims 1 to 4.
Citation Information
Patent Citations
Model training method and device, recommendation method and device and related equipment
CN119150926A