Model training method, recommendation method and related device
By using training identification sequences and loss functions in the recommendation system to train the sequence model, the problem of excessive computing resource consumption during the training process is solved, and the better model convergence effect is achieved.
Patent Information
- Application Number
- CN202411424240.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-12
- Publication Date
- 2025-03-28
- Estimated Expiration
- 2044-10-12
AI Technical Summary
When training a sequence model, the existing recommendation system needs to calculate the probability of users' interest in each candidate recommendation object, resulting in excessive consumption of computing resources and affecting the convergence effect of the model.
A model training method is proposed, by obtaining the training identification sequence, modeling the predicted feature sequence using the sequence model to be trained, and determining the predicted recommended object category and comprehensive correlation data of the sample object based on the predicted feature sequence, and generating the first and second loss functions for training the sequence model.
This method can reduce the computing resources consumed during training, reduce the computational burden, and ensure that the sequence model achieves better convergence effect.
Smart Images

Figure CN118939984B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a model training method, a recommendation method and related devices. Background Art
[0002] In the recommendation system, modeling the user's behavior sequence is a very important task. By modeling the user's behavior sequence, we can understand the user's interests, habits, and behavior patterns, and then predict the objects of interest to the user and make targeted recommendations.
[0003] The sequence model is an effective tool for modeling user behavior sequences. Currently, many studies have migrated sequence models with better performance in the field of natural language processing (such as large language models) to recommendation models in recommendation systems, so as to make generative recommendations through the recommendation model. Specifically, the recommendation model can first model the user's behavior sequence, and then calculate the user's interest probability for each candidate recommendation object based on the modeling results, and then select the candidate recommendation objects that the user is interested in.
[0004] In practical applications, the number of candidate recommendation objects in the recommendation system is extremely large. When training the recommendation model, directly using the recommendation model to calculate the probability of users being interested in each candidate recommendation object will consume more computing resources, generate a heavy computing burden, and also affect the convergence effect of the recommendation model during the training process. Summary of the invention
[0005] The embodiments of the present application provide a model training method, a recommendation method and related devices, which can reduce the computing resources consumed when training a sequence model, alleviate the computing burden, and ensure that the sequence model obtains a better convergence effect.
[0006] In view of this, the first aspect of the present application provides a model training method, the method comprising:
[0007] Acquire a training identification sequence; the training identification sequence includes identifications of a plurality of sample objects, and the identifications are arranged in the order in which the sample users trigger reference behaviors on the plurality of sample objects;
[0008] By using the sequence model to be trained, modeling is performed according to the training identification sequence to obtain a prediction feature sequence; the prediction feature sequence includes prediction modeling features corresponding to each of the plurality of sample objects;
[0009] For each of the sample objects, determine the predicted recommended object category corresponding to the sample object according to the predicted modeling features corresponding to the sample object; determine the comprehensive correlation data corresponding to the sample object according to the predicted modeling features corresponding to the sample object, the embedded features of the label recommended object corresponding to the sample object, and the embedded features of the negatively correlated object corresponding to the sample object;
[0010] Generate a first loss function according to the predicted recommended object categories corresponding to each of the multiple sample objects; generate a second loss function according to the comprehensive correlation data corresponding to each of the multiple sample objects;
[0011] Based on the first loss function and the second loss function, the sequence model is trained to obtain a target sequence model; the target sequence model is used for feature modeling in the recommendation task.
[0012] A second aspect of the present application provides a recommendation method, the method comprising:
[0013] Acquire a target identification sequence; the target identification sequence includes identifications of multiple behavior objects, and each identification is arranged in the order in which the target user triggers reference behaviors on the multiple behavior objects;
[0014] Using a target sequence model, a target feature sequence is modeled according to the target identification sequence; the target sequence model is trained by the model training method described in the first aspect above;
[0015] Extracting target representative features from the target feature sequence;
[0016] Based on the target representative feature, at least one target recommendation object is selected from each candidate recommendation object; the distance between the embedded feature of the target recommendation object and the target representative feature meets a preset distance proximity condition, and the target recommendation object is the object recommended to the target user.
[0017] A third aspect of the present application provides a model training device, the device comprising:
[0018] A sequence acquisition module, used to acquire a training identification sequence; the training identification sequence includes identifications of a plurality of sample objects, and the identifications are arranged in the order in which the sample users trigger reference behaviors on the plurality of sample objects;
[0019] A feature modeling module, used to obtain a prediction feature sequence by modeling according to the training identification sequence through a sequence model to be trained; the prediction feature sequence includes prediction modeling features corresponding to each of the multiple sample objects;
[0020] A data processing module is used to determine, for each of the sample objects, the predicted recommended object category corresponding to the sample object according to the predicted modeling features corresponding to the sample object; and to determine the comprehensive correlation data corresponding to the sample object according to the predicted modeling features corresponding to the sample object, the embedded features of the label recommended object corresponding to the sample object, and the embedded features of the negatively correlated object corresponding to the sample object;
[0021] A loss generation module, configured to generate a first loss function according to the predicted recommended object categories corresponding to each of the plurality of sample objects; and generate a second loss function according to the comprehensive correlation data corresponding to each of the plurality of sample objects;
[0022] A training module is used to train the sequence model based on the first loss function and the second loss function to obtain a target sequence model; the target sequence model is used to perform feature modeling in the recommendation task.
[0023] A fourth aspect of the present application provides a recommendation device, the device comprising:
[0024] A sequence acquisition module, used to acquire a target identification sequence; the target identification sequence includes identifications of multiple behavior objects, and each identification is arranged in the order in which the target user triggers reference behaviors on the multiple behavior objects;
[0025] A feature modeling module, used to model a target feature sequence according to the target identification sequence through a target sequence model; the target sequence model is trained by the model training method described in the first aspect above;
[0026] A feature extraction module, used to extract target representative features from the target feature sequence;
[0027] A recommendation module is used to select at least one target recommendation object from each candidate recommendation object based on the target representative feature; the distance between the embedded feature of the target recommendation object and the target representative feature meets a preset distance proximity condition, and the target recommendation object is an object recommended to the target user.
[0028] A fifth aspect of the present application provides a computer device, the device comprising a processor and a memory:
[0029] The memory is used to store computer programs;
[0030] The processor is used to execute the model training method described in the first aspect or the recommendation method described in the second aspect according to the computer program.
[0031] In a sixth aspect, the present application provides a computer-readable storage medium, which is used to store a computer program. When the computer program is executed by a computer device, it implements the model training method described in the first aspect or the recommendation method described in the second aspect.
[0032] The seventh aspect of the present application provides a computer program product, which includes a computer program. When the computer program is executed by a processor, it implements the model training method described in the first aspect or the recommendation method described in the second aspect.
[0033] It can be seen from the above technical solutions that the embodiments of the present application have the following advantages:
[0034] The embodiment of the present application provides a model training method, which proposes a new training mechanism for the sequence model in the recommendation system, which can not only reduce the computing resources consumed in the model training process, but also enable the trained sequence model to obtain a better convergence effect. Specifically, when the sequence model is trained by this method, two loss functions will be used at the same time, namely the first loss function and the second loss function. Among them, the first loss function is generated based on the predicted recommended object category corresponding to the sample object, and the predicted recommended object category is determined according to the predicted modeling features output by the sequence model to be trained, and the predicted modeling features are obtained by the sequence model according to the training identification sequence including the identifications of multiple sample objects; through the first loss function, the sequence model can model the features as accurately as possible, which is conducive to accurately predicting the recommended object category based on the predicted modeling features obtained by modeling; since the present application only predicts the category to which the recommended object belongs based on the predicted modeling features output by the sequence model, but does not predict the specific recommended object, therefore, the amount of data required for calculation can be greatly reduced, and accordingly, the required computing resources can be reduced, and the computing burden can be reduced. While reducing the consumption of computing resources, in order to ensure the convergence effect of the sequence model, the present application also introduces a second loss function to train the sequence model. The second loss function is determined based on the comprehensive correlation data corresponding to the sample object, and the comprehensive correlation data corresponding to the sample object is determined according to the predictive modeling features corresponding to the sample object, the embedded features of the label recommendation object, and the embedded features of the negatively correlated object. Through the second loss function, the predictive modeling features corresponding to the sample object output by the sequence model can be close to the embedded features of the label recommendation object and away from the embedded features of the negatively correlated object, thereby improving the modeling effect of the sequence model from the dimension of feature correlation, so that the sequence model obtains a better convergence effect, and since the correlation data between the calculation features does not need to consume more computing resources, it can be ensured that the introduction of the second loss function does not cause excessive computing burden. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 A schematic diagram of an application scenario of the model training method provided in an embodiment of the present application;
[0036] Figure 2 A flowchart of a model training method provided in an embodiment of the present application;
[0037] Figure 3 A schematic diagram of the working principle of a sequence model provided in an embodiment of the present application;
[0038] Figure 4 A schematic diagram of the structure of a Transformer decoder block provided in an embodiment of the present application;
[0039] Figure 5 A schematic diagram of the implementation principle of determining the initial embedding features provided in an embodiment of the present application;
[0040] Figure 6 A schematic diagram of the working principle of another sequence model provided in an embodiment of the present application;
[0041] Figure 7 A flowchart of a recommended method provided in an embodiment of the present application;
[0042] Figure 8 A schematic diagram of the structure of a model training device provided in an embodiment of the present application;
[0043] Fig. 9 A schematic diagram of the structure of a recommended device provided in an embodiment of the present application;
[0044] Fig.10 A schematic diagram of the structure of a terminal device provided in an embodiment of the present application;
[0045] Fig.11 A schematic diagram of the structure of a server provided in an embodiment of the present application. DETAILED DESCRIPTION
[0046] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0047] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0048] The model training method and recommendation method provided in the embodiments of the present application can be executed by a computer device, which can be a terminal device or a server. The terminal device includes but is not limited to a mobile phone, a computer, an intelligent voice interaction device, a smart home appliance, a vehicle terminal, an aircraft, etc. The server can be an independent physical server, a server cluster composed of multiple physical servers, a distributed system, or a cloud server.
[0049] In addition, the information, data, and signals involved in the embodiments of the present application are authorized by the relevant objects or fully authorized by all parties, and the collection, use, and processing of relevant data comply with the relevant laws, regulations, and standards of the relevant countries and regions.
[0050] In order to facilitate understanding of the model training method provided in the embodiment of the present application, the application scenario of the model training method is executored as a server as an example to executor of the model training method.
[0051] See also Figure 1 , Figure 1 Schematic diagram of application scenarios of the model training method provided in the embodiment of the present application. Figure 1 As shown, the application scenario includes a server 110 and a database 120. The server 110 can access the database 120 through a network, or the database 120 can be integrated inside the server 110. The server 110 is used to execute the model training method provided in the embodiment of the present application to train the sequence model used in the recommendation system; the database 120 is used to provide the server 110 with the data required in the model training process.
[0052] In actual applications, before the server 110 trains the sequence model, it is necessary to obtain a training identification sequence from the database 120. The training identification sequence includes identifications of multiple sample objects, and in the training identification sequence, the multiple identifications are arranged in the order in which the sample users trigger reference behaviors on the multiple sample objects. Exemplarily, the above-mentioned sample users may be users of a target application with a recommendation function; the sample objects may be objects for which the sample users have triggered reference behaviors (including but not limited to browsing, purchasing, and collecting) through the target application, and the sample objects may include but are not limited to commodities, videos, audios, articles, news, etc.
[0053] After the server 110 obtains the training identification sequence, it can use the sequence model to be trained to model a prediction feature sequence according to the identification of the sample objects included in the training identification sequence. The prediction feature sequence includes the prediction modeling features corresponding to each of the above-mentioned multiple sample objects. The prediction modeling features corresponding to the sample objects can indicate, to a certain extent, the objects that the sample user may be interested in after the sample object.
[0054] Then, for each sample object, the server 110 can determine the predicted recommended object category corresponding to the sample object according to the predicted modeling features corresponding to the sample object. The predicted recommended object category is the recommended object category predicted based on the predicted modeling features corresponding to the sample object, and is used to indicate the category to which the object that the sample user may be interested after the sample object belongs. After the server 110 calculates the predicted recommended object category corresponding to each sample object, it can generate a first loss function for training the sequence model according to the predicted recommended object category corresponding to each sample object. It should be understood that the use of the first loss function when training the sequence model can enable the sequence model to model features as accurately as possible, thereby facilitating accurate prediction of the recommended object category based on the predicted modeling features obtained by modeling; since the application only predicts the category to which the object that the sample user may be interested belongs based on the predicted modeling features output by the sequence model, but does not predict the specific object of interest, the amount of data required for calculation can be greatly reduced, and accordingly, the required computing resources can be reduced, reducing the computing burden.
[0055] In addition, for each sample object, the server 110 can also determine the comprehensive correlation data corresponding to the sample object based on the prediction modeling features corresponding to the sample object, the embedded features of the label recommendation object corresponding to the sample object, and the embedded features of the negatively correlated object corresponding to the sample object; the label recommendation object corresponding to the sample object is the object that the sample user is actually interested in after the sample object, and the label recommendation object can be specifically pre-labeled, or the next sample object after the sample object can be used as the label recommendation object according to the order in which the sample user triggers reference behaviors for multiple sample objects; the negatively correlated object corresponding to the sample object is other objects that are weakly correlated with the sample object, and can be specifically pre-labeled. After the server 110 calculates and obtains the comprehensive correlation data corresponding to each sample object, it can generate a second loss function for training the sequence model based on the comprehensive correlation data corresponding to each sample object. It should be understood that using the second loss function when training the sequence model can make the predictive modeling features corresponding to the sample objects output by the sequence model close to the embedded features of the label recommendation objects, and away from the embedded features of the negatively correlated objects. Thus, the modeling effect of the sequence model is improved from the dimension of feature correlation, so that the sequence model can obtain a better convergence effect; since calculating the correlation data between features does not require consuming more computing resources, it can be ensured that the introduction of the second loss function does not cause excessive computing burden.
[0056] Finally, the server 110 can train the sequence model based on the first loss function and the second loss function to obtain a target sequence model that can be put into practical application, and the target sequence model is used for feature modeling in the recommendation task. In combination with the above, using the first loss function and the second loss function to train the sequence model can, on the one hand, reduce the consumption of computing resources and the computing burden during the training process, and on the other hand, ensure that the sequence model obtains a better convergence effect.
[0057] It should be understood that Figure 1 The application scenarios shown are only examples. In actual applications, the model training method provided in the embodiments of the present application can also be applied to other scenarios. No limitation is made to the application scenarios of the model training method provided in the embodiments of the present application.
[0058] The model training method provided in this application is introduced in detail below through a method embodiment.
[0059] See also Figure 2 , Figure 2 The following is a flow chart of the model training method provided in the embodiment of the present application. Figure 2 As shown, the model training method includes the following steps:
[0060] Step 201: Obtain a training identification sequence.
[0061] In an embodiment of the present application, the training identification sequence is the data input to the sequence model when training the sequence model, and the training identification sequence includes the identification of each of the multiple sample objects, and in the training identification sequence, these multiple identifications are arranged in the order in which the sample users trigger reference behaviors for these multiple sample objects.
[0062] The sample user may be a user of a target application with a recommendation function. The target application here may include, but is not limited to, shopping applications, video playback applications, audio playback applications, information reading applications, etc. The recommendation function of the target application is implemented through the recommendation system. The sample object is an object on which the sample user has triggered a reference behavior. It may be an object provided by the target application and is a candidate recommendation object in the recommendation system. The sample object may include, but is not limited to, merchandise, video, audio, text, news, etc. The reference behavior may be any behavior that can indicate that the sample user is interested in the sample object, such as, but not limited to, browsing, purchasing, collecting, adding to a shopping cart, liking, commenting, etc. The identity document (ID) of the sample object is information used to uniquely indicate the sample object. The recommendation system of the target application can pre-configure a unique identifier for each candidate recommendation object.
[0063] Taking the above target application as a shopping application as an example, the training identification sequence may include identifications of multiple commodities browsed by the sample user, and the identifications of the multiple commodities are arranged in the order in which the sample user browsed the multiple commodities. Taking the above target application as a video playback application as an example, the training identification sequence may include identifications of multiple videos liked by the sample user, and the identifications of the multiple videos are arranged in the order in which the sample user liked the multiple videos.
[0064] It should be understood that the acquired training identification sequence usually has a specific length, that is, the training identification sequence needs to include a specific number of identifications, such as the training identification sequence should include identifications of 20 sample objects. If the length of the acquired training identification sequence does not reach the required length, it is necessary to use a mask to fill the subsequent positions in the training identification sequence so that the length of the training identification sequence reaches the required length.
[0065] As an example, a computer device for training a sequence model can obtain the above-mentioned training identification sequence from a relevant database. Specifically, the database of the target application usually stores historical behavior data of each user of the target application, and the historical behavior data can reflect the behavior triggered by the user through the target application; the computer device can randomly collect historical behavior data of several users within a preset time period (for example, within the past week) from the database, and these users are sample users; then, for each sample user, the computer device can extract a preset number of adjacent reference behavior data from the historical behavior data of the sample user, and arrange the identifications of the behavior objects (i.e., sample objects) indicated by these reference behavior data in the order of the execution time of the reference behavior indicated by these reference behavior data from front to back, thereby obtaining a training identification sequence.
[0066] It should be understood that in practical applications, a computer device used to train a sequence model usually needs to obtain a large number of training identification sequences to train the sequence model based on these training identification sequences so that the sequence model has strong robustness. In addition, the above-mentioned method of obtaining the training identification sequence is only an example, and the computer device used to train the sequence model can also obtain the training identification sequence in other ways, and the embodiments of the present application do not impose any limitation on this.
[0067] Step 202: Using the sequence model to be trained, a prediction feature sequence is obtained by modeling according to the training identification sequence.
[0068] In an embodiment of the present application, the sequence model is a neural network model used to perform feature modeling based on sequence data. During the training phase of the sequence model, it is used to perform feature modeling based on a training identification sequence.
[0069] Exemplarily, the sequence model can be a language model in the field of natural language processing. The language model is usually used to model natural language and can predict the next word or character based on a given text sequence. The language model can be used to perform a variety of natural language processing tasks, such as text semantic extraction, text generation, machine translation, speech recognition, etc. At present, Transformer-based pre-trained models (Pre-trained Models, PTMs) have achieved good results in various natural language processing tasks. Common pre-trained models include but are not limited to Bert (Bidirectional Encoder Representations from Transformers) model, GPT (Generative Pre-Trained) model, etc. Further, the sequence model can also be a large language model (Large Language Model, LLM) in the field of natural language processing. The large language model is a model with large-scale parameters and trained with massive data. It can usually be trained with a large text corpus in an unsupervised learning manner, so that the large language model can learn the probability distribution and language rules of the language. At present, common large language models include but are not limited to OpenAI's GPT series models, which are also based on the Transformer model.
[0070] In the related art, the above-mentioned language model or large language model is transferred and applied to the recommendation system. When it is used as a sequence model in the recommendation system, it is usually further fine-tuned and trained on the basis of the pre-trained language model or large language model to make it suitable for the recommendation system, so that feature modeling can be performed based on the object identification sequence in the recommendation system, and objects that the user may be interested in in the future can be determined from a large number of candidate recommended objects based on the feature modeling results. However, since the pre-trained language model and the large language model have usually learned a wealth of natural language knowledge, after fine-tuning and applying them to the recommendation system, it is easy for the model to give a recommendation result that exceeds the range of candidate recommended objects. For example, the model may give a recommendation result that is a natural language result or a result that is a mixture of natural language and recommended objects.
[0071] In order to avoid the above situation, the embodiment of the present application can refer to the model structure of the above-mentioned language model or large language model, build a sequence model used in the recommendation system, and then use the data in the recommendation system to train the sequence model. That is, the sequence model in the embodiment of the present application can have the same model structure as the language model or large language model in the field of natural language processing, but when training the sequence model, the model parameters of the sequence model are completely initialized, and the original model parameters of the language model or large language model pre-trained based on natural language text are not referenced or retained. Then, the sequence model is trained completely based on the relevant data in the recommendation system (such as object identification, object embedding features, etc.), so that the sequence model is fully adapted to the recommendation system.
[0072] In the embodiment of the present application, the prediction feature sequence is a feature sequence obtained by modeling the currently trained sequence model based on the training identification sequence, and the prediction feature sequence includes prediction modeling features corresponding to multiple sample objects, and the multiple sample objects are sample objects corresponding to multiple identifiers in the training identification sequence; for example, assuming that the training identification sequence includes sample objects I1, I2, ..., I n The predicted feature sequence will include sample objects I1, I2, ..., I n The corresponding predictive modeling features. The predictive modeling features corresponding to the sample object are obtained by the sequence model based on the identifiers of each sample object before the sample object in the training identifier sequence and the identifier of the sample object itself, which is used to indicate the objects after the sample object that the sample user may be interested in; for example, sample object I i The corresponding predictive modeling features are based on the sample objects I1, I2, ..., I i-1 ,I i The respective identification modeling is used to indicate the sample user in the sample object I i The object that may be of interest later is the object that may appear at the i+1th position in the training identification sequence.
[0073] As an example, Figure 3 The following is a schematic diagram of the working principle of a sequence model provided in an embodiment of the present application. Figure 3As shown, the sequence model is a neural network model based on the Transformer structure, which includes an input layer, an embedding layer and a Transformer layer. When the sequence model predicts a feature sequence based on a training identifier sequence model, the training identifier sequence including identifiers of multiple sample objects can be first input into the input layer of the sequence model; then, through the embedding layer of the sequence model, the identifiers of the multiple sample objects are respectively mapped to corresponding embedded features; further, through the multiple Transformer decoder blocks cascaded in the Transformer layer of the sequence model, feature modeling is performed based on the embedded features corresponding to each of the multiple sample objects, and a predicted feature sequence including the predicted modeling features corresponding to each of the multiple sample objects is obtained.
[0074] It should be understood that Figure 3 The structure and working principle of the sequence model shown are only examples. In practical applications, the sequence model in the embodiment of the present application may also have other structures. The embodiment of the present application does not impose any limitation on the structure of the sequence model.
[0075] Step 203: For each of the sample objects, determine the predicted recommended object category corresponding to the sample object based on the predicted modeling features corresponding to the sample object; determine the comprehensive correlation data corresponding to the sample object based on the predicted modeling features corresponding to the sample object, the embedded features of the label recommended object corresponding to the sample object, and the embedded features of the negatively correlated object corresponding to the sample object.
[0076] After obtaining the predictive modeling features corresponding to each sample object through sequence modeling, the predicted recommended object category corresponding to each sample object and the comprehensive correlation data corresponding to each sample object can be determined based on the predictive modeling features corresponding to each sample object, so as to facilitate the subsequent construction of different loss functions based on the predicted recommended object category and comprehensive correlation data corresponding to each sample object.
[0077] The predicted recommended object category corresponding to the sample object is a recommended object category predicted based on the predicted modeling features corresponding to the sample object, and the recommended object category is used to indicate the category to which the sample user may be interested after the sample object. When specifically determining the predicted recommended object category corresponding to the sample object, the object category to which the sample user may be interested indicated by the predicted modeling features may belong can be determined from multiple object categories based on the predicted modeling features corresponding to the sample object, and then used as the predicted recommended object category corresponding to the sample object; the above-mentioned multiple candidate object categories are usually pre-divided based on all candidate recommended objects already in the recommendation system.
[0078] It should be noted that the embodiment of the present application does not predict individual objects that the sample user may be interested in after the sample object based on the predictive modeling features corresponding to the sample object, but only predicts the categories to which the sample user may be interested after the sample object. Since the number of object categories is much smaller than the number of individual objects, compared with predicting individual objects, predicting the category to which the object belongs can greatly reduce the relevant calculation amount, thereby reducing the required computing resources and alleviating the computational burden.
[0079] Among them, the comprehensive correlation data corresponding to the sample object is the correlation data calculated based on the predictive modeling features corresponding to the sample object, the embedded features of the label recommendation object corresponding to the sample object, and the embedded features of the negatively correlated object corresponding to the sample object. It can comprehensively reflect the correlation between the predictive modeling features corresponding to the sample object and the embedded features of the label recommendation object corresponding to the sample object, as well as the correlation between the predictive modeling features corresponding to the sample object and the embedded features of the negatively correlated object corresponding to the sample object.
[0080] The label recommendation object corresponding to the sample object is the object that the sample user is actually interested in after the sample object; the label recommendation object corresponding to the sample object can be specifically determined according to the arrangement order of the identifiers in the training identifier sequence. For example, the training identifier sequence includes sample objects I1, I2, ..., I n In the case of their respective identifications, the label recommendation object corresponding to sample object I1 is sample object I2, the label recommendation object corresponding to sample object I2 is sample object I3, and so on; the label recommendation objects corresponding to the sample objects can also be specifically marked and determined in advance, and the training identification sequence still includes sample objects I1, I2, ... I n For example, the sample object I n The corresponding tag recommendation object can be pre-labeled and determined. The embedding feature of the tag recommendation object refers to the distributed representation (embedding) used to indicate the tag recommendation object; in the recommendation system, each candidate recommendation object has an embedding feature, and the main function of the embedding feature is to convert the high-dimensional sparse vector of the candidate recommendation object into a low-dimensional dense vector, so that the low-dimensional dense vector can express certain features of the candidate recommendation object accordingly, and the distance between different embedding features can reflect the similarity between their corresponding candidate recommendation objects; in the embodiment of the present application, the embedding feature of the tag recommendation object can be determined by the embedding layer in the sequence model.
[0081] The negatively correlated object corresponding to the sample object is an object with a weak correlation with the sample object, such as an object whose correlation with the sample object satisfies a preset weak correlation condition; the negatively correlated object corresponding to the sample object can be specifically pre-labeled and determined, for example, for each sample object, a number of objects with a weak correlation with the sample object can be pre-extracted from all candidate recommended objects in the recommendation system as the negatively correlated objects corresponding to the sample object. The embedded features of the negatively correlated object refer to the distributed representation used to indicate the negatively correlated object, which can express certain features of the negatively correlated object in the form of a low-dimensional dense vector; specifically, the embedded features of the negatively correlated object can be determined by the embedding layer in the sequence model.
[0082] Step 204: Generate a first loss function according to the predicted recommended object categories corresponding to each of the multiple sample objects; generate a second loss function according to the comprehensive correlation data corresponding to each of the multiple sample objects.
[0083] After determining the predicted recommended object category corresponding to each sample object through step 203, the predicted recommended object category corresponding to each sample object can be used to generate a first loss function. The first loss function can also be called a category prediction loss function, which is used to make the predicted recommended object category determined according to the predicted modeling features corresponding to the sample object close to the object category to which the label recommended object corresponding to the sample object belongs, thereby helping to improve the feature modeling ability of the sequence model, so that the sequence model can more accurately model features based on the identification sequence, that is, the predicted modeling features obtained by the sequence modeling can more accurately reflect the objects that the sample user may be interested in to a certain extent.
[0084] When specifically generating the first loss function, the cross entropy may be calculated based on the predicted recommended object category corresponding to each sample object and the object category to which the label recommended object corresponding to each sample object belongs, thereby obtaining the first loss function.
[0085] After determining the comprehensive correlation data corresponding to each sample object in step 203, the comprehensive correlation data corresponding to each sample object can be used to generate a second loss function. The second loss function can also be called a correlation loss function, which is used to make the prediction modeling feature corresponding to the sample object close to the embedded feature of the label recommendation object corresponding to the sample object, and away from the embedded feature of the negatively correlated object corresponding to the sample object, that is, to make the recommended object indicated by the prediction modeling feature corresponding to the sample object as close as possible to the label recommendation object corresponding to the sample object, and to make the recommended object indicated by the prediction modeling feature corresponding to the sample object as far as possible from the negatively correlated object corresponding to the sample object, thereby improving the feature modeling ability of the sequence model from the dimension of feature correlation.
[0086] When generating the second loss function, the cross entropy can be calculated according to the comprehensive correlation data and label correlation data corresponding to each sample object, thereby obtaining the second loss function. Depending on the calculation method of the comprehensive correlation data, the label correlation data can be set to 1 or 0.
[0087] Step 205: Based on the first loss function and the second loss function, the sequence model is trained to obtain a target sequence model; the target sequence model is used for feature modeling in the recommendation task.
[0088] After the first loss function and the second loss function are generated in step 204, the first loss function and the second loss function may be linearly weighted to obtain a total loss function. Further, based on the total loss function, the model parameters of the sequence model are adjusted to train the sequence model.
[0089] It should be understood that in practical applications, the sequence model can be iteratively trained for multiple rounds based on different training identification sequences, that is, based on different training identification sequences, the above steps 202 to 205 are executed to implement iterative training for the sequence model until the training end condition is reached, and a trained target sequence model is obtained; the target sequence model is a sequence model that can be put into practical application. The target sequence model can be used for feature modeling in recommendation tasks. For details on the application of the target sequence model, please refer to Figure 7 The relevant contents of the corresponding embodiments.
[0090] Exemplarily, the training termination condition may be that the number of training rounds for the sequence model reaches a preset number of rounds; the training termination condition may also be that the model performance of the sequence model reaches a preset performance requirement, for example, the accuracy of the predicted recommendation object category determined by the predictive modeling features obtained based on the sequence model modeling reaches a preset prediction accuracy threshold, and the comprehensive correlation data determined by the predictive modeling features obtained based on the sequence model modeling reaches a preset correlation accuracy threshold; the training termination condition may also be that the model performance of the sequence model no longer improves significantly with the progress of training, for example, the model performance difference between the sequence models of adjacent training rounds does not meet the preset significant difference condition. Of course, the above-mentioned training termination condition may also be other conditions, and the embodiments of the present application do not impose any limitation on this.
[0091] The model training method provided in the embodiment of the present application proposes a new training mechanism for the sequence model in the recommendation system, which can not only reduce the computing resources consumed in the model training process, but also enable the trained sequence model to obtain a better convergence effect. Specifically, when the sequence model is trained by this method, two loss functions will be used at the same time, namely the first loss function and the second loss function. Among them, the first loss function is generated based on the predicted recommended object category corresponding to the sample object, and the predicted recommended object category is determined according to the predicted modeling features output by the sequence model to be trained, and the predicted modeling features are obtained by the sequence model according to the training identification sequence including the identifications of multiple sample objects; through the first loss function, the sequence model can model the features as accurately as possible, which is conducive to accurately predicting the recommended object category based on the predicted modeling features obtained by modeling; since the present application only predicts the category to which the recommended object belongs based on the predicted modeling features output by the sequence model, but does not predict the specific recommended object, therefore, the amount of data required for calculation can be greatly reduced, and accordingly, the required computing resources can be reduced, and the computing burden can be reduced. While reducing the consumption of computing resources, in order to ensure the convergence effect of the sequence model, the present application also introduces a second loss function to train the sequence model. The second loss function is determined based on the comprehensive correlation data corresponding to the sample object, and the comprehensive correlation data corresponding to the sample object is determined according to the predictive modeling features corresponding to the sample object, the embedded features of the label recommendation object, and the embedded features of the negatively correlated object. Through the second loss function, the predictive modeling features corresponding to the sample object output by the sequence model can be close to the embedded features of the label recommendation object and away from the embedded features of the negatively correlated object, thereby improving the modeling effect of the sequence model from the dimension of feature correlation, so that the sequence model obtains a better convergence effect, and since the correlation data between the calculation features does not need to consume more computing resources, it can be ensured that the introduction of the second loss function does not cause excessive computing burden.
[0092] In a possible implementation, the "using the sequence model to be trained and modeling the training identification sequence to obtain a prediction feature sequence" in the above step 202 may include the following steps 2021 and 2022 (not shown in the figure):
[0093] Step 2021: determining an embedded feature sequence according to the training identification sequence through the embedding layer in the sequence model; the embedded feature sequence includes the embedded features of each of the multiple sample objects arranged in the order.
[0094] like Figure 3As shown, the sequence model includes an embedding layer, which is a structure for converting the identifiers of sample objects in the training identifier sequence into embedded features. Specifically, the embedding layer can query the embedded features of each sample object based on the identifier of each sample object in the training identifier sequence. The embedded features of the sample object are feature data that represent the sample object in the form of a low-dimensional dense vector; then, according to the arrangement order of the identifiers of each sample object in the training identifier sequence, the embedded features of each sample object are arranged accordingly to obtain an embedded feature sequence.
[0095] Step 2022: Modeling the predicted feature sequence based on the embedded feature sequence through the feature modeling layer in the sequence model.
[0096] The feature modeling layer in the sequence model is used to model the structure of the predicted feature sequence based on the embedded feature sequence, such as Figure 3 As shown, the feature modeling layer can be specifically a Transformer layer formed by stacking multiple Transformer decoder blocks (Decoding Block). The above-mentioned Transformer decoder blocks are all decoder structures with a mask mechanism. Through the mask mechanism, when processing each embedded feature, the Transformer decoder block only pays attention to the embedded feature itself and the embedded features before the embedded feature in the embedded feature sequence, without referring to the information of the embedded features after the embedded feature in the embedded feature sequence. In this way, when a certain sample object and the sample objects for which the sample user has triggered reference behavior before the sample object are known, the object that the sample user may be interested in after the sample object is predicted, which is consistent with the actual working mechanism in the recommendation system.
[0097] For example, Figure 4 A schematic diagram of the structure of the Transformer decoder block provided in the embodiment of the present application, such as Figure 4 As shown, each Transformer decoder block can specifically include the following three parts:
[0098] 1) Masked Multi-Head Self-Attention Structure: This structure captures the dependencies between different positions in the feature sequence by performing multi-head self-attention calculations on the input feature sequence based on a mask mechanism. It should be understood that for the first Transformer decoder block in the Transformer layer, the input feature sequence is the embedded feature sequence, while for other Transformer decoder blocks in the Transformer layer, the input feature sequence is the feature sequence output by the previous Transformer decoder block.
[0099] 2) Residual Connection and Layer Normalization Structure: The residual connection structure is used to perform residual connection on the feature sequence output by the aforementioned multi-head self-attention structure with the feature sequence input to the multi-head self-attention structure to ensure that important feature information is not lost during the processing; the layer normalization structure is used to perform layer normalization on the result after the residual connection, thereby accelerating the training of the sequence model and improving the performance of the sequence model.
[0100] 3) Feedforward Neural Network structure: This structure usually consists of two connected fully connected layers. The feature representation of each position is calculated through the fully connected layer to enhance the feature expression ability of each position. Sparse hybrid expert network can also be used to replace the feedforward neural network structure.
[0101] After the embedded feature sequence is processed by each Transformer decoder block in the Transformer layer, a predicted feature sequence is output. In the case where the training identifier sequence includes n identifiers and the embedded feature sequence includes n embedded features, the predicted feature sequence includes n predictive modeling features, and the n predictive modeling features correspond to the sample objects indicated by each of the n identifiers.
[0102] In the case where the sequence model determines the prediction feature sequence based on the embedded features of each sample object, the method provided in the embodiment of the present application may further include the following step 206 (not shown in the figure):
[0103] Step 206: Based on the first loss function and the second loss function, train the embedding features of the sample object.
[0104] That is, while the sequence model is trained based on the first loss function and the second loss function, the embedded features of each sample object are also trained. Specifically, the first loss function and the second loss function can be linearly weighted to obtain a total loss function; then, the embedded features of the sample object are adjusted based on the total loss function to achieve the training of the embedded features of the sample object.
[0105] It should be noted that in the field of natural language processing, when training a language model or a large language model, it is often necessary to simultaneously train the feature representation (token) of each word or character, so as to determine an accurate mathematical representation for each word or character, so as to indicate the semantics of the word or character through the mathematical representation. Similarly, in an embodiment of the present application, when training a sequence model applied in a recommendation system, it is also necessary to simultaneously train the feature representation (i.e., embedded features) of each candidate recommendation object in the recommendation system, so as to determine an accurate mathematical representation for each candidate recommendation object, so as to indicate the relevant information (such as type, content, etc.) of the candidate recommendation object through the mathematical representation.
[0106] In this way, through the above method, the sequence model is based on the feature modeling layer with a mask mechanism, and the prediction feature sequence is obtained according to the embedded feature sequence modeling, which can more accurately model the prediction modeling features corresponding to each sample object. In addition, the embedded features corresponding to the sample object are finally trained based on the first loss function and the second loss function at the same time, which is conducive to training to obtain more accurate embedded features of the sample object, that is, the embedded features obtained by training can more accurately reflect the characteristics of the corresponding sample object.
[0107] It should be understood that the embedding features of the above sample objects are trained based on the initial embedding features of the sample objects. The initial embedding features of the sample objects are the embedding features that originally correspond to the sample objects. When the embedding features of the sample objects are trained for the first time, the initial embedding features of the sample objects need to be adjusted. Usually, the initial embedding features of the sample objects are determined by random initialization. However, considering that training based on the initial embedding features obtained by random initialization requires a long training time, the embodiments of the present application propose the following method for determining the initial embedding features of the sample objects:
[0108] Acquire the associated image and the associated text corresponding to the sample object; and extract the initial embedding feature corresponding to the sample object based on the associated image and the associated text through a multimodal feature extraction model.
[0109] The associated image corresponding to the sample object refers to an image that can reflect the specific content or related content of the sample object, and the associated text corresponding to the sample object refers to a text that can reflect the specific content or related content of the sample object. Taking the sample object as a commodity in a shopping application as an example, the associated image corresponding to the sample object can be a commodity image, and the associated text corresponding to the sample object can be a commodity name, commodity introduction text, commodity evaluation text, etc. Taking the sample object as a video in a video application as an example, the associated image corresponding to the sample object can be a cover image of the video, a key frame image of the video, and the associated text corresponding to the sample image can be a video name, video description text, video evaluation text, video lines, etc. In actual applications, the associated images and associated texts corresponding to the sample objects can be obtained from the relevant database of the recommendation system.
[0110] The multimodal feature extraction model is a neural network model that can extract features based on input data of multiple different modalities. In an embodiment of the present application, the multimodal feature extraction model is a neural network model that can extract features based on images and texts. Exemplarily, an open source multimodal large language model can be used as the above-mentioned multimodal feature extraction model. Common multimodal large language models include but are not limited to Large Language and Vision Assistant (LLaVA), MiniGPT model, and BLIP-2 (Bootstrapping Language-Image Pre-training 2) model.
[0111] Figure 5 A schematic diagram of the implementation principle of determining the initial embedding feature provided in the embodiment of the present application, such as Figure 5 As shown, after the associated image and associated text corresponding to the sample object are input into the multimodal feature extraction model, the multimodal feature extraction model will generate an embedded feature of the image and text fusion based on the associated image and the associated text, and the embedded feature can be used as the initial embedded feature of the sample object. The initial embedded feature of the sample object will be provided to the embedding layer of the sequence model, so that the embedding layer can find the initial embedded feature of the sample object according to the identifier of the sample object, and adjust the weight of the initial embedded feature during the model training process to realize the training of the embedded feature of the sample object.
[0112] In this way, through the above method, using the multimodal feature extraction model, based on the associated image and associated text corresponding to the sample object, the initial embedding features of the sample object are generated, which can ensure that the initial embedding features of each sample object can reflect the specific content of the sample object to a certain extent. Accordingly, model training and feature training based on the initial embedding features can accelerate convergence.
[0113] In a possible implementation, the step 203 of “determining the predicted recommended object category corresponding to the sample object according to the predicted modeling features corresponding to the sample object” may include the following step 203a (not shown in the figure):
[0114] Step 203a: According to the prediction modeling features corresponding to the sample object, determine the object category to which the predicted recommended object corresponding to the sample object belongs from multiple object categories as the predicted recommended object category.
[0115] Among them, the multiple object categories are obtained in advance based on clustering of each candidate recommendation object, or are determined based on the classification directory to which each candidate recommendation object belongs; the sample object belongs to the candidate recommendation object; the predicted recommendation object corresponding to the sample object is a candidate recommendation object predicted based on the predictive modeling features and is of interest to the sample user after the sample object.
[0116] Specifically, before training the sequence model, multiple object categories can be determined based on each candidate recommended object in the recommendation system, so that when training the sequence model, it is convenient to determine the predicted recommended object category from these multiple object categories based on the predictive modeling features output by the sequence model.
[0117] As an example, the above-mentioned multiple object categories can be determined by clustering, that is, clustering the candidate recommended objects in the recommendation system to obtain multiple object categories. More specifically, feature encoding processing can be performed for each candidate recommended object. For example, feature encoding processing can be performed on the attribute information of the candidate recommended object to obtain the attribute characteristics of the candidate recommended object; further, a clustering algorithm, such as the Kmeas algorithm, the K-NearestNeighbor (KNN) algorithm, etc., can be used to perform clustering processing based on the attribute characteristics of each candidate recommended object to obtain multiple cluster clusters, each cluster cluster corresponds to an object category, and the candidate recommended objects included in the cluster cluster belong to the object category corresponding to the cluster cluster.
[0118] As another example, the above-mentioned multiple object categories can also be determined based on the classification directory in the recommendation system. Generally, the recommendation system has its corresponding classification directory, which is determined based on the candidate recommended objects in the recommendation system, and includes the object categories to which each candidate recommended object belongs; the classification directory usually includes object categories of different granularities. When determining the object category based on which the training sequence model is based, the object category of the appropriate granularity can be selected according to the training requirements to avoid the difficulty of the sequence model to reliably learn the feature modeling ability due to the coarse granularity of the selected object category, and to avoid consuming more computing resources during the model training process due to the fine granularity of the selected object category.
[0119] It should be understood that the above-mentioned method of determining multiple object categories based on the training sequence model is only an example. In practical applications, other methods can also be used to determine multiple object categories, and the embodiments of the present application do not impose any limitation on this. In addition, it should be noted that in the embodiments of the present application, each candidate recommended object belongs to only one object category, and each object category can include multiple candidate recommended objects.
[0120] On the basis of having determined multiple object categories, when training the sequence model, after obtaining the predictive modeling features corresponding to each sample object output by the sequence model, the object category of the candidate recommended object (i.e., the predicted recommended object) that the sample user may be interested in after the sample object can be determined from among the multiple object categories based on the predictive modeling features corresponding to the sample object. This object category is the predicted object category corresponding to the sample object.
[0121] In this way, through the above method, the predicted recommended object category corresponding to the sample object can be determined from multiple predetermined object categories based on the predictive modeling features corresponding to the sample object output by the sequence model, so that the predicted recommended object that the sample user may be interested in after the sample object is located only in the category dimension. Compared with locating the predicted recommended object in the object dimension, the relevant calculation amount can be greatly reduced, thereby reducing the required computing resources and alleviating the computational burden.
[0122] As an example, in the above step 203a, "determining, according to the prediction modeling features corresponding to the sample object, from multiple object categories, the object category to which the predicted recommended object corresponding to the sample object belongs, as the predicted recommended object category" may include:
[0123] Through a linear transformation structure, according to the prediction modeling features corresponding to the sample objects, the prediction probabilities corresponding to each of the multiple object categories are determined; and the object category with the largest corresponding prediction probability is determined as the predicted recommended object category.
[0124] The linear transformation structure can specifically be a fully connected layer, which is used to map the predictive modeling features corresponding to the sample object to a vector space whose dimension is equal to the number of object categories through linear transformation. In this vector space, each element represents the possibility that the predicted recommended object corresponding to the sample object belongs to its corresponding object category.
[0125] Figure 6 A schematic diagram of the working principle of a sequence model provided in an embodiment of the present application is shown in FIG. Figure 6 As shown, after the sequence model, an output layer is also included, and the output layer includes a category probability prediction layer, and the category probability prediction layer is the above-mentioned linear transformation structure. The input data of the sequence model includes sample objects I1, I2, ..., I n In the case of a training sequence of respective identifiers, the output data of the sequence model includes predictive modeling features h1, h2, ..., h n The prediction feature sequence, prediction modeling features h1, h2, ..., h n With sample objects I1, I2, ..., I n One-to-one correspondence. Then, the prediction probability corresponding to each candidate object category can be determined according to each prediction modeling feature through the category probability prediction layer in the output layer; that is, the input data dimension of the category probability prediction layer is the dimension of a single prediction modeling feature, and the output data dimension is the object category set (including all pre-divided object categories, which can be expressed as ), where each dimension is a probability score s(c i ), represents the predicted probability corresponding to the i-th object category, i is an integer greater than or equal to 1 and less than or equal to the total number of object categories in the object category set.
[0126] For example, the class probability prediction layer can be used to predict the modeling feature h j (prediction modeling feature corresponding to the jth sample object, j is an integer greater than or equal to 1 and less than or equal to n), determine the prediction probability corresponding to each object category in the object category set, and the prediction probability corresponding to each object category represents the prediction modeling feature h based on the output of the sequence model j The predicted possibility that the j+1th sample object belongs to the object category. Furthermore, the maximum predicted probability can be determined among the predicted probabilities corresponding to each object category, and the object category corresponding to the maximum predicted probability can be determined. The object category is the object category to which the j+1th sample object finally predicted belongs, that is, the predicted recommended object category corresponding to the jth sample object.
[0127] In this way, through the above method, the linear transformation structure is used to determine the predicted recommended object category corresponding to the sample object based on the predictive modeling features corresponding to the sample object, so that the predicted recommended object category corresponding to the sample object can be determined quickly and efficiently, thereby improving the model training efficiency.
[0128] As another example, in step 203a above, “determining, according to the prediction modeling features corresponding to the sample object, from multiple object categories, the object category to which the predicted recommended object corresponding to the sample object belongs, as the predicted recommended object category” may include:
[0129] For each of the object categories, calculating the correlation between the prediction modeling features corresponding to the sample object and the embedded features of the object category as the prediction probability corresponding to the object category; determining the object category with the largest corresponding prediction probability as the predicted recommended object category;
[0130] In this example, an embedded feature may be determined in advance for each object category that is a candidate, and the embedded feature of an object category is feature data representing the object category in the form of a low-dimensional dense vector.
[0131] On this basis, the method of embedding weight binding can be further adopted to determine the prediction probability corresponding to each object category. The prediction probability corresponding to the object category is used to indicate the possibility that the object that the sample user may be interested in after the sample object belongs to the object category, which is predicted based on the prediction modeling features corresponding to the sample object. Specifically, for each object category as a candidate, the correlation between the prediction modeling features and the embedding features of the object category can be obtained by performing a dot product between the embedding features of the object category and the prediction modeling features corresponding to the sample object, and then the correlation is used as the prediction probability corresponding to the object category. After calculating the prediction probabilities corresponding to each object category based on the prediction modeling features corresponding to the sample object, the maximum prediction probability can be determined, and the object category corresponding to the maximum prediction probability is used as the predicted recommended object category corresponding to the sample object.
[0132] In the case where the prediction probability corresponding to each object category is determined by embedding weight binding, the method provided in the embodiment of the present application may further include the following step 207 (not shown in the figure):
[0133] Step 207: Based on the first loss function and the second loss function, train the embedding features of each of the multiple object categories.
[0134] Generally speaking, the embedded features determined in advance for each object category are usually difficult to accurately reflect the object category. Therefore, while training the sequence model, it is also necessary to train the embedded features of each object category; specifically, the first loss function and the second loss function can be linearly weighted to obtain the total loss function; then, based on the total loss function, the embedded features of each object category are adjusted to achieve the training of the embedded features of each object category.
[0135] It should be understood that the embedding features of each object category are trained based on the initial embedding features of the object category. The initial embedding features of the object category here can be obtained, for example, by random initialization, or can be calculated based on the embedding features of the candidate recommended objects under the object category (such as calculating the mean of the embedding features of each candidate recommended object, etc.). The embodiments of the present application do not impose any limitation on the method of determining the initial embedding features of the object category.
[0136] In this way, through the above method, the prediction probability corresponding to each object category is determined by embedding weight binding, and the embedding features of each object category are trained while training the sequence model. The predicted recommended object category corresponding to the sample object can be accurately determined, and the embedded features of the object category finally trained can also be applied in other tasks of the recommendation system, so that the training results can be more fully applied.
[0137] In a possible implementation, the "generating a first loss function according to the predicted recommended object categories corresponding to each of the plurality of sample objects" in the above step 204 may include the following steps 204a1 and 204a2 (not shown in the figure):
[0138] Step 204a1: For each of the sample objects, determine the first loss value corresponding to the sample object according to the predicted recommended object category corresponding to the sample object and the label recommended object category corresponding to the sample object; when the sample object is the last sample object in the sequence, the label recommended object category is pre-labeled, and when the sample object is not the last sample object in the sequence, the label recommended object category is the object category to which the next sample object adjacent to the sample object in the sequence belongs.
[0139] Specifically, for each sample object, it is necessary to determine the label recommendation object category corresponding to the sample object. The label recommendation object category corresponding to the sample object is used to indicate the category to which the object that the sample user is actually interested in after the sample object belongs. The object that the sample user is actually interested in after the sample object can also be called the label recommendation object corresponding to the sample object.
[0140] As an example, when the identifier of a sample object is not the last identifier in the training identifier sequence, that is, among the sample objects based on which the training identifier sequence is constructed, the sample object is not the last sample object that triggers the reference behavior of the sample user, the label recommendation object corresponding to the sample object is the sample object corresponding to the next identifier adjacent to the identifier in the training identifier sequence, and accordingly, the label recommendation object category corresponding to the sample object is the object category to which the sample object corresponding to the next identifier adjacent to the identifier in the training identifier sequence belongs. For example, assuming that the training identifier sequence includes sample objects I1, I2, ..., I n The label recommendation object corresponding to sample object I1 is sample object I2, and the label recommendation object corresponding to sample object I2 is sample object I3, ..., sample object I n-1 The corresponding label recommendation object is the sample object I n Correspondingly, the label recommendation object category corresponding to sample object I1 is the object category to which sample object I2 belongs, and the label recommendation object category corresponding to sample object I2 is the object category to which sample object I3 belongs, ..., sample object I n-1 The corresponding label recommendation object category is sample object I n The object category to which it belongs.
[0141] When the identification of the sample object is the last identification in the training identification sequence, that is, when the sample object is the last sample object that triggers the reference behavior of the sample user among the sample objects based on which the training identification sequence is constructed, the label recommendation object corresponding to the sample object can be manually annotated or annotated according to the reference behavior data of the sample object thereafter. Accordingly, the label recommendation object category corresponding to the sample object is the object category to which the annotated label recommendation object belongs. n For example, the sample object I n The corresponding label recommendation object can be marked and determined, sample object I n The corresponding label recommendation object category is the labeled sample object I n The corresponding label recommendation object belongs to the object category.
[0142] On the basis of determining the predicted recommended object category and the label recommended object category corresponding to each sample object, for each sample object, the first loss value corresponding to the sample object can be calculated based on the predicted recommended object category corresponding to the sample object and the label recommended object category corresponding to the sample object. For example, the predicted recommended object category corresponding to the sample object can be represented by the predicted probability distribution determined based on the predictive modeling features corresponding to the sample object (including the predicted probabilities corresponding to each of the above-mentioned object categories), and the label probability distribution corresponding to the sample object (the dimension is equal to the total number of object categories, where the element corresponding to the label recommended object category is equal to 1, and the elements corresponding to other object categories are equal to 0) can be used to represent the label recommended object category corresponding to the sample object; and then, based on the difference between the two, the first loss value corresponding to the sample object is determined.
[0143] Step 204a2: Generate the first loss function according to the first loss values corresponding to each of the multiple sample objects.
[0144] Finally, a first loss function can be generated based on the first loss values corresponding to each of the multiple sample objects. The first loss function can be specifically expressed as the following formula (1):
[0145] (1)
[0146] Wherein, L1 represents the first loss function. n is the number of identifiers included in the training identifier sequence, that is, the total number of sample objects involved in the training identifier sequence. <t represents the sub-identifier sequence consisting of the first to the t-1th identifiers in the training identifier sequence. t The object category recommended for the label corresponding to the t-1th sample object is the object category to which the actual tth sample object belongs. is the first loss value corresponding to the t-1th sample object; It means that given the above sub-identification sequence, the predicted t-th sample object belongs to C t The probability that the predicted recommended object corresponding to the t-1th sample object belongs to C t The probability of It can be determined by the following formula (2):
[0147] (2)
[0148] in, , ,……, They respectively represent the prediction probabilities corresponding to each object category calculated based on the prediction modeling features corresponding to the t-1th sample object; Represents the sum of the predicted probabilities corresponding to each object category. It is the ratio of the maximum predicted probability to the sum of all predicted probabilities.
[0149] During the model training process, the training goal is to maximize the conditional probabilities (i.e., ), that is, minimizing the negative log-likelihood loss L1. The model adjusts the prediction probability corresponding to the determined object category through the above cross entropy loss function, improves the prediction probability corresponding to the label recommended object category, and correspondingly reduces the prediction probability corresponding to other object categories.
[0150] In this way, constructing the first loss function in the above manner and subsequently training the sequence model based on the first loss function can help the sequence model to obtain more accurate features. Accordingly, based on the features obtained by modeling, it is possible to more accurately predict the object category to which the user may be interested in the future.
[0151] When the comprehensive correlation data corresponding to the sample object is determined through the above step 203, the label recommendation object corresponding to the sample object and the negatively correlated object corresponding to the sample object are involved. Among them, the implementation method of determining the label recommendation object corresponding to the sample object has been introduced in the above step 204a1. Next, three exemplary implementation methods of determining the negatively correlated object corresponding to the sample object will be introduced.
[0152] Method 1: Remove the plurality of sample objects from the full sampling pool consisting of the candidate recommendation objects to obtain a first sampling pool. For each sample object, extract a preset number of candidate recommendation objects from the first sampling pool as negatively correlated objects corresponding to the sample object.
[0153] Specifically, each candidate recommended object in the recommendation system can be used to form a full sampling pool, and then the sample objects indicated by each identifier in the training identifier sequence are removed from the full sampling pool to obtain a first sampling pool. Furthermore, for each sample object, N candidate recommended objects can be randomly selected from the first sampling pool, and these N candidate recommended objects are used as negatively correlated objects corresponding to the sample object; N here is the above-mentioned preset number, which is usually in the order of 100 to 1000.
[0154] In this way, by means of simple sampling, the negatively correlated objects corresponding to each sample object can be quickly extracted from the first sampling pool, and the corresponding negatively correlated objects can be determined for each sample object with high efficiency.
[0155] Method 2: Remove the candidate recommendation objects with the target semantic attribute from the full sampling pool composed of the candidate recommendation objects to obtain a second sampling pool; the target semantic attribute is the semantic attribute possessed by each of the sample objects. For each of the sample objects, a preset number of candidate recommendation objects are extracted from the second sampling pool as negatively related objects corresponding to the sample object.
[0156] Specifically, the candidate recommendation objects in the recommendation system can be used to form a full sampling pool, and then the candidate recommendation objects with target semantic attributes can be removed from the full sampling pool to obtain a second sampling pool. The target semantic attributes here can be determined according to the semantic attributes of the sample objects indicated by each identifier in the training identifier sequence. For example, the semantic attributes of each sample object can be used as the target semantic attributes; the semantic attributes of the sample object can be specifically represented by the label and category of the sample object. Furthermore, for each sample object, N candidate recommendation objects can be randomly selected from the second sampling pool, and these N candidate recommendation objects can be used as negatively correlated objects corresponding to the sample object; N here is the above-mentioned preset number, which is usually in the order of 100 to 1000.
[0157] Exemplarily, assume that the training identification sequence includes the identifications of sample objects I1, I2, I3, I4 and I5, wherein the label of sample object I1 is women's top, pink, and commuting; the label of sample object I2 is women's top, black, and work clothes; the label of sample object I3 is women's dress, and commuting; the label of sample object I4 is women's dress, black, and the label of sample object I5 is women's skirt, and commuting; accordingly, women's top, women's dress, women's skirt, pink, black, commuting, and work clothes are all target semantic attributes; based on this, candidate recommendation objects with any of the above target semantic attributes (i.e., labels) can be removed from the full sampling pool to obtain a second sampling pool; and then, for each sample object, N candidate recommendation objects can be randomly selected from the second sampling pool as negatively correlated objects corresponding to the sample object.
[0158] In this way, through the above method, the full sampling pool is first filtered based on the semantic attributes of each sample object, and then the negatively correlated objects corresponding to the sample objects are extracted from the second sampling pool obtained by filtering. This can ensure that the determined negatively correlated objects have obvious differences in semantic attributes from the sample objects, thereby ensuring the accuracy of the determined negatively correlated objects.
[0159] Method 3: Remove the candidate recommendation objects with the target semantic attribute from the full sampling pool composed of the candidate recommendation objects to obtain the second sampling pool; use the candidate recommendation objects with the target semantic attribute to form the third sampling pool; the target semantic attribute is the semantic attribute possessed by each of the sample objects. For each of the sample objects, extract a first preset number of candidate recommendation objects from the second sampling pool as negatively related objects corresponding to the sample object; extract a second preset number of candidate recommendation objects whose semantic attribute coincidence with the sample object is lower than the preset coincidence threshold from the third sampling pool as negatively related objects corresponding to the sample object.
[0160] Specifically, the method for determining the second sampling pool has been described in detail in the above method 2, and will not be repeated here. When determining the third sampling pool, the third sampling pool can be directly composed of each candidate recommendation object with the target semantic attribute, that is, the third sampling pool is composed of each candidate recommendation object with the target semantic attribute filtered out from the full sampling pool when determining the second sampling pool; in other words, the second sampling pool and the third sampling pool are combined to restore the full sampling pool.
[0161] Furthermore, for each sample object, N1 candidate recommendation objects can be randomly selected from the second sampling pool as a part of negatively correlated objects corresponding to the sample object, where N1 is a first preset number, which is an integer less than the above preset number N. In addition, N2 candidate recommendation objects whose semantic attribute coincidence with the sample object is lower than the preset coincidence threshold can be extracted from the third sampling pool as another part of negatively correlated objects corresponding to the sample object; the coincidence of semantic attributes between the sample object and the candidate recommendation object can be determined according to the coincidence between the semantic attributes of the sample object and the semantic attributes of the candidate recommendation object. For example, in the case where the semantic attribute is a label, assuming that the labels of a sample object include women's tops, pink, and commuting, and the labels of a candidate recommendation object include women's tops, blue, and sports, then there is an overlapping label between the sample object and the candidate recommendation object, and the semantic attribute coincidence between the two can be calculated based on the number of overlapping labels; the preset coincidence threshold is a pre-set coincidence threshold for reference when extracting negatively correlated objects. If the semantic attribute coincidence between the sample object and the candidate recommendation object is lower than the preset coincidence threshold, it means that the difference between the candidate recommendation object and the sample object meets the negatively correlated object selection requirement; N2 is a second preset number, which is an integer less than the above-mentioned preset number N, and the sum of N2 and the above-mentioned N1 is the preset number N.
[0162] It should be noted that the negatively correlated objects extracted from the second sampling pool can be considered as simple negative samples, and the negatively correlated objects extracted from the third sampling pool can be considered as hard negative samples. In the embodiment of the present application, the ratio of the simple negative samples to the hard negative samples can be adjusted according to actual needs, that is, the first preset number N1 and the second preset number N2 can be flexibly adjusted to adjust the exploration (Explorer) and utilization (Exploit) capabilities of the model.
[0163] In this way, through the above method, simple negative samples and difficult negative samples are collected in the second sampling pool and the third sampling pool respectively according to a specific sampling ratio. On the one hand, the accuracy of the collected negative samples can be guaranteed. On the other hand, the feature modeling ability of the sequence model can be further improved by distinguishing the predictive modeling features output by the sequence model from the embedded features of the difficult negative samples, making the features obtained by the modeling more accurate.
[0164] It should be understood that the above three implementation methods of determining the negatively correlated objects corresponding to the sample objects are only examples. In practical applications, the negatively correlated objects corresponding to the sample objects may also be determined by other methods, and the embodiments of the present application do not impose any limitation on this.
[0165] In a possible implementation, the above step 203 of “determining the comprehensive correlation data corresponding to the sample object according to the prediction modeling features corresponding to the sample object, the embedded features of the label recommendation object corresponding to the sample object, and the embedded features of the negatively correlated object corresponding to the sample object” may include the following steps 203b1 to 203b3 (not shown in the figure):
[0166] Step 203b1: Calculate the first correlation between the predictive modeling feature and the embedded feature of the label recommendation object; when the sample object is the last sample object in the sequence, the label recommendation object is pre-labeled, and when the sample object is not the last sample object in the sequence, the label recommendation object is the next sample object adjacent to the sample object in the sequence.
[0167] For each sample object, the dot product result between the prediction modeling feature corresponding to the sample object and the embedded feature of the label recommendation object corresponding to the sample object (which can be obtained through the embedding layer in the sequence model) can be calculated as the first correlation between the prediction modeling feature and the embedded feature of the label recommendation object; for example, for the prediction modeling feature h corresponding to the kth sample object output by the sequence model k , and the embedding feature e of the label recommendation object corresponding to the kth sample object lk , the first correlation between the two r(hk , e lk ) =h k ·e lk The first correlation may represent a correlation between the predicted recommended object indicated by the predictive modeling feature and the tag recommended object.
[0168] Step 203b2: Calculate a second correlation between the predictive modeling feature and the embedded feature of each of the negatively correlated objects.
[0169] Similarly, for each sample object, the dot product result between the prediction modeling feature corresponding to the sample object and the embedded feature of each negatively correlated object corresponding to the sample object (which can be obtained through the embedding layer in the sequence model) can be calculated as the second correlation between the prediction modeling feature and the embedded feature of each negatively correlated object; for example, for the prediction modeling feature h corresponding to the kth sample object output by the sequence model k , and the embedding feature e of the i-th negatively correlated object corresponding to the k-th sample object i , the first correlation between the two r(h k , e i ) =h k ·e i The second correlation may represent the correlation between the predicted recommended object indicated by the predictive modeling feature and the negatively correlated object.
[0170] It should be understood that in actual applications, step 203b1 may be executed first and then step 203b2, or step 203b2 may be executed first and then step 203b1, or step 203b1 and step 203b2 may be executed simultaneously. The embodiment of the present application does not impose any limitation on the execution order of step 203b1 and step 203b2.
[0171] Step 203b3: Determine the comprehensive correlation data based on the first correlation and each of the second correlations.
[0172] Figure 6 A schematic diagram of the working principle of a sequence model provided in an embodiment of the present application is shown in FIG. Figure 6 As shown, an output layer is also included after the sequence model, and the output layer includes a sampling probability prediction layer. The sampling probability output layer is used to determine the comprehensive correlation data corresponding to the sample object.
[0173] Specifically, the sampling probability prediction layer can calculate the comprehensive correlation data corresponding to the sample object according to the first correlation between the prediction modeling feature corresponding to the sample object and the embedded feature of the label recommendation object, and the second correlation between the prediction modeling feature corresponding to the sample object and the embedded feature of each negatively correlated object through the following formula (3):
[0174] (3)
[0175] in, is the comprehensive correlation data corresponding to the t-1th sample object. <t represents the sub-identifier sequence consisting of the first to t-1th identifiers in the training identifier sequence. t-1 , e lt ) is the first correlation between the prediction modeling feature corresponding to the t-1th sample object and the embedded feature of the tth sample object, and the tth sample object is the label recommendation object of the t-1th sample object. is the set of negatively correlated objects corresponding to the t-1th sample object, including each negatively correlated object corresponding to the t-1th sample object, r(h t-1 , e i ) is the second correlation between the predicted modeling features corresponding to the t-1th sample object and the embedded features of the i-th negatively correlated object.
[0176] In this way, through the above method, the first correlation between the predictive modeling features and the embedded features of the label recommendation objects, and the second correlation between the predictive modeling features and the embedded features of the negatively correlated objects are used to calculate the comprehensive correlation data, which can ensure that the comprehensive correlation data accurately reflects the correlation between the sample objects and their corresponding label recommendation objects, as well as the correlation between them and their corresponding negatively correlated objects.
[0177] In a possible implementation, the "generating a second loss function according to the comprehensive correlation data corresponding to each of the plurality of sample objects" in the above step 204 may include the following steps 204b1 and 204b2 (not shown in the figure):
[0178] Step 204b1: for each of the sample objects, determine the second loss value corresponding to the sample object according to the comprehensive correlation data corresponding to the sample object and the label correlation data corresponding to the sample object; the label correlation data is 1.
[0179] When the comprehensive correlation data corresponding to the sample object is calculated through the above steps 203b1 to 203b3, the label correlation data corresponding to the sample object should be equal to 1. Specifically, during the model training process, it is usually expected that the prediction modeling features corresponding to the sample object are close to the embedded features of the label recommendation object corresponding to the sample object, and far away from the embedded features of the negatively correlated object corresponding to the sample object; when the above formula (3) is used to calculate the comprehensive correlation data, it is expected that Larger, is smaller, accordingly, we hope to obtain It approaches 1, based on which, the label correlation data corresponding to the sample object can be set to 1.
[0180] Correspondingly, for each sample object, the difference between the comprehensive correlation data and the label correlation data corresponding to the sample object can be calculated as the second loss value corresponding to the sample object.
[0181] Step 204b2: Generate the second loss function according to the second loss values corresponding to each of the multiple sample objects.
[0182] Finally, a second loss function can be generated based on the second loss values corresponding to the multiple sample objects. The second loss function can be specifically expressed as the following formula (4):
[0183] (4)
[0184] Wherein, L2 represents the second loss function. n is the number of identifiers included in the training identifier sequence, that is, the total number of sample objects involved in the training identifier sequence. <t Represents a sub-identifier sequence consisting of the first to the t-1th identifiers in the training identifier sequence. is the second loss value corresponding to the t-1th sample object, which is calculated based on the comprehensive correlation data and label correlation data corresponding to the t-1th sample object.
[0185] During the model training process, the training goal is to minimize the negative log-likelihood loss L2. The model uses the cross entropy loss function to adjust the difference between the determined predictive modeling features and the embedded features of the label recommendation object, as well as the difference between the embedded features of the negatively correlated object, that is, to increase the correlation between the predictive modeling features and the embedded features of the label recommendation object, while reducing the correlation between the predictive modeling features and the negatively correlated object.
[0186] In this way, constructing the second loss function in the above manner and subsequently training the sequence model based on the second loss function can help the sequence model modeling to obtain more accurate features, so that the modeled features are closer to the embedded features of the label recommendation objects and further away from the embedded features of the negatively correlated objects, thereby improving the modeling ability of the sequence model at a finer granularity.
[0187] In addition, an embodiment of the present application also provides a recommendation method, which is used to perform a recommendation task using a sequence model trained by the above-mentioned model training method.
[0188] See also Figure 7 , Figure 7 A flowchart of a recommended method provided in an embodiment of the present application is shown in FIG. Figure 7As shown, the recommended method includes the following steps:
[0189] Step 701: Obtain a target identification sequence.
[0190] In an embodiment of the present application, the target identification sequence is the data input into the sequence model when the sequence model is applied. The target identification sequence includes the identification of each of the multiple behavior objects, and in the target identification sequence, the multiple identifications are arranged in the order in which the target user triggers the reference behavior for the multiple behavior objects.
[0191] The target user may be a user of a target application with a recommendation function. The target application here may include, but is not limited to, shopping applications, video playback applications, audio playback applications, information reading applications, etc. The recommendation function of the target application is implemented through a recommendation system. The behavior object is an object for which the target user has triggered a reference behavior. It may be an object provided by the target application and is a candidate recommendation object in the recommendation system. The behavior object may include, but is not limited to, merchandise, video, audio, text, news, etc. The reference behavior may be any behavior that can indicate the target user's interest in the behavior object, such as, but not limited to, browsing, purchasing, collecting, adding to a shopping cart, liking, commenting, etc. The identification (ID) of the behavior object is information used to uniquely indicate the behavior object. The recommendation system of the target application can pre-configure a unique identification for each candidate recommendation object.
[0192] As an example, a computer device for implementing the recommendation function of a target application can obtain the above-mentioned target identification sequence from a relevant database. Specifically, the database of the target application usually stores historical behavior data of each user of the target application, and the historical behavior data can reflect the behavior that the user has triggered through the target application; when it is necessary to determine the subsequent recommended object for the target user, the computer device can obtain the historical behavior data of the target user in a preset time period (for example, within the past week) from the database, and then extract a preset number of adjacent reference behavior data from the obtained historical behavior data, and arrange the identifiers of the behavior objects indicated by these reference behavior data in the order of the execution time of the reference behavior indicated by these reference behavior data from front to back, thereby obtaining the target identification sequence.
[0193] Step 702: Using a target sequence model, a target feature sequence is modeled based on the target identification sequence.
[0194] After the target identification sequence is obtained, the target identification sequence can be input into the target sequence model trained by the above-mentioned model training method, so as to obtain the target feature sequence through the target sequence model based on the target identification sequence.
[0195] As introduced above, the model structure of the target sequence model can refer to the model structure of the language model or large language model in the field of natural language processing, and the model parameters of the target sequence model are determined by training using the model training method described above.
[0196] The target feature sequence is a feature sequence obtained by the target sequence model based on the target identification sequence, which includes the modeling features corresponding to multiple behavior objects. These multiple behavior objects are the behavior objects corresponding to the multiple identifications in the target identification sequence. For example, assuming that the target identification sequence includes behavior objects J1, J2, ..., J n The target feature sequence will include behavior objects J1, J2, ..., J n The modeling features corresponding to each behavior object are obtained by the target sequence model based on the identifiers of each behavior object before the behavior object in the target identifier sequence and the identifier of the behavior object itself. They are used to indicate the objects after the behavior object that the target user may be interested in. For example, the behavior object J i The corresponding modeling features are based on the behavior objects J1, J2, ..., J in the target identification sequence. i-1 , J i The respective identification modeling is used to indicate the target user in the behavior object J i The object that may be of interest later, that is, the object that may appear at the i+1th position in the target identification sequence.
[0197] For example, the working principle of the target sequence model can be specifically referred to Figure 3 As shown, it includes an input layer, an embedding layer and a Transformer layer. When the target sequence model models the target feature sequence based on the target identification sequence, the target identification sequence including the identifications of multiple behavior objects can be first input into the input layer of the target sequence model; then, through the embedding layer of the target sequence model, the identifications of the multiple behavior objects are respectively mapped to corresponding embedding features, and the embedding features are also obtained by training in the above-mentioned model training method; then, through the multiple Transformer decoder blocks cascaded in the Transformer layer of the target sequence model, feature modeling is performed based on the embedding features corresponding to each of the multiple behavior objects, and a target feature sequence including the modeling features corresponding to each of the multiple behavior objects is obtained.
[0198] Step 703: extracting target representative features from the target feature sequence.
[0199] After the target feature sequence is obtained through target sequence modeling, the target representative feature can be extracted from each modeling feature included in the target feature sequence. For example, the modeling feature located at the last position can be extracted from the target feature sequence, that is, the modeling feature corresponding to the last behavior object can be extracted as the target representative feature.
[0200] It should be understood that since the target sequence model refers to all the behavior objects in the target identification sequence when modeling the modeling features corresponding to the last behavior object, the modeling features corresponding to the last behavior object can best represent the interest preferences of the target user. Accordingly, using the modeling features corresponding to the last behavior object as the target representative features and predicting the objects that the target user may be interested in in the future based on them is most conducive to achieving more accurate recommendation predictions.
[0201] Step 704: Based on the target representative feature, select at least one target recommendation object from each candidate recommendation object; the distance between the embedded feature of the target recommendation object and the target representative feature meets a preset distance proximity condition, and the target recommendation object is the object recommended to the target user.
[0202] After determining the target representative feature, the target user may be subsequently interested in the object based on the target representative feature. Specifically, one or more target recommended objects may be determined from each candidate recommended object based on the target representative feature and the embedded features of each candidate recommended object in the recommendation system; the target recommended object is the object that the target application recommends to the target user in the future, and the distance between the embedded feature of the target recommended object and the target representative feature should meet the preset distance closeness condition, that is, the target recommended object should be close to the object indicated by the target representative feature.
[0203] Exemplarily, an approximate nearest neighbor algorithm (ANN) can be used to find the top k candidate recommendation objects whose corresponding embedded features are closest to the target representative features among each candidate recommendation object, and use them as the target recommendation objects; the approximate nearest neighbor algorithm is a fast nearest neighbor search algorithm for high-dimensional data, which can perform efficient nearest neighbor search on large-scale data sets and is often used in computer vision, natural language processing and other fields.
[0204] The recommendation method provided in the embodiment of the present application utilizes the target sequence model obtained by training through the above-mentioned model training method, and performs feature modeling based on the target identification sequence, which can ensure that the target representative features obtained by modeling accurately reflect the behavioral preferences of the target user, thereby facilitating accurate recommendations for the target user. In addition, when determining the target recommendation object recommended to the target user, multiple target recommendation objects with a close distance to the target representative feature can be selected at one time based on the target representative feature. Compared with the related art that only predicts one target recommendation object each time through autoregression, and it is necessary to iterate and execute multiple prediction processes to predict multiple target recommendation objects, the embodiment of the present application can greatly improve the prediction efficiency of the target recommendation object, thereby improving the recommendation efficiency.
[0205] With respect to the model training method described above, the present application also provides a corresponding model training device so that the above model training method can be applied and implemented in practice. Figure 8 , Figure 8 It is the same as above Figure 2 The structural diagram of the model training device 800 corresponding to the model training method shown in FIG. Figure 8 As shown, the model training device 800 includes:
[0206] The sequence acquisition module 801 is used to acquire a training identification sequence; the training identification sequence includes identifications of multiple sample objects, and each identification is arranged in the order in which the sample user triggers the reference behavior of the multiple sample objects;
[0207] The feature modeling module 802 is used to obtain a prediction feature sequence by modeling the training identification sequence through the sequence model to be trained; the prediction feature sequence includes the prediction modeling features corresponding to each of the multiple sample objects;
[0208] The data processing module 803 is used to determine, for each of the sample objects, the predicted recommended object category corresponding to the sample object according to the predicted modeling features corresponding to the sample object; determine the comprehensive correlation data corresponding to the sample object according to the predicted modeling features corresponding to the sample object, the embedded features of the label recommended object corresponding to the sample object, and the embedded features of the negatively correlated object corresponding to the sample object;
[0209] The loss generating module 804 is used to generate a first loss function according to the predicted recommended object categories corresponding to each of the plurality of sample objects; and to generate a second loss function according to the comprehensive correlation data corresponding to each of the plurality of sample objects;
[0210] The training module 805 is used to train the sequence model based on the first loss function and the second loss function to obtain a target sequence model; the target sequence model is used to perform feature modeling in the recommendation task.
[0211] Optionally, the feature modeling module 802 is specifically used for:
[0212] Determining an embedded feature sequence according to the training identification sequence through an embedding layer in the sequence model; the embedded feature sequence includes the embedded features of each of the plurality of sample objects arranged in the order;
[0213] The predicted feature sequence is obtained by modeling according to the embedded feature sequence through the feature modeling layer in the sequence model;
[0214] Then the training module 805 is also used for:
[0215] Based on the first loss function and the second loss function, the embedding features of the sample object are trained.
[0216] Optionally, the embedding feature of the sample object is trained based on the initial embedding feature of the sample object; the device further comprises an embedding feature determination module, which is used to:
[0217] Obtaining the associated image and associated text corresponding to the sample object;
[0218] The initial embedding features corresponding to the sample object are extracted based on the associated image and the associated text through a multimodal feature extraction model.
[0219] Optionally, the data processing module 803 is specifically used for:
[0220] According to the prediction modeling features corresponding to the sample object, determining, from a plurality of object categories, an object category to which the predicted recommended object corresponding to the sample object belongs, as the predicted recommended object category;
[0221] Among them, the multiple object categories are obtained in advance based on clustering of each candidate recommendation object, or are determined based on the classification directory to which each candidate recommendation object belongs; the sample object belongs to the candidate recommendation object; the predicted recommendation object corresponding to the sample object is a candidate recommendation object predicted based on the predictive modeling features and is of interest to the sample user after the sample object.
[0222] Optionally, the data processing module 803 is specifically used for:
[0223] Determining the prediction probabilities corresponding to each of the plurality of object categories according to the prediction modeling features corresponding to the sample objects through a linear transformation structure;
[0224] The object category with the largest corresponding prediction probability is determined as the predicted recommended object category.
[0225] Optionally, the data processing module 803 is specifically used for:
[0226] For each of the object categories, calculating the correlation between the prediction modeling features corresponding to the sample object and the embedded features of the object category as the prediction probability corresponding to the object category;
[0227] Determine the object category with the largest corresponding prediction probability as the predicted recommended object category;
[0228] Then the training module 805 is also used for:
[0229] Based on the first loss function and the second loss function, embedding features of each of the multiple object categories are trained.
[0230] Optionally, the loss generating module 804 is specifically used for:
[0231] For each of the sample objects, a first loss value corresponding to the sample object is determined according to the predicted recommended object category corresponding to the sample object and the label recommended object category corresponding to the sample object; when the sample object is the last sample object in the sequence, the label recommended object category is pre-labeled; when the sample object is not the last sample object in the sequence, the label recommended object category is the object category to which the next sample object adjacent to the sample object in the sequence belongs;
[0232] The first loss function is generated according to the first loss values corresponding to each of the multiple sample objects.
[0233] Optionally, the device further includes a first sampling module, which is used to:
[0234] Removing the plurality of sample objects from the full sampling pool consisting of the candidate recommendation objects to obtain a first sampling pool;
[0235] For each of the sample objects, a preset number of candidate recommendation objects are extracted from the first sampling pool as negatively correlated objects corresponding to the sample object.
[0236] Optionally, the device further comprises a second sampling module, which is used to:
[0237] Removing candidate recommendation objects with target semantic attributes from the full sampling pool consisting of candidate recommendation objects to obtain a second sampling pool; the target semantic attribute is a semantic attribute possessed by each of the sample objects;
[0238] For each of the sample objects, a preset number of candidate recommendation objects are extracted from the second sampling pool as negatively correlated objects corresponding to the sample object.
[0239] Optionally, the device further comprises a third sampling module, which is used to:
[0240] Removing candidate recommendation objects with target semantic attributes from the full sampling pool composed of candidate recommendation objects to obtain a second sampling pool; using candidate recommendation objects with the target semantic attributes to form a third sampling pool; the target semantic attributes are the semantic attributes possessed by each of the sample objects;
[0241] For each of the sample objects, a first preset number of candidate recommendation objects are extracted from the second sampling pool as negatively related objects corresponding to the sample object; a second preset number of candidate recommendation objects whose semantic attribute overlap with the sample object is lower than a preset overlap threshold are extracted from the third sampling pool as negatively related objects corresponding to the sample object.
[0242] Optionally, the data processing module 803 is specifically used for:
[0243] Calculating a first correlation between the prediction modeling feature and the embedded feature of the label recommendation object; when the sample object is the last sample object in the sequence, the label recommendation object is pre-labeled, and when the sample object is not the last sample object in the sequence, the label recommendation object is a subsequent sample object adjacent to the sample object in the sequence;
[0244] Calculating a second correlation between the predictive modeling feature and the embedded feature of each of the negatively correlated objects;
[0245] The comprehensive correlation data is determined based on the first correlation and each of the second correlations.
[0246] Optionally, the loss generating module 804 is specifically used for:
[0247] For each of the sample objects, determining a second loss value corresponding to the sample object according to the comprehensive correlation data corresponding to the sample object and the label correlation data corresponding to the sample object; the label correlation data is 1;
[0248] Generate the second loss function according to the second loss values corresponding to each of the multiple sample objects.
[0249] With respect to the recommendation method described above, the present application also provides a corresponding recommendation device so that the recommendation method can be applied and implemented in practice. Fig. 9 , Fig. 9 It is the same as above Figure 7 The structure diagram of the recommendation device 900 corresponding to the recommendation method shown in FIG. Fig. 9 As shown, the recommendation device 900 includes:
[0250] The sequence acquisition module 901 is used to acquire a target identification sequence; the target identification sequence includes identifications of multiple behavior objects, and each identification is arranged in the order in which the target user triggers the reference behavior on the multiple behavior objects;
[0251] A feature modeling module 902 is used to model a target feature sequence according to the target identification sequence through a target sequence model; the target sequence model is obtained by training using the model training method in the above method embodiment;
[0252] A feature extraction module 903 is used to extract target representative features from the target feature sequence;
[0253] The recommendation module 904 is used to select at least one target recommendation object from each candidate recommendation object based on the target representative feature; the distance between the embedded feature of the target recommendation object and the target representative feature meets the preset distance proximity condition, and the target recommendation object is the object recommended to the target user.
[0254] The embodiment of the present application also provides a computer device, which is used to execute the model training method or recommendation method provided by the embodiment of the present application. It can specifically be a terminal device or a server. The terminal device and server provided by the embodiment of the present application will be introduced from the perspective of hardware entity below.
[0255] See also Fig.10 , Fig.10 Schematic diagram of the structure of the terminal device provided in the embodiment of the present application. Fig.10 For the sake of convenience, only the parts related to the embodiments of the present application are shown. For specific technical details not disclosed, please refer to the method part of the embodiments of the present application. The terminal device can be, but is not limited to, a mobile phone, a computer, an intelligent voice interaction device, a smart home appliance, a vehicle terminal, an aircraft, etc. Take the terminal device as a computer as an example:
[0256] Fig.10 FIG. 1 is a block diagram showing a partial structure of a computer related to a terminal provided in an embodiment of the present application. Fig.10The computer includes: a radio frequency (RF) circuit 1010, a memory 1020, an input unit 1030 (including a touch panel 1031 and other input devices 1032), a display unit 1040 (including a display panel 1041), a sensor 1050, an audio circuit 1060 (which can be connected to a speaker 1061 and a microphone 1062), a wireless fidelity (WiFi) module 1070, a processor 1080, and a power supply 1090. Those skilled in the art can understand that Fig.10 The computer structure shown in the figure does not constitute a limitation of the computer, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.
[0257] The memory 1020 can be used to store software programs and modules. The processor 1080 executes various functional applications and data processing of the computer by running the software programs and modules stored in the memory 1020. The memory 1020 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the computer (such as audio data, a phone book, etc.), etc. In addition, the memory 1020 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0258] The processor 1080 is the control center of the computer. It uses various interfaces and lines to connect various parts of the entire computer. It executes various functions of the computer and processes data by running or executing software programs and / or modules stored in the memory 1020 and calling data stored in the memory 1020. Optionally, the processor 1080 may include one or more processing units; preferably, the processor 1080 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 1080.
[0259] In an embodiment of the present application, the processor 1080 is also used to execute the steps of any implementation method of the model training method or recommendation method provided in the embodiment of the present application.
[0260] See also Fig.11 , Fig.11A schematic diagram of the structure of a server 1100 provided for an embodiment of the present application. The server 1100 may have relatively large differences due to different configurations or performances, and may include one or more central processing units (CPU) 1122 (for example, one or more processors) and memory 1132, and one or more storage media 1130 (for example, one or more mass storage devices) storing application programs 1142 or data 1144. Among them, the memory 1132 and the storage medium 1130 may be short-term storage or permanent storage. The program stored in the storage medium 1130 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in the server. Furthermore, the central processing unit 1122 may be configured to communicate with the storage medium 1130 to execute a series of instruction operations in the storage medium 1130 on the server 1100.
[0261] The server 1100 may also include one or more power supplies 1126, one or more wired or wireless network interfaces 1150, one or more input and output interfaces 1158, and / or one or more operating systems, such as Windows Server 2003. TM , Mac OS X TM , Unix TM , Linux TM , FreeBSD TM etc.
[0262] The steps performed by the server in the above embodiment can be based on the Fig.11 The server structure shown. Among them, CPU 1122 can also be used to execute the steps of any implementation method of the model training method or recommendation method provided in the embodiments of the present application.
[0263] An embodiment of the present application also provides a computer-readable storage medium for storing a computer program, which is used to execute any implementation of a model training method or a recommendation method described in the aforementioned embodiments.
[0264] The present application also provides a computer program product, which includes a computer program stored in a computer-readable storage medium. The processor of the computer device reads the computer program from the computer-readable storage medium, and the processor executes the computer program, so that the computer device executes any one of the implementations of a model training method or a recommendation method described in the above embodiments.
[0265] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0266] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0267] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0268] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0269] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc., various media that can store computer programs.
[0270] It should be understood that in this application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0271] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A model training method, characterized in that: The method comprises: Acquire a training identification sequence; the training identification sequence includes identifications of a plurality of sample objects, and the identifications are arranged in the order in which the sample users trigger reference behaviors on the plurality of sample objects; the sample objects include at least one of commodities, videos, audios, texts and news; the reference behaviors include at least one of browsing, purchasing, collecting, adding to a shopping cart, liking and commenting; By using a sequence model to be trained, a prediction feature sequence is obtained according to the training identification sequence modeling; the prediction feature sequence includes prediction modeling features corresponding to each of the plurality of sample objects; the sequence model is a language model or a large language model in the field of natural language processing; For each of the sample objects, determine the predicted recommended object category corresponding to the sample object according to the predicted modeling features corresponding to the sample object; calculate a first correlation between the predicted modeling features corresponding to the sample object and the embedded features of the label recommended object corresponding to the sample object; calculate a second correlation between the predicted modeling features and the embedded features of each negatively correlated object corresponding to the sample object; determine the comprehensive correlation data corresponding to the sample object according to the first correlation and each of the second correlations; Generate a first loss function according to the predicted recommended object categories corresponding to each of the multiple sample objects; generate a second loss function according to the comprehensive correlation data corresponding to each of the multiple sample objects; Based on the first loss function and the second loss function, the sequence model is trained to obtain a target sequence model; the target sequence model is used for feature modeling in the recommendation task.
2. The method according to claim 1, characterized in that The method of obtaining a prediction feature sequence by modeling the sequence model to be trained according to the training identification sequence includes: Determining an embedded feature sequence according to the training identification sequence through an embedding layer in the sequence model; the embedded feature sequence includes the embedded features of each of the plurality of sample objects arranged in the order; The predicted feature sequence is obtained by modeling according to the embedded feature sequence through the feature modeling layer in the sequence model; The method further comprises: Based on the first loss function and the second loss function, the embedding features of the sample object are trained.
3. The method according to claim 2, characterized in that The embedding features of the sample object are trained based on the initial embedding features of the sample object; the initial embedding features of the sample object are determined in the following manner: Obtaining the associated image and associated text corresponding to the sample object; The initial embedding features corresponding to the sample object are extracted based on the associated image and the associated text through a multimodal feature extraction model.
4. The method according to claim 1, characterized in that The determining, according to the prediction modeling features corresponding to the sample object, the predicted recommended object category corresponding to the sample object comprises: According to the prediction modeling features corresponding to the sample object, determining, from a plurality of object categories, an object category to which the predicted recommended object corresponding to the sample object belongs, as the predicted recommended object category; Among them, the multiple object categories are obtained in advance based on clustering of each candidate recommendation object, or are determined based on the classification directory to which each candidate recommendation object belongs; the sample object belongs to the candidate recommendation object; the predicted recommendation object corresponding to the sample object is a candidate recommendation object predicted based on the predictive modeling features and is of interest to the sample user after the sample object.
5. The method according to claim 4, characterized in that The step of determining, according to the prediction modeling features corresponding to the sample object, the object category to which the predicted recommended object corresponding to the sample object belongs from a plurality of object categories as the predicted recommended object category, includes: Determining the prediction probabilities corresponding to each of the plurality of object categories according to the prediction modeling features corresponding to the sample objects through a linear transformation structure; The object category with the largest corresponding prediction probability is determined as the predicted recommended object category.
6. The method according to claim 4, characterized in that The step of determining, according to the prediction modeling features corresponding to the sample object, the object category to which the predicted recommended object corresponding to the sample object belongs from a plurality of object categories as the predicted recommended object category, includes: For each of the object categories, calculating the correlation between the prediction modeling features corresponding to the sample object and the embedded features of the object category as the prediction probability corresponding to the object category; Determine the object category with the largest corresponding prediction probability as the predicted recommended object category; The method further comprises: Based on the first loss function and the second loss function, embedding features of each of the multiple object categories are trained.
7. The method according to any one of claims 1 or 4 to 6, characterized in that: The generating a first loss function according to the predicted recommended object categories corresponding to each of the plurality of sample objects comprises: For each of the sample objects, a first loss value corresponding to the sample object is determined according to the predicted recommended object category corresponding to the sample object and the label recommended object category corresponding to the sample object; when the sample object is the last sample object in the sequence, the label recommended object category is pre-labeled; when the sample object is not the last sample object in the sequence, the label recommended object category is the object category to which the next sample object adjacent to the sample object in the sequence belongs; The first loss function is generated according to the first loss values corresponding to each of the multiple sample objects.
8. The method according to claim 1, characterized in that The negatively correlated object corresponding to the sample object is determined in the following manner: Removing the plurality of sample objects from the full sampling pool consisting of the candidate recommendation objects to obtain a first sampling pool; For each of the sample objects, a preset number of candidate recommendation objects are extracted from the first sampling pool as negatively correlated objects corresponding to the sample object.
9. The method according to claim 1, characterized in that: The negatively correlated object corresponding to the sample object is determined in the following manner: Removing candidate recommendation objects with target semantic attributes from the full sampling pool consisting of candidate recommendation objects to obtain a second sampling pool; the target semantic attribute is a semantic attribute possessed by each of the sample objects; For each of the sample objects, a preset number of candidate recommendation objects are extracted from the second sampling pool as negatively correlated objects corresponding to the sample object.
10. The method according to claim 1, characterized in that The negatively correlated object corresponding to the sample object is determined in the following manner: Removing candidate recommendation objects with target semantic attributes from the full sampling pool composed of candidate recommendation objects to obtain a second sampling pool; using candidate recommendation objects with the target semantic attributes to form a third sampling pool; the target semantic attributes are the semantic attributes possessed by each of the sample objects; For each of the sample objects, a first preset number of candidate recommendation objects are extracted from the second sampling pool as negatively related objects corresponding to the sample object; a second preset number of candidate recommendation objects whose semantic attribute overlap with the sample object is lower than a preset overlap threshold are extracted from the third sampling pool as negatively related objects corresponding to the sample object.
11. The method according to any one of claims 1 or 8 to 10, characterized in that: When the sample object is the last sample object in the sequence, the label recommendation object is pre-labeled; When the sample object is not the last sample object in the sequence, the tag recommendation object is the next sample object adjacent to the sample object in the sequence.
12. The method according to claim 11, characterized in that The generating a second loss function according to the comprehensive correlation data corresponding to each of the plurality of sample objects comprises: For each of the sample objects, determining a second loss value corresponding to the sample object according to the comprehensive correlation data corresponding to the sample object and the label correlation data corresponding to the sample object; the label correlation data is 1; Generate the second loss function according to the second loss values corresponding to each of the multiple sample objects.
13. A recommendation method, characterized in that: The method comprises: Acquire a target identification sequence; the target identification sequence includes identifications of multiple behavior objects, and each identification is arranged in the order in which the target user triggers reference behaviors on the multiple behavior objects; A target sequence model is used to model a target feature sequence according to the target identification sequence; the target sequence model is obtained by training the model training method according to any one of claims 1 to 12; Extracting target representative features from the target feature sequence; Based on the target representative feature, at least one target recommendation object is selected from each candidate recommendation object; the distance between the embedded feature of the target recommendation object and the target representative feature meets a preset distance proximity condition, and the target recommendation object is the object recommended to the target user.
14. A model training device, characterized in that: The device comprises: A sequence acquisition module is used to acquire a training identification sequence; the training identification sequence includes identifications of multiple sample objects, and each identification is arranged in the order in which the sample user triggers reference behaviors on the multiple sample objects; the sample objects include at least one of commodities, videos, audios, texts and news; the reference behaviors include at least one of browsing, purchasing, collecting, adding to shopping cart, liking and commenting; A feature modeling module, used to obtain a prediction feature sequence by modeling the training identification sequence through a sequence model to be trained; the prediction feature sequence includes prediction modeling features corresponding to each of the multiple sample objects; the sequence model is a language model or a large language model in the field of natural language processing; A data processing module is used to determine, for each of the sample objects, the predicted recommended object category corresponding to the sample object according to the predicted modeling features corresponding to the sample object; calculate a first correlation between the predicted modeling features corresponding to the sample object and the embedded features of the label recommended object corresponding to the sample object; calculate a second correlation between the predicted modeling features and the embedded features of each negatively correlated object corresponding to the sample object; and determine the comprehensive correlation data corresponding to the sample object according to the first correlation and each of the second correlations; A loss generation module, configured to generate a first loss function according to the predicted recommended object categories corresponding to each of the plurality of sample objects; and generate a second loss function according to the comprehensive correlation data corresponding to each of the plurality of sample objects; A training module is used to train the sequence model based on the first loss function and the second loss function to obtain a target sequence model; the target sequence model is used to perform feature modeling in the recommendation task.
15. A recommendation device, characterized in that: The device comprises: A sequence acquisition module, used to acquire a target identification sequence; the target identification sequence includes identifications of multiple behavior objects, and each identification is arranged in the order in which the target user triggers reference behaviors on the multiple behavior objects; A feature modeling module, used to model a target feature sequence according to the target identification sequence through a target sequence model; the target sequence model is trained by the model training method according to any one of claims 1 to 12; A feature extraction module, used to extract target representative features from the target feature sequence; A recommendation module is used to select at least one target recommendation object from each candidate recommendation object based on the target representative feature; the distance between the embedded feature of the target recommendation object and the target representative feature meets a preset distance proximity condition, and the target recommendation object is an object recommended to the target user.
16. A computer device, characterized in that: The device includes a processor and a memory; The memory is used to store computer programs; The processor is used to execute the model training method described in any one of claims 1 to 12, or the recommendation method described in claim 13 according to the computer program.
17. A computer-readable storage medium, characterized in that: The computer-readable storage medium is used to store a computer program, and when the computer program is executed by a computer device, it implements the model training method described in any one of claims 1 to 12, or the recommendation method described in claim 13.
18. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, it implements the model training method described in any one of claims 1 to 12, or the recommendation method described in claim 13.
Citation Information
Patent Citations
Object feature representation method and device, equipment and medium
CN117216567A
Model training and data recommendation method and device, equipment, medium and program product
CN118035567A