Feature processing method and apparatus, computing device, and medium
By acquiring offline models and feature sets, it is possible to directly determine whether online features meet the threshold, thus solving the problem of poor real-time performance in model training and achieving more efficient feature admission and real-time training of online models.
Patent Information
- Application Number
- CN202111473771.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-30
- Publication Date
- 2025-11-21
- Estimated Expiration
- 2041-11-30
AI Technical Summary
The real-time performance of model training in existing technologies is poor because real-time samples need to be accumulated for a period of time before feature admission can be performed, resulting in a long delay.
By acquiring offline models and offline features, it is possible to directly determine whether online features meet the occurrence threshold, and directly use the features that meet the threshold as online training features, without accumulating sample data, thus achieving feature admission.
It improves the real-time performance of model training, enabling it to better reflect changes in online data and enhance the prediction accuracy of online models.
Smart Images

Figure CN114139727B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] Embodiments of the present disclosure relate to the technical field of machine learning, and more particularly, embodiments of the present disclosure relate to a feature processing method and device, a computing device and a medium. BACKGROUND
[0002] This section is intended to provide background information to facilitate a better understanding of embodiments of the disclosure recited in the claims. The description herein does not constitute admission of prior art.
[0003] With the continuous development of machine learning, online learning as a solution that can improve the real-time performance of model training is increasingly widely used in the model training process. In the process of training the model through online learning, the features with low occurrence times entering the model training will result in poor training effect of the model, and therefore, the features with low occurrence times are often filtered out through a feature access mechanism to ensure the training effect of the model.
[0004] In related technologies, when implementing the feature access mechanism, the online real-time samples are first accumulated for a period of time, and then the occurrence times of each feature in the samples are counted, so that the sum of the historical occurrence times of the features and the occurrence times of the features in the period of time is compared with a set number threshold, and the model is trained based on the features with the sum value greater than the set number threshold.
[0005] In the above implementation process, the real-time samples need to be accumulated for a period of time before the feature access can be performed, which results in a certain delay in the model training of the features, and further results in poor real-time performance of the model training. SUMMARY
[0006] In view of the poor real-time performance of the model training in related technologies, embodiments of the present disclosure provide at least a feature processing method, device, computing device and medium.
[0007] In a first aspect of the embodiments of the present disclosure, a feature processing method is provided, which includes:
[0008] obtaining a first offline model and at least one first offline feature used for training the first offline model;
[0009] obtaining online sample data corresponding to at least one first online feature;
[0010] in a case where the first online feature exists in the at least one first offline feature, determining the first online feature as an online training feature used for training the first offline model.
[0011] In an embodiment of the present disclosure, the method further includes:
[0012] obtaining a number of occurrences of the first online feature in the case that the first online feature is not present in the at least one first offline feature;
[0013] determining the first online feature as an online training feature for training the first offline model in the case that the number of occurrences of the first online feature is greater than a set number threshold.
[0014] In an embodiment of the present disclosure, obtaining the number of occurrences of the first online feature in the case that the first online feature is not present in the at least one first offline feature comprises:
[0015] obtaining the number of occurrences of the first online feature based on the online features included in the first online feature set and the number of occurrences of each online feature in the case that the first online feature is not present in the at least one first offline feature.
[0016] In an embodiment of the present disclosure, before obtaining the number of occurrences of the first online feature in the case that the first online feature is not present in the at least one first offline feature, the method further comprises any one of the following:
[0017] adding the first online feature to the first online feature set and determining the number of occurrences of the first online feature as 1 in the case that the first online feature is not present in the at least one first offline feature and the first online feature set does not include the first online feature;
[0018] updating the number of occurrences of the first online feature in the first online feature set in the case that the first online feature is not present in the at least one first offline feature and the first online feature set includes the first online feature.
[0019] In an embodiment of the present disclosure, obtaining the first offline model and the at least one first offline feature for training the first offline model comprises:
[0020] obtaining the first offline model and a first offline feature set corresponding to the first offline model, the first offline feature set including the at least one first offline feature for training the first offline model.
[0021] In an embodiment of the present disclosure, determining the first online feature as an online training feature for training the first offline model comprises:
[0022] adding the first online feature to a first feature queue, the first feature queue being used to store online training features for training the first offline model.
[0023] In an embodiment of the present disclosure, the first offline model corresponds to a first start timestamp, the first start timestamp being used to indicate a time for starting to obtain online training features from the first feature queue.
[0024] After determining the first online feature as the online training feature for training the first offline model, the method further includes:
[0025] From the first feature queue, obtaining the online training feature whose corresponding time is after the first start timestamp;
[0026] Training the first offline model based on the online training feature whose corresponding time is after the first start timestamp, to obtain the first online model.
[0027] In an embodiment of the present disclosure, the method further includes:
[0028] Obtaining a second offline model and at least one second offline feature for training the second offline model, the second offline model corresponding to a second end timestamp, the second end timestamp being used to indicate the data end time of the offline sample data used for training the second offline model, the second offline model being associated with a second feature queue, the second offline model corresponding to a second start timestamp, the second start timestamp being used to indicate the time for starting to obtain the online training feature from the second feature queue;
[0029] Training the second offline model based on the online training feature whose corresponding time is between the second end timestamp and the second start timestamp, to obtain the second online model to be trained.
[0030] In an embodiment of the present disclosure, after training the second offline model based on the online training feature whose corresponding time is between the second end timestamp and the second start timestamp, to obtain the second online model to be trained, the method further includes:
[0031] From the second feature queue, obtaining the online training feature whose corresponding time is after the second start timestamp;
[0032] Training the second online model to be trained based on the online training feature whose corresponding time is after the second start timestamp, to obtain the second online model.
[0033] In an embodiment of the present disclosure, different offline models correspond to different version information;
[0034] The method further includes:
[0035] In response to receiving the model obtaining instruction, obtaining the offline model indicated by the version information corresponding to the model obtaining instruction.
[0036] In a second aspect of the embodiments of the present disclosure, a feature processing apparatus is provided, and the apparatus includes:
[0037] obtaining a first offline model and at least one first offline feature used for training the first offline model;
[0038] The obtaining module is further configured to obtain online sample data, the online sample data corresponding to at least one first online feature;
[0039] The determining module is configured to, in a case where the at least one first offline feature includes the first online feature, determine the first online feature as an online training feature used for training the first offline model.
[0040] In an embodiment of the present disclosure, the obtaining module is further configured to, in a case where the at least one first offline feature does not include the first online feature, obtain a number of occurrences of the first online feature;
[0041] The determining module is further configured to, in a case where the number of occurrences of the first online feature is greater than a set number threshold, determine the first online feature as the online training feature used for training the first offline model.
[0042] In an embodiment of the present disclosure, the obtaining module, when obtaining the number of occurrences of the first online feature in the case where the at least one first offline feature does not include the first online feature, is configured to:
[0043] In the case where the at least one first offline feature does not include the first online feature, obtain the number of occurrences of the first online feature based on online features included in the first online feature set and the number of occurrences of each online feature.
[0044] In an embodiment of the present disclosure, the apparatus further includes:
[0045] The feature processing module is configured to, in a case where the at least one first offline feature does not include the first online feature and the first online feature set does not include the first online feature, add the first online feature to the first online feature set and determine the number of occurrences of the first online feature as 1.
[0046] The updating module is configured to, in a case where the at least one first offline feature does not include the first online feature and the first online feature set includes the first online feature, update the number of occurrences of the first online feature in the first online feature set.
[0047] In an embodiment of the present disclosure, the obtaining module, when obtaining the first offline model and the at least one first offline feature used for training the first offline model, is configured to:
[0048] Obtain the first offline model and a first offline feature set corresponding to the first offline model, the first offline feature set including the at least one first offline feature used for training the first offline model.
[0049] In one embodiment of the present disclosure, the determining module, when determining the first online feature as an online training feature for training the first offline model, is configured to:
[0050] add the first online feature to a first feature queue, the first feature queue being configured to store online training features for training the first offline model.
[0051] In one embodiment of the present disclosure, the first offline model corresponds to a first start timestamp, the first start timestamp being configured to indicate a time for starting to obtain online training features from the first feature queue;
[0052] The obtaining module is further configured to obtain, from the first feature queue, online training features corresponding to times after the first start timestamp.
[0053] The apparatus further comprises:
[0054] The first training module is configured to train the first offline model based on the online training features corresponding to times after the first start timestamp, to obtain a first online model.
[0055] In one embodiment of the present disclosure, the obtaining module is further configured to obtain a second offline model and at least one second offline feature for training the second offline model, the second offline model corresponding to a second end timestamp, the second end timestamp being configured to indicate a data end time of offline sample data used for training the second offline model, the second offline model being associated with a second feature queue, the second offline model corresponding to a second start timestamp, the second start timestamp being configured to indicate a time for starting to obtain online training features from the second feature queue;
[0056] The apparatus further comprises:
[0057] The second training module is configured to train the second offline model based on online training features corresponding to times between the second end timestamp and the second start timestamp, to obtain a second online model to be trained.
[0058] In one embodiment of the present disclosure, the obtaining module is further configured to obtain, from the second feature queue, online training features corresponding to times after the second start timestamp.
[0059] The second training module is further configured to train the second online model to be trained based on the online training features corresponding to times after the second start timestamp, to obtain the second online model.
[0060] In one embodiment of the present disclosure, different offline models correspond to different version information.
[0061] The acquisition module is further configured to acquire, in response to receiving the model acquisition instruction, an offline model indicated by version information corresponding to the model acquisition instruction.
[0062] In a third aspect of the embodiments of the present disclosure, a computing device is provided, including a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the processor implements the operations performed by the above-mentioned feature processing method when executing the computer program.
[0063] In a fourth aspect of the embodiments of the present disclosure, a computer-readable storage medium is provided, and the computer-readable storage medium stores a program, and the program is executed by a processor to perform the operations performed by the above-mentioned feature processing method.
[0064] According to a fifth aspect of the embodiments of the present disclosure, a computer program product is provided, including a computer program, and the program is executed by a processor to implement the operations performed by the above-mentioned feature processing method.
[0065] According to the feature processing method, device, computing device, and medium of the embodiments of the present disclosure, the first offline model and the at least one first offline feature used for training the first offline model are acquired, so that after the online sample data corresponding to the at least one first online feature is acquired, it is determined whether the first online feature is allowed to enter the training process of the model based on the at least one first offline feature, and then in the case that the at least one first offline feature includes the first online feature, the first online feature is determined as an online training feature used for training the first offline model. Through the above process, the feature admission can be realized without accumulating the online sample data, so as to ensure the real-time performance of the model training. BRIEF DESCRIPTION OF DRAWINGS
[0066] The above and other objects, features and advantages of the present disclosure will become more apparent from the following detailed description read in conjunction with the accompanying drawings, in which:
[0067] Figure 1 is a flowchart of a feature processing method according to an example embodiment of the present disclosure;
[0068] Figure 2 is a principle schematic diagram of a feature processing method according to an example embodiment of the present disclosure;
[0069] Figure 3 is a structural schematic diagram of a feature processing device according to an example embodiment of the present disclosure;
[0070] Figure 4is a schematic diagram of a computer-readable storage medium according to an example embodiment of the present disclosure;
[0071] Figure 5 is a structural schematic diagram of a computing device according to an example embodiment of the present disclosure;
[0072] In the drawings, identical or corresponding reference signs indicate identical or corresponding parts. DETAILED DESCRIPTION
[0073] The principles and spirits of the present disclosure will be described below with reference to several example embodiments. It should be understood that these embodiments are given only to enable those skilled in the art to better understand and implement the present disclosure, and in no way limit the scope of the present disclosure. On the contrary, these embodiments are provided to make the present disclosure more thorough and complete, and to fully convey the scope of the present disclosure to those skilled in the art.
[0074] Those skilled in the art know that the embodiments of the present disclosure can be implemented as a system, device, apparatus, method or computer program product. Therefore, the present disclosure can be embodied as a complete hardware, complete software (including firmware, resident software, microcode, etc.), or a combination of hardware and software.
[0075] According to the embodiments of the present disclosure, a feature processing method, device, computing device and medium are proposed.
[0076] In this document, it should be understood that any number of elements in the drawings is used for illustration only and not limitation, and any naming is only for distinction and does not have any limiting meaning.
[0077] The present disclosure provides a feature processing method for feature admission of features corresponding to online sample data, so as to train a model based on the admitted features. For example, an offline model obtained through offline training can be acquired, and then after the offline model is acquired, the online features to be used in the process of online learning are determined through the feature processing method provided by the present disclosure, and then the offline model is trained online based on the determined online features to obtain an online model, so as to realize online learning based on the offline model.
[0078] Wherein, the offline training is a process of training a model using all data generated in history, and the offline training needs to provide a complete training set at one time, and is trained in batch mode, and the weight is updated once after each batch is trained, so as to obtain a trained offline model.
[0079] After obtaining the offline model through offline training, new training data can be received, and the offline model is continuously trained based on the new training data, and the effective information learned by the offline model is not flushed out, thereby realizing incremental learning based on the offline model.
[0080] Online learning is a special case of incremental learning. Incremental learning can receive new training data in batches, thereby training the offline model in batches. Online learning can obtain one new online data, and use the online data as training data to train the model based on the online data, thereby improving the real-time performance of model training. Online learning can train the offline model based on online data in real time, and apply the online model obtained through online learning to online prediction.
[0081] Optionally, the offline model and the online model can be a recommendation model for recommending content items, such as a recommendation model for recommending videos, a recommendation model for recommending advertisements, a recommendation model for recommending news, a recommendation model for recommending goods, and the like. Alternatively, the offline model and the online model can also be other types of models, and the specific type of the model is not limited in the present disclosure.
[0082] Taking the offline model and the online model as a recommendation model for recommending content items as an example, the sample data used to train the offline model and the online model can include sample user information, at least one sample content item, and a target sample content item clicked by a user. When training the offline model or the online model, taking the training process of the offline model as an example, the sample user information and the at least one sample content item can be input into the offline model, and the offline model can output a predicted sample content item to be recommended, thereby training the offline model based on a loss function indicating the difference between the target sample content item and the predicted sample content item.
[0083] It should be noted that when the sample user information and the at least one sample content item are input into the offline model, the sample user information and the at least one sample content item can be converted into features that can better express the essence of the data through feature engineering, so that the offline model can perform model training based on the features corresponding to the sample user information and the features corresponding to the at least one sample content item.
[0084] Taking the sample user information as an example, the sample user information can include data corresponding to multiple features such as sample user age, sample user gender, sample user preference information (such as preferred content item type, for example, preference for technology product advertisements, preference for beauty product advertisements, and the like), and the like. The sample user age, the sample user gender, and the sample user preference information are features corresponding to the sample user information.
[0085] In the actual model training process, in order to ensure the effect of model training, before training the model based on the features, the features corresponding to the sample data are often subjected to feature access. As a mechanism for controlling whether a feature can enter the model, feature access can filter out features with low occurrence times to avoid low occurrence times of features entering model training, resulting in an untrusted model training result, and ensuring the training effect of the model. The feature processing method provided by the present disclosure can realize feature access in the online learning process.
[0086] The feature processing method provided by the present disclosure can be executed by a computing device, which can be a server, such as a server, multiple servers, a server cluster, a cloud computing platform, etc. The present disclosure does not limit the specific type of computing device.
[0087] The feature processing method according to the exemplary embodiments of the present disclosure will be described below in conjunction with the above application scenarios, with reference to Figure 1 It should be noted that the above application scenarios are only shown for the purpose of facilitating the understanding of the spirit and principles of the present disclosure, and the embodiments of the present disclosure are not limited in this respect. On the contrary, the embodiments of the present disclosure can be applied to any applicable scenario.
[0088] Referring to Figure 1 , Figure 1 is a flowchart of a feature processing method according to an exemplary embodiment of the present disclosure, which comprises:
[0089] Step 101, obtaining a first offline model and at least one first offline feature used for training the first offline model.
[0090] The first offline model can be a model trained based on offline sample data, and the first offline model can be used for content item recommendation, that is, the first offline model can be a first offline recommendation model. Alternatively, the first offline model can also be other types of models, which are not limited by the present disclosure.
[0091] The at least one first offline feature can be a feature corresponding to offline sample data used for training the first offline model. Taking the first offline model as a first offline recommendation model used for content item recommendation as an example, the offline sample data used for training the first offline model can include sample user information, and the sample user information can correspond to sample user age, sample user gender, sample user preference information, etc. multiple features, such as sample user age, sample user gender, sample user preference information, etc. multiple features are at least one first offline feature.
[0092] Further, for the first offline model for making content item recommendation, the offline data for training the first offline model can further include at least one content, which can correspond to a plurality of features such as a content item type, a keyword included in the content item, and the like, which are also the at least one first offline feature.
[0093] Optionally, in the offline training process, feature admission can be performed on the features corresponding to the plurality of offline sample data. For example, the occurrence times of each feature can be determined based on the features corresponding to the plurality of offline sample data, so that the features with occurrence times exceeding a set number threshold are taken as the at least one offline feature. The set number threshold can be any positive integer value, and the present disclosure does not limit the value of the set number threshold.
[0094] Taking the process of processing the features corresponding to the sample user information as an example, the features with occurrence times exceeding a set number threshold can be determined from a plurality of features such as sample user age, sample user gender, sample user preference information, and the like, so that the features with occurrence times exceeding the set number threshold are taken as the at least one offline feature for training the first offline model.
[0095] Step 102, obtaining online sample data, the online sample data corresponding to at least one first online feature.
[0096] In one possible implementation, after obtaining the first offline model, the first offline model can be applied to the online prediction process. Taking the first offline model as the first offline recommendation model for making content item recommendation as an example, after obtaining the first offline recommendation model, the first offline recommendation model can be applied to the online content item recommendation process, so that the first offline recommendation model is used to recommend content items for users.
[0097] After completing an online prediction process by using the first offline model, an online sample data is generated, so that the first offline model can be trained online based on the generated online sample data. The features corresponding to the online sample data can be introduced with reference to the introduction of the features corresponding to the offline sample data in step 101 above, and details are not described herein.
[0098] It should be noted that before training the first offline model based on the obtained online sample data, feature admission can be performed on the features corresponding to the online sample data by using step 103 described below.
[0099] Step 103, in a case where the first online feature exists in the at least one first offline feature, determining the first online feature as an online training feature for training the first offline model.
[0100] Through the step 103, the feature admission based on the online sample data is realized, and the first offline feature is the feature whose occurrence number is greater than the set number threshold, so that the occurrence number of the first online feature used for training the first offline model is also greater than the set number threshold, and the accuracy of the model training result is ensured, and the model training effect is improved.
[0101] The present disclosure obtains the first offline model and at least one first offline feature used for training the first offline model, so that after obtaining the online sample data corresponding to the at least one first online feature, it is determined whether the first online feature is allowed to enter the training process of the model based on the at least one first offline feature, and then in the case that the first online feature exists in the at least one first offline feature, the first online feature is determined as an online training feature used for training the first offline model. Through the above process, the feature admission can be realized without accumulating the online sample data, so that the real-time performance of the model training can be ensured, the model can better reflect the changes of the online data, and the prediction accuracy of the online model is improved.
[0102] After introducing the basic principles of the present disclosure, various non-limiting embodiments of the present disclosure will be specifically introduced below.
[0103] In some embodiments, the at least one first offline feature used for training the first offline model can be composed into a first offline feature set, so that the first offline feature set composed of the at least one offline feature is directly obtained, and the at least one first offline feature is obtained. For example, after completing the offline training of the first offline model, the first offline feature set can be generated based on the at least one first offline feature used for training the first offline model, and optionally, the first offline feature set can also be generated at other times, which is not limited by the present disclosure.
[0104] Based on the above embodiments, for the step 101, when the first offline model and the at least one first offline feature used for training the first offline model are obtained, the first offline model and the first offline feature set corresponding to the first offline model can be obtained, and the first offline feature set includes the at least one first offline feature used for training the first offline model.
[0105] In a possible implementation, the first offline feature set can adopt the form of a list to record the at least one first offline feature, that is, the at least one offline feature can be composed into a first offline feature word table (also referred to as a first offline word table). Optionally, the first offline feature set can also adopt other forms, which are not limited by the present disclosure.
[0106] It should be noted that, for the at least one first offline feature included in the first offline feature set, before the model is trained offline based on the at least one first offline feature, the at least one first offline feature is determined by feature admission on the features corresponding to the offline sample data, that is, the at least one first offline feature is an admitted feature, and thus each feature included in the first offline feature set is an admitted feature. Generally, feature admission is achieved based on the number of occurrences of the feature, and thus the number of occurrences of the at least one first offline feature included in the first offline feature set is greater than a set number threshold.
[0107] Based on the implementation of recording the at least one first offline feature through the first offline feature set in the above embodiments, after the online sample data is obtained through the above step 102, the at least one first online feature corresponding to the obtained online sample data can be subjected to feature admission one by one based on the first offline feature set.
[0108] In some embodiments, taking the process of admitting any first online feature as an example, whether the first online feature is included in the first offline feature set is judged, and whether the first online feature is determined as an online training feature for training the first offline model is determined according to the judgment result.
[0109] In a possible implementation, when the first online feature is included in the first offline feature set, that is, when the first online feature is included in the at least one first offline feature, the first online feature can be determined as an online training feature for training the first offline model.
[0110] In another possible implementation, when the first online feature is not included in the first offline feature set, that is, when the first online feature is not included in the at least one first offline feature, whether the first online feature is determined as an online training feature for training the first offline model can be determined based on the number of occurrences of the first online feature.
[0111] When the first online feature is not included in the at least one first offline feature, the number of occurrences of the first online feature is obtained, and when the number of occurrences of the first online feature is greater than a set number threshold, the first online feature is determined as an online training feature for training the first offline model. The number of occurrences of the first online feature can include the number of occurrences of the first online feature in the offline sample data used for training the first offline model and the number of occurrences of the first online feature in the online sample data used for training the first offline model. In addition, the number of occurrences of the first online feature can only include the number of occurrences of the first online feature in the online sample data used for training the first offline model, which is not limited in the present disclosure.
[0112] Optionally, the first offline recommendation model can be further associated with a first online feature set, which is used to record non-admission features corresponding to online sample data (i.e., features with occurrence times less than a set threshold) and occurrence times of each non-admission feature.
[0113] The first online feature set can be generated when the first non-admission feature is determined, i.e., after the first non-admission feature is determined, the first online feature set is generated, the determined non-admission feature is added to the first online feature set, the occurrence time of the non-admission feature in the online sample data used to train the first offline model is obtained, and then the obtained occurrence time is incremented by 1, so that the number obtained after incrementing by 1 is used as the occurrence time of the non-admission feature. In this case, the occurrence time of the first online feature can include the occurrence time of the first online feature in the offline sample data used to train the first offline model, and the occurrence time of the first online feature in the online sample data used to train the first offline model.
[0114] Optionally, the first online feature set can also be generated after the first offline model is obtained, i.e., after the first offline model is obtained, the first online feature set is generated, at this time the first online feature set is an empty set, after the first non-admission feature is determined, the non-admission feature and the occurrence time of the non-admission feature are added to the first online feature set in the same way as the above process. In this case, the occurrence time of the first online feature can only include the occurrence time of the first online feature in the online sample data used to train the first offline model.
[0115] Based on the implementation of recording non-admission features and occurrence times of each non-admission feature in the first online feature set in the above embodiments, when obtaining the occurrence time of the first online feature, the occurrence time of the first online feature can be obtained based on the online features included in the first online feature set and the occurrence times of each online feature.
[0116] Due to the diversity of online sample data and features, the first online feature set can record the first online feature or can not record the first online feature, so after the first online feature is obtained, there are two implementation ways to update the first online feature set based on the obtained first online feature:
[0117] In one possible implementation, when the first online feature does not exist in the at least one first offline feature and the first online feature does not exist in the first online feature set, the first online feature is added to the first online feature set, and the occurrence time of the first online feature is determined to be 1.
[0118] In another possible implementation, the first online feature is not present in the at least one first offline feature, but the first online feature is present in the first online feature set, and in this case, the number of occurrences of the first online feature in the first online feature set is updated.
[0119] It should be noted that in the case where the first online feature is present in the first online feature set, the first online feature does not need to be added to the first online feature set, but only the number of occurrences of the first online feature recorded in the first online feature set is updated.
[0120] When updating the number of occurrences of the first online feature recorded in the first online feature set, the number of occurrences of the first online feature recorded in the first online feature set can be increased by 1, so as to obtain the updated number of occurrences of the first online feature, thereby updating the number of occurrences.
[0121] Through the above process, the online features and the number of occurrences recorded in the first online feature set can be updated, so as to obtain the number of occurrences of the first online feature based on the updated first online feature set, and then determine the first online feature as an online training feature for training the first offline model in the case where the number of occurrences of the first online feature is greater than a set number threshold.
[0122] In addition, by using the offline feature set and the online feature set, the dual access of the online feature can be realized, which can improve the accuracy of feature access while ensuring the real-time of feature access.
[0123] In some embodiments, after the first online feature is determined as an online training feature for training the first offline model, the first offline model can be trained online based on the online sample data corresponding to the first online feature.
[0124] In a possible implementation, the first offline model can be associated with a first feature queue for storing online training features for training the first offline model. After the first online feature is determined as an online training feature for training the first offline model, the first online feature can be added to the first feature queue, so that the corresponding online sample data can be obtained based on the online sample features included in the first feature queue, and then the first offline model can be trained online based on the obtained online sample data.
[0125] Taking the first offline model as a model for content item recommendation and the first online feature as a sample user gender as an example, after the first online feature is determined as an access feature, the sample user gender as the first online feature can be stored in the first feature queue.
[0126] It should be noted that the first offline model can also be associated with a first start timestamp, and the first start timestamp is used to indicate a time of starting to obtain online training features from the first feature queue. In addition, the online training features stored in the first feature queue are all labeled with corresponding online sample data and data acquisition time of the online sample data, so that when the online training features are obtained from the first feature queue, the online training features can be obtained based on the first start timestamp and the data acquisition time of the online sample data corresponding to each online training feature.
[0127] In a possible implementation, when the first offline recommendation model is online trained, online training features corresponding to a time (that is, corresponding data acquisition time) located after the first start timestamp are obtained from the first feature queue, so that the first offline model is trained based on the online training features corresponding to the time located after the first start timestamp, to obtain the first online model.
[0128] Optionally, the first offline model can also correspond to a first end timestamp, and the first end timestamp is used to indicate a data end time of offline sample data used for training the first offline model, so that based on the first end timestamp, it can be determined that the first offline model is trained based on offline sample data before which time point.
[0129] After the first online model is obtained, online prediction can be performed based on the first online model, so that new online sample data is obtained, and the new online sample data obtained is processed in the same manner as the processing manners of the above embodiments, and the specific process can be referred to the above embodiments, which will not be described here.
[0130] It should be noted that the first offline model, the first offline feature set, the first feature queue, the first start timestamp, the first end timestamp, the first online feature set and the set number threshold mentioned in the above process can be associated with each other, so that any one of them can be used to obtain the other items associated therewith.
[0131] In a possible implementation, after the first offline feature set is obtained, version information can be generated for the first offline feature set, and the first offline model, the first feature queue, the first start timestamp, the first end timestamp, the first online feature set and the set number threshold are bound to the generated version information, so as to realize the association between the first offline model, the first offline feature set, the first feature queue, the first start timestamp, the first end timestamp, the first online feature set and the set number threshold.
[0132] Optionally, the version information can be a version identifier, such as a version number, and in addition, the version information can also be of other types, which are not limited by the present disclosure.
[0133] By associating the offline model, the offline feature set, the online feature set, the feature queue, the start timestamp, the end timestamp and the set number threshold with the version information, the training process for different models can be implemented based on the version information.
[0134] It should be noted that while the first offline model is trained online, the first offline model can also be continuously trained offline based on offline sample data of different time periods to obtain a second offline model.
[0135] For example, the first offline model is an offline model trained based on offline sample data from 0:00 to 24:00 on November 25, 2021, and the first offline model is pushed to the prediction end at 8:00 on November 26, 2021, and the prediction end can train the first offline model online. While the first offline model is trained online, the first offline model can be continuously trained offline based on offline sample data from 0:00 to 8:00 on November 26, 2021, to obtain a second offline model, and then the second offline recommendation model is trained online.
[0136] However, since the second offline recommendation model is trained based on offline sample data before 8:00 on November 26, 2021, that is, the second offline recommendation model is not trained based on the online training data used when the first offline model is trained online, therefore, before the second offline model is trained online, the second offline model can be trained based on the online training data used when the first offline model is trained online through data backtracking.
[0137] In a possible implementation, the second offline model and at least one second offline feature used to train the second offline model are obtained, so as to perform data backtracking based on the second offline model and perform feature access to online features based on the at least one second offline feature.
[0138] The second offline model is associated with a second feature queue, and the second feature queue is used to store online training features for training the second online model to be trained. In addition, the second offline model also corresponds to a second end timestamp and a second start timestamp, the second end timestamp is used to indicate the data end time of the offline sample data used to train the second offline model, and the second start timestamp is used to indicate the time of starting to obtain online training features from the second feature queue.
[0139] In addition, the second offline model can be associated with a second offline feature set, a second online feature set, and a set number threshold. The second offline feature set includes at least one second offline feature used to train the second offline model. The second online feature set is used to record non-admission features (i.e., features with occurrence numbers less than the set number threshold) corresponding to the online sample data and the occurrence numbers of the respective non-admission features. For details of the second offline feature set and the second online feature set, refer to the descriptions of the first offline feature set and the first online feature set in the above embodiments, which will not be repeated here.
[0140] It should be noted that the set number threshold corresponding to the first offline model can be the same as or different from the set number threshold corresponding to the second offline model, which is not limited in the present disclosure.
[0141] In a possible implementation, when data is backtracked based on the second offline model, the second offline model is trained based on online training features corresponding to a time located between the second end timestamp and the second start timestamp, to obtain the second online model to be trained.
[0142] By backtracking the data of the second offline model, the second online model to be trained is obtained, so that online training is performed based on the second online model to be trained, to ensure that the model used in online training is trained based on full data before online training, thereby ensuring the training effect of the model.
[0143] After the second online model to be trained is obtained, at least one second online feature corresponding to online sample data obtained by the second online model to be trained can be subjected to feature admission based on at least one second offline feature, to obtain a second online feature used to perform online training on the second online model to be trained, and then the second online model to be trained is subjected to online training based on the online sample data corresponding to the second online feature, to obtain the second online model.
[0144] In a possible implementation, online training features corresponding to a time located after the second start timestamp are obtained from the second feature queue, so that the second online model to be trained is trained based on the online training features corresponding to a time located after the second start timestamp, to obtain the second online model.
[0145] Optionally, the second offline feature set, the second offline model, the second feature queue, the second start timestamp, the second end timestamp, the second online feature set, and the set number threshold can be associated through version information. Different offline models correspond to different version information, so that the corresponding offline model can be obtained based on the version information subsequently.
[0146] In a possible implementation, in response to receiving the model obtaining instruction, an offline model indicated by the version information corresponding to the model obtaining instruction is obtained.
[0147] By providing a mechanism for model rollback based on version information, the entire online learning process has a memory function, which enables the model to quickly rollback to any previous version, that is, the online learning process has a rollback capability. In the case that the prediction result of the new offline model has a large deviation, the model can quickly rollback to the previous normal version, so that the online learning process has stronger risk resistance.
[0148] The first feature queue and the second feature queue can be located in a distributed message queue (Kafka) platform. Optionally, the Kafka platform can also include other feature queues. One feature queue corresponds to one round of online learning process, and the feature queues corresponding to adjacent two online learning processes are different, that is, the feature queues corresponding to adjacent two offline models are different. It should be noted that the feature queues in the Kafka platform can also be referred to as Topic.
[0149] For example, the first offline model corresponds to the first feature queue, and the second offline model adjacent to the first offline model corresponds to the second feature queue. The third offline model adjacent to the second offline model can correspond to the first feature queue, and can also correspond to any one of the third feature queue, the fourth feature queue, and the like, as long as the feature queue corresponding to the third offline model is not the second feature queue.
[0150] By using the Kafka queue and the double Topic switching mode, adjacent two versions can obtain online training features from different Topics, so as to train the model based on the online training data corresponding to the online training features in different Topics, thereby ensuring the separation of sample data before and after the offline model is loaded, so that subsequent data backtracking can be more convenient, and the separation of online features corresponding to different offline models can be realized.
[0151] The processes shown in the above embodiments can be referred to Figure 2 , Figure 2 is a principle diagram of a feature processing method according to an exemplary embodiment of the present disclosure, as shown in Figure 2As shown, after generating the offline vocabulary and the offline model through offline training, the offline vocabulary and the offline model generated by offline training are acquired, so that after the online sample data is acquired, the online features corresponding to the online sample data are subjected to feature access through feature engineering, so that the accessed features are added to the Topic corresponding to the model, so as to acquire the online features corresponding to the time located after the starting time stamp from the Topic, and then the offline model is trained online based on the acquired online features. It should be noted that after the new offline model is acquired, the new offline model can be subjected to data backtracking through feature engineering, and then online learning is performed based on the new offline model. In addition, corresponding version information can be generated for different models, so that subsequent model quick switching can be performed based on the version information.
[0152] Figure 2 and Figure 2 The corresponding process is only a conceptual introduction to the present disclosure. For the specific embodiments of the present disclosure, please refer to the above-mentioned various embodiments, which will not be described here.
[0153] In order to realize the feature processing method of any embodiment of the present disclosure, the present disclosure further provides a feature processing device. Referring to Figure 3 , Figure 3 is a structural schematic diagram of a feature processing device according to an exemplary embodiment of the present disclosure, which comprises:
[0154] The acquisition module 301 is configured to acquire a first offline model and at least one first offline feature used for training the first offline model.
[0155] The acquisition module 301 is further configured to acquire online sample data, the online sample data corresponding to at least one first online feature.
[0156] The determination module 302 is configured to, in a case where the first online feature exists in the at least one first offline feature, determine the first online feature as an online training feature used for training the first offline model.
[0157] In an embodiment of the present disclosure, the acquisition module 301 is further configured to, in a case where the first online feature does not exist in the at least one first offline feature, acquire a number of occurrences of the first online feature.
[0158] The determination module 302 is further configured to, in a case where the number of occurrences of the first online feature is greater than a set number threshold, determine the first online feature as the online training feature used for training the first offline model.
[0159] In an embodiment of the present disclosure, the acquisition module 301, when acquiring the number of occurrences of the first online feature in a case where the first online feature does not exist in the at least one first offline feature, is configured to:
[0160] In a case where the first online feature does not exist in the at least one first offline feature, the number of occurrences of the first online feature is obtained based on the online features included in the first online feature set and the number of occurrences of each online feature.
[0161] In an embodiment of the present disclosure, the apparatus further includes:
[0162] The feature processing module is configured to, in a case where the first online feature does not exist in the at least one first offline feature and the first online feature does not exist in the first online feature set, add the first online feature to the first online feature set and determine the number of occurrences of the first online feature as 1.
[0163] The updating module is configured to, in a case where the first online feature does not exist in the at least one first offline feature and the first online feature exists in the first online feature set, update the number of occurrences of the first online feature in the first online feature set.
[0164] In an embodiment of the present disclosure, the obtaining module 301, when obtaining the first offline model and the at least one first offline feature used for training the first offline model, is configured to:
[0165] Obtain the first offline model and a first offline feature set corresponding to the first offline model, the first offline feature set including the at least one first offline feature used for training the first offline model.
[0166] In an embodiment of the present disclosure, the determining module 302, when determining the first online feature as an online training feature used for training the first offline model, is configured to:
[0167] Add the first online feature to a first feature queue, the first feature queue being used to store the online training features used for training the first offline model.
[0168] In an embodiment of the present disclosure, the first offline model corresponds to a first start timestamp, the first start timestamp being used to indicate a time when the online training features are started to be obtained from the first feature queue.
[0169] The obtaining module 301 is further configured to obtain, from the first feature queue, the online training features corresponding to times located after the first start timestamp.
[0170] The apparatus further includes:
[0171] The first training module is configured to train the first offline model based on the online training features corresponding to times located after the first start timestamp, to obtain the first online model.
[0172] In an embodiment of the present disclosure, the obtaining module 301 is further configured to obtain a second offline model and at least one second offline feature used for training the second offline model, the second offline model corresponding to a second end time stamp, the second end time stamp being used to indicate a data end time of offline sample data used for training the second offline model, the second offline model being associated with a second feature queue, the second offline model corresponding to a second start time stamp, the second start time stamp being used to indicate a time for starting to obtain the online training feature from the second feature queue;
[0173] The apparatus further includes:
[0174] The second training module is configured to train the second offline model based on the online training feature corresponding to a time between the second end time stamp and the second start time stamp, to obtain the second online model to be trained.
[0175] In an embodiment of the present disclosure, the obtaining module 301 is further configured to obtain, from the second feature queue, the online training feature corresponding to a time after the second start time stamp.
[0176] The second training module is further configured to train the second online model to be trained based on the online training feature corresponding to a time after the second start time stamp, to obtain the second online model.
[0177] In an embodiment of the present disclosure, different offline models correspond to different version information.
[0178] The obtaining module 301 is further configured to obtain, in response to receiving a model obtaining instruction, an offline model indicated by version information corresponding to the model obtaining instruction.
[0179] It should be noted that although several modules or units of the feature processing apparatus are mentioned in the foregoing detailed description, such division is merely exemplary and not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules / unit described above can be embodied in one module / unit. Conversely, the features and functions of one module / unit described above can be further divided into multiple modules / units for embodiment.
[0180] The present disclosure further provides a computer readable storage medium. Figure 4 is a schematic diagram of a computer readable storage medium according to an exemplary embodiment of the present disclosure, as Figure 4 shown, the storage medium stores a computer program 401, the computer program 401 can execute the feature processing method provided by any embodiment of the present disclosure when executed by a processor.
[0181] The embodiment of the present disclosure further provides a computing device, which can comprise a memory and a processor, the memory is used to store computer instructions executable on the processor, and the processor is used to implement the feature processing method provided by any embodiment of the present disclosure when executing the computer instructions.
[0182] Referring to Figure 5 , Figure 5 is a structural schematic diagram of a computing device 500 according to an exemplary embodiment of the present disclosure, which can comprise but is not limited to a processor 501, a memory 502 and a bus 503 connecting different system components including the memory 502 and the processor 501.
[0183] The memory 502 stores computer instructions executable by the processor 501, so that the processor 501 can execute the feature processing method provided by any embodiment of the present disclosure. The memory 502 can comprise a random access memory unit RAM 5021, a cache memory unit 5022 and / or a read-only memory unit ROM 5023. The memory 502 can further comprise a program tool 5025 having a set of program modules 5024, which can comprise but is not limited to an operating system, one or more application programs, other program modules and program data, and one or more combinations of these program modules can comprise the implementation of a network environment.
[0184] The bus 503 can comprise a data bus, an address bus and a control bus, etc. The computing device 500 can further communicate with an external device 505, which can be a keyboard, a Bluetooth device, etc., through an I / O interface 504. The computing device 500 can further communicate with one or more networks, which can be a local area network, a wide area network, a public network, etc., through a network adapter 506. As Figure 5 shown, the network adapter 506 can also communicate with other modules of the computing device 500 through the bus 503.
[0185] The embodiment of the present disclosure further provides a computer program product comprising a computer program, which can implement the feature processing method provided by any embodiment of the present disclosure when executed by the processor 501 of the computing device 500.
[0186] In addition, although the operations of the method of the present disclosure are described in a specific order in the accompanying drawings, this does not require or imply that the operations must be performed in this specific order, or that all of the shown operations must be performed to achieve the desired result. Additionally or alternatively, some steps can be omitted, a plurality of steps can be combined into one step, and / or one step can be divided into a plurality of steps.
[0187] While the spirit and principles of the present disclosure have been described with reference to several specific embodiments, it is to be understood that the present disclosure is not limited to the specific embodiments disclosed and that the division of the aspects is not meant to imply that features from the aspects cannot be combined to benefit from the disclosure, but is merely for convenience of presentation. The present disclosure is intended to cover various modifications and equivalent arrangements included within the spirit and scope of the claims appended hereto.
Claims
1. A feature processing method characterized by, The method comprises: obtaining a first offline model and at least one first offline feature used for training the first offline model, wherein the first offline model is a recommendation model used for content item recommendation, and the first offline feature comprises a feature corresponding to sample user information and a feature corresponding to at least one sample content item; obtaining online sample data generated after online prediction is completed by the first offline model, wherein the online sample data comprises sample user information and at least one sample content item as input of the first offline model, and a target content item clicked by a user as output of the first offline model, and the online sample data corresponds to at least one first online feature, wherein the first online feature comprises a feature corresponding to sample user information and a feature corresponding to at least one sample content item; in a case where the first online feature exists in the at least one first offline feature, determining the first online feature as an online training feature used for training the first offline model; wherein the content item comprises at least one of a video, an advertisement, news, and a commodity.
2. The method of claim 1, wherein, The method further comprises: in a case where the first online feature does not exist in the at least one first offline feature, obtaining a number of occurrences of the first online feature; in a case where the number of occurrences of the first online feature is greater than a set number threshold, determining the first online feature as an online training feature used for training the first offline model.
3. The method of claim 2, wherein, The obtaining, in the case where the first online feature does not exist in the at least one first offline feature, the number of occurrences of the first online feature comprises: in the case where the first online feature does not exist in the at least one first offline feature, obtaining the number of occurrences of the first online feature based on online features included in a first online feature set and the number of occurrences of each online feature.
4. The method of claim 3, wherein, Before the obtaining, in the case where the first online feature does not exist in the at least one first offline feature, the number of occurrences of the first online feature, the method further comprises any one of the following: in a case where the first online feature does not exist in the at least one first offline feature and the first online feature set, adding the first online feature to the first online feature set and determining the number of occurrences of the first online feature as 1; in a case where the first online feature does not exist in the at least one first offline feature but exists in the first online feature set, updating the number of occurrences of the first online feature in the first online feature set.
5. The method of claim 1, wherein, The obtaining the first offline model and the at least one first offline feature used for training the first offline model comprises: obtaining a first offline model and a first offline feature set corresponding to the first offline model, wherein the first offline feature set comprises at least one first offline feature used for training the first offline model.
6. The method of claim 1, wherein, After the determining the first online feature as the online training feature used for training the first offline model, the method further comprises: add the first online feature to a first feature queue, the first feature queue being used to store online training features for training the first offline model.
7. The method of claim 6, wherein, the first offline model corresponds to a first start timestamp, the first start timestamp being used to indicate a time to start obtaining online training features from the first feature queue; after determining the first online feature as an online training feature for training the first offline model, the method further comprises: obtaining, from the first feature queue, an online training feature corresponding to a time after the first start timestamp; training the first offline model based on the online training feature corresponding to the time after the first start timestamp, to obtain a first online model.
8. The method of claim 1, wherein, the method further comprises: obtaining a second offline model and at least one second offline feature used for training the second offline model, the second offline model corresponding to a second end timestamp, the second end timestamp being used to indicate a data end time of offline sample data used for offline training of the second offline model, the second offline model being associated with a second feature queue, the second offline model corresponding to a second start timestamp, the second start timestamp being used to indicate a time to start obtaining online training features from the second feature queue; training the second offline model based on online training features corresponding to a time between the second end timestamp and the second start timestamp, to obtain a second online model to be trained.
9. The method of claim 8, wherein, after training the second offline model based on the online training features corresponding to the time between the second end timestamp and the second start timestamp, to obtain the second online model to be trained, the method further comprises: obtaining, from the second feature queue, an online training feature corresponding to a time after the second start timestamp; training the second online model to be trained based on the online training feature corresponding to the time after the second start timestamp, to obtain a second online model.
10. The method according to any one of claims 1 to 9, characterized in that, different offline models correspond to different version information; the method further comprises: in response to receiving a model obtaining instruction, obtaining an offline model indicated by version information corresponding to the model obtaining instruction.
11. A feature processing apparatus characterized by comprising: the apparatus comprises: an obtaining module, configured to obtain a first offline model and at least one first offline feature used for training the first offline model, wherein the first offline model is a recommendation model used for content item recommendation, and the first offline feature includes features corresponding to sample user information and features corresponding to at least one sample content item; the obtaining module is further configured to obtain online sample data generated after online prediction is completed by the first offline model, the online sample data including sample user information and at least one sample content item as input of the first offline model, and a target content item clicked by a user as output of the first offline model, the online sample data corresponding to at least one first online feature, wherein the first online feature includes features corresponding to sample user information and features corresponding to at least one sample content item; determining, by the determining module, the first online feature as an online training feature for training the first offline model, in a case where the first online feature exists in the at least one first offline feature; The content item includes at least one of a video, an advertisement, news, and a commodity.
12. The apparatus of claim 11, wherein, The obtaining module is further configured to, in a case where the first online feature does not exist in the at least one first offline feature, obtain a number of occurrences of the first online feature. The determining module is further configured to, in a case where the number of occurrences of the first online feature is greater than a set number threshold, determine the first online feature as an online training feature for training the first offline model.
13. The apparatus of claim 12, wherein, The obtaining module, when obtaining the number of occurrences of the first online feature in a case where the first online feature does not exist in the at least one first offline feature, is configured to: obtain the number of occurrences of the first online feature based on online features included in the first online feature set and the number of occurrences of each online feature, in a case where the first online feature does not exist in the at least one first offline feature.
14. The apparatus of claim 13, wherein, The apparatus further includes: The feature processing module is configured to, in a case where the first online feature does not exist in the at least one first offline feature and the first online feature does not exist in the first online feature set, add the first online feature to the first online feature set and determine the number of occurrences of the first online feature as 1. The updating module is configured to, in a case where the first online feature does not exist in the at least one first offline feature and the first online feature exists in the first online feature set, update the number of occurrences of the first online feature in the first online feature set.
15. The apparatus of claim 11, wherein, The obtaining module, when obtaining the first offline model and the at least one first offline feature for training the first offline model, is configured to: obtain a first offline model and a first offline feature set corresponding to the first offline model, the first offline feature set including the at least one first offline feature for training the first offline model.
16. The apparatus of claim 11, wherein, The determining module, when determining the first online feature as an online training feature for training the first offline model, is configured to: add the first online feature to a first feature queue, the first feature queue being used to store online training features for training the first offline model.
17. The apparatus of claim 16, wherein, The first offline model corresponds to a first start timestamp, the first start timestamp being used to indicate a time of starting to obtain online training features from the first feature queue; The obtaining module is further configured to obtain, from the first feature queue, online training features corresponding to times located after the first start timestamp. The apparatus further includes: The first training module is configured to train the first offline model based on the online training features corresponding to the times located after the first start timestamp, to obtain a first online model.
18. The apparatus of claim 11, wherein, The acquisition module is further configured to acquire a second offline model and at least one second offline feature used for training the second offline model, the second offline model corresponding to a second cutoff timestamp, the second cutoff timestamp being used to indicate a data cutoff time of offline sample data used for training the second offline model offline, the second offline model being associated with a second feature queue, the second offline model corresponding to a second start timestamp, the second start timestamp being used to indicate a time for starting to acquire online training features from the second feature queue; The apparatus further includes: The second training module is configured to train the second offline model based on online training features corresponding to a time between the second cutoff timestamp and the second start timestamp, to obtain a second offline model to be trained.
19. The apparatus of claim 18, wherein, The acquisition module is further configured to acquire online training features corresponding to a time after the second start timestamp from the second feature queue. The second training module is further configured to train the second offline model to be trained based on the online training features corresponding to the time after the second start timestamp, to obtain a second offline model.
20. The apparatus of any one of claims 11-19, wherein, Different offline models correspond to different version information. The acquisition module is further configured to acquire an offline model indicated by version information corresponding to a model acquisition instruction in response to receiving the model acquisition instruction.
21. A computing device, comprising: The computing device includes a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the processor executes the program to implement operations performed by the feature processing method of any one of claims 1-10.
22. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a program, and the program is executed by the processor to perform operations performed by the feature processing method of any one of claims 1-10.
Citation Information
Patent Citations
Online prediction model training method and device, equipment and storage medium
CN112070226A
Online model learning method, system and device and computer readable storage medium
CN112241754A