Model training method and device, electronic equipment and readable storage medium
Through the method of teachers-student models and dynamic confidence thresholds, the problem of limited training data in existing technologies has been solved, the diversity and representativeness of the model are realized, and the robustness and practical application performance of the model is improved.
Patent Information
- Application Number
- CN202411270444.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-11
- Publication Date
- 2025-01-28
- Estimated Expiration
- 2044-09-11
AI Technical Summary
The amount of training data available in the prior art is limited, resulting in the model that may lack sufficient diversity and representation, which in turn leads to poor model training results.
The method of using the teacher-student model and dynamic trust threshold to generate pseudo-labels through pre-trained teacher models, and divide the noise voice as a high settlement sample based on the first settlement threshold of the training rotation according to the pseudo-label calculation category. Collection and low -set reliability sample sets to conduct positive and negative learning.
It significantly reduces the cost and time of data preparation and processing, improves the robustness of the model and the performance in the real environment, so that the model can adapt to the true characteristics and changes of the target domain.
Smart Images

Figure CN119378709A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of natural language processing technology, and in particular to a model training method, device, electronic device and readable storage medium. Background Art
[0002] Natural language recognition aims to use machine learning technology to process human language into readable text. During the model training process, a large amount of data needs to be collected and labeled to train the model. However, in practical applications, the distribution of data is constantly changing. For example, people in different places have different accents. Accurately labeling a large amount of data requires a lot of human resources and time. In addition, due to privacy issues in some fields, the original data may not be available or is strictly restricted. These will limit the amount of available training data, resulting in the model may lack sufficient diversity and representativeness, which in turn leads to poor model training results, thereby reducing the model recognition accuracy and robustness, making the model perform poorly in practical applications. Summary of the invention
[0003] In view of this, the present application provides a model training method, device, electronic device and readable storage medium, the main purpose of which is to solve the technical problem in the prior art that the amount of available training data is limited, resulting in the model may lack sufficient diversity and representativeness, and thus leading to poor model training results.
[0004] According to the first aspect of the present application, a model training method is provided, the method comprising:
[0005] Obtain a teacher model, a student model, multiple batches of multiple sample data in a target domain, multiple preset categories, and preset training rounds;
[0006] For any training round, multiple sample data of each batch are input into the teacher model in turn to generate pseudo labels corresponding to each sample data, where the pseudo labels are the confidence distribution of each sample data predicted by the teacher model to belong to multiple preset categories;
[0007] Input multiple sample data of each batch into the student model in turn to generate prediction results corresponding to each sample data, wherein the prediction results are the confidence distribution of each sample data predicted by the student model belonging to multiple preset categories;
[0008] Determine a first confidence threshold for each preset category in each batch based on the pseudo-labels;
[0009] Generate a first high-confidence sample data set corresponding to the teacher model and a second high-confidence sample data set corresponding to the student model according to the multiple sample data, pseudo labels, prediction results and the first confidence threshold;
[0010] Determine a positive loss value and a negative loss value based on the first high confidence sample data set, the second high confidence sample data set, the pseudo label, and the prediction result;
[0011] Update the parameters of the student model based on the positive and negative loss values;
[0012] Update the parameters of the teacher model based on the updated parameters of the student model.
[0013] Optionally, the step of determining a first confidence threshold of each preset category in each batch according to the pseudo-label specifically includes:
[0014] According to the pseudo label of each sample data, calculate the second confidence threshold of each batch;
[0015] According to the pseudo-label of each sample data, calculate the target confidence of each preset category;
[0016] The first confidence threshold of each preset category in each batch is obtained by multiplying the target confidence of each preset category by the second confidence threshold of each batch.
[0017] Optionally, the step of calculating the second confidence threshold of each batch according to the pseudo label of each sample data specifically includes:
[0018] Importing multiple pseudo labels of multiple sample data of each batch into the first preset mapping relationship, and calculating a second confidence threshold of each batch;
[0019] The first preset mapping relationship is:
[0020]
[0021] Among them, the above Ω t,j is the second confidence threshold of the jth batch in the tth training round; the above α is the moving average parameter; the above Ω t,j-1 is the second confidence threshold of the j-1th batch in the tth training round; N is the number of sample data in the jth batch; is the maximum confidence in the pseudo label of the i-th sample data in the j-th batch in the t-th training round.
[0022] Optionally, the step of calculating the target confidence of each preset category according to the pseudo label of each sample data specifically includes:
[0023] Importing the pseudo label of each sample data into the second preset mapping relationship, and calculating the average confidence of each preset category;
[0024] Determine the maximum confidence level of this round of training based on multiple pseudo labels of multiple sample data;
[0025] The target confidence of each preset category is obtained by dividing the average confidence of each preset category by the maximum confidence of this round of training;
[0026] The second preset mapping relationship is:
[0027]
[0028] Among them, the above ∈ c is the average confidence of the c-th preset category; is the pseudo label of the i-th sample data in the t-th training round; is the number of categories whose maximum confidence in the pseudo-label of the i-th sample data in the t-th training round corresponds to the c-th preset category.
[0029] Optionally, the step of generating a first high-confidence sample data set corresponding to the teacher model and a second high-confidence sample data set corresponding to the student model according to the multiple sample data, pseudo labels, prediction results and the first confidence threshold specifically includes:
[0030] For any sample data, according to the pseudo-label of the sample data, determine the maximum confidence in the pseudo-label as the first target confidence of the sample data;
[0031] Using the preset category corresponding to the first target confidence as the first target category of the sample data;
[0032] Obtaining a first target confidence threshold of a first target category of a batch where the sample data resides;
[0033] If the first target confidence of the sample data is greater than or equal to the first target confidence threshold, determining the sample data as a first high confidence sample;
[0034] Generating a first high-confidence sample data set based on a plurality of first high-confidence samples;
[0035] According to the prediction results of the sample data, determining the maximum confidence level in the prediction results as the second target confidence level of the sample data;
[0036] The preset category corresponding to the second target confidence is used as the second target category of the sample data;
[0037] Obtaining a second target confidence threshold of a second target category of the batch where the sample data is located;
[0038] If the second target confidence of the sample data is greater than or equal to the second target confidence threshold, determine that the sample data is a second high confidence sample;
[0039] A second high confidence sample data set is generated based on a plurality of second high confidence samples.
[0040] Optionally, the step of determining the positive loss value and the negative loss value based on the first high confidence sample data set, the second high confidence sample data set, the pseudo label and the prediction result specifically includes:
[0041] Performing positive learning based on the first high confidence sample data set and the second high confidence sample data set to obtain a positive loss value;
[0042] Generate a complementary sample data set according to the pseudo labels of the sample data and a preset threshold vector;
[0043] Negative learning is performed based on the pseudo labels of the sample data in the complementary sample data set and multiple prediction results of multiple sample data to obtain a negative loss value.
[0044] Optionally, the step of performing positive learning based on the first high-confidence sample data set and the second high-confidence sample data set to obtain a positive loss value specifically includes:
[0045] Importing the pseudo labels of the first high-confidence samples included in the first high-confidence sample data set and the prediction results of the second high-confidence samples included in the second high-confidence sample data set into the loss function for positive learning to obtain a positive loss value;
[0046] The loss function is:
[0047]
[0048] Among them, the above is a positive loss value; the above c is a preset category, the above C is the number of preset categories; the above is the pseudo label of the first high confidence sample with preset category c in the first high confidence sample data set; is the prediction result of the second highest confidence sample with preset category c in the second highest confidence sample data set.
[0049] According to a second aspect of the present application, a model training device is provided, the device comprising:
[0050] An acquisition module, used to acquire a teacher model, a student model, multiple batches of multiple sample data in a target domain, multiple preset categories, and preset training rounds;
[0051] A first generation module is used to input multiple sample data of each batch into the teacher model in sequence for any training round, and generate a pseudo label corresponding to each sample data, wherein the pseudo label is a confidence distribution that each sample data predicted by the teacher model belongs to multiple preset categories;
[0052] The second generation module is used to input multiple sample data of each batch into the student model in sequence to generate a prediction result corresponding to each sample data, wherein the prediction result is a confidence distribution that each sample data predicted by the student model belongs to multiple preset categories;
[0053] The first determination module is used to determine a first confidence threshold of each preset category in each batch according to the pseudo-label.
[0054] A third generation module is used to generate a first high-confidence sample data set corresponding to the teacher model and a second high-confidence sample data set corresponding to the student model according to the multiple sample data, pseudo labels, prediction results and the first confidence threshold;
[0055] A second determination module, used to determine a positive loss value and a negative loss value based on the first high confidence sample data set, the second high confidence sample data set, the pseudo label and the prediction result;
[0056] A first updating module, for updating parameters of the student model based on positive loss values and negative loss values;
[0057] A second updating module is used to update the parameters of the teacher model based on the parameters of the updated student model;
[0058] According to a third aspect of the present application, an electronic device is provided, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of any one of the methods described in the first aspect when executing the computer program.
[0059] According to a fourth aspect of the present application, a readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of any one of the methods in the first aspect are implemented.
[0060] By means of the above technical scheme, the present application provides a model training method, device, electronic device and readable storage medium, specifically, using a pre-trained teacher model to generate pseudo labels, and based on the pseudo labels, calculating the first confidence threshold of the category that changes with the training round. The noisy speech is divided into two groups of data, a high-confidence sample set and a low-confidence sample set, using a dynamic first confidence threshold, and then the two groups of data are subjected to positive learning and negative learning to complete the adaptation during the speech recognition test. Compared with the related art, the model training is performed using a large amount of sample data from a normal environment and a fixed confidence threshold. There are technical problems such as high time and resource costs required to collect and label high-quality data, and the fixed threshold may ignore the diversity of the data set, fail to fully utilize the complementarity of different types of data, and weaken the applicability and robustness of the model under different environments or conditions. This application uses unlabeled noisy speech in the target domain as sample data, and adopts the teacher-student model and the idea of dynamic threshold to obtain high-quality pseudo-labels. It does not require denoising of the original data, and does not require denoising and labeling of the sample data, which can significantly reduce the cost and time of data preparation and processing. It combines the dynamic confidence threshold of the category that changes over time for model training, so that the model can learn how to deal with noise conditions in practical applications. As the training progresses, the dynamic threshold can provide feedback on the model's learning status in each category, helping the model to continuously adjust and improve the learning strategy, so that it adapts to the real characteristics and changes of the target domain, and improves the model's robustness and performance in real environments.
[0061] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0062] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present application. Also, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:
[0063] Figure 1 A schematic diagram of a model training method provided in an embodiment of the present application is shown;
[0064] Figure 2 A schematic diagram of another model training method provided in an embodiment of the present application is shown;
[0065] Figure 3 A schematic diagram of the structure of a model training device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0066] The exemplary embodiments of the present application will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present application are shown in the accompanying drawings, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present application and to fully convey the scope of the present application to those skilled in the art.
[0067] The present application embodiment provides a model training method, such as Figure 1 As shown, the method includes:
[0068] S101, obtaining a teacher model, a student model, multiple batches of multiple sample data in a target domain, multiple preset categories, and preset training rounds.
[0069] The model training method provided in the embodiment of the present application is mainly used in natural language recognition model training scenarios under specific scenarios. The executor of the embodiment of the present application is a device or equipment capable of model training, which can be specifically set on the server side. The server uses the target domain data in a specific environment or condition as a sample, and adjusts the model through domain adaptive adjustment so that the model can work better in the target domain.
[0070] Specifically, a pre-trained teacher model is selected, and a student model with the same network structure as the teacher model is constructed to obtain a pre-trained teacher model and a pre-trained student model.
[0071] In order to ensure that the model can adapt to the characteristics and data distribution of specific application scenarios, a target domain is selected based on a specific environment or condition, and a large amount of speech data containing noise (such as speech containing rain sound) in the target domain is obtained, and these speech data are used as sample data. Furthermore, due to the large amount of sample data, during the training process, samples are usually sent to the model for training in batches, and the model makes predictions in each batch. Therefore, a suitable batch size is selected, which determines the number of samples included in each input to the model. The large amount of sample data collected is divided into multiple batches according to the batch size, and each batch contains the same amount of sample data to achieve batch processing of sample data.
[0072] The preset category can be a category label, category description or other relevant features. According to the characteristics of the target domain, multiple categories are defined to ensure that multiple preset categories can fully cover the data distribution of the target domain.
[0073] The training rounds are set in advance, and the teacher model and student model are updated according to the training rounds. Through continuous iteration and adjustment, the model can be continuously improved during the training process to improve the performance and robustness of the model.
[0074] In actual application scenarios, according to the natural language processing task, select a suitable model architecture, prepare a labeled data set under normal environment, and use the data set to train the teacher model. After the training is completed, obtain the parameters of the teacher model, build a learning model with the same network structure as the teacher model, and use the parameters of the teacher model to initialize the student model. Obtain a specific environment (such as rain sound environment, noisy environment, etc.) as the target domain, extract a large amount of speech data in the target domain, perform data cleaning and other preprocessing on the large amount of speech data, and form multiple batches of sample data sets according to the batch size.
[0075] S102. For any training round, multiple sample data of each batch are input into the teacher model in turn to generate a pseudo label corresponding to each sample data, wherein the pseudo label is the confidence distribution that each sample data predicted by the teacher model belongs to multiple preset categories.
[0076] In this step, in the current training round, for any batch, multiple sample data of the current batch are input into the teacher model, and through the forward propagation of the teacher model, the confidence distribution of each sample data belonging to all preset categories is obtained as a pseudo label.
[0077] S103. Input multiple sample data of each batch into the student model in sequence to generate a prediction result corresponding to each sample data, wherein the prediction result is a confidence distribution that each sample data predicted by the student model belongs to multiple preset categories.
[0078] In this step, for any batch, multiple sample data of the current batch are input into the student model, and prediction is performed through the forward propagation process of the student model. The student model outputs the confidence distribution (i.e., prediction result) that each sample data belongs to each preset category.
[0079] S104: Determine a first confidence threshold for each preset category in each batch according to the pseudo-label.
[0080] In this step, the confidence threshold of the category is a set threshold value. Only when the confidence of the model prediction is higher than this threshold, the sample will be classified into this category. In the related art, the confidence threshold of each category is usually pre-set. During the model training process, a fixed confidence threshold is used to determine whether the sample confidence is high enough. However, the fixed threshold cannot adapt to changes in data distribution. If the data distribution changes, the fixed threshold may cause the model's prediction effect on certain categories to decline, affecting the overall performance of the model. Based on the above problems, the present application proposes that as the training process progresses, in each training round, the confidence distribution of the sample belonging to all categories is output by the teacher model, and the first confidence threshold of each preset category in each batch is calculated to achieve dynamic adjustment of the category confidence threshold as the training round changes, which can better adapt to the characteristics of the current batch, better adapt to data changes in real scenes, and ensure that the model learns more accurately for each category.
[0081] S105. Generate a first high-confidence sample data set corresponding to the teacher model and a second high-confidence sample data set corresponding to the student model according to multiple sample data, pseudo labels, prediction results and a first confidence threshold.
[0082] In this step, for any sample data, the maximum confidence predicted by the teacher model and its corresponding category are determined according to the confidence distribution of the sample data in the pseudo-label. The category is the category to which the sample data predicted by the teacher model belongs. Obtain the first confidence threshold corresponding to the category to which the sample belongs in the batch where the sample data is located, compare the maximum confidence of the sample with the first confidence threshold, and if the maximum confidence is greater than or equal to the first confidence threshold, divide the sample data into the first high-confidence sample data set; otherwise, divide the sample data into the low-confidence sample data set. In the above manner, each sample data is divided by the pseudo-label generated by the teacher model and the first confidence threshold of the preset category in each batch to generate a first high-confidence sample data set.
[0083] Furthermore, for any sample data, based on the confidence distribution of the sample data in the prediction results, determine the maximum confidence predicted by the student model and its corresponding category, which is the category to which the sample data predicted by the student model belongs. Obtain the first confidence threshold corresponding to the category in the batch where the sample data is located, compare the maximum confidence with the first confidence threshold, and if the maximum confidence is greater than or equal to the first confidence threshold, divide the sample data into the second high confidence sample data set; otherwise, divide the sample data into the low confidence sample data set. In the above manner, each sample data is divided according to the prediction result generated by the student model and the first confidence threshold of the preset category to generate a second high confidence sample data set.
[0084] Through the above method, based on the pseudo labels generated by the teacher model, the prediction results generated by the student model and the first confidence threshold of the preset category, the samples are divided to obtain high-confidence sample data sets corresponding to the teacher model and the student model respectively, which can effectively improve data quality, optimize training effects and efficiency, enhance the generalization ability of the model, and support data analysis and model improvement.
[0085] S106. Determine a positive loss value and a negative loss value based on the first high confidence sample data set, the second high confidence sample data set, the pseudo labels, and the prediction results.
[0086] In this step, the first high confidence sample data set and the second high confidence sample data set are used for positive learning to calculate the positive loss value. Subsequently, the complementary sample data set is determined using the pseudo label and the preset threshold vector, and the complementary sample data set and the prediction results of the student model are used for negative learning to calculate the negative loss value.
[0087] S107. Update the parameters of the student model based on the positive loss value and the negative loss value.
[0088] S108. Update the parameters of the teacher model based on the updated parameters of the student model.
[0089] In steps S107 and S108, the total loss function is defined using positive loss values and negative loss values, and the total loss function is minimized using an optimization algorithm (such as SGD, Adam, etc.) to update the parameters of the student model. During the training process, a gradient descent algorithm can be applied to calculate the gradient of the parameters, and these gradients are used to adjust the parameters of the student model. After the student model is trained and its parameters are updated, the latest weights of the student model are obtained. Finally, the parameters of the updated student model are used to update the parameters of the teacher model.
[0090] Optionally, after completing the parameter update of the teacher model and the student model, the current round of training is completed, and a new round of training is started according to the above steps until the preset training rounds are reached, and the training of the teacher model and the student model is completed.
[0091] Through the above method, mutual promotion and improvement between the teacher model and the student model can be achieved, which helps to improve the overall performance and robustness of the model.
[0092] The model training method provided in the embodiment of the present application uses a pre-trained teacher model to generate pseudo labels, and based on the pseudo labels, calculates the first confidence threshold of the category that changes with the training round. The noisy speech is divided into two groups of data, a high-confidence sample set and a low-confidence sample set, using a dynamic first confidence threshold. The two groups of data are then subjected to positive learning and negative learning to complete the adaptation during the speech recognition test. Compared with the related art, the model training is performed using a large amount of sample data from a normal environment and a fixed confidence threshold. There are technical problems such as high time and resource costs required to collect and annotate high-quality data, and the fixed threshold may ignore the diversity of the data set, fail to fully utilize the complementarity of different types of data, and weaken the applicability and robustness of the model in different environments or conditions. This application uses unlabeled noisy speech in the target domain as sample data, and adopts the teacher-student model and the idea of dynamic threshold to obtain high-quality pseudo-labels. It does not require denoising of the original data, and does not require denoising and labeling of the sample data, which can significantly reduce the cost and time of data preparation and processing. It combines the dynamic confidence threshold of the category that changes over time for model training, so that the model can learn how to deal with noise conditions in practical applications. As the training progresses, the dynamic threshold can provide feedback on the model's learning status in each category, helping the model to continuously adjust and improve the learning strategy, so that it adapts to the real characteristics and changes of the target domain, and improves the model's robustness and performance in real environments.
[0093] Further, as a refinement and extension of the specific implementation of the above embodiment, in order to fully illustrate the specific implementation process of this embodiment, the embodiment of this application provides another model training method, such as Figure 2 As shown, the method includes:
[0094] S201, obtaining a teacher model, a student model, multiple batches of multiple sample data in a target domain, multiple preset categories, and preset training rounds.
[0095] This step and Figure 1 The method of step S101 shown is the same and will not be repeated here.
[0096] Optionally, before model training, parameters such as multiple batches, preset training rounds, and preset threshold vectors of the model are pre-set.
[0097] S202. For any training round, multiple sample data of each batch are input into the teacher model in turn to generate a pseudo label corresponding to each sample data, wherein the pseudo label is the confidence distribution that each sample data predicted by the teacher model belongs to multiple preset categories.
[0098] This step and Figure 1 The method of step S102 shown is the same and will not be repeated here.
[0099] S203. Input multiple sample data of each batch into the student model in sequence to generate a prediction result corresponding to each sample data, wherein the prediction result is a confidence distribution that each sample data predicted by the student model belongs to multiple preset categories.
[0100] This step and Figure 1 The method of step S103 shown is the same and will not be repeated here.
[0101] S204: Calculate a second confidence threshold for each batch according to the pseudo label of each sample data.
[0102] In this step, during the training process, the data distribution in each batch may be different. By calculating the second confidence threshold of each batch, the sample characteristics of the current batch can be used as the basis for calculating the threshold of subsequent categories, so that the calculated category threshold can adapt to changes in data distribution.
[0103] In the embodiment of the present application, optionally, in order to accurately calculate the second confidence threshold of each batch, step S204, according to the pseudo-label of each sample data, calculates the second confidence threshold of each batch, specifically including: importing multiple pseudo-labels of multiple sample data of each batch into the first preset mapping relationship, and calculating the second confidence threshold of each batch;
[0104] The first preset mapping relationship is:
[0105]
[0106] Among them, the above Ω t,j is the second confidence threshold of the jth batch in the tth training round; the above α is the moving average parameter; the above Ω t,j-1 is the second confidence threshold of the j-1th batch in the tth training round; N is the number of sample data in the jth batch; is the maximum confidence in the pseudo label of the i-th sample data in the j-th batch in the t-th training round.
[0107] Optionally, Ω 0,0 =1 / C, where C is the number of preset categories.
[0108] In this embodiment, the first preset mapping relationship includes the correspondence between the confidence threshold of each batch and the pseudo label of each sample data. The pseudo label of each sample data of the jth batch is imported into the first preset mapping relationship, and then the confidence threshold of each batch is calculated.
[0109] S205: Calculate the target confidence of each preset category according to the pseudo label of each sample data.
[0110] In this step, the average confidence of each preset category is calculated using pseudo labels, and then the target confidence of each preset category is calculated to achieve standardized processing of the confidence of each preset category.
[0111] In an embodiment of the present application, optionally, in order to accurately calculate the target confidence of each preset category, step S205 calculates the target confidence of each preset category based on the pseudo-label of each sample data, specifically including: importing the pseudo-label of each sample data into a second preset mapping relationship, and calculating the average confidence of each preset category; determining the maximum confidence of this round of training based on multiple pseudo-labels of multiple sample data; and obtaining the target confidence of each preset category by dividing the average confidence of each preset category by the maximum confidence of this round of training.
[0112] The second preset mapping relationship is:
[0113]
[0114] Among them, the above ∈ c is the average confidence of the c-th preset category; is the pseudo label of the i-th sample data in the t-th training round; is the number of categories whose maximum confidence in the pseudo-label of the i-th sample data in the t-th training round corresponds to the c-th preset category.
[0115] In this embodiment, the pseudo-label of each sample data of each batch is imported into the second preset mapping relationship, and the average confidence of each preset category is calculated. Thereafter, in the current training round, the maximum confidence in the sample data is screened out, and the average confidence of each preset category is divided by the maximum confidence of the current training round to obtain the target confidence of each preset category.
[0116] In actual application scenarios, Calculate the target confidence for each preset category;
[0117] Among them, the above η t,c is the target confidence of the cth preset category in the tth training round; the above ∈ t,c is the average confidence of the cth preset category in the tth training round; the above max∈ t is the maximum confidence in the tth training round.
[0118] S206. Obtain a first confidence threshold for each preset category in each batch by multiplying the target confidence of each preset category by the second confidence threshold of each batch.
[0119] In this step, the target confidence of each preset category is multiplied by the second confidence threshold of each batch to obtain the first confidence threshold of each preset category in each batch.
[0120] In actual application scenarios, through Ω t,j,c =η t,c Ω t,j Calculate the first confidence threshold of each preset category in each batch; where the above Ω t,j,c is the first confidence threshold of the cth preset category in the jth batch in the tth training round; η t,c is the target confidence of the cth preset category in the tth training round; the above Ω t,j is the second confidence threshold of the j-th batch in the t-th training round.
[0121] S207. Generate a first high-confidence sample data set corresponding to the teacher model and a second high-confidence sample data set corresponding to the student model according to multiple sample data, pseudo labels, prediction results and a first confidence threshold.
[0122] This step and Figure 1 The method of step S105 shown is the same and will not be repeated here.
[0123] In an embodiment of the present application, optionally, in order to accurately generate a first high-confidence sample data set and a second high-confidence sample data set, step S207, based on multiple sample data, pseudo-labels, prediction results and a first confidence threshold, generates a first high-confidence sample data set corresponding to the teacher model and a second high-confidence sample data set corresponding to the student model, specifically including: for any sample data, based on the pseudo-label of the sample data, determining the maximum confidence in the pseudo-label as the first target confidence of the sample data; using the preset category corresponding to the first target confidence as the first target category of the sample data; obtaining the first target confidence threshold of the first target category of the batch where the sample data is located; if the sample data If the first target confidence of the sample data is greater than or equal to the first target confidence threshold, the sample data is determined to be a first high-confidence sample; a first high-confidence sample data set is generated based on multiple first high-confidence samples; according to the prediction result of the sample data, the maximum confidence in the prediction result is determined to be the second target confidence of the sample data; the preset category corresponding to the second target confidence is used as the second target category of the sample data; the second target confidence threshold of the second target category of the batch where the sample data is located is obtained; if the second target confidence of the sample data is greater than or equal to the second target confidence threshold, the sample data is determined to be a second high-confidence sample; and a second high-confidence sample data set is generated based on multiple second high-confidence samples.
[0124] In this embodiment, first, a first target confidence and a corresponding first target category of each sample data are determined.
[0125]
[0126] Among them, the above con t,i is the first target confidence of the i-th sample data; is the maximum confidence in the pseudo label of the i-th sample data in the t-th training round;
[0127]
[0128] Among them, the above c t,i is the target category to which the i-th sample data belongs in the t-th training round; is the first target category corresponding to the maximum confidence in the pseudo-label of the i-th sample data in the t-th training round.
[0129] Secondly, determine the batch to which the sample data belongs, and determine the first target confidence threshold of the target category of the sample data in the batch in the first confidence threshold. t , i(the first target confidence of the i-th sample data in the t-th training round) ≥ (In the tth training round, the first target confidence threshold of the target category in the batch to which the i-th sample data belongs), classify the sample data as the first high confidence sample set Otherwise, it is classified into the low confidence sample set. middle.
[0130] Furthermore, for any sample data, according to the above method, based on the prediction result of the sample data, the maximum confidence in the prediction result is determined as the second target confidence, and the preset category corresponding to the second target confidence is used as the second target category of the sample data. Afterwards, the second target confidence threshold of the second target category of the batch where the sample data is located is obtained. If the second target confidence of the sample data is greater than or equal to the second target confidence threshold, the sample data is divided into the second high confidence sample set. Otherwise, it is classified into the low confidence sample set. middle.
[0131] Optionally, in order to improve the generalization ability of the model, after generating the high-confidence sample data set and the low-confidence sample data set, the predicted distribution of the pseudo labels in the two sets of sample sets is sharpened:
[0132]
[0133] Among them, the above γ is the temperature hyperparameter.
[0134] Afterwards, the sharpened pseudo-label is used as the new pseudo-label of the sample data.
[0135] S208. Determine a positive loss value and a negative loss value based on the first high confidence sample data set, the second high confidence sample data set, the pseudo labels, and the prediction results.
[0136] This step and Figure 1 The method of step S106 shown is the same and will not be repeated here.
[0137] In an embodiment of the present application, optionally, in order to accurately calculate positive loss values and negative loss values, step S208 determines positive loss values and negative loss values based on the first high-confidence sample data set, the second high-confidence sample data set, the pseudo-labels and the prediction results, specifically including: performing positive learning based on the first high-confidence sample data set and the second high-confidence sample data set to obtain positive loss values; generating a complementary sample data set based on the pseudo-labels of the sample data; performing negative learning based on the pseudo-labels of the sample data in the complementary sample data set and the prediction results of multiple sample data to obtain negative loss values.
[0138] In this embodiment, first, positive learning is performed using the first high-confidence sample data set and the second high-confidence sample data set to obtain a positive loss value.
[0139] Afterwards, obtain the pseudo labels in the complementary sample dataset:
[0140]
[0141] Among them, the above is the pseudo label of the sample data in the complementary sample dataset; For the sample data of the cth preset category whose pseudo label is less than or equal to the preset threshold vector, a complementary sample data set is generated; the above α is the preset threshold vector.
[0142] Furthermore, negative learning is performed based on the pseudo labels of the sample data in the complementary sample dataset and the prediction results of the student model to calculate the negative loss value:
[0143]
[0144] Among them, the above is a negative loss value; the above is the pseudo label of the sample data of the cth preset category in the complementary sample data set; is the prediction result of the cth preset category.
[0145] In an embodiment of the present application, optionally, in order to accurately calculate the positive loss value, positive learning is performed based on the first high-confidence sample data set and the second high-confidence sample data set to obtain the positive loss value, specifically including: importing the pseudo label of the first high-confidence sample included in the first high-confidence sample data set and the prediction result of the second high-confidence sample included in the second high-confidence sample data set into the loss function for positive learning to obtain the positive loss value;
[0146] The loss function is:
[0147]
[0148] Among them, the above is a positive loss value; the above is the pseudo label of the sample data category c in the first high confidence sample data set; It is the prediction result of the sample data category c in the second highest confidence sample data set.
[0149] In this embodiment, the pseudo labels of the first high-confidence samples included in the first high-confidence sample data set and the prediction results of the second high-confidence samples included in the second high-confidence sample data set are positively learned to obtain positive loss values.
[0150] S209. Update the parameters of the student model based on the positive loss value and the negative loss value.
[0151] S210. Update the parameters of the teacher model based on the updated parameters of the student model.
[0152] In steps S209 and S210, the total loss value is calculated by the positive loss value and the negative loss value:
[0153]
[0154] Among them, the above is the total loss value; is the positive loss value; the above λ is the weight value between positive loss and negative loss; the above Negative loss value.
[0155] Afterwards, the gradient descent algorithm is used to update the parameters of the student model.
[0156] Furthermore, the parameters of the teacher model are updated using the updated parameters of the student model:
[0157]
[0158] Among them, the above For the teacher model; is the student model; the above t is the training round of the model; the above β is the moving average parameter.
[0159] In order to make the technical problems, technical solutions and beneficial effects solved by the present application more clearly understood, the present application is further described in detail below in conjunction with the embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0160] This application performs adaptation tests on a variety of different types of dataset domains, such as the CHiME-3 dataset, the TED-LIUM2 dataset, the Common Voice dataset, and the Valentini dataset.
[0161] This application uses the LibriSpeech dataset as the source domain dataset, uses the AdamW optimizer to train the model, and applies the cosine annealing learning rate strategy, that is, the learning rate is adjusted by changing the cosine function. In this strategy, the learning rate changes in the form of a cosine function within a cycle, from the initial learning rate to the minimum learning rate, and then returns to the initial learning rate. This adjustment can help the model converge better and avoid falling into a local optimal solution. In this application, the initial learning rate is set to 0.00004 and the final learning rate is set to 0.00002. At the same time, this application uses three different backbone networks to test the generalization ability of the invention: CTC model, Conformer and Transducer.
[0162] This application uses a quantitative approach to evaluate the performance of the method and compares it with the current state-of-the-art methods: Source, NormAdapt, TENT, SHOT and MEMO.
[0163] This application uses word error rate (WER) to evaluate the performance of different models. The lower the value of this parameter, the better the performance. Table 1 (quantitative evaluation results of accuracy on the CHiME-3 test set), Table 2 (quantitative evaluation results of accuracy on the TED-LIUM2 test set), Table 3 (quantitative evaluation results of accuracy on the Common Voice test set) and Table 4 (quantitative evaluation results of accuracy on the Valentini test set) list the quantitative results of the model proposed in this application on the test sets CHiME-3, TED-LIUM2, Common Voice and Valentini. The results show that the model proposed in this application can achieve better results than the existing most advanced models on the CHiME-3, TED-LIUM2, Common Voice and Valentini test sets and three different backbone networks, proving the superiority of this application in versatility and accuracy, and has better application value.
[0164] Table 1
[0165]
[0166] Table 2
[0167]
[0168]
[0169] Table 3
[0170]
[0171] Table 4
[0172]
[0173] Further, as Figure 1 For the specific implementation of the method, the present application embodiment provides a model training device 300, such as Figure 3 As shown, the device includes: an acquisition module 301, a first generation module 302, a second generation module 303, a first determination module 304, a third generation module 305, a second determination module 306, a first update module 307 and a second update module 308.
[0174] An acquisition module 301 is used to acquire a teacher model, a student model, multiple batches of sample data in a target domain, multiple preset categories, and preset training rounds;
[0175] The first generation module 302 is used to input multiple sample data of each batch into the teacher model in sequence for any training round, and generate a pseudo label corresponding to each sample data, wherein the pseudo label is a confidence distribution that each sample data predicted by the teacher model belongs to multiple preset categories;
[0176] The second generation module 303 is used to input the multiple sample data of each batch into the student model in sequence, and generate a prediction result corresponding to each sample data, wherein the prediction result is a confidence distribution that each sample data predicted by the student model belongs to multiple preset categories;
[0177] The first determination module 304 is used to determine a first confidence threshold of each preset category in each batch according to the pseudo-label.
[0178] A third generating module 305, for generating a first high-confidence sample data set corresponding to the teacher model and a second high-confidence sample data set corresponding to the student model according to the multiple sample data, pseudo labels, prediction results and the first confidence threshold;
[0179] A second determination module 306, configured to determine a positive loss value and a negative loss value based on the first high confidence sample data set, the second high confidence sample data set, the pseudo labels, and the prediction results;
[0180] A first updating module 307, for updating parameters of the student model based on the positive loss value and the negative loss value;
[0181] The second updating module 308 is used to update the parameters of the teacher model based on the updated parameters of the student model.
[0182] In a specific application scenario, the first determining module 304 specifically includes:
[0183] A calculation unit, used for calculating a second confidence threshold of each batch according to the pseudo label of each sample data;
[0184] The calculation unit is also used to calculate the target confidence of each preset category according to the pseudo label of each sample data;
[0185] The calculation unit is further configured to obtain a first confidence threshold of each preset category in each batch by multiplying the target confidence of each preset category by the second confidence threshold of each batch.
[0186] In specific application scenarios, the computing unit is specifically used for:
[0187] Importing multiple pseudo labels of multiple sample data of each batch into the first preset mapping relationship, and calculating a second confidence threshold of each batch;
[0188] The first preset mapping relationship is:
[0189]
[0190] Among them, the above Ω t,j is the second confidence threshold of the jth batch in the tth training round; the above α is the moving average parameter of the teacher model; the above Ω t,j-1 is the second confidence threshold of the j-1th batch in the tth training round; N is the number of sample data in the jth batch; is the maximum confidence in the pseudo label of the i-th sample data in the j-th batch in the t-th training round.
[0191] In specific application scenarios, the computing unit is also used for:
[0192] Importing the pseudo label of each sample data into the second preset mapping relationship, and calculating the average confidence of each preset category;
[0193] Determine the maximum confidence level of this round of training based on multiple pseudo labels of multiple sample data;
[0194] The target confidence of each preset category is obtained by dividing the average confidence of each preset category by the maximum confidence of this round of training;
[0195] The second preset mapping relationship is:
[0196]
[0197] Among them, the above ∈ c is the average confidence of the c-th preset category; is the pseudo label of the i-th sample data in the t-th training round; is the number of categories whose maximum confidence in the pseudo-label of the i-th sample data in the t-th training round corresponds to the c-th preset category.
[0198] In a specific application scenario, the third generation module 305 specifically includes:
[0199] A first determining unit is used to determine, for any sample data, based on the pseudo-label of the sample data, the maximum confidence in the pseudo-label as the first target confidence of the sample data;
[0200] A first generating unit, configured to use a preset category corresponding to the first target confidence as a first target category of the sample data;
[0201] A first acquisition unit, used to acquire a first target confidence threshold of a first target category of a batch where the sample data is located;
[0202] A comparison unit, comparing the first target confidence of the sample data with a first target confidence threshold;
[0203] a second determining unit, configured to determine that the sample data is a first high-confidence sample if the first target confidence of the sample data is greater than or equal to a first target confidence threshold;
[0204] A second generating unit, configured to generate a first high-confidence sample data set based on a plurality of first high-confidence samples;
[0205] A third determining unit, configured to determine, based on the prediction result of the sample data, a maximum confidence level in the prediction result as a second target confidence level of the sample data;
[0206] A third generating unit, configured to use the preset category corresponding to the second target confidence as the second target category of the sample data;
[0207] A second acquisition unit, used to acquire a second target confidence threshold of a second target category of the batch where the sample data is located;
[0208] The comparison unit is further used to compare the second target confidence of the sample data with a second target confidence threshold;
[0209] a fourth determination unit, configured to determine that the sample data is a second high confidence sample if the second target confidence of the sample data is greater than or equal to a second target confidence threshold;
[0210] The fourth generating unit is used to generate a second high-confidence sample data set based on multiple second high-confidence samples.
[0211] In a specific application scenario, the second determining module 306 specifically includes:
[0212] A first learning unit is used to perform positive learning based on the first high-confidence sample data set and the second high-confidence sample data set to obtain a positive loss value;
[0213] A fifth generating unit, used to generate a complementary sample data set according to the pseudo label of the sample data and a preset threshold vector;
[0214] The second learning unit is used to perform negative learning according to the pseudo labels of the sample data in the complementary sample data set and multiple prediction results of the multiple sample data to obtain a negative loss value.
[0215] In specific application scenarios, the first learning unit is specifically used for:
[0216] Importing the pseudo labels of the first high-confidence samples included in the first high-confidence sample data set and the prediction results of the second high-confidence samples included in the second high-confidence sample data set into the loss function for positive learning to obtain a positive loss value;
[0217] The loss function is:
[0218]
[0219] Among them, the above is a positive loss value; the above c is a preset category, the above C is the number of preset categories; the above is the pseudo label of the first high confidence sample with preset category c in the first high confidence sample data set; is the prediction result of the second highest confidence sample with preset category c in the second highest confidence sample data set.
[0220] The model training device 300 provided in the embodiment of the present application uses a pre-trained teacher model to generate pseudo labels, and based on the pseudo labels, calculates the first confidence threshold of the category that changes with the training round. The noisy speech is divided into two groups of data, a high-confidence sample set and a low-confidence sample set, using a dynamic first confidence threshold, and then the two groups of data are subjected to positive learning and negative learning to complete the adaptation during the speech recognition test. Compared with the related art, the model training is performed using a large amount of sample data from a normal environment and a fixed confidence threshold. There are technical problems such as high time and resource costs required to collect and annotate high-quality data, and the fixed threshold may ignore the diversity of the data set, fail to fully utilize the complementarity of different types of data, and weaken the applicability and robustness of the model in different environments or conditions. This application uses unlabeled noisy speech in the target domain as sample data, and adopts the teacher-student model and the idea of dynamic threshold to obtain high-quality pseudo-labels. It does not require denoising of the original data, and does not require denoising and labeling of the sample data, which can significantly reduce the cost and time of data preparation and processing. It combines the dynamic confidence threshold of the category that changes over time for model training, so that the model can learn how to deal with noise conditions in practical applications. As the training progresses, the dynamic threshold can provide feedback on the model's learning status in each category, helping the model to continuously adjust and improve the learning strategy, so that it adapts to the real characteristics and changes of the target domain, and improves the model's robustness and performance in real environments.
[0221] In an exemplary embodiment, the present application further provides an electronic device, including a memory and a processor. The memory stores a computer program, and the processor is used to execute the program stored in the memory and execute the model training method in the above embodiment.
[0222] In an exemplary embodiment, the present application also provides a readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the model training method are implemented.
[0223] Through the description of the above implementation methods, those skilled in the art can clearly understand that the present application can be implemented by hardware, or by means of software plus a necessary general hardware platform. Based on such an understanding, the technical solution of the present application can be embodied in the form of a software product, which can be stored in a non-volatile readable storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.), including a number of instructions for enabling an electronic device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each implementation scenario of the present application.
[0224] Those skilled in the art will appreciate that the accompanying drawings are merely schematic diagrams of a preferred implementation scenario, and the modules or processes in the accompanying drawings are not necessarily required for implementing the present application.
[0225] Those skilled in the art will appreciate that the modules in the devices in the implementation scenario can be distributed in the devices in the implementation scenario according to the implementation scenario description, or can be changed accordingly and located in one or more devices different from the implementation scenario. The modules in the above implementation scenario can be combined into one module, or can be further split into multiple units.
[0226] The above application serial numbers are for description only and do not represent the advantages or disadvantages of the implementation scenarios.
[0227] The above disclosure only discloses several specific implementation scenarios of the present application. However, the present application is not limited thereto, and any changes that can be conceived by technicians in this field should fall within the scope of protection of the present application.
Claims
1. A model training method, characterized in that: include: Obtain a teacher model, a student model, multiple batches of sample data in a target domain, multiple preset categories, and preset training rounds; For any training round, multiple sample data of each batch are sequentially input into the teacher model to generate pseudo labels corresponding to each sample data, wherein the pseudo labels are the confidence distribution of each sample data predicted by the teacher model to belong to the multiple preset categories; Inputting the multiple sample data of each batch into the student model in sequence, generating a prediction result corresponding to each sample data, wherein the prediction result is a confidence distribution of each sample data predicted by the student model to belong to the multiple preset categories; Determining a first confidence threshold of each preset category in each batch according to the pseudo-label; Generate a first high-confidence sample data set corresponding to the teacher model and a second high-confidence sample data set corresponding to the student model according to the multiple sample data, the pseudo labels, the prediction results and the first confidence threshold; Determine a positive loss value and a negative loss value based on the first high confidence sample data set, the second high confidence sample data set, the pseudo label and the prediction result; updating parameters of the student model based on the positive loss value and the negative loss value; Update the parameters of the teacher model based on the updated parameters of the student model.
2. The method according to claim 1, characterized in that The step of determining the first confidence threshold of each preset category in each batch according to the pseudo-label specifically includes: Calculate a second confidence threshold for each batch according to the pseudo label of each sample data; Calculating the target confidence of each preset category according to the pseudo label of each sample data; The first confidence threshold of each preset category in each batch is obtained by multiplying the target confidence of each preset category by the second confidence threshold of each batch.
3. The method according to claim 2, characterized in that The step of calculating the second confidence threshold of each batch according to the pseudo label of each sample data specifically includes: Importing the plurality of pseudo labels of the plurality of sample data of each batch into the first preset mapping relationship, and calculating the second confidence threshold of each batch; The first preset mapping relationship is: Among them, the above Ω t,j is the second confidence threshold of the jth batch in the tth training round; the above α is the moving average parameter; the above Ω t,j-1 is the second confidence threshold of the j-1th batch in the tth training round; N is the number of sample data in the jth batch; is the maximum confidence in the pseudo label of the i-th sample data in the j-th batch in the t-th training round.
4. The method according to claim 2, characterized in that: The step of calculating the target confidence of each preset category according to the pseudo label of each sample data specifically includes: Importing the pseudo label of each sample data into a second preset mapping relationship, and calculating the average confidence of each preset category; Determine the maximum confidence level of this training round based on multiple pseudo labels of multiple sample data; Obtain the target confidence of each preset category by dividing the average confidence of each preset category by the maximum confidence of this round of training; The second preset mapping relationship is: Among them, the above ∈ c is the average confidence of the c-th preset category; is the pseudo label of the i-th sample data in the t-th training round; is the number of categories whose maximum confidence in the pseudo-label of the i-th sample data in the t-th training round corresponds to the c-th preset category.
5. The method according to claim 1, characterized in that The step of generating a first high-confidence sample data set corresponding to the teacher model and a second high-confidence sample data set corresponding to the student model according to the multiple sample data, the pseudo labels, the prediction results and the first confidence threshold specifically includes: For any sample data, according to the pseudo-label of the sample data, determine the maximum confidence in the pseudo-label as the first target confidence of the sample data; Using the preset category corresponding to the first target confidence as the first target category of the sample data; Obtaining a first target confidence threshold of the first target category of the batch where the sample data is located; If the first target confidence of the sample data is greater than or equal to the first target confidence threshold, determine that the sample data is a first high-confidence sample; Generating the first high-confidence sample data set based on a plurality of first high-confidence samples; According to the prediction results of the sample data, determining the maximum confidence level in the prediction results as the second target confidence level of the sample data; Using the preset category corresponding to the second target confidence as the second target category of the sample data; Obtaining a second target confidence threshold of the second target category of the batch where the sample data is located; If the second target confidence of the sample data is greater than or equal to the second target confidence threshold, determine that the sample data is a second high confidence sample; The second high-confidence sample data set is generated based on a plurality of second high-confidence samples.
6. The method according to claim 1, characterized in that The step of determining the positive loss value and the negative loss value based on the first high confidence sample data set, the second high confidence sample data set, the pseudo label and the prediction result specifically includes: Performing positive learning based on the first high-confidence sample data set and the second high-confidence sample data set to obtain the positive loss value; Generate a complementary sample data set according to the pseudo labels of the sample data and a preset threshold vector; Negative learning is performed according to the pseudo labels of the sample data in the complementary sample data set and multiple prediction results of the multiple sample data to obtain the negative loss value.
7. The method according to claim 6, characterized in that The step of performing positive learning based on the first high-confidence sample data set and the second high-confidence sample data set to obtain the positive loss value specifically includes: Importing the pseudo labels of the first high-confidence samples included in the first high-confidence sample data set and the prediction results of the second high-confidence samples included in the second high-confidence sample data set into the loss function for positive learning to obtain a positive loss value; The loss function is: Among them, the above is a positive loss value; the above c is a preset category, the above C is the number of preset categories; the above is the pseudo label of the first high confidence sample with preset category c in the first high confidence sample data set; is the prediction result of the second highest confidence sample with preset category c in the second highest confidence sample data set.
8. A model training device, characterized in that: include: An acquisition module, used to acquire a teacher model, a student model, multiple batches of multiple sample data in a target domain, multiple preset categories, and preset training rounds; A first generating module is used for, for any training round, sequentially inputting a plurality of sample data of each batch into the teacher model to generate a pseudo label corresponding to each sample data, wherein the pseudo label is a confidence distribution that each sample data predicted by the teacher model belongs to the plurality of preset categories; A second generating module is used to input the multiple sample data of each batch into the student model in sequence, and generate a prediction result corresponding to each sample data, wherein the prediction result is a confidence distribution of each sample data predicted by the student model to belong to the multiple preset categories; A first determination module, configured to determine a first confidence threshold of each preset category in each batch according to the pseudo-label; A third generating module, configured to generate a first high-confidence sample data set corresponding to the teacher model and a second high-confidence sample data set corresponding to the student model according to the multiple sample data, the pseudo labels, the prediction results and the first confidence threshold; A second determination module, configured to determine a positive loss value and a negative loss value based on the first high-confidence sample data set, the second high-confidence sample data set, the pseudo label, and the prediction result; A first updating module, configured to update parameters of a student model based on the positive loss value and the negative loss value; The second updating module is used to update the parameters of the teacher model based on the parameters of the updated student model.
9. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When a processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Student model training method and device, computer equipment and storage medium
CN112749728A
Self-supervised speaker model training method, electronic equipment and storage medium
CN114707668A
Semi-supervised target detection method based on teach-student model
CN115115886A
Named entity recognition method and device, equipment and storage medium
CN115713082A
Pseudo-label unsupervised data training method and device, equipment and medium
CN116912624A