Model training method, recommendation method and related equipment
By feature encoding and training the model on object data and interactive data, the problem that the recommendation method in the prior art cannot flexibly adapt to the personalized needs of users, and the recommendation effect of efficiently matching user needs is achieved.
Patent Information
- Application Number
- CN202411932601.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-24
- Publication Date
- 2025-03-25
AI Technical Summary
Recommendation methods in the prior art usually rely on a fixed recommendation list, resulting in low matching efficiency between user needs and recommended content and cannot flexibly adapt to users' personalized needs.
The model uses the model to feature codes the object data and interaction data in the sample dataset, and builds a loss function based on the first description data, and trains the model to learn object features and user interaction features, thereby improving the recommended matching efficiency.
It quickly understands user needs and generates corresponding recommendation objects, improves the matching efficiency between user needs and recommended objects, and enhances the reliability and accuracy of recommendation results.
Smart Images

Figure CN119691283A_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 equipment. Background Art
[0002] With the development of smart terminal technology, more and more types of applications are installed in smart terminal devices such as smartphones and personal computers, including shopping, news, video, and interactive applications. With the development of Internet big data analysis technology, application developers pay more and more attention to the personalized needs of users, and often recommend content that users are interested in through applications. However, the recommendation methods in related technologies usually rely on fixed recommendation lists, which have low matching efficiency between user needs and recommended content, and cannot flexibly adapt to the personalized needs of users, thus affecting the user experience. Summary of the invention
[0003] In view of the above, it is necessary to provide a recommendation method and related devices to solve the problem that the above recommendation methods usually rely on a fixed recommendation list, have low efficiency in matching user needs and recommended content, and cannot flexibly adapt to the personalized needs of users.
[0004] In a first aspect, an embodiment of the present application provides a model training method, the method comprising: using a model to perform feature encoding on object data in a sample data set to obtain a first encoding feature, and to perform feature encoding on interaction data in the sample data set to obtain a second encoding feature; obtaining first description data based on the interaction data; determining a first loss value of the model based on the first description data and a preset first loss function; determining a second loss value of the model based on the first encoding feature, the second encoding feature, the first description data and a preset second loss function; and training the model according to the first loss value and the second loss value.
[0005] In a second aspect, an embodiment of the present application provides a recommendation method, which includes: receiving a recommendation request from a user, wherein the recommendation request is used to obtain an object required by the user; using a recommendation model to obtain a target object corresponding to the recommendation request and a recommendation reason text corresponding to the target object, wherein the recommendation model is obtained by executing the above-mentioned model training method; and displaying the target object and the recommendation reason text to the user.
[0006] In a third aspect, an embodiment of the present application provides an electronic device, comprising a memory and a processor: wherein the memory is used to store program instructions; the processor is used to read and execute the program instructions stored in the memory, and when the program instructions are executed by the processor, the electronic device implements the above-mentioned model training method, or implements the above-mentioned recommendation method.
[0007] In a fourth aspect, an embodiment of the present application provides a computer storage medium, wherein the computer storage medium stores program instructions. When the program instructions are executed on an electronic device, the electronic device implements the above-mentioned model training method or the above-mentioned recommendation method.
[0008] The model training method and recommendation method provided in the embodiments of the present application perform feature encoding on the object data and interaction data in the sample data set through the model to obtain a first encoding feature and a second encoding feature; obtain first description data based on the interaction data, and then construct a first loss function based on the first encoding feature and the first description data, and construct a second loss function based on the first encoding feature, the second encoding feature, and the first description data; finally, combine the first loss value output by the first loss function and the second loss value output by the second loss function to train the model accordingly. Since object data (object data of the recommended object) and interaction data (interaction data between the user and the recommended object), as well as the first description data (the reason why the recommended object is recommended) are used when training the model, the model can learn the feature information of the object itself and the interaction feature information between the object and the user during the model training process, thereby utilizing the model's cross-domain capability and language understanding capability to quickly understand user needs and generate corresponding recommended objects, thereby improving the matching efficiency between user needs and recommended objects. Furthermore, the model can also learn the reasons for recommending the object to the user in combination with the first description information, thereby utilizing the model's text generation capability to quickly generate recommended content that meets the user's interests while further generating recommendation reason text, thereby improving the reliability and accuracy of the recommendation results. BRIEF DESCRIPTION OF THE DRAWINGS
[0009] Figure 1 It is a flowchart of a model training method provided in one embodiment of the present application.
[0010] Figure 2 This is a flowchart of feature encoding of object data provided by an embodiment of the present application.
[0011] Figure 3 This is a flowchart of feature encoding of interactive data provided by an embodiment of the present application.
[0012] Figure 4 This is a flowchart of determining the first loss value of a recommendation model provided by an embodiment of the present application.
[0013] Figure 5 This is a flowchart of determining the second loss value of a recommendation model provided by an embodiment of the present application.
[0014] Figure 6 It is a flowchart of a recommended method provided in one embodiment of the present application.
[0015] Figure 7 It is a flowchart of a method for obtaining a target object by using a recommendation model provided by an embodiment of the present application.
[0016] Figure 8 It is a structural diagram of a model training device provided in one embodiment of the present application.
[0017] Fig. 9 It is a structural diagram of a recommended device provided in one embodiment of the present application.
[0018] Fig.10 It is a structural diagram of an electronic device provided in one embodiment of the present application. DETAILED DESCRIPTION
[0019] The terms "first" and "second" involved in the embodiments of the present application are only used for descriptive purposes and should not be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more features. In the description of the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a concrete way.
[0020] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those generally understood by technicians in the technical field in this application. The terms used in the specification of this application are only for the purpose of describing specific embodiments and are not intended to limit this application. It should be understood that, unless otherwise specified in this application, " / " means or. For example, A / B can represent A or B. "And / or" in this application is only a description of the association relationship of associated objects, indicating that three relationships can exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. "At least one" refers to one or more. "Multiple" refers to two or more than two. For example, at least one of a, b or c can represent: a, b, c, a and b, a and c, b and c, a, b and c. In the absence of conflict, the following embodiments and the features in the embodiments can be combined with each other.
[0021] With the development of smart terminal technology, more and more types of applications are installed in smart terminal devices such as smartphones and personal computers, including shopping, news, video, and interactive applications. In addition, with the development of Internet big data analysis technology, application developers pay more and more attention to the personalized needs of users, and often recommend content of interest to users through applications. For example, shopping applications can recommend products of interest to users, news applications can recommend news of interest to users, video applications can recommend videos of interest to users, and interactive applications can recommend interactive information of interest to users.
[0022] However, the recommendation methods in related technologies cannot provide more recommended content that matches user interests, and usually rely on fixed recommendation lists. The matching efficiency between user needs and recommended content is low, and it cannot flexibly adapt to the personalized needs of users. The recommended content can often only cover popular items, and the recommendation ability for long-tail items that are not frequently in demand and become larger is weak, which cannot meet the diverse needs of users. In addition, it can only recommend content in a single or fewer fields, and cannot effectively utilize information in different fields. The accuracy and personalization of recommendations are low, which affects the user experience.
[0023] In order to solve the problem that recommendation methods usually rely on fixed recommendation lists, have low matching efficiency between user needs and recommended content, and cannot flexibly adapt to users' personalized needs, the embodiments of the present application provide a model training method and a recommendation method, which uses a model to perform feature encoding on object data and interaction data in a sample data set to obtain a first encoding feature and a second encoding feature; obtain first description data based on the interaction data, and then construct a first loss function based on the first encoding feature and the first description data, and construct a second loss function with the first encoding feature, the second encoding feature, and the first description data; finally, combine the first loss value output by the first loss function and the second loss value output by the second loss function to train the model accordingly. Since object data (object data of the recommended object) and interaction data (interaction data between the user and the recommended object), as well as the first description data (the reason why the recommended object is recommended) are used when training the model, the model can learn the feature information of the object itself and the interaction feature information between the object and the user during the model training process, thereby utilizing the model's cross-domain capability and language understanding capability to quickly understand user needs and generate corresponding recommended objects, thereby improving the matching efficiency between user needs and recommended objects. Furthermore, the model can also learn the reasons for recommending the object to the user in combination with the first description information, thereby utilizing the model's text generation capability to quickly generate recommended content that meets the user's interests while further generating recommendation reason text, thereby improving the reliability and accuracy of the recommendation results.
[0024] See also Figure 1 FIG. 1 is a flow chart of a model training method provided in an embodiment of the present application. The method is applied in an electronic device, and the model training method includes: S102, using the model to perform feature encoding on the object data in the sample data set to obtain a first encoding feature, and to perform feature encoding on the interaction data in the sample data set to obtain a second encoding feature.
[0025] In one embodiment of the present application, a sample data set can be used to train a model to obtain a recommendation model. In order to train a recommendation model that can understand user preferences and generate accurate recommendation reasons, the training scheme of the model can be divided into two pre-training tasks. For example, the first pre-training task can focus on improving the model's ability to understand language texts, so that it can generate accurate and user-friendly recommendation reason description texts based on the user's interaction data with the object and the given task prompts. The second pre-training task focuses on improving the model's object recommendation capabilities, that is, the model needs to be able to accurately judge the user's preference for each object and recommend the object that best suits the user's preferences.
[0026] In one embodiment of the present application, in order to achieve the above two pre-training tasks, a sample data set may be constructed and a model may be trained based on the sample data set. The sample data set may include but is not limited to object data, interaction data and first description data.
[0027] In one embodiment of the present application, the objects in the object data represent objects that the user has interacted with historically. For example, the object data includes, but is not limited to, object identification and attribute data. Among them, the object identification represents the unique identification of the object, for example, the object ID (for example, product ID-789012, movie ID-765432). The attribute data includes multiple types of data, wherein each type of data corresponds to the basic data of an object. In one example, if the object is a product, the multiple types of data included in the object attribute data may be: product name, product brand, product production place, product price, etc. In another example, if the object is a movie, the multiple types of data included in the attribute data may be: movie name (for example, "Kung Fu"), movie type (for example, comedy), movie actor (for example, Zhang San), movie director (for example, Li Si), etc.
[0028] In one embodiment of the present application, the interaction data includes interaction data between a user and an object. For example, the interaction data includes but is not limited to: user data, object identifier of the object, interaction behavior category of the interaction behavior and interaction time, etc. In another example, the interaction data may also include object data of the object, such as object name and object attribute data.
[0029] In one embodiment of the present application, user data includes but is not limited to user identification and user device information. For example, the user identification may include the user's name, account name, user ID, etc. User device information may include device identification, for example, the device identification is a device name, device ID, etc.
[0030] In one embodiment of the present application, the interactive behavior category includes categories of various interactive behaviors of the user on the recommended object, for example, including but not limited to click, browse, collect, purchase, score, etc. The interactive time indicates the date and time when the interactive behavior between the user and the object occurs.
[0031] In one example, the interaction data may be represented as: user ID-123456, product ID-789012, interaction behavior category-click, interaction time-2024-04-15-10:00:00. In another example, the interaction data may be represented as: user ID-123456, movie ID-765439, movie name-"Kung Fu", movie type-comedy, interaction behavior category-browse, interaction time-2024-04-15-11:00:00. In yet another example, the interaction data may be represented as: user ID-123456, movie ID-765432, movie name-"The Mermaid", movie type-comedy, interaction behavior category-browse, interaction time-2024-04-16-12:00:00. In yet another example, the interaction data may be represented as: user ID-123456, movie ID-765489, movie name-"The King of Comedy", movie type-comedy, interaction behavior category-browsing, interaction time-2024-04-17-16:00:00.
[0032] In one embodiment of the present application, the interaction data may also include a historical interaction sequence. The object data with which each user has interacted historically may be aggregated based on the interaction data to obtain a historical interaction sequence of each user sorted by interaction time. In one example, the historical interaction sequence includes a user ID and a sequence of object IDs with which the user ID has interacted. For example, the historical interaction sequence is represented as: {user ID - 123456, sequence of object IDs - [789012, 345678, 901234, 765439, 765432, 765489, ...]}.
[0033] In another embodiment of the present application, the object data of each type of object that each user has interacted with historically can be aggregated based on the interaction data to obtain a historical interaction sequence of each user sorted by interaction time. In one example, the object data of the movie category can be aggregated, and the obtained historical interaction sequence includes the user ID and the sequence of object IDs of the movie category that the user ID has interacted with. For example, the historical interaction sequence is represented as: {user ID-123456, sequence of object IDs-[765439, 765432, 765489, ...]}.
[0034] By collecting data on various interactive behaviors between users and objects, as well as the time when these behaviors occur and the historical interaction sequences, we can more accurately capture user behavior patterns and preference changes, thereby providing a basis for training models and ensuring that the model can learn user preferences, object features, and the relationships between them.
[0035] In one embodiment of the present application, during the process of a user using an electronic device, data such as interaction data and object data are collected based on the user's operation on at least one application program, so as to construct a sample data set based on the object data and interaction data. For example, if the manufacturer of the electronic device performs the recommendation task, the electronic device may collect interaction data and object data based on the user's operation on all applications. If the application developer performs the recommendation task, interaction data and object data may be collected based on the user's operation on the application program corresponding to the application developer.
[0036] In one embodiment of the present application, in order to enable the model to understand the data in the sample data set in subsequent recommendation tasks and the like, feature encoding can be performed on the original data (e.g., object data, interaction data) in the sample data set based on the model to convert the original data into a format that the model can understand, i.e., encoding features. For example, the original data can be directly converted into numerical data.
[0037] In one embodiment of the present application, different types of data (such as different types of object attribute data) can also be normalized during the feature encoding process, so that the normalized different types of data are comparable. In another embodiment of the present application, feature encoding can be regarded as a special form of feature extraction, that is, the process of converting raw data into numerically encoded feature data can also be regarded as a feature extraction process.
[0038] In one embodiment of the present application, the model may include a feature encoding module, and the network structure of the feature encoding module may include but is not limited to a combination of one or more of the following network structures: Fully Connected Neural Networks (FCNNs), Convolutional Neural Networks (CNNs), Recurrent Neural Networks (RNNs), Self-Attention Mechanisms, Embedding Layers. The feature encoding module can be used to feature encode input data to obtain corresponding encoding features. For example, feature encoding is performed on object data to obtain a first encoding feature, or feature encoding is performed on interaction data to obtain a second encoding feature.
[0039] In one embodiment of the present application, feature encoding is performed on the object data to obtain a first encoding feature, which can be referred to in Figure 2 The flowchart of feature encoding of object data is shown in FIG. Feature encoding of interaction data to obtain the second encoding feature can be referred to in Figure 3 The flowchart for feature encoding of interaction data is shown.
[0040] S103: Obtain first description data based on the interaction data.
[0041] In one embodiment of the present application, first description data may be obtained based on the interaction data, and the first description data includes the reason why the object is recommended. Specifically, the interaction data may be concatenated to obtain second description data, and the second description data may be used to indicate the user's preference for different objects. The first description data is obtained based on the second description data and the preset task prompt information.
[0042] In one embodiment of the present application, when text splicing is performed on the interaction data, the interaction data can be processed to remove object identifiers, and multiple data except for the object identifiers in the object data in the interaction data can be spliced into long sentences to obtain second description data, which represents the interaction history description text between the user and the object.
[0043] In one example, based on the historical interaction sequence {user ID-123456, object ID sequence-[765439, 765432, 765489, ...]} in the interaction data of user ID-123456, object names can be used instead of object identifiers to implement object identification processing, and multiple data can be concatenated into long sentences to obtain second description data. For example: user 123456 has browsed the following comedy movies in the past month: "The King of Comedy", "Kung Fu", and "The Mermaid", among which "Kung Fu" has the longest browsing time.
[0044] In one embodiment of the present application, the interaction data and the preset task prompt information can be input into the large language model, and the first description data can be output through the large language model. The task prompt information represents the text corresponding to the recommendation request, which is used to prompt the large language model to output the object according to the recommendation request and generate the recommendation reason. Among them, the recommendation request can be generated based on the user's input operation, that is, the user can enter the recommendation request in the application, such as entering "recommended snacks", "recommended comedy movies", etc., and the electronic device can also automatically generate a recommendation request when the user accesses the application. For example, when the user accesses snack-related content in the application, a snack recommendation request is automatically generated. When the user accesses comedy movie-related content in the application, a comedy movie recommendation request is automatically generated. In other embodiments of the present application, the recommendation request may also be a prompt information for the recommendation task.
[0045] In one embodiment of the present application, the large language model may be ChatGLM (interactive general language model) or other types of upstream large models, and the interaction data and preset task prompt information are input into the interactive general language model, and the first description data is output through the interactive general language model. The first description data includes text data used to describe the reason why the object is recommended. For example, the first description data is "Based on your browsing history in the past month, "Kung Fu" is recommended to you. You have previously browsed "The King of Comedy", "Kung Fu" and "The Mermaid", among which "Kung Fu" has the longest browsing time, so this funny comedy movie is recommended to you."
[0046] Based on the in-depth analysis and understanding of the interaction data, the large language model can use its powerful text generation capabilities to generate accurate first description data, thus providing a basis for training the language understanding capabilities of the recommendation model.
[0047] S104: Determine a first loss value of the model based on the first description data and a preset first loss function.
[0048] In one embodiment of the present application, the model may include a language understanding module, and the first description data and the first loss function may be used to train the language understanding ability of the language understanding module. The smaller the first loss value, the stronger the language understanding ability of the language understanding module, so that more accurate recommendation reasons can be output. The language understanding module may refer to the detailed description of the subsequent embodiments.
[0049] In one embodiment of the present application, the training task of the language understanding module of the model can be implemented based on the masked language model technology, and the semantic feature and context feature parsing ability of the language understanding module can be improved, so that the model can accurately predict the masked text.
[0050] In one example, the text in the first description data can be randomly masked to extract its semantic and context features, and the masked text can be predicted using these features. The difference between the first text and the model's predicted text can be calculated using a first loss function (such as cross entropy loss, mean square error loss, etc.) to determine a first loss value, thereby evaluating the model's performance in understanding and predicting the masked text. Figure 4 Flowchart for determining the first loss value of the model is shown.
[0051] S105, determining a second loss value of the model based on the first coding feature, the second coding feature, the first description data and a preset second loss function.
[0052] In one embodiment of the present application, the model may include an object recommendation module, and the first coding feature, the second coding feature, the first description data, and the preset second loss function may be used to train the object recommendation capability of the object recommendation module, and the smaller the second loss value, the more the object output by the object recommendation module conforms to the user preference. The object recommendation module may refer to the detailed description of the subsequent embodiments.
[0053] In one example, feature extraction can be performed on the first description data to obtain its semantic features and context features; based on the semantic features and context features, a first vector corresponding to the first coding feature and a second vector corresponding to the second coding feature are extracted respectively; a second loss function (such as Euclidean distance, cosine similarity, etc.) is used to calculate the distance between the first vector and the second vector, and a second loss value is determined based on the distance. The size of the second loss value reflects the degree of match between the object recommended by the object recommendation module and the user's preference. The smaller the second loss value, the more accurate the recommendation of the object recommendation module. For details, please refer to Figure 5 A flowchart for determining a second loss value for a model is shown.
[0054] S106, training the model according to the first loss value and the second loss value.
[0055] In one embodiment of the present application, if the first loss value is greater than a preset first loss threshold, the parameters of the language understanding module (e.g., connection weights between neurons, etc.) may be adjusted to optimize the language understanding module. If the second loss value is greater than a preset second loss threshold, the parameters of the object recommendation module may be adjusted to optimize the object recommendation module.
[0056] In one example, the third loss value may also be determined based on the first loss value and the second loss value, for example, the weighted sum of the first loss value and the second loss value is used as the third loss value. The calculation formula of the third loss value may be exemplarily expressed as: , in, represents the first loss value, represents the second loss function, α is the weight coefficient, which is used to balance the importance of the language understanding module and the object recommendation module. The weight coefficient can be adjusted dynamically according to actual needs. For example, if the user has a high click-through rate on the recommended results recently, the weight of the object recommendation module can be increased by reducing α, thereby paying more attention to the optimization of the object recommendation module.
[0057] In one example, if the third loss value indicates that the model meets the preset requirements, a recommended model is obtained. If the third loss value indicates that the model does not meet the preset requirements, the parameters of the model are adjusted until the third loss value of the adjusted model meets the preset requirements, and a recommended model is obtained. The preset requirement may be less than or equal to a preset loss threshold, and the first loss threshold, the second loss threshold, and the preset loss threshold may be set according to actual needs, and this application does not limit this.
[0058] The model training method provided in the embodiment of the present application performs feature encoding on the object data and interaction data in the sample data set through the model to obtain the first encoding feature and the second encoding feature; obtain the first description data based on the interaction data, then construct the first loss function based on the first encoding feature and the first description data, and construct the second loss function based on the first encoding feature, the second encoding feature, and the first description data, and finally combine the first loss value output by the first loss function and the second loss value output by the second loss function to train the model accordingly. Since the object data (the object data of the recommended object) and the interaction data (the interaction data between the user and the recommended object) and the first description data (the reason why the recommended object is recommended) are used when training the model, the model can learn the feature information of the object itself and the interaction feature information between the object and the user in the process of training the model. The trained model can have language understanding ability, so that it can quickly understand user needs and generate corresponding recommendation content, improve the matching efficiency of user needs and recommendation results, and improve the recommendation ability of long-tail items, as well as information interaction and knowledge transfer between different fields, and improve the cross-domain ability and accuracy of recommendation results.
[0059] See also Figure 2 As shown, it is a flowchart of feature encoding of object data provided by an embodiment of the present application.
[0060] S201, performing text concatenation on the object data to obtain third description data.
[0061] In one embodiment of the present application, when text splicing is performed on the object data, the object data may be de-identified, and multiple attribute data except the object identifier in the object data may be spliced into a long sentence to obtain the third description data. In this way, the third description data is the attribute data corresponding to the object data. For example, if the attribute data of a certain commodity includes commodity name X, brand Y, and price Z, the attribute data such as commodity name X, brand Y, and price Z may be spliced into a long sentence: the price of commodity X of brand Y is Z, and the long sentence may be used as the corresponding third description data.
[0062] S202, setting weights for the attribute data according to the types of the attribute data, to obtain attribute data with weights.
[0063] In one embodiment of the present application, a corresponding weight is set for the attribute data according to the importance of the type of attribute data. The electronic device pre-stores the correspondence between the importance of the type of attribute data and the weight, and the corresponding weight can be set for the attribute data according to the correspondence. In one example, if the object is a commodity, the weight of the commodity name in the attribute data is greater than the weight of the commodity brand, and the weight of the commodity brand is greater than the weight of the commodity price. For example, the importance of the commodity name is high, and the weight is 0.6; the importance of the commodity brand is medium, and the weight is 0.3; the importance of the commodity price is low, and the weight is 0.1.
[0064] Obtaining attribute data with weights according to the category of attribute data can indicate the importance of the corresponding attribute data, thereby reflecting the user's preference for the object to a certain extent. For example, the name of a product may reflect the user's preference better than the brand or price, so it is given a higher weight.
[0065] S203: Based on the model, feature encoding is performed on the third description data according to the attribute data with weights to obtain a first encoding feature.
[0066] In one embodiment of the present application, the third description data may be feature encoded according to the attribute data with weights, for example, the third description data may be modeled using word embedding or an attention mechanism to obtain a first encoding feature.
[0067] In one example, the third description data may be preprocessed, including but not limited to word segmentation, lowercase, stop word removal, stem extraction, and word form restoration. A vocabulary is constructed for the preprocessed third description data, and each word in the third description data is mapped to a unique index. The vocabulary is input into a feature encoding module of the model, and the first encoding feature is output through the feature encoding module.
[0068] For example, the vocabulary is represented as a continuous vector in a high-dimensional space through the embedding layer of the feature encoding module, and the features of the continuous vector are extracted and processed to output the first encoding feature. According to the weight of the attribute data with weights, the extracted features are weighted and fused (for example, spliced) to obtain the first encoding feature. For attribute data with higher weights, the corresponding features will occupy a larger proportion in the final first encoding feature. For example, the first encoding feature corresponding to product ID789012 is [0.8, -0.3, 0.6, …], where, from the numerical value point of view, the attribute data corresponding to 0.8 is the product name, and its corresponding weight is the highest, so the numerical value is the largest.
[0069] By performing feature encoding on object data, including text splicing to generate third description data, setting weights for features of the third description data according to the importance of attribute types, and finally integrating these weighted features to form first coding features, the first coding features can more effectively reflect the user's preference for the object and the importance of the object's attributes.
[0070] See also Figure 3 As shown, it is a flowchart of feature encoding of interactive data provided by an embodiment of the present application.
[0071] S301, setting weights for corresponding objects according to the interactive behavior categories to obtain weighted objects.
[0072] In one embodiment of the present application, a corresponding weight is set for each object according to the interactive behavior category. The electronic device pre-stores the correspondence between the interactive behavior category and the weight, and the weight can be set for the corresponding object according to the correspondence. In one example, the weight of the collection behavior is greater than the weight of the click behavior, and the weight of the click behavior is greater than the weight of the browsing behavior. For example, the weight of the collection behavior is 0.6, the weight of the click behavior is 0.3, and the weight of the browsing behavior is 0.1.
[0073] In one example, if an object in the second description data corresponds to an interactive behavior category, the weight of the object is set to the weight value corresponding to the interactive behavior category. For example, if the user performs a browsing operation on the object, the weight value of the object is set to 0.1. If an object in the user interaction history data corresponds to multiple interactive behavior categories, the weight value of the object is set to the sum of the weights corresponding to the multiple interactive behavior categories. For example, if the user performs a browsing operation and a click operation on the object, the weight of the object is set to 0.4.
[0074] The weight is set based on the degree to which the interactive behavior reflects the user's preference. For example, the collection behavior may better reflect the user's real interest than the click or browse behavior, so it will be given a higher weight. By assigning weights to the objects in the second description data, the object weights obtained can reflect the user's interest in different objects.
[0075] S302, according to the object with weight and the interaction time in the interaction data, use the model to perform feature encoding on the second description data to obtain a second encoding feature.
[0076] In one embodiment of the present application, the second description data may be feature encoded according to an object with a weight, for example, the second description data may be modeled using sequence embedding (Sequence Embedding) or a recurrent neural network (RNN) to obtain a second encoded feature of the second description data.
[0077] In one example, the second description data may be preprocessed, including but not limited to word segmentation, lowercase, stop word removal, stem extraction, and word form restoration. A vocabulary is constructed for the preprocessed second description data, and each word in the text is mapped to a unique index. The vocabulary is input into the feature encoding module of the recommendation model, and the second encoding feature is output through the feature encoding module. For example, the vocabulary is represented as a continuous vector in a high-dimensional space through the embedding layer of the feature encoding module, and the features of the continuous vector are extracted and processed to output the second encoding feature.
[0078] Among them, according to the weight of the object, the extracted features are weighted and fused (for example, concatenated) to obtain the second coded feature. For objects with higher weights, the corresponding features will occupy a larger proportion in the final second coded feature. In addition, the features corresponding to the objects can be sorted according to the order of interaction time, and the extracted features can be weighted and fused based on this sequence, so as to retain the order information of the objects in the interaction data, which can help capture the changes in user preferences for objects over time.
[0079] For example, the second encoding feature corresponding to user ID 123456 is [0.2, 0.5, -0.1, …], where, from the numerical value point of view, the interactive behavior category of the object corresponding to 0.5 is collection, and its corresponding weight is the highest, so the numerical value is the largest.
[0080] By analyzing the categories of user interaction behaviors and setting corresponding weights, and combining the recommendation model to perform feature encoding on the second description data, we can accurately reflect the user's preference for different objects, while retaining the sequential information of the interaction data and effectively capturing the changes in user preferences over time, thereby generating a second encoding feature with rich information.
[0081] See also Figure 4 As shown, it is a flowchart of determining the first loss value of the recommendation model provided by an embodiment of the present application.
[0082] S401, randomly masking text in first description data based on preset mask data, and using the text masked by the mask data as first text.
[0083] In one embodiment of the present application, the type of mask data and the mask ratio can be determined. For example, the type of mask data can include but is not limited to preset marks, random words, zero vectors, etc. The mask ratio indicates how much proportion of text should be masked, such as 10%. The text in the first description data is randomly masked according to the type of mask data and the mask ratio. For example, words or characters of the mask ratio are randomly selected from the text of the first description data and replaced with the mask data. The first text (i.e., the text before the mask) shielded by the mask data is recorded as the first text for subsequent comparison with the second text.
[0084] S402: Extract features from the first description data to obtain semantic features and context features of the first description data.
[0085] In one embodiment of the present application, the model may include a language understanding module, and the network structure of the language understanding module may include but is not limited to an encoder structure (such as a Transformer encoder, a BERT model, etc.). The first description data is input into the language processing module, and the encoder of the language processing module extracts features from the first description data to capture semantic features and context features in the first description data.
[0086] Among them, semantic features usually involve keywords, phrases or topics in the first description data, while contextual features focus on the positions and relationships of these words or topics in the first description data. The semantic features and contextual features of the first description data extracted from the encoder can be used for subsequent text prediction tasks.
[0087] S403: predicting the first text according to the semantic features and the context features to obtain a second text.
[0088] In one embodiment of the present application, the model can use semantic features and context features extracted from the first description data to predict the masked first text to obtain the second text.
[0089] S404: Determine the difference between the first text and the second text based on the first loss function, and determine a first loss value according to the difference.
[0090] In one embodiment of the present application, a first loss function (such as cross entropy loss, mean square error loss, etc.) is used to calculate the difference between the first text and the second text. For example, the first text and the second text are concatenated into a comparable format (such as probability distribution or vector representation), and the distance or difference between them is calculated as a first loss value. The first loss value reflects the performance of the model's language understanding module in predicting the masked text. If the difference is large, the first loss value will also be large, indicating that the model's prediction performance is poor; conversely, if the difference is small, the first loss value will also be small, indicating that the model's prediction performance is good.
[0091] In another embodiment of the present application, the language understanding module may include a masked language model or a transformer model (Transformer). For example, the language understanding module includes an input layer, an intermediate layer, a head, and an output layer. The input layer is used to receive the input first description data; the intermediate layer includes a plurality of encoders for processing the first description data and extracting the semantic features and context features of the first description data. The head is used to predict the probability distribution of the masked text (masked token, such as the first text) in the first description data. For example, the head is a fully connected layer, which can map the output of the intermediate layer to the probability distribution of the masked text. The head sends the mapped probability distribution of the masked text to the output layer, and outputs the probability distribution of the masked text through the output layer to obtain the predicted probability distribution of the masked text.
[0092] In one example, the first loss function corresponding to the language understanding module may include a cross entropy loss function L1, which may be exemplarily expressed as: ; Among them, p(x i ) is the probability distribution of the actual masked text of the ith sample, and q(xi) is the probability distribution of the predicted masked text of the ith sample.
[0093] Through the above embodiment, the first text in the first description data can be randomly masked to extract its semantic and contextual features, and the masked text can be predicted using these features to obtain the second text, and the difference between the first text and the second text can be calculated by the first loss function to determine the first loss value, thereby evaluating the performance of the model in understanding and predicting the masked text. The smaller the first loss value, the stronger the model's language understanding ability of the first description data, and the more accurate the first description data of the recommended object can be generated according to the text language logic of the first description data in the subsequent use process.
[0094] See also Figure 5 As shown, it is a flowchart of determining the second loss value of the recommendation model provided by an embodiment of the present application.
[0095] S501, extracting features from first description data to obtain semantic features and context features of the first description data.
[0096] In one embodiment of the present application, the model may include an object recommendation module, and the object recommendation module may share an encoder with the language understanding module, thereby also realizing feature extraction of the first description data to obtain semantic features and context features of the first description data.
[0097] In one example, the object recommendation module receives the first description data and uses an encoder to capture semantic features and context features in the first description data. By extracting semantic features and context features, the object recommendation module can learn a more general representation method, rather than being limited to a specific data set or field, thereby improving the generalization ability of the object recommendation module when applied to new fields or data sets.
[0098] S502, based on the semantic features and context features of the first description data, obtaining a first vector corresponding to the first coding feature and obtaining a second vector corresponding to the second coding feature.
[0099] In one embodiment of the present application, compared to the numerical data of the original data (e.g., object data, interaction data) represented by the encoded features, the representation vector represents the representation of the numerical data in the vector space, which can be used to capture the intrinsic characteristics and patterns of the original data. Therefore, the representation vector contains abstract information or high-level features of the original data.
[0100] In one embodiment of the present application, the encoding features can be further transformed or extracted based on semantic features and context features to obtain a more expressive representation vector. In one example, the first encoding feature is further processed and extracted by a convolutional neural network or a recurrent neural network of the model to obtain a more discriminative first vector (or a first representation vector). The second encoding feature is further processed and extracted by a convolutional neural network or a recurrent neural network to obtain a more discriminative second vector (or a second representation vector).
[0101] The representation vector extracted based on semantic features and contextual features has higher flexibility and interpretability. It can reflect the degree of association between users and objects, and how this association is reflected through different feature dimensions, which helps to improve the accuracy of object recommendations.
[0102] S503: Determine a distance between the first vector and the second vector based on a second loss function, and determine a second loss value according to the distance.
[0103] In one embodiment of the present application, the second loss function can be defined based on the distance between the first vector and the second vector in the vector space (such as Euclidean distance, cosine similarity, etc.) or other measurement methods, so that the second loss function can be used to calculate the distance between the first vector and the second vector. The greater the distance between the first vector and the second vector, the greater the second loss value.
[0104] In one embodiment of the present application, the second loss function L2 may be a mean square error function, and the calculation formula is: ; ; .
[0105] Among them, MSE1 is the mean square error function corresponding to the second vector, x i is the i-th feature of the second predicted vector, x i P is the i-th feature of the actual second vector, MSE2 is the mean square error function corresponding to the first vector, and y i is the i-th feature of the first predicted vector, y i P is the actual i-th feature of the first vector, and n is the number of features in the second vector and the first vector.
[0106] In one embodiment of the present application, the training goal of the object recommendation module of the model is to minimize the distance between the first vector and the second vector, because this means that the recommended object is more likely to meet the user's preferences and needs.
[0107] In one example, the training data of the object recommendation module may include positive sample data and negative sample data, wherein the positive sample data may include first description data, second description data, second vector, and attribute data and first vector of the object that the user has interacted with. These positive sample data may be marked as interesting (e.g., label 1) because the user has interacted with the objects in these data. The negative sample data may include first description data, second description data, second vector, and attribute data and first vector of the object that has not been interacted with by the user. These negative sample data may be marked as uninteresting (e.g., label 0) because the user has not interacted with the objects in these data.
[0108] In one example, when training the object recommendation module of the model, it is required to enable it to output recommended objects based on the input second description data, and minimize the distance between the first vector and the second vector of the recommended object. The smaller the distance, the more the object recommended by the object recommendation module meets the user's preferences and needs.
[0109] In one example, multiple sets of positive and negative sample data can be used as inputs of the object recommendation module and processed by the object recommendation module. The object recommendation module outputs a first vector and compares it with a second vector, and calculates the distance between the output first vector and the second vector. According to the distance and label (e.g., 1 or 0), the parameters of the object recommendation module are adjusted to minimize the distance of the positive sample and maximize the distance of the negative sample. The above process is repeated until the model achieves satisfactory performance. In this way, through training with a large amount of positive and negative sample data, the object recommendation module can learn how to map the second description data and the first description data into the same vector space and accurately recommend objects that meet the user's preferences.
[0110] The above method introduces the training method of the recommendation model. Next, the application method of the recommendation model will be explained. Figure 6 FIG. 1 is a flowchart of a recommendation method provided in an embodiment of the present application. The method is applied in an electronic device, and the recommendation method includes: S601, receiving a recommendation request from a user.
[0111] In one embodiment of the present application, the recommendation request may be text data containing the user's recommendation request, and the recommendation request is used to obtain the object required by the user. The application may provide the user with an interactive interface, and receive the user's recommendation request in the interactive interface. For example, the user may input data in the interactive interface by text input, voice input, etc., and the application receives the user's recommendation request and converts it into text format data. In one example, the user's recommendation request may be "find me a funny movie".
[0112] S602: Obtain a target object corresponding to the recommendation request and a recommendation reason text corresponding to the target object by using a recommendation model.
[0113] In one embodiment of the present application, the language understanding module of the recommendation model has a high language understanding ability, and the encoder of the language understanding module can be used to extract the semantic features and context features of the recommendation request (refer to step S402). After extracting the semantic features and context features, the language understanding module will use these features to determine the user's needs. This process is essentially the recognition of user intent. The language understanding module will analyze the keywords, phrases and context information in the recommendation request to determine the category of the object required by the user and other requirements. For example, the user's recommendation request is "Find me a funny movie", and the object required by the user can be identified as "comedy movie".
[0114] In one embodiment of the present application, reference Figure 7 As shown, using the recommendation model to obtain the target object corresponding to the recommendation request requirement data may include the following process.
[0115] S701, using a recommendation model to perform feature encoding on object data of each object corresponding to a recommendation request in a preset object library, to obtain a third encoding feature corresponding to each object.
[0116] In one embodiment of the present application, the preset object library may contain object data of all objects, which may include objects with which the user has interacted, and may also include objects with which the user has not interacted. The object data may include object data of any object in the object library, such as object name and attribute data. For details, please refer to the relevant description in step S101.
[0117] In one embodiment of the present application, an object of the category indicated by the recommendation request can be selected from a preset object library as the object corresponding to the recommendation request, and the third coding feature of the selected object can be obtained using the recommendation model. For example, if the category indicated by the recommendation request is comedy movies, the third coding feature of the object of the comedy movie category can be obtained using the recommendation model. For the specific implementation, reference can be made to the specific implementation of obtaining the first coding feature shown in S102, S201-S203, which will not be repeated here.
[0118] S702: Perform feature encoding on the user's interaction data using the recommendation model to obtain a fourth encoding feature corresponding to the user.
[0119] In one embodiment of the present application, the user's interaction data refers to the interaction data of the object with which the user has interacted, such as user data, object identifiers of the object with which the user has interacted, interaction behavior categories of the interaction behaviors, and interaction time, etc. In another example, the user's interaction data may also include object data of the object with which the user has interacted, such as object names and object attribute data. For details, please refer to the relevant description in step S102.
[0120] In one embodiment of the present application, the specific implementation method of obtaining the fourth coding feature corresponding to the user can refer to the specific implementation method of obtaining the second coding feature shown in S102 and S301-S302, which will not be repeated here.
[0121] In one embodiment of the present application, the recommendation model can be integrated into an application in the user's electronic device. The application can obtain the user's interaction data and the object data of the object while complying with privacy requirements, thereby integrating the user's interaction data and the object data of the object into the recommendation model.
[0122] S703: Select a target object from a preset object library according to the third coding feature and the fourth coding feature.
[0123] In one embodiment of the present application, a third vector corresponding to the third coding feature and a fourth vector corresponding to the fourth coding feature may be obtained, the distance between the third vector and the fourth vector is determined, and objects corresponding to a preset number of third vectors with the smallest distance are selected as target objects.
[0124] In one embodiment of the present application, the third encoding feature may be further processed and extracted by a convolutional neural network or a recurrent neural network to obtain a third vector. The fourth encoding feature may be further processed and extracted by a convolutional neural network or a recurrent neural network of the recommendation model to obtain a fourth vector. The method for obtaining the first vector and the second vector in S502 may be referred to and will not be described in detail.
[0125] In one embodiment of the present application, the similarity and matching degree between the user and the object may be determined based on the distance between the third vector and the fourth vector in the vector space (such as Euclidean distance, cosine similarity, etc.). The smaller the distance, the higher the similarity and matching degree between the user and the object.
[0126] In one embodiment of the present application, an object corresponding to a preset number of third vectors with the smallest distance may be selected as a target object, and the target object may be recommended to the user.
[0127] In one embodiment of the present application, a language understanding module can be used to output a recommendation reason text of the target object, which is used to describe the reason why the target object is recommended, referring to the first description text. After being trained based on the first description text, the language understanding module learns how to generate accurate object recommendation reasons, and can therefore be used to generate a recommendation reason text for the target object.
[0128] S603: Display the target object and the recommendation reason text to the user.
[0129] In one embodiment of the present application, the target object and the recommendation reason text may be displayed on the interactive interface of the application program, thereby presenting the object recommendation result to the user.
[0130] The recommendation method provided in the embodiment of the present application, after receiving the recommendation request from the user, uses the recommendation model to obtain the target object corresponding to the recommendation request and the recommendation reason text corresponding to the target object, and then displays the target object and the recommendation reason text to the user. Figure 1 The model training method in the embodiment obtains that the recommendation model has language understanding ability, can quickly understand user needs and generate corresponding recommended content, and generation ability, can further generate reasons and reasons for recommending recommended content to users. Therefore, according to the user's recommendation request, reliable and accurate recommendation objects can be recommended to users, thereby improving user experience.
[0131] See also Figure 8 , which is a structural diagram of a model training device provided by an embodiment of the present application. The model training device 8 may include a plurality of functional modules composed of computer program segments. The computer programs of the various program segments in the model training device 8 may be stored in a memory of an electronic device and executed by at least one processor to perform (see Figure 1 Description) model's training function.
[0132] In one embodiment of the present application, the model training device 8 can be divided into multiple functional modules according to the functions it performs. The functional modules may include: feature encoding module 81, data acquisition module 82, loss calculation module 83, and training module 84. The module referred to in this application refers to a series of computer program segments that can be executed by at least one processor and can complete fixed functions, which are stored in the memory. In one embodiment of the present application, the model training device 8 can be used to implement the following Figure 1 The model training method shown.
[0133] The feature encoding module 81 is used to use the model to perform feature encoding on the object data in the sample data set to obtain a first encoding feature, and to perform feature encoding on the interaction data in the sample data set to obtain a second encoding feature.
[0134] The data acquisition module 82 is used to obtain first description data based on the interaction data.
[0135] The loss calculation module 83 is used to determine the first loss value of the model based on the first description data and a preset first loss function.
[0136] The loss calculation module 83 is also used to determine the second loss value of the model based on the first coding feature, the second coding feature, the first description data and the preset second loss function.
[0137] The training module 84 is used to train the model according to the first loss value and the second loss value.
[0138] See also Fig. 9 , which is a structural diagram of a recommendation device provided by an embodiment of the present application. The recommendation device 9 may include a plurality of functional modules composed of computer program segments. The computer programs of the various program segments in the recommendation device 9 may be stored in a memory of an electronic device and executed by at least one processor to perform (see Figure 6 Description) Recommended features.
[0139] In one embodiment of the present application, the recommendation device 9 can be divided into multiple functional modules according to the functions it performs. The functional modules may include: a receiving module 91, a recommendation module 92, and a display module 93. The module referred to in the present application refers to a series of computer program segments that can be executed by at least one processor and can perform fixed functions, which are stored in a memory. In one embodiment of the present application, the recommendation device 9 can be used to implement the following Figure 6 The recommended method is shown.
[0140] The receiving module 91 is used to receive a recommendation request from a user, wherein the recommendation request is used to obtain an object required by the user.
[0141] The recommendation module 92 is used to obtain the target object corresponding to the recommendation request and the recommendation reason text corresponding to the target object by using the recommendation model.
[0142] The display module 93 is used to display the target object and the recommendation reason text to the user.
[0143] See also Fig.10 , which is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device 1 may be a server, for example, the electronic device 1 may be a central server, an edge server, or a local server of a local data center. The electronic device 1 may include a communication module 11, a memory 12, a processor 13, an input / output (I / O) interface 14, and a bus 15. The processor 13 is coupled to the communication interface 11, the memory 12, and the I / O interface 14 through the bus 15.
[0144] The communication module 11 may include a wired communication module and / or a wireless communication module. The wired communication module may provide one or more wired communication solutions such as universal serial bus (USB), controller area network bus (CAN, Controller Area Network). The wireless communication module may provide one or more wireless communication solutions such as wireless fidelity (wireless fidelity, Wi-Fi), bluetooth (bluetooth, BT), mobile communication network, frequency modulation (frequency modulation, FM), near field communication technology (near field communication, NFC), infrared technology (infrared, IR), etc.
[0145] The memory 12 may include one or more random access memories (RAM) and one or more non-volatile memories (NVM). The random access memory can be directly read and written by the processor 13, and can be used to store executable programs (such as machine instructions) of the operating system or other running programs, and can also be used to store user and application data. The random access memory may include static random-access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), etc.
[0146] The non-volatile memory may also store executable programs and user and application data, etc., and may be loaded into the random access memory in advance for direct reading and writing by the processor 13. The non-volatile memory may include a disk storage device and a flash memory.
[0147] The memory 12 is used to store one or more computer programs. The one or more computer programs are configured to be executed by the processor 13. The one or more computer programs include multiple instructions. When the multiple instructions are executed by the processor 13, the model training method and the recommendation method executed on the electronic device 1 can be implemented.
[0148] In other embodiments, the electronic device 1 further includes an external memory interface for connecting to an external memory to expand the storage capacity of the electronic device 1 .
[0149] The processor 13 may include one or more processing units, for example, the processor 13 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0150] The processor 13 provides computing and control capabilities. For example, the processor 13 is used to execute computer programs stored in the memory 12 .
[0151] The I / O interface 14 is used to provide a channel for user input or output. For example, the I / O interface 14 can be used to connect various input and output devices, such as a mouse, keyboard, touch device, display screen, etc., so that the user can enter information or visualize information.
[0152] The bus 15 is at least used to provide a channel for mutual communication among the communication module 11 , the memory 12 , the processor 13 , and the I / O interface 14 in the electronic device 1 .
[0153] It is understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 1. In other embodiments of the present application, the electronic device 1 may include more or fewer components than shown in the figure, or combine certain components, or separate certain components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0154] An embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. The computer program includes program instructions. The method implemented when the program instructions are executed can refer to the methods in the above-mentioned embodiments of the present application.
[0155] The computer-readable storage medium may be an internal memory of the electronic device described in the above embodiment, such as a hard disk or memory of the electronic device. The computer-readable storage medium may also be an external storage device of the electronic device, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device.
[0156] In some embodiments, the computer-readable storage medium may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function, etc.; the data storage area may store data created according to the use of the electronic device, etc.
[0157] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0158] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0159] In the embodiments provided in the present application, it should be understood that the disclosed devices / terminal equipment and methods can be implemented in other ways. For example, the device / terminal equipment embodiments described above are only schematic. For example, the division of the modules or 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 through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0160] 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.
[0161] The embodiments described above 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, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such 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, and should all be included in the protection scope of the present application.
Claims
1. A model training method, characterized in that: The method comprises: Using the model to perform feature encoding on the object data in the sample data set to obtain a first encoding feature, and to perform feature encoding on the interaction data in the sample data set to obtain a second encoding feature; Obtaining first description data based on the interaction data; Determining a first loss value of the model based on the first description data and a preset first loss function; Determining a second loss value of the model based on the first encoding feature, the second encoding feature, the first description data, and a preset second loss function; The model is trained according to the first loss value and the second loss value.
2. The model training method according to claim 1, characterized in that: The acquiring the first description data based on the interaction data includes: Performing text concatenation on the interaction data to obtain second description data; wherein the second description data is used to indicate the user's preference for different objects; The first description data is obtained according to the second description data and preset task prompt information, where the first description data includes a reason why the object is recommended.
3. The model training method according to claim 1, characterized in that: The method of using the model to perform feature encoding on the object data in the sample data set to obtain the first encoding feature includes: Performing text concatenation on the object data to obtain third description data, wherein the third description data includes attribute data corresponding to the object data; Setting weights for the attribute data according to the types of the attribute data to obtain attribute data with weights; Based on the model, feature encoding is performed on the third description data according to the attribute data with weights to obtain the first encoding feature.
4. The model training method according to claim 2, characterized in that: The interaction data includes interaction behavior categories and interaction time, and the feature encoding of the interaction data in the sample data set to obtain a second encoding feature includes: Setting weights for corresponding objects according to the interaction behavior categories to obtain objects with weights; The second description data is feature-encoded using the model according to the weighted object and the interaction time to obtain the second encoding feature.
5. The model training method according to claim 1, characterized in that: The determining the first loss value of the model based on the first description data and a preset first loss function includes: Randomly masking the text in the first description data based on preset mask data, and using the text masked by the mask data as the first text; Performing feature extraction on the first description data to obtain semantic features and context features of the first description data; Predicting the first text according to the semantic features and the context features to obtain a second text; The difference between the first text and the second text is determined based on the first loss function, and the first loss value is determined according to the difference.
6. The model training method according to claim 1, characterized in that: The determining the second loss value of the model based on the first coding feature, the second coding feature, the first description data and a preset second loss function includes: Performing feature extraction on the first description data to obtain semantic features and context features of the first description data; Based on the semantic features and context features of the first description data, obtaining a first vector corresponding to the first coding feature, and obtaining a second vector corresponding to the second coding feature; The distance between the first vector and the second vector is determined based on the second loss function, and the second loss value is determined according to the distance.
7. A recommendation method, characterized in that: The method comprises: receiving a recommendation request from a user, wherein the recommendation request is used to obtain an object required by the user; Using a recommendation model to obtain a target object corresponding to the recommendation request and a recommendation reason text corresponding to the target object, wherein the recommendation model is obtained by executing the model training method according to any one of claims 1 to 6; The target object and the recommendation reason text are displayed to the user.
8. The recommendation method according to claim 7, characterized in that: The obtaining the target object corresponding to the recommendation request by using the recommendation model comprises: Using the recommendation model, feature encoding is performed on the object data of each object corresponding to the recommendation request in the preset object library to obtain a third encoding feature corresponding to each object; Using the recommendation model to perform feature encoding on the user's interaction data to obtain a fourth encoding feature corresponding to the user; The target object is selected from the preset object library according to the third encoding feature and the fourth encoding feature.
9. The recommendation method according to claim 8, characterized in that: The selecting the target object from the preset object library according to the third encoding feature and the fourth encoding feature includes: Obtaining a third vector corresponding to the third coding feature and a fourth vector corresponding to the fourth coding feature; The distance between the third vector and the fourth vector is determined, and objects corresponding to a preset number of third vectors with the smallest distance are selected as the target objects.
10. An electronic device, characterized in that: The electronic device comprises a memory and a processor: Wherein, the memory is used to store program instructions; The processor is used to read and execute the program instructions stored in the memory. When the program instructions are executed by the processor, the electronic device implements the model training method as described in any one of claims 1 to 6, or implements the recommendation method as described in any one of claims 7 to 9.