Model training method, task processing method and related products
By constructing soft labels in model training and dynamically updating them, using the category prediction probability and soft labels of training samples, the impact of noise annotation data on the model is solved, the robustness and accuracy of the model is improved, and the noise is reduced for model training The impact of
Patent Information
- Application Number
- CN202411138831.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-19
- Publication Date
- 2024-12-06
AI Technical Summary
In the prior art, noise labeling data causes confusion on deep learning model training, resulting in model overfitting. How to reduce the impact of noise samples and improve the robustness of the model is an urgent problem.
By constructing soft labels during model training, using the category prediction probability and soft labels of the training samples for model updates, reducing dependence on hard labels, dynamically updating soft labels to maintain their stability and accuracy, thereby reducing noise impact.
It effectively reduces the impact of noise samples on model training, improves the robustness of the model, ensures the stability and accuracy of soft label updates, reduces the content of labeling noise, and avoids model overfitting.
Smart Images

Figure CN119089292A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and specifically to a model training method, a task processing method and related products. Background Art
[0002] In the process of data processing in the real world, the problem of noisy labeling is almost unavoidable. Labels generated by users on social media platforms or labels produced by manual labeling may cause noise in the labeled data. This noisy labeled data can be called a noisy sample, and the existing noise is called labeling noise. Figure 1 As shown in the figure, the jacket is marked as a down jacket, and the sweater is marked as a shirt. However, using these noise samples will confuse the training of the model, especially for large-scale deep learning models, which will regard these noise samples as valuable information during the learning process, resulting in overfitting of the model to the noise samples.
[0003] Therefore, how to weaken the impact of noise samples on model training and enhance the training robustness of the model when facing noise samples is a technical problem that needs to be solved urgently. Summary of the invention
[0004] The embodiments of the present application provide a model training method, a task processing method and related products to reduce the impact of noise samples on model training and improve the robustness of the model.
[0005] In a first aspect, an embodiment of the present application provides a model training method, comprising:
[0006] Using the classification model to perform a t-th round of category prediction on the training sample, and obtaining the category prediction probability of the training sample in the t-th round, wherein the soft label is used to indicate the probability of the training sample belonging to each category;
[0007] Determine the soft label of the training sample in the t-1th round based on the soft label of the training sample in the t-1th round and the class prediction probability in the tth round;
[0008] Based on the soft labels of the tth round, the category prediction probabilities of the tth round, and the hard labels of the training samples, the classification model is trained for the tth round, wherein the hard labels are used to indicate the category to which the training samples belong.
[0009] In a second aspect, an embodiment of the present application provides a task processing method, including:
[0010] Get the content to be processed;
[0011] Performing feature extraction on the content to be processed through a target feature extraction network to obtain a first target feature, wherein the target feature extraction network is trained by the method described in the first aspect;
[0012] Perform downstream task processing based on the first target feature.
[0013] In a third aspect, an embodiment of the present application provides a model training device, including: a classification unit and a training unit;
[0014] The classification unit is used to perform a t-th round category prediction on the training sample using the classification model to obtain the category prediction probability of the training sample in the t-th round;
[0015] The training unit is used to determine the soft labels of the training samples in the t-1 round based on the soft labels of the training samples in the t-1 round and the category prediction probabilities in the t round, wherein the soft labels are used to indicate the probabilities that the training samples belong to each category; based on the soft labels in the t-1 round, the category prediction probabilities in the t round and the hard labels of the training samples, perform the t-round training on the classification model, wherein the hard labels are used to indicate the categories to which the training samples belong.
[0016] In a fourth aspect, an embodiment of the present application provides a task processing device, including: an acquisition unit and a processing unit;
[0017] The acquisition unit is used to acquire the content to be processed;
[0018] The processing unit is used to extract features of the content to be processed through a target feature extraction network to obtain a first target feature, wherein the target feature extraction network is trained by the method described in the first aspect;
[0019] Perform downstream task processing based on the first target feature.
[0020] In a fifth aspect, an embodiment of the present application provides an electronic device, comprising: a processor and a memory, wherein the processor is connected to the memory, the memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory, so that the electronic device performs the method described in the first aspect or the second aspect.
[0021] In a sixth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method described in the first aspect or the second aspect is implemented.
[0022] In a seventh aspect, an embodiment of the present application provides a computer program product, wherein the computer program product includes a computer program, and when the computer program is executed by a processor, the method described in the first aspect or the second aspect is implemented.
[0023] Implementing the embodiments of the present application has the following beneficial effects:
[0024] It can be seen that in an embodiment of the present application, when using training samples to train the model, soft labels are constructed for the training samples for model training, so that content can be learned from the soft labels without over-reliance on hard labels, thereby reducing the impact of labeling noise on model training and improving the robustness of the classification model. In addition, when updating the soft labels along the training edges in each round, it is not simply the soft labels of the training samples in the previous round that are used to update the soft labels of this round, but the category prediction probability of this round and the soft labels of the previous round are used to simultaneously update the soft labels of the training samples in this round, thereby achieving reference to the category prediction of the classification model in this round, updating the soft labels of the previous round, maintaining the stability and accuracy of the soft label update of the training samples, thereby reducing the content of labeling noise in the soft labels, weakening the impact of labeling noise on model training, and improving the robustness of the model. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0026] Figure 1 A schematic diagram of a case where annotation noise exists provided in an embodiment of the present application;
[0027] Figure 2 A flowchart of a model training method provided in an embodiment of the present application;
[0028] Figure 3 A schematic diagram of a model structure provided in an embodiment of the present application;
[0029] Figure 4 A schematic diagram of a task processing scenario provided in an embodiment of the present application;
[0030] Figure 5 A flowchart of a task processing method provided in an embodiment of the present application;
[0031] Figure 6 A flowchart of another task processing method provided in an embodiment of the present application;
[0032] Figure 7 A schematic diagram of reviewing content to be processed provided in an embodiment of the present application;
[0033] Figure 8 A schematic diagram of a model training device provided in an embodiment of the present application;
[0034] Fig. 9 A schematic diagram of a task processing device provided in an embodiment of the present application;
[0035] Fig.10 A schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0036] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0037] The terms "first", "second", "third" and "fourth" etc. in the specification and claims of the present application and the drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or devices.
[0038] Reference to "embodiments" herein means that a particular feature, result, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0039] To facilitate understanding, the relevant terms involved in this application are first introduced and explained.
[0040] Soft label: The probability distribution represents the probability that a sample belongs to a certain category. For example, for a three-category task, the soft label of a sample is [0.3, 0.5, 0.2], which means that the probability that the sample belongs to the three categories is 30%, 50%, and 20% respectively.
[0041] Hard label: Use 0 or 1 to indicate that a sample belongs to a certain category, that is, to clearly characterize whether the sample belongs to a certain category or not. For example, if the hard label of a sample is [1, 0, 0], it means that the sample belongs to the first category, but not the second and third categories. Therefore, the hard label can also be understood as the annotation label or true label of the sample.
[0042] Noise sample: A noise sample is a training sample whose category is incorrectly marked in the hard label. For example, the category of a training sample is sweater, but the category of the training sample is marked as jacket. Such a training sample is a noise sample.
[0043] In order to facilitate understanding of the technical solution of the present application, the model training process of the present application is first introduced.
[0044] See also Figure 2 , Figure 2 A flow chart of a model training method provided in an embodiment of the present application. The method is applied to a model training device. The method includes but is not limited to the following steps:
[0045] 201: Use the classification model to perform round t category prediction on the training samples to obtain the category prediction probability of the training samples in the round t.
[0046] Among them, the training sample is the nth training sample among the M training samples for model training in this application, which can also be called training sample n. The training sample n is any one of multiple training samples, and M is an integer greater than or equal to 1.
[0047] The training sample may be any type of training sample. For example, the training sample may be training text, training image, training audio, training video, social relationship, behavior data, etc. This application does not limit the type of training sample, and this application mainly uses training text, training audio, and training image as examples for explanation.
[0048] It should be noted that for each training sample, each training sample is labeled in advance to obtain a hard label for each training sample, that is, the category corresponding to each training sample is labeled. However, due to labeling errors, the labeled category may not be the true category of the training sample. For example, Figure 1 The jacket in the video is mistakenly labeled as a down jacket. Therefore, the multiple training samples of this application include noise samples and normal samples, where the noise samples are training samples with incorrect categories labeled by hard labels, and the normal samples are training samples with correct categories labeled by hard labels. The above training sample n can be a noise sample or a normal training sample, which is not limited in this application.
[0049] It should be noted that the model training in this application includes multiple rounds of model training processes. This application mainly uses the t-th round of model training as an example for explanation, wherein the t-th round of model training is any round of model training among multiple rounds of model training. Therefore, the above-mentioned t-th round category prediction is the category prediction in the t-th round of model training process.
[0050] Alternatively, if Figure 3 As shown, the classification model includes an initial feature extraction network and a classification network.
[0051] For example, when the training sample is trained for the tth round of model training, the classification model is first used to extract the features of the training sample for the tth round, and the second target features of the training sample for the tth round are obtained. Specifically, Figure 3 As shown, during the tth round of training, the training samples are input into the initial feature extraction network for feature extraction to obtain the second target feature.
[0052] It should be noted that the above-mentioned initial feature extraction network can be any type of feature extraction network. And the type of the initial feature extraction network corresponds to the type of the training sample. For example, if the training sample is a training image, then the initial feature extraction network can be an image feature extraction network, more specifically, the image feature extraction network can be a deep network, a convolutional neural network, a residual network (ResNet), a transform network, an Inception network, etc.; for another example, if the training sample is a training text, then the initial feature extraction network can be a text feature extraction network, more specifically, the text feature extraction network can be a recurrent neural network, a long short-term memory network, a Transformer network, a Bert network, etc.
[0053] Then, class prediction is performed based on the second target feature to obtain the class prediction probability of the training sample in the tth round. Specifically, Figure 3 As shown, the second target feature of the nth training sample can be input into the classification network to obtain the category prediction probability of the training sample in the tth round, wherein the category prediction probability includes the probability that the training sample belongs to each category. In this application, the number of categories is set to U, therefore, the category prediction probability is (P1, P2, P3, ..., P U ).
[0054] 202: Determine a soft label of the training sample in the tth round based on the soft label of the training sample in the t-1th round and the category prediction probability in the tth round, wherein the soft label is used to indicate the probability that the training sample belongs to each category.
[0055] The soft label is used to indicate the probability that the training sample belongs to each category after the tth round of category prediction.
[0056] Exemplarily, the maximum prediction probability among the category prediction probabilities of the tth round is obtained, that is, the maximum prediction probability among the prediction probabilities that the training samples belong to each category is obtained. Exemplarily, the maximum prediction probability can be expressed by formula (1):
[0057]
[0058] in, is the maximum prediction probability, max() is the maximum value operation, is the predicted probability of the category of the training sample in the tth round.
[0059] Then, based on the maximum prediction probability, the soft labels of the t-1 round and the class prediction probability of the t-th round are weighted to obtain the soft labels of the t-th round. Specifically, based on the maximum prediction probability, the weights corresponding to the class prediction probability of the t-th round and the weights corresponding to the soft labels of the t-1 round are determined; then, based on the weights corresponding to the class prediction probability of the t-th round and the weights corresponding to the soft labels of the t-1 round, the soft labels of the t-1 round and the class prediction probability of the t-th round are weighted to obtain the soft labels of the training samples in the t-th round.
[0060] For example, the soft label of the training sample in the tth round can be expressed by formula (2):
[0061]
[0062] in, is the soft label of the training sample in the tth round, λ is the preset hyperparameter, is the soft label of the training sample in the t-1 round, and when t=1, that is, in the first round of training, the soft label of the t-1 round is the hard label of the training sample.
[0063] First of all, in order to prevent the impact of labeling noise and improve the robustness of the model, this application tries to learn content from soft labels as much as possible when training the model, rather than fixedly learning content from hard labels. In other words, this application believes that soft labels have higher accuracy in labeling the categories of training samples.
[0064] Therefore, when updating the soft labels of this round, in addition to using the preset hyperparameter λ, the maximum predicted probability for the category in this round is also used as the weight. In this way, when the maximum predicted probability is relatively large, Relatively large, is relatively small, so the soft label of this round is more inclined to use the category prediction probability of this round. Since the maximum prediction probability can represent the confidence of the correct prediction category, when the maximum prediction probability When it is relatively large, it means that the model is confident that the category it predicts is correct, which makes the model more confident as it predicts, and is more inclined to use the category prediction probability of this round as the soft label of this round, so that the update of the soft label is more accurate, reducing the impact of labeling noise, and thus improving the robustness of the model. When it is smaller, Relatively small, is relatively large, and is more inclined to use the soft label of the previous round as the soft label of this round. If it is relatively small, it means that the model is not confident enough in predicting all categories, that is to say, the model is not sure to make the correct classification in this round, so it retains more soft labels from the previous round, thereby reducing the impact of noise. Specifically, the model was not overly affected by noise samples in the early stage, so the soft labels updated in the early stage are more convincing. Therefore, when the model cannot make accurate predictions in the later training, it retains more previous soft labels to ensure that the soft labels are not disturbed by noise samples as much as possible, reduce the noise content, and thus improve the robustness of the model. In summary, this application uses the maximum prediction probability of this round as the weight to dynamically update the soft labels of the training samples, rather than using a fixed ratio to update the soft labels. It can better balance the past information and current information of the model, and help maintain the stability and accuracy of the update of the soft labels of the training samples during the iterative training process.
[0065] It should be noted that in practical applications, the maximum prediction probability is not necessarily used. The second largest prediction probability can also be used for weighting, or the average of the first j prediction probabilities can be used for weighting. This application only uses the maximum prediction probability as an example for explanation.
[0066] 203: Performing a t-round training on the classification model based on the t-round soft labels, the t-round category prediction probabilities, and the hard labels of the training samples, wherein the hard labels are used to indicate the category to which the training samples belong.
[0067] Exemplarily, based on the soft label of the tth round and the class prediction probability of the tth round, a first cross entropy loss is determined, that is, a first cross entropy loss corresponding to the training sample during the tth round of model training is determined. Optionally, the first cross entropy loss is obtained by calculating a symmetric cross entropy loss on the soft label of the tth round and the class prediction probability of the tth round.
[0068] Exemplarily, the category prediction probability of the tth round is used as a supervisory label, and the third cross entropy loss between the soft label of the tth round and the category prediction probability of the tth round is determined, that is, the third cross entropy loss corresponding to the training sample during the tth round model training is determined.
[0069] Among them, the third cross entropy loss can be expressed by formula (3):
[0070]
[0071] in, is the third cross entropy loss, is the probability that the training sample n belongs to the kth category in the soft label of the tth round, is the probability that the training sample n belongs to the kth category in the category prediction probability of the tth round, and U is the number of categories.
[0072] It should be noted that the third cross entropy loss is mainly to make the category prediction probability of the training sample as close to the soft label as possible, thereby forcing the model to learn content from the soft label instead of relying too much on the hard label, reducing the impact of noise in the hard label and improving the robustness of the model.
[0073] Exemplarily, the soft label of the tth round is used as a supervision label, and the fourth cross entropy loss between the soft label of the tth round and the category prediction probability of the tth round is determined, that is, the fourth cross entropy loss corresponding to the training sample during the tth round model training is determined.
[0074] Among them, the fourth cross entropy loss can be expressed by formula (4):
[0075]
[0076] in, is the fourth cross entropy loss.
[0077] It should be noted that the fourth cross entropy loss is mainly to force the model to make a relatively smooth prediction when making category predictions, that is, the prediction probabilities falling into each category are similar, and extreme prediction probabilities are not easily output. In this way, even if the training sample is a noise sample, the difference between the predicted category and the real category will not be too large due to the relatively smooth prediction of the category, thereby reducing the impact of noise. For example, the real category is category a, and the labeled category is category b. If no smooth prediction is made, the extreme predicted category is category b, then the predicted category will be very different from the real category, and it will be exactly the same as the labeled category. At this time, the model believes that the prediction is completely correct, so the entire annotation noise is brought into the model, and the model will cause overfitting. After making a smooth prediction, even if the prediction is related to category b, there will only be a smooth category prediction probability on category b, for example, 0.05. In this way, when the model is learning, it will not think that the prediction is completely correct, and it will still perform reverse learning based on the category prediction probability of 0.05, thereby reducing the impact of annotation noise.
[0078] Furthermore, since the fourth cross entropy loss is designed in this application, the model is forced to make smooth category predictions when predicting categories. Combined with formula (2), if If is relatively large, the model will be more confident that the category prediction is correct, thus further ensuring that the soft label update is highly accurate.
[0079] Finally, based on the third cross entropy loss and the fourth cross entropy loss, the first cross entropy loss is obtained. For example, the third cross entropy loss and the fourth cross entropy loss are summed to obtain the first cross entropy loss.
[0080] Exemplarily, the second cross entropy loss is determined based on the soft label of the tth round, the class prediction probability of the tth round, and the hard label of the training sample. Specifically, based on the soft label of the tth round, the cross entropy loss between the class prediction probability of the tth round and the hard label of the training sample is weighted to obtain the second cross entropy loss, that is, the soft label of the tth round is used as the weight, and the cross entropy loss between the class prediction probability of the tth round and the hard label of the training sample is weighted to obtain the second cross entropy loss. The second cross entropy loss can be expressed by formula (5):
[0081]
[0082] in, is the second cross entropy loss, Y nk is the label value of the training in the kth category in the hard label, that is, whether the training sample belongs to the kth category. If so, then Y nk is 1, if not, then the Y nk is 0.
[0083] Finally, based on the first cross entropy loss and the second cross entropy loss, the target cross entropy loss is obtained.
[0084] It should be understood that there will be multiple training samples for model training, so the target first cross entropy loss can be obtained based on the first cross entropy loss corresponding to each training sample. For example, the multiple first cross entropy losses corresponding to multiple training samples can be summed to obtain the target first cross entropy loss. The target first cross entropy loss can be expressed by formula (6):
[0085]
[0086] in, is the target first cross entropy loss, and M is the number of training samples.
[0087] Of course, in practical applications, multiple first cross entropy losses can be averaged, linearly summed, and other operations can be performed to obtain the target first cross entropy loss. This application mainly uses the summation method as an example.
[0088] Similarly, by summing up multiple second cross entropy losses corresponding to multiple training samples, the target second cross entropy loss can be obtained.
[0089] Among them, the target second cross entropy loss can be expressed by formula (7):
[0090]
[0091] in, is the target second cross entropy loss.
[0092] Similarly, in practical applications, multiple second cross entropy losses can be averaged, linearly summed, or other operations can be performed to obtain the target second cross entropy loss. This application mainly uses the summation method as an example.
[0093] Finally, the target first cross entropy loss and the target second cross entropy loss are summed to obtain the target cross entropy loss, and the tth round of model training is performed based on the target cross entropy loss.
[0094] Exemplarily, the model parameters are updated based on the target cross entropy loss and the gradient descent method to perform the tth round of model training. It should be noted that the classification network in the present application can be pre-trained or untrained, and the present application does not limit this. If the classification network is pre-trained, the above-mentioned model parameters include the model parameters of the feature extraction network, and the process of training the classification model in the present application is essentially to train the initial feature extraction network, so the model training method of the present application can also be regarded as a feature network training method. If the classification network is untrained, the above-mentioned model parameters include the model parameters of the feature extraction network and the model parameters of the classification network.
[0095] It is understandable that the present application will perform multiple rounds of model training until the model converges and completes the training of the model. For the sake of distinction, the present application refers to the trained initial feature extraction network as the target feature extraction network. The present application mainly uses the example that the classification network is pre-trained, and after the classification model is trained, the target feature extraction network can be used to perform any type of feature extraction task.
[0096] It can be seen that in the embodiment of the present application, when using training samples to train the model, soft labels are constructed for the training samples for model training, so that content can be learned from the soft labels without over-reliance on hard labels, thereby reducing the impact of labeling noise on model training and improving the robustness of the model. In addition, when updating the soft labels of the training samples in each round, it is not simply the soft labels of the training samples in the previous round that are used to update the soft labels of the current round. Instead, the category prediction probability of the current round and the soft labels of the previous round are used to simultaneously update the soft labels of the training samples in the current round, thereby achieving reference to the category prediction of the current round model, updating the soft labels of the previous round, and maintaining the stability and accuracy of the soft label updates of the training samples, thereby reducing the content of labeling noise in the soft labels, weakening the impact of labeling noise on model training, and improving the robustness of the model.
[0097] The training process of this application is explained below using actual training samples.
[0098] Exemplarily, when the training sample is a training text, the above-mentioned initial feature extraction network can be a text feature extraction network, and the categories corresponding to the training text include but are not limited to: tourism, scenery, marketing, education, parent-child, etc. Therefore, when the training text is used to perform the t-th round of model training on the text feature extraction network, the training text can be input into the text initial feature extraction network for feature extraction to obtain the second target feature; then, the second target feature is input into the classification network to obtain the category prediction probability corresponding to the training text. Then, the t-th round of model training is performed based on the category prediction probability.
[0099] Exemplarily, when the training sample is a training audio, the above-mentioned initial feature extraction network can be an audio feature extraction network, and the categories corresponding to the training text include but are not limited to: classical music, folk music, pop music, rock music, etc. Therefore, when the training audio is used to perform the t-th round of model training on the audio feature extraction network, the training audio can be input into the audio feature extraction network for feature extraction to obtain the second target feature; then, the second target feature is input into the classification network to obtain the category prediction probability corresponding to the training audio. Then, the t-th round of model training is performed based on the category prediction probability.
[0100] Exemplarily, when the training sample is a training image, the initial feature extraction network can be an image feature extraction network, and the categories corresponding to the training image include but are not limited to: animals, people, plants, etc. Therefore, when the training image is used to perform the t-th round of model training on the image feature extraction network, the training image can be input into the image feature extraction network for feature extraction to obtain the second target feature; then, the second target feature is input into the classification network to obtain the category prediction probability corresponding to the training image. Then, the t-th round of model training is performed based on the category prediction probability.
[0101] See also Figure 4 , Figure 4 A schematic diagram of a task processing scenario provided in an embodiment of the present application. For example, Figure 4As shown, the task processing device obtains the content to be processed. Exemplarily, the task processing device can obtain the content to be processed from the client. For example, when the user needs to publish the content to be processed, the user can send the content to be processed to the task processing device; or, obtain the content to be processed from the database. For example, after the above-mentioned target feature extraction network is trained, the content to be processed in the database needs to be reprocessed, and the content to be processed can be obtained from the database. Then, the task processing device calls the target feature extraction network to extract features from the content to be processed and obtains the first target feature; finally, downstream task processing is performed based on the first target feature. For example, downstream tasks include but are not limited to: classification tasks, target detection tasks, sentiment classification tasks, natural language processing tasks, identity recognition tasks, audit tasks, and the like.
[0102] It should be stated that Figure 4 The task processing device shown can be the above-mentioned model training device, or a device different from the model training device. It can be understood that if the task processing device is not the above-mentioned model training device, the above-mentioned target feature extraction network can be first trained by the model training device, and then the target feature extraction network can be deployed to the task processing device, or the target feature extraction network can be called by the task processing device, and finally the task processing method of the present application is executed through the target feature extraction network.
[0103] It should be noted that the task processing device may be a server. The server may be a cloud computing server, a content delivery network (CDN) server, a network time protocol (NTP), a domain name resolution system (DNS) server, or other types of servers.
[0104] See also Figure 5 , Figure 5 A flowchart of a task processing method provided in an embodiment of the present application is provided. The method applies the above-mentioned task processing device. The method includes but is not limited to the following steps:
[0105] 501: Get content to be processed.
[0106] Among them, the content to be processed can be any type of processing content. For example, the content to be processed can be one or more of text, image, audio, video, behavior data, and log information. This application does not limit the type of content to be processed. It should be noted that different downstream tasks can be performed for different types of content to be processed. For example, when the content to be processed is an image, the downstream task can be identity recognition; when the content to be processed is text, the downstream task can be a sentiment classification task.
[0107] 502: Extract features of the content to be processed through a target feature extraction network to obtain a first target feature.
[0108] Among them, the target feature extraction network is trained by the above-mentioned model training method.
[0109] Exemplarily, the content to be processed is input into a target feature extraction network for feature extraction to obtain a first target feature.
[0110] If the content to be processed is text, the first target feature is a first text feature; if the content to be processed is an image, the first target feature is a first image feature; if the content to be processed is audio, the first target feature is a first audio feature.
[0111] 503: Perform downstream task processing based on the first target feature.
[0112] Exemplarily, based on the scenario of the downstream task, the first target feature is used to perform downstream task processing.
[0113] The downstream tasks include, but are not limited to, classification tasks, target detection tasks, sentiment classification tasks, natural language processing tasks, identity recognition tasks, audit tasks, etc. For example, when the downstream task is an identity recognition task, identity recognition can be performed based on the first target feature; for another example, when the downstream task is an audit task, audit can be performed based on the first target feature.
[0114] It can be seen that in the embodiment of the present application, feature extraction is performed on the content to be processed through a trained target feature extraction network. Since the target feature extraction network is less affected by noise during training and has higher robustness, the accuracy of the extracted first target feature is relatively high, thereby improving the processing accuracy of downstream tasks.
[0115] Different scenarios correspond to different downstream task scenarios. The following takes the content to be processed as a note as an example to illustrate the execution process of each downstream task of this application.
[0116] Downstream task 1: classification task
[0117] Optionally, the notes can be classified to facilitate subsequent recommendations based on the classified notes. Exemplarily, the notes are input into a target feature extraction network for feature extraction to obtain a first target feature. Then, the notes are classified based on the first target feature to obtain a category of the notes, where the category includes but is not limited to: marketing notes, travel notes, food notes, outfit notes, etc.
[0118] Downstream task 2: target detection task
[0119] For example, if the note includes an image, the image can be input into a target feature extraction network for feature extraction to obtain a first target feature (i.e., a feature map), and then target detection is performed based on the first target feature.
[0120] Downstream task 3: sentiment classification task
[0121] Exemplarily, feature extraction can be performed on the note through a target feature extraction network to obtain a first target feature; then, emotion classification can be performed based on the first target feature to obtain an emotion category corresponding to the note, wherein the emotion categories include happy, sad, happy, sad, depressed, and so on.
[0122] Downstream Task 4: Natural Language Processing Task
[0123] Exemplarily, the content to be processed is input into a target feature extraction network for feature extraction to obtain a first target feature; then, natural language processing is performed based on the first target feature, such as title generation, summary generation, and the like.
[0124] Downstream Task 5: Audit Task
[0125] Exemplarily, the note is input into the target feature extraction network for feature extraction to obtain a first target feature. Then, the note is reviewed based on the first target feature to obtain a review result. For example, the note may be reviewed for legality, risk, etc. This application does not limit the type of review.
[0126] Combine the following Figure 6 and Figure 7 , and taking the content to be processed as a note and the note including images and text as an example, the detailed process of reviewing the note is explained.
[0127] See also Figure 6 , Figure 6 A flowchart of another task processing method provided in an embodiment of the present application. The method is applied to the above-mentioned task processing device. The method includes but is not limited to the following steps:
[0128] 601: Obtain content to be processed, where the content to be processed includes text to be processed and image to be processed.
[0129] 602: Perform feature extraction on the image to be processed to obtain a first target feature map.
[0130] For example, Figure 7As shown, the image to be processed is input into the first target feature extraction network for feature extraction to obtain a first target feature map, and the first target feature extraction network is used to extract features from the image, and the first target feature extraction network can also be called a first target image feature extraction network. Therefore, it can be understood that the first target feature obtained by extracting features from the content to be processed includes the first target feature map.
[0131] Among them, the first target feature extraction network is trained using training images with category labels and through the above-mentioned model training method, and will not be described again.
[0132] 603: Perform category prediction based on the first target feature map to obtain a first category prediction probability.
[0133] For example, Figure 7 As shown, the first target feature map is input into the first classification network for category prediction to obtain the first category prediction probability.
[0134] 604: Extract features from the text to be processed to obtain first target text features.
[0135] For example, Figure 7 As described above, the text to be processed can be input into the second target feature extraction network for feature extraction to obtain the first target text feature. Since the second target feature extraction network is used for extracting text features, the second target feature extraction network can also be called the first target text feature extraction network. Therefore, it can be understood that the first target feature obtained by feature extraction of the content to be processed includes the first target text feature.
[0136] Among them, the second target feature extraction network adopts training text with category labels and is trained through the above-mentioned model training method, and will not be described again.
[0137] 605: Perform category prediction based on the first target text feature to obtain a second category prediction probability.
[0138] For example, Figure 7 As shown, the first target text feature can be input into the second classification network for category prediction to obtain the second category prediction probability.
[0139] 606: Extract features of the content to be processed to obtain second target text features corresponding to the image to be processed and third target text features corresponding to the text to be processed.
[0140] For example, Figure 7As shown, the third target feature extraction network includes a second target image feature extraction network and a second target text feature extraction network, as well as a picture-text alignment network. Therefore, the image to be processed can be input into the second target feature extraction network to obtain a second target feature map, and then the second target feature map can be input into the picture-text alignment network to convert the second target feature map into the text space to obtain the second target text feature. At the same time, the text to be processed is input into the second target text feature extraction network for feature extraction to obtain the third target text feature. Therefore, it can be understood that the feature extraction of the content to be processed to obtain the first target feature includes the second target text feature and the third target text feature.
[0141] The third target feature extraction network is trained using labeled training samples through the above-mentioned model training method, and the training samples include texts and images.
[0142] 607: Perform category prediction based on the second target text feature and the third target text feature to obtain a second category prediction probability.
[0143] For example, Figure 7 As shown, the second target text feature and the third target text feature are concatenated to obtain a fourth target text feature. Then, the fourth target text feature is input into the third classification network for category prediction to obtain a third category prediction probability.
[0144] 608: Obtain target category prediction probability based on the first category prediction probability, the second category prediction probability, and the third category prediction probability.
[0145] For example, Figure 7 As shown, the weight W1 corresponding to the first category prediction probability, the weight W2 corresponding to the second category prediction probability, and the weight W3 corresponding to the third category prediction probability are obtained; then, based on the weight W1 corresponding to the first category prediction probability, the weight W2 corresponding to the second category prediction probability, and the weight W3 corresponding to the third category prediction probability, the first category prediction probability, the second category prediction probability, and the third category prediction probability are weighted to obtain the target category prediction probability.
[0146] Exemplarily, the maximum prediction probability corresponding to each training sample in the last round of training of the first target feature extraction network is obtained; based on the maximum prediction probability corresponding to each training sample, the weight corresponding to the first target feature extraction network is determined, for example, the average value of the maximum prediction probability corresponding to each training sample is used as the weight. Similarly, the maximum prediction probability corresponding to each training sample in the last round of training of the second target feature extraction network is obtained; based on the maximum prediction probability corresponding to each training sample, the weight corresponding to the second target feature extraction network is determined; and the maximum prediction probability corresponding to each training sample in the last round of training of the third target feature extraction network is obtained; based on the maximum prediction probability corresponding to each training sample, the weight corresponding to the third target feature extraction network is determined. Then, the weight corresponding to the first target feature extraction network, the weight corresponding to the second target feature extraction network, and the weight corresponding to the third target feature extraction network are normalized to obtain the weight corresponding to the first category prediction probability, the weight corresponding to the second category prediction probability, and the weight corresponding to the third category prediction probability.
[0147] It can be seen that in this embodiment, the maximum prediction probability in the last round of training of each target feature extraction network is used to set weights for each category prediction probability. Since the maximum prediction probability represents the confidence of the model in accurately predicting the category, the weight is set using the maximum prediction probability. The weight of each category prediction probability can be matched with the recognition accuracy of the target feature extraction network corresponding to the category prediction probability, so that the accuracy of the weight set for each category prediction probability is relatively high, thereby making the weighted target category prediction probability more accurate and more convincing, thereby improving the accuracy of content review.
[0148] 609: Based on the predicted probability of the target category, the content to be processed is reviewed.
[0149] Exemplarily, the maximum predicted probability among the target category predicted probabilities is obtained; based on the category corresponding to the maximum predicted probability, the content to be processed is reviewed. For example, the review of the content to be processed is mainly to review whether the content to be processed is legal, and the target category predicted probability includes the probability of being legal and the probability of being illegal. If the maximum predicted probability is illegal, the review result of the content to be processed is determined to be illegal.
[0150] Furthermore, the above category predictions all perform the same category prediction, that is, category prediction is performed on the content of the note, and the category includes but is not limited to: false, discriminatory, illegal, normal, etc.
[0151] It should be noted that the first category network, the second category network and the third category network may be the same or different, and this application does not limit this.
[0152] See also Figure 8 , Figure 8 A schematic diagram of a model training device provided in an embodiment of the present application. The model training device 800 includes: a classification unit 801 and a training unit 802, wherein:
[0153] The classification unit 801 is used to perform a t-th round category prediction on the training sample using the classification model to obtain the category prediction probability of the training sample in the t-th round;
[0154] The training unit 802 is used to determine the soft labels of the training samples in the t-1 round based on the soft labels of the training samples in the t-1 round and the category prediction probabilities in the t-th round, wherein the soft labels are used to indicate the probabilities that the training samples belong to each category; and perform the t-th round training on the classification model based on the soft labels in the t-1 round, the category prediction probabilities in the t-th round and the hard labels of the training samples, wherein the hard labels are used to indicate the categories to which the training samples belong.
[0155] In one embodiment of the present application, in terms of determining the soft label of the training sample in the tth round based on the soft label of the training sample in the t-1th round and the class prediction probability in the tth round, the training unit 802 is specifically configured to:
[0156] Obtaining the maximum prediction probability among the category prediction probabilities of the t-th round;
[0157] Based on the maximum prediction probability, the soft label of the t-1th round and the category prediction probability of the tth round are weighted to obtain the soft label of the tth round.
[0158] In one embodiment of the present application, in performing the t-th round model training based on the t-th round soft label, the t-th round class prediction probability and the hard label of the training sample, the training unit 802 is specifically used to:
[0159] Determining a first cross entropy loss based on the soft label of the t-th round and the class prediction probability of the t-th round;
[0160] Determining a second cross entropy loss based on the soft label of the t-th round, the class prediction probability of the t-th round, and the hard label of the training sample;
[0161] Determining a target cross entropy loss based on the first cross entropy loss and the second cross entropy loss;
[0162] The t-th round of model training is performed based on the target cross entropy loss.
[0163] In one embodiment of the present application, in determining the first cross entropy loss based on the soft label of the t-th round and the category prediction probability of the t-th round, the training unit 802 is specifically configured to:
[0164] Taking the class prediction probability of the t-th round as a supervision label, determining a third cross entropy loss between the soft label of the t-th round and the class prediction probability of the t-th round;
[0165] Taking the soft label of the t-th round as a supervision label, determining a fourth cross entropy loss between the soft label of the t-th round and the class prediction probability of the t-th round;
[0166] The first cross entropy loss is determined based on the third cross entropy loss and the fourth cross entropy loss.
[0167] In one embodiment of the present application, in determining the second cross entropy loss based on the soft label of the tth round, the class prediction probability of the tth round, and the hard label of the training sample, the training unit 802 is specifically used to:
[0168] Based on the soft label of the tth round, the cross entropy loss between the category prediction probability of the tth round and the hard label of the training sample is weighted to obtain the second cross entropy loss.
[0169] In one embodiment of the present application, when t=1, the soft label of the t-1th round is the hard label of the training sample.
[0170] In one embodiment of the present application, the training sample includes at least one of the following: training text, training image, training audio and training video.
[0171] See also Fig. 9 , Fig. 9 A schematic diagram of a task processing device provided in an embodiment of the present application. Fig. 9 As shown, the task processing device 900 includes: an acquisition unit 901 and a processing unit 902, wherein:
[0172] An acquisition unit 901 is used to acquire content to be processed;
[0173] The processing unit 902 is used to extract features of the content to be processed through a target feature extraction network to obtain a first target feature, wherein the target feature extraction network is trained through the above-mentioned model training;
[0174] Perform downstream task processing based on the first target feature.
[0175] See also Fig.10 , Fig.10A schematic diagram of an electronic device provided in an embodiment of the present application. Fig.10 As shown, the electronic device 1000 includes a transceiver 1001, a processor 1002 and a memory 1003. They are connected via a bus 1004. The memory 1003 is used to store computer programs and data, and can transmit the data stored in the memory 1003 to the processor 1002.
[0176] Optionally, the electronic device 1000 may be the model training device 800 or the task processing device 900 described above.
[0177] Optionally, when the electronic device 1000 is the above-mentioned model training device 800, the processor 1002 is used to read the computer program in the memory 1003 to perform the following operations:
[0178] Using the classification model to perform round t category prediction on the training samples, and obtain the category prediction probability of the training samples in round t;
[0179] Determine the soft label of the training sample in the tth round based on the soft label of the training sample in the t-1th round and the class prediction probability in the tth round, wherein the soft label is used to indicate the probability that the training sample belongs to each class;
[0180] Based on the t-th round soft labels, the t-th round category prediction probabilities, and the hard labels of the training samples, the classification model is trained for the t-th round, wherein the hard labels are used to indicate the category to which the training samples belong.
[0181] Specifically, the above-mentioned classification unit 801 and training unit 802 may be different functional modules in the processor 1002. Therefore, the specific functions of the processor 1002 may refer to the specific functions of the above-mentioned classification unit 801 and training unit 802, and will not be described again.
[0182] Optionally, when the electronic device 1000 is the task processing device 900, the processor 1002 is configured to read the computer program in the memory 1003 to perform the following operations:
[0183] Get the content to be processed;
[0184] Extracting features of the content to be processed through a target feature extraction network to obtain a first target feature, wherein the target feature extraction network is trained through the above-mentioned model training;
[0185] Perform downstream task processing based on the first target feature.
[0186] Specifically, the acquisition unit 901 and the processing unit 902 may be different functional modules in the processor 1002. Therefore, the specific functions of the processor 1002 may refer to the specific functions of the acquisition unit 901 and the processing unit 902, and will not be described again.
[0187] It should be understood that the client in this application may include a smart phone, a tablet computer, a PDA, a laptop computer, a mobile Internet device or a wearable device, etc. The above electronic devices are only examples, not exhaustive, and include but are not limited to the above electronic devices. In practical applications, the above electronic devices may also include: smart vehicle terminals, computer devices, etc.
[0188] An embodiment of the present application also provides a computer-readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement part or all of the steps of any model training method or task processing method recorded in the above method embodiments.
[0189] An embodiment of the present application also provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause a computer to execute part or all of the steps of any one of the model training methods or task processing methods recorded in the above method embodiments.
[0190] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required by the present application.
[0191] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0192] In the several embodiments provided in the present application, it should be understood that the disclosed device can be implemented in other ways. For example, the device embodiments described above are only schematic, such as the division of the units, which 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, and the indirect coupling or communication connection of the device or unit can be electrical or other forms.
[0193] 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.
[0194] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above integrated unit may be implemented in the form of hardware or in the form of a software program module.
[0195] If the integrated unit is implemented in the form of a software program module and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a memory, including a number of instructions to enable a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned memory includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or CD-ROM and other media that can store program codes.
[0196] A person skilled in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable memory, and the memory can include: a flash drive, a read-only memory (English: Read-Only Memory, abbreviated as: ROM), a random access memory (English: Random Access Memory, abbreviated as: RAM), a magnetic disk or an optical disk, etc.
[0197] The embodiments of the present application are introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method and core idea of the present application. At the same time, for general technical personnel in this field, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A model training method, characterized in that: include: Using the classification model to perform round t category prediction on the training samples, and obtain the category prediction probability of the training samples in round t; Determine the soft label of the training sample in the tth round based on the soft label of the training sample in the t-1th round and the class prediction probability in the tth round, wherein the soft label is used to indicate the probability that the training sample belongs to each class; Based on the soft labels of the tth round, the category prediction probabilities of the tth round, and the hard labels of the training samples, the classification model is trained for the tth round, wherein the hard labels are used to indicate the category to which the training samples belong.
2. The method according to claim 1, characterized in that The step of determining the soft label of the training sample in the t-1 round based on the soft label of the training sample in the t-1 round and the category prediction probability in the t round includes: Obtaining the maximum prediction probability among the category prediction probabilities of the t-th round; Based on the maximum prediction probability, the soft label of the t-1th round and the category prediction probability of the tth round are weighted to obtain the soft label of the tth round.
3. The method according to claim 1 or 2, characterized in that: The performing the t-th round of model training based on the t-th round of soft labels, the t-th round of category prediction probabilities, and the hard labels of the training samples includes: Determining a first cross entropy loss based on the soft label of the t-th round and the class prediction probability of the t-th round; Determining a second cross entropy loss based on the soft label of the t-th round, the class prediction probability of the t-th round, and the hard label of the training sample; Determining a target cross entropy loss based on the first cross entropy loss and the second cross entropy loss; The t-th round of model training is performed based on the target cross entropy loss.
4. The method according to claim 3, characterized in that The determining of the first cross entropy loss based on the soft label of the t-th round and the category prediction probability of the t-th round includes: Taking the class prediction probability of the t-th round as a supervision label, determining a third cross entropy loss between the soft label of the t-th round and the class prediction probability of the t-th round; Taking the soft label of the t-th round as a supervision label, determining a fourth cross entropy loss between the soft label of the t-th round and the class prediction probability of the t-th round; The first cross entropy loss is determined based on the third cross entropy loss and the fourth cross entropy loss.
5. The method according to claim 3 or 4, characterized in that: The determining a second cross entropy loss based on the soft label of the t-th round, the category prediction probability of the t-th round, and the hard label of the training sample includes: Based on the soft label of the tth round, the cross entropy loss between the category prediction probability of the tth round and the hard label of the training sample is weighted to obtain the second cross entropy loss.
6. The method according to any one of claims 1 to 5, characterized in that: When t=1, the soft label of the t-1th round is the hard label of the training sample.
7. The method according to any one of claims 1 to 6, characterized in that: The training sample includes at least one of the following: training text, training image, training audio and training video.
8. A task processing method, characterized in that: include: Get the content to be processed; Performing feature extraction on the content to be processed through a target feature extraction network to obtain a first target feature, wherein the target feature extraction network is trained by the method according to any one of claims 1 to 7; Perform downstream task processing based on the first target feature.
9. A model training device, characterized in that: include: Classification units and training units; The classification unit is used to perform a t-th round category prediction on the training sample using the classification model to obtain the category prediction probability of the training sample in the t-th round; The training unit is used to determine the soft labels of the training samples in the t-1 round based on the soft labels of the training samples in the t-1 round and the category prediction probabilities in the t round, wherein the soft labels are used to indicate the probabilities that the training samples belong to each category; based on the soft labels in the t-1 round, the category prediction probabilities in the t round and the hard labels of the training samples, perform the t-round training on the classification model, wherein the hard labels are used to indicate the categories to which the training samples belong.
10. A task processing device, characterized in that: include: Acquisition unit and processing unit; The acquisition unit is used to acquire the content to be processed; The processing unit is used to extract features of the content to be processed through a target feature extraction network to obtain a first target feature, wherein the target feature extraction network is trained by the method according to any one of claims 1 to 7; Perform downstream task processing based on the first target feature.
11. An electronic device, characterized in that: include: A processor and a memory, wherein the processor is connected to the memory, the memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory, so that the electronic device executes the method according to any one of claims 1 to 8.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and the computer program is executed by a processor to implement the method according to any one of claims 1 to 8.
