Text processing model training method and device, equipment and storage medium
By expanding and updating the sample set of text processing models in the medical field, the problems of difficulty in data acquisition and scarcity of annotation resources are solved, and the training effect and prediction accuracy of the model are improved.
Patent Information
- Application Number
- CN202411855091.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-17
- Publication Date
- 2025-01-14
AI Technical Summary
In the medical field, difficulties in obtaining data and scarce labeling resources lead to difficulties in training text processing models.
By obtaining the sample set, the first text processing model to be trained is trained based on the text sample data in the sample set, the sample data to be amplified is determined, and the sample data to be amplified is amplified through the trained second text processing model, The sample set is updated, and finally the first text processing model is continued to be trained based on the updated sample set.
It solves the problem of scarce text sample data acquisition and annotation resources in the medical field, increases the number of sample sets required for model training, and improves the prediction accuracy of the model.
Smart Images

Figure CN119312096A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a training method, device, equipment and storage medium for a text processing model. Background Art
[0002] With the development of artificial intelligence and big data technologies, the field of medical consultation increasingly relies on artificial intelligence technology to understand and match user conversations to provide personalized services.
[0003] In the existing technology, large-parameter models are valued for their powerful general and generative capabilities. These models are able to handle complex tasks such as natural language processing and image recognition, bringing new solutions to the medical field. Specifically, through natural language understanding and generation technology, large-parameter models can understand and classify user inputs, assisting doctors in making diagnosis and treatment decisions. At the same time, small-parameter models have also shown their unique advantages in specific fields due to their lightweight and fast response characteristics. They can be integrated into mobile devices or edge computing devices to provide instant data processing and analysis without relying on large-scale computing resources. The flexibility and cost-effectiveness of small-parameter models make them of great application value in resource-constrained environments, such as telemedicine and emergency response scenarios.
[0004] However, although large parameter models have strong general capabilities, they require high computing resources, which is impractical in a medical environment with limited resources, and the understanding ability of large parameter models in some vertical fields is not satisfactory. At the same time, although small parameter models have lower computing resource requirements and perform better in vertical fields, they require more training data for secondary training, which is also difficult to achieve in the medical field where data acquisition is difficult and annotation resources are scarce. Summary of the invention
[0005] The present invention provides a training method, device, equipment and storage medium for a text processing model to solve the problem of difficulty in training a text processing model when data acquisition in the medical field is difficult and annotation resources are scarce.
[0006] According to one aspect of the present invention, a method for training a text processing model is provided, the method comprising:
[0007] Obtain a sample set, the sample set including text sample data;
[0008] Based on the text sample data in the sample set, the first text processing model to be trained is trained, and the sample data to be amplified in the text sample data is determined; the processed data obtained by processing the sample data to be amplified by the first text processing model satisfies the first set condition;
[0009] Performing amplification processing on the sample data to be amplified by using the trained second text processing model to obtain at least one amplified sample data, and updating the sample set based on the amplified sample data;
[0010] The first text processing model continues to be trained based on the updated sample set until a trained first text processing model is obtained.
[0011] According to another aspect of the present invention, there is provided a training device for a text processing model, the device comprising:
[0012] A sample set acquisition module is used to acquire a sample set, wherein the sample set includes text sample data;
[0013] The module for determining sample data to be amplified is used to train the first text processing model to be trained based on the text sample data in the sample set, and determine the sample data to be amplified in the text sample data; the processed data obtained by processing the sample data to be amplified by the first text processing model meets the first set condition;
[0014] A sample set updating module, configured to perform amplification processing on the sample data to be amplified by using the trained second text processing model to obtain at least one amplified sample data, and update the sample set based on the amplified sample data;
[0015] The first text processing model training module is used to continue training the first text processing model based on the updated sample set until a trained first text processing model is obtained.
[0016] According to another aspect of the present invention, there is provided an electronic device, the electronic device comprising:
[0017] at least one processor; and
[0018] a memory communicatively connected to at least one processor; wherein,
[0019] The memory stores a computer program that can be executed by at least one processor, and the computer program is executed by at least one processor so that the at least one processor can execute the training method of the text processing model provided in any embodiment of the present invention.
[0020] According to another aspect of the present invention, a computer-readable storage medium is provided, which stores computer instructions, and the computer instructions are used to implement the training method of the text processing model provided by any embodiment of the present invention when executed by a processor.
[0021] The technical solution of the embodiment of the present invention is as follows: a sample set is obtained, wherein the sample set includes text sample data; a first text processing model to be trained is trained based on the text sample data in the sample set, and sample data to be amplified in the text sample data is determined; the processed data obtained by processing the sample data to be amplified by the first text processing model satisfies a first set condition; the sample data to be amplified is amplified by a trained second text processing model to obtain at least one amplified sample data, and the sample set is updated based on the amplified sample data; the first text processing model is continuously trained based on the updated sample set until a trained first text processing model is obtained, thereby solving the problems of difficulty in acquiring data in the medical field and scarcity of annotation resources during model training, increasing the number of sample sets required for training the first text processing model, and improving the accuracy of the first text processing model.
[0022] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0024] Figure 1 is a flowchart of a method for training a text processing model provided in Embodiment 1 of the present invention;
[0025] Figure 2 is a structural diagram of a first text processing model provided by an embodiment of the present invention;
[0026] Figure 3 is a structural schematic diagram of a second text processing model provided by an embodiment of the present invention;
[0027] Figure 4 is a flowchart of a training method for a text processing model provided in Embodiment 2 of the present invention;
[0028] Figure 5 It is a structural schematic diagram of a training device for a text processing model provided in Embodiment 3 of the present invention;
[0029] Figure 6 It is a structural schematic diagram of an electronic device provided in Embodiment 4 of the present invention. DETAILED DESCRIPTION
[0030] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0031] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. 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 necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0032] Embodiment 1
[0033] Figure 1 This is a flowchart of a text processing model training method provided in the first embodiment of the present invention. This embodiment is applicable to the case where a text processing model is trained when a sample set is limited. The method can be executed by a text processing model training device. The text processing model training device can be implemented in the form of hardware and / or software. The text processing model training device can be configured in an electronic device provided in the embodiment of the present invention. The electronic device can be a server, a computer, a mobile terminal, etc. For example, the mobile terminal can include a mobile phone, a tablet computer, etc. Figure 1 As shown, the method includes:
[0034] S110: Obtain a sample set, where the sample set includes text sample data.
[0035] In this embodiment, the text sample data may include sample data of text type, which is used to train the first text processing model. The sample set can be set according to the application scenario of the first processing model. In different application scenarios, different text sample data are used to train the first text processing model. For example, the application scenario may be a question-and-answer scenario, and the text sample data may be a question-and-answer pair consisting of a question and a corresponding answer. Exemplarily, it may be a question-and-answer scenario in the medical field, and the text sample data may be a question-and-answer pair consisting of an input text of the medical scenario and a corresponding label. The text sample data may include long sentences and / or short sentences, which may be set according to the requirements of the application scenario.
[0036] The sample set may be a set of multiple text sample data. Since the sample set collection is difficult, the number of collected sample sets is relatively small. The sample set can be obtained by reading from a database, wherein the database stores historically collected text sample data. The historically collected text sample data may include questions and corresponding answers recorded during the question-and-answer process. The user's data may also be manually collected in the form of question-and-answer.
[0037] Optionally, the sample set may include a small sample amount of initial text sample data, where the initial text sample data is historical sample data actually collected in the application scenario.
[0038] It can be understood that in this embodiment, based on a sample set with a small sample size, in the process of training the first text processing model, the sample set is gradually amplified to obtain an amplified sample set. Correspondingly, the amplified sample set includes initial text sample data and amplified sample data, and the amplified sample data is newly added sample data. In this embodiment, the sample set amplification process can include amplification of one training round, or amplification of multiple training rounds, which can be set according to user needs and is not limited here. Therefore, the sample set can be the initial sample set, or it can be a sample set after any round of amplification. Exemplarily, for the first training round, the sample set can include the initial text sample data; for the intermediate training rounds, the sample set can include the initial text sample data and the amplified sample data obtained by completing the training round amplification.
[0039] S120, training a first text processing model to be trained based on the text sample data in the sample set, and determining sample data to be amplified in the text sample data; the processed data obtained by processing the sample data to be amplified by the first text processing model meets a first set condition.
[0040] In this embodiment, a first text processing model to be trained is created in advance, model parameters of the first text processing model to be trained are initialized, and the initialized first text processing model is trained based on the text sample data in the sample set to obtain a trained first text processing model. The first text processing model can be a transformer encoder model and its variants. Optionally, the first text processing model can include one or more of a Bert encoder, a Robert encoder, and a Bart encoder, which can be selected according to user needs. For example, different application scenarios can use first text processing models with different structures, which is not limited here.
[0041] For example, see Figure 2 , Figure 2It is a structural schematic diagram of a first text processing model provided by an embodiment of the present invention. The first text processing model includes a word segmenter, an embedding layer, a hidden state, a first text processing layer, a layer normalization, a linear layer, a loss layer and an output layer connected in sequence, wherein the embedding layer includes sequence embedding and position embedding. The word segmenter can divide the text sample data into word segments of a preset length to form a word segmentation list. The embedding layer can map the input word segments into vectors in a high-dimensional space. In order to distinguish word segments at different positions, the word embedding vector obtained by sequence embedding and the position encoding vector obtained by position embedding are added and input into the embedding layer to obtain a word embedding vector including position information. The first text processing layer is the core part of the first text processing model, including a multi-head attention mechanism and a feedforward neural network, which can capture the complex relationship between the input word embedding vectors. Layer normalization can be used to improve the training stability and speed up the training of the first text processing model. The linear layer can be used to perform a linear transformation on the input data. The text sample data in the sample set are respectively input into the first text processing model, and are processed by the word segmenter to obtain multiple word segments of preset lengths. The multiple word segments of preset lengths are numbered respectively and input into the embedding layer to obtain multiple word embedding vectors including position information. The hidden state is input into the first text processing layer for processing to obtain the features of multiple word embedding vectors. After layer normalization and linear layer processing, the prediction results are output.
[0042] Optionally, the sample data to be augmented may be text sample data of a set proportion sampled from a sample set when the number of sample sets is small, and the sampled text sample data is determined as the sample data to be augmented.
[0043] Optionally, the sample data to be amplified may be text sample data that is not clearly predicted or is not accurately predicted by the first text processing model, and the sample data to be amplified is text sample data to be further learned. Wherein, the sample data to be amplified is text sample data that is not accurately predicted by the first text processing model, which can be understood as the prediction result of the first text processing model for the sample data to be amplified and the label of the sample data to be amplified are greatly different, that is, the sample data to be amplified may be text sample data whose loss function value is greater than the first set threshold value during the processing of the first text processing model. The sample data to be amplified is text sample data that is not clearly predicted by the first text processing model, which can be understood as the confidence of multiple prediction results is similar during the processing of the sample data to be amplified by the first text processing model, and the prediction result corresponding to the sample data to be amplified cannot be accurately predicted, that is, the sample data to be amplified may be text sample data whose confidence difference of each prediction result is less than the second set threshold value during the processing of the first text processing model.
[0044] The first set condition can be understood as a judgment condition for whether the text sample data belongs to the sample data to be amplified. During the training process of the first text processing model, the processing data of each text sample data can be obtained. For the processing data of each text sample data, the text sample data is judged based on the first set condition to determine whether the text sample data is the sample data to be amplified. For example, the first set condition can be that the difference between the processing data of each text sample data is less than a preset threshold, and the difference between the processing data of each text sample data is calculated. When the difference is less than the preset threshold, it means that the first text processing model does not clearly predict the text sample data, and the text sample data can be determined as the sample data to be amplified. For another example, the first set condition can also be that the loss value corresponding to the text sample data exceeds the set threshold, and the loss function value corresponding to each text sample data is calculated. When the loss function value exceeds the set threshold, it means that the first text processing model does not accurately predict the text sample data, and the text sample data can be determined as the sample data to be amplified.
[0045] The processed data may include data obtained during the processing of the text sample data by the first text processing model. For example, the processed data may be the input or output of a setting layer in the first text processing model. Optionally, the setting layer may include an output layer of the first text processing model. The text sample data in the sample set is input into the first text processing model to be trained for processing, and the processed data of each text sample data can be obtained. The processed data of each text sample data is determined according to the first setting condition, and the text sample data corresponding to the processed data that meets the first setting condition is determined as the sample data to be amplified.
[0046] Optionally, determining sample data to be amplified in text sample data includes: inputting the text sample data into a first text processing model to be trained, obtaining processed data generated by the first text processing model to be trained in the process of processing the text sample data, the processed data being input data corresponding to an output layer of the first text processing model to be trained; the processed data including confidence data of the text sample data on multiple prediction results; determining a prediction result probability entropy corresponding to the text sample data based on the confidence data on multiple prediction results in the processed data; and determining the text sample data as sample data to be amplified when the prediction result probability entropy corresponding to the text sample data is greater than a first threshold.
[0047] Specifically, the processed data may be data that has not been normalized during the processing of the first text processing model, for example, it may be a logits value. The output layer is the last layer in the first text processing model that processes data, and may be used for normalization of input data, for example, it may be a softmax layer. The confidence data may characterize the confidence of the text sample data on each prediction result, and the confidence data may be a probability value or a score value characterizing the confidence. The processed data may include confidence data of multiple prediction results. It is understandable that during the processing of the text sample data by the first text processing model, multiple prediction results and confidence data corresponding to the multiple prediction results may be obtained, and the first text processing model may output the prediction result corresponding to the maximum confidence data as the processing result of the text sample data.
[0048] The prediction result probability entropy can characterize the probability entropy of the text sample data on all prediction results. The first threshold can be a threshold in the first setting condition, which can be used to determine whether the text sample data is determined as the sample data to be amplified. The first setting condition here includes that the prediction result probability entropy is greater than the first threshold.
[0049] Confidence data on multiple prediction results in the processed data are calculated based on the input data corresponding to the output layer of the first text processing model to be trained, and the probability entropy of the prediction results corresponding to the text sample data is calculated based on the confidence data. Exemplarily, based on the processed data of the text sample data, the confidence data corresponding to the multiple prediction results of the text sample data are obtained, and the number of prediction results can be n. The sum of the confidence data of the text sample data on multiple prediction results is obtained, and the ratio of the confidence data of the text sample data on the i-th prediction result to the sum of the confidence data of the text sample data on the multiple prediction results is determined, and the ratio is the probability distribution value of the text sample data on the i-th prediction result. The probability distribution values corresponding to the text sample data on the multiple prediction results are determined respectively. Based on the logarithm operation of the probability distribution values of the text sample data on the multiple prediction results, the intermediate logarithm data is obtained, and based on the probability distribution values of the text sample data on the multiple prediction results and the corresponding intermediate logarithm data, the probability entropy of the prediction results of the text sample data can be obtained. The calculation formulas of the probability distribution value and the probability entropy of the prediction result are as follows:
[0050] ;
[0051] ;
[0052] in, Represents the probability distribution value of the text sample data x on the prediction result, represents the logits value of the first text processing model to be trained, Represents the confidence data of the text sample data x in the i-th prediction result, represents the prediction result probability entropy corresponding to the text sample data x, and n represents the number of prediction results corresponding to the text sample data x. Compare the size between the prediction result probability entropy and the first threshold value, and when the prediction result probability entropy is greater than the first threshold value, the text sample data is determined as the sample data to be amplified. Exemplarily, the first threshold value is 0.65, and the prediction result probability entropy of the text sample data x is 0.7. Since the prediction result probability entropy is greater than the first threshold value, the text sample data x can be determined as the sample data to be amplified.
[0053] In the process of processing the text sample data by the first text processing model, the text sample data is trained for multiple training rounds, and the sample data to be amplified in the text sample data can be determined according to the probability entropy of the prediction results of the multiple training rounds.
[0054] Optionally, the method also includes: obtaining prediction result probability entropy of text sample data in multiple training rounds, and determining the number of rounds in which the prediction result probability entropy in multiple training rounds exceeds a second threshold; based on the total number of training rounds and the number of rounds in which the prediction result probability entropy in multiple training rounds exceeds the second threshold, determining a first proportion value in which the prediction result probability entropy in multiple training rounds exceeds the second threshold; when the first proportion value is greater than a third threshold, determining the text sample data as sample data to be amplified.
[0055] The first text processing model to be trained can perform multiple training rounds on the acquired text sample data, and in each training round, the first text processing model to be trained processes each text sample data. Specifically, the second threshold value can be a threshold value in the first setting condition, for example, it can be a probability value. The first ratio value can characterize the ratio of the number of rounds in which the probability entropy of the prediction result exceeds the second threshold value in the total number of training rounds. For example, the first ratio value can be obtained by counting the number of rounds in which the probability entropy of the prediction result exceeds the second threshold value in the training rounds, and calculating the ratio between it and the total number of training rounds. The third threshold value can be a threshold value in the first setting condition, which can be used to determine whether the text sample data is determined as the sample data to be amplified. For example, when the first ratio value is greater than the third threshold value, the text sample data can be determined as the sample data to be amplified. The first setting condition here includes that the first ratio value of the probability entropy of the prediction result exceeds the second threshold value is greater than the third threshold value. The first threshold value, the second threshold value and the third threshold value can all be threshold values in the first setting condition, and can all be adaptively changed according to the change of the first setting condition. According to the total number of training rounds and the number of rounds in which the probability entropy of the prediction results in multiple training rounds exceeds the second threshold, a first proportion value of the probability entropy of the prediction results in multiple training rounds exceeding the second threshold is calculated, which can be calculated by the following formula:
[0056] ;
[0057] in, Indicates that the text sample data x exceeds the second threshold in the prediction result probability entropy The first proportional value at Represents the probability entropy of the prediction result corresponding to the text sample data x, represents the total number of training rounds of the first text processing model to be trained, and n represents the number of prediction results corresponding to the text sample data x. Compare the first ratio value and the third threshold value, and when the first ratio value is greater than the third threshold value, the text sample data is determined as the sample data to be amplified. Exemplarily, the third threshold value is 0.7, and the first ratio value of the text sample data x is 0.75. Since the first ratio value is greater than the third threshold value, the text sample data x can be determined as the sample data to be amplified.
[0058] S130 , performing amplification processing on the sample data to be amplified by using the trained second text processing model to obtain at least one amplified sample data, and updating the sample set based on the amplified sample data.
[0059] In this embodiment, the parameter amount of the first text processing model is less than the parameter amount of the second text processing model, the first text processing model can be a lightweight model, and the second text processing model can be a model with a complex structure, wherein the processing result of the second text processing model is accurate, and can provide accurate text sample data for the training of the first text processing model, omitting the collection process of the sample set, and simplifying the collection process of the text sample data. The second text processing model can be a decoder model and its variants in the transformer model. Optionally, the second text processing model can include one or more of the LlaMa decoder and the Qwen decoder, which can be selected according to user needs, and is not limited here. The amplified sample data can be the data obtained by processing the sample data to be amplified by the trained second text processing model. The amplified sample data is added to the sample set, and the sample set is updated. The updated sample set includes the text sample data and the amplified sample data.
[0060] For example, see Figure 3 , Figure 3It is a structural schematic diagram of a second text processing model provided by an embodiment of the present invention. The second text processing model includes a word segmenter, an embedding layer, a hidden state, a second text processing layer, RMS normalization, a linear layer and an output layer connected in sequence. The word segmenter can divide the text sample data into word segments of a preset length to form a word segmentation list. The embedding layer can be used to convert the input word segments into word vectors of fixed dimensions. The second text processing layer is the core part of the second text processing model, including a masked attention mechanism and a feedforward neural network, which can capture the features between the input word vectors. The RMS normalization layer can be used to fuse the input features to reduce the problem of gradient disappearance or gradient explosion. The linear layer can be used to linearly transform the features that have passed the RMS normalization layer and output the amplified sample data. The sample data to be amplified are respectively input into the second text processing model, processed by the word segmenter to obtain multiple word segments of preset length, the multiple word segments of preset length are numbered respectively, and input into the embedding layer to obtain multiple word vectors of fixed dimensions, the multiple word vectors of fixed dimensions are input into the second text processing layer through the hidden state for processing, and the features of the multiple word vectors of fixed dimensions are obtained, and the amplified sample data are output after RMS normalization and linear layer processing.
[0061] Optionally, the text sample data is provided with original labels.
[0062] Specifically, the original label can represent the theoretical processing result corresponding to the text sample data. For example, in a question-and-answer scenario, the original label can be the answer data corresponding to the text sample data. For example, when the text sample data is the user's main complaint text data, the original label can include the name of the drug, the doctor of the specific department of the hospital, and the type of disease. The original label can be obtained in a variety of ways. Optionally, the original label of the text sample data can be pre-set. Specifically, the original label of the acquired text sample data can be set manually. Optionally, the original label of the text sample data can also be that when the text sample label is the amplified sample data, the amplified sample data is processed based on the first text processing model to obtain a prediction result, and the prediction result is used as the original label of the amplified sample data.
[0063] S140: Continue training the first text processing model based on the updated sample set until a trained first text processing model is obtained.
[0064] In this embodiment, the updated sample set is input into the first text processing model, the first text processing model is trained, and the model parameters of the first text processing model are adjusted until the prediction effect of the first text processing model on the updated sample set reaches the training end condition. For example, the training end condition may be that each text sample data in the updated sample set reaches the total number of training rounds, the training end condition may also be that the loss function of the first text processing model reaches a converged state, and the training end condition may also be that the prediction accuracy of the first text processing model reaches a preset threshold. When the prediction effect of the first text processing model on the updated sample set reaches one or more of the above-mentioned training end conditions, the training of the first text processing model is terminated.
[0065] The technical solution of this embodiment is as follows: a sample set is obtained, wherein the sample set includes text sample data; a first text processing model to be trained is trained based on the text sample data in the sample set, and sample data to be amplified in the text sample data is determined; the processed data obtained by processing the sample data to be amplified by the first text processing model satisfies a first set condition; the sample data to be amplified is amplified by a trained second text processing model to obtain at least one amplified sample data, and the sample set is updated based on the amplified sample data; the first text processing model is continuously trained based on the updated sample set until a trained first text processing model is obtained, which solves the problems of difficulty in obtaining text sample data in the medical field and scarcity of original labels during model training, increases the number of sample sets required for training the first text processing model, and improves the accuracy of prediction by the first text processing model.
[0066] Embodiment 2
[0067] Figure 4 1 is a flowchart of a text processing model training method provided by the second embodiment of the present invention, which is optimized on the basis of the above embodiment. In this embodiment, the first text processing model is trained by signature verification. Figure 4 As shown, the method includes:
[0068] S210: Acquire a sample set, where the sample set includes text sample data.
[0069] S220, training a first text processing model to be trained based on the text sample data in the sample set, and determining sample data to be amplified in the text sample data; the processed data obtained by processing the sample data to be amplified by the first text processing model meets a first set condition.
[0070] Optionally, determining sample data to be amplified in text sample data includes: inputting the text sample data into a first text processing model to be trained, obtaining processed data generated by the first text processing model to be trained in the process of processing the text sample data, the processed data being input data corresponding to an output layer of the first text processing model to be trained; the processed data including confidence data of the text sample data on multiple prediction results; determining a prediction result probability entropy corresponding to the text sample data based on the confidence data on multiple prediction results in the processed data; and determining the text sample data as sample data to be amplified when the prediction result probability entropy corresponding to the text sample data is greater than a first threshold.
[0071] Optionally, the method also includes: obtaining prediction result probability entropy of text sample data in multiple training rounds, and determining the number of rounds in which the prediction result probability entropy in multiple training rounds exceeds a second threshold; based on the total number of training rounds and the number of rounds in which the prediction result probability entropy in multiple training rounds exceeds the second threshold, determining a first proportion value in which the prediction result probability entropy in multiple training rounds exceeds the second threshold; when the first proportion value is greater than a third threshold, determining the text sample data as sample data to be amplified.
[0072] S230 , performing amplification processing on the sample data to be amplified by using the trained second text processing model to obtain at least one amplified sample data, and updating the sample set based on the amplified sample data.
[0073] Optionally, the text sample data is provided with an original label. Optionally, the original label of the text sample data may be pre-set. Optionally, the original label of the text sample data may also be that when the text sample label is the augmented sample data, the augmented sample data is processed based on the first text processing model to obtain a prediction result, and the prediction result is used as the original label of the augmented sample data.
[0074] S240: Continue training the first text processing model based on the updated sample set.
[0075] S250: Train the first text processing model to be trained based on the text sample data in the sample set, and determine the text data to be verified in the text sample data, and the processed data obtained by processing the text data to be verified by the first text processing model meets the second set condition.
[0076] Since there may be errors in the labels of the text sample data in the sample set, which may affect the training of the first text processing model, in order to reduce the impact of the wrong labels in the text sample data on the training of the first text processing model, the text sample data in the sample set may be subjected to signature verification.
[0077] In this embodiment, the text data to be verified may be text sample data to be subjected to label verification processing. The second setting condition may be understood as a determination condition for whether the text sample data belongs to the text data to be verified. During the training process of the first text processing model, the processing data of each text sample data may be obtained. For the processing data of each text sample data, the text sample data may be determined based on the second setting condition to determine whether the text sample data is the text data to be verified. For example, the second setting condition may be that the difference between the processing data of each text sample data is less than a preset threshold value, and the difference between the processing data of each text sample data is calculated. When the difference is less than the preset threshold value, it indicates that the first text processing model predicts the text sample data clearly. In order to verify whether the label of the text sample data is correct, the text sample data subjected to label verification processing is determined as the text data to be verified, and the text data to be verified is subjected to label verification processing. The text sample data is input into the first text processing model for processing, and the processing data corresponding to the text sample data is obtained. The processing data is determined according to the second setting condition. When the processing data meets the second setting condition, the text sample data is determined as the text data to be verified.
[0078] Optionally, determining the text data to be verified in the text sample data includes: inputting the text sample data into the first text processing model to be trained, and obtaining processed data generated by the first text processing model to be trained in the process of processing the text sample data; the processed data is the input data corresponding to the output layer of the first text processing model to be trained; the processed data includes confidence data of the text sample data on multiple prediction results; determining the prediction result probability entropy corresponding to the text sample data based on the confidence data on the multiple prediction results in the processed data; when the prediction result probability entropy corresponding to the text sample data is less than a fourth threshold, determining the text sample data as the text data to be verified.
[0079] Specifically, the fourth threshold value may be a threshold value in the second setting condition, which may be used to determine whether to determine the text sample data as the text data to be verified. When the prediction result probability entropy corresponding to the text sample data is less than the fourth threshold value, the text sample data may be determined as the text data to be verified. The second setting condition here includes that the prediction result probability entropy is less than the fourth threshold value.
[0080] Optionally, determining the text data to be verified in the text sample data includes: obtaining the prediction result probability entropy of the text sample data in multiple training rounds, and determining the number of rounds in which the prediction result probability entropy in the multiple training rounds is less than a fifth threshold; based on the total number of training rounds and the number of rounds in which the prediction result probability entropy in the multiple training rounds is less than the fifth threshold, determining a second proportion value in which the prediction result probability entropy in the multiple training rounds is less than the fifth threshold; when the second proportion value is greater than a sixth threshold, determining the text sample data as the text data to be verified.
[0081] Specifically, the fifth threshold value may be a threshold value in the second setting condition, for example, a probability value. The second ratio value may be a ratio of the number of rounds in which the probability entropy of the prediction result is less than the fifth threshold value in the total number of training rounds. For example, the second ratio value may be obtained by counting the number of rounds in which the probability entropy of the prediction result exceeds the fifth threshold value in multiple training rounds and calculating the ratio between the number of rounds and the total number of training rounds. The sixth threshold value may be a threshold value in the second setting condition, which may be used to determine whether the text sample data is determined as the text data to be verified. For example, when the second ratio value is greater than the sixth threshold value, it indicates that the first text processing model can clearly predict the original label of the text sample data. In order to verify whether the label of the text sample data is correct, the text sample data may be determined as the text data to be verified, and the text sample data and the original label corresponding to the text sample data may be verified. The second setting condition here includes that the second ratio value of the probability entropy of the prediction result exceeds the fifth threshold value is greater than the sixth threshold value. The fourth threshold value, the fifth threshold value and the sixth threshold value may all be threshold values in the second setting condition, and may all be adaptively changed according to the change of the second setting condition.
[0082] According to the total number of training rounds and the number of rounds in which the probability entropy of the prediction results in the training rounds exceeds the fifth threshold, the second proportion value of the probability entropy of the prediction results in the training rounds less than the fifth threshold is calculated, which can be calculated by the following formula:
[0083] ;
[0084] in, Indicates that the text sample data x has a probability entropy less than the fifth threshold in the prediction result The second ratio value, Represents the probability entropy of the prediction result corresponding to the text sample data x, Indicates the total number of training rounds of the first text processing model to be trained. Compare the second ratio value and the sixth threshold value. When the second ratio value is greater than the sixth threshold value, the text sample data is determined as the text data to be verified. Exemplarily, the sixth threshold value is 0.5, and the second ratio value of the text sample data x is 0.75. Since the second ratio value is greater than the sixth threshold value, the text sample data x can be determined as the text data to be verified.
[0085] S260: Based on the trained third text processing model, perform signature verification on the text data to be verified to obtain a target label for the text data to be verified.
[0086] In this embodiment, the third text processing model may be a model for performing signature verification on the text data to be verified. The third text processing model may be a transformer decoder model and its variants. Optionally, the third text processing model may include one or more of an LlaMa decoder and a Qwen decoder, which may be selected according to user needs and is not limited here. Optionally, the third text processing model and the second text processing model may be the same model or different models. When the third text processing model and the second text processing model are the same model, in order to realize two different functions of signature verification and amplification, the identification information of the corresponding function of the model may be input, and the identification information may be a mark in any form such as text form or character form, which is used to distinguish between data amplification and signature verification. For example, when the second text processing model performs amplification processing on the sample data to be amplified, while inputting the sample data to be amplified, the words "amplification processing" are input, and the second text processing model may perform amplification processing on the input sample data to be amplified; when the third text processing model performs signature verification processing on the text data to be verified, while inputting the text data to be verified, the words "signature verification processing" are input, and the third text processing model may perform signature verification processing on the text data to be verified. The target label may be the correct label corresponding to the text data to be verified. The text data to be verified is input into the third text processing model for verification processing to obtain the target label of the text data to be verified.
[0087] S270: When the target label of the text data to be verified is inconsistent with the original label, the original label is updated based on the target label, and the first text processing model is continuously trained based on the text data to be verified and the target label of the text data to be verified, until a trained first text processing model is obtained.
[0088] In this embodiment, the target label of the text data to be verified is compared with the original label. When the target label of the text data to be verified is inconsistent with the original label, it means that the original label of the text data to be verified is wrong. The target label is used to replace the original label, and the text data to be verified with the replaced label is input into the first text processing model to continue training the first text processing model.
[0089] The technical solution of this embodiment is as follows: by obtaining a sample set, the sample set includes text sample data, training a first text processing model to be trained based on the text sample data in the sample set, and determining the text data to be verified in the text sample data, the processed data obtained by processing the text data to be verified by the first text processing model meets the second set condition, and verifying the text data to be verified based on a trained third text processing model to obtain a target label of the text data to be verified, and when the target label of the text data to be verified is inconsistent with the original label, updating the original label based on the target label, and continuing to train the first text processing model based on the text data to be verified and the target label of the text data to be verified until a trained first text processing model is obtained, thereby solving the problem that the wrong label in the text sample data affects the training of the first text processing model, and improving the accuracy of the training of the first text processing model.
[0090] In the above embodiment, the steps S210-S270 may be executed serially, or they may be executed in parallel in the order of S220-S240 and S250-S270 to train the first text processing model until a trained first text processing model is obtained, which will not be described in detail here.
[0091] Embodiment 3
[0092] Figure 5 Schematic diagram of a text processing model training device provided in Embodiment 3 of the present invention. Figure 5 As shown, the device comprises:
[0093] A sample set acquisition module 210 is used to acquire a sample set, wherein the sample set includes text sample data;
[0094] The sample data to be amplified determining module 220 is used to train the first text processing model to be trained based on the text sample data in the sample set, and determine the sample data to be amplified in the text sample data; the processed data obtained by processing the sample data to be amplified by the first text processing model meets the first set condition;
[0095] The sample set updating module 230 is used to perform amplification processing on the sample data to be amplified by using the trained second text processing model to obtain at least one amplified sample data, and update the sample set based on the amplified sample data;
[0096] The first text processing model training module 240 is used to continue training the first text processing model based on the updated sample set until a trained first text processing model is obtained.
[0097] On the basis of the above embodiment, optionally, the module 220 for determining sample data to be amplified is also used to: input the text sample data into the first text processing model to be trained, and obtain the processed data generated by the first text processing model to be trained in the process of processing the text sample data, wherein the processed data is the input data corresponding to the output layer of the first text processing model to be trained; the processed data includes confidence data of the text sample data on multiple prediction results; based on the confidence data on multiple prediction results in the processed data, the prediction result probability entropy corresponding to the text sample data is determined; when the prediction result probability entropy corresponding to the text sample data is greater than a first threshold, the text sample data is determined as the sample data to be amplified.
[0098] Optionally, the sample data to be amplified determination module 220 is also used to: obtain prediction result probability entropy of text sample data in multiple training rounds, and determine the number of rounds in which the prediction result probability entropy in multiple training rounds exceeds a second threshold; based on the total number of training rounds and the number of rounds in which the prediction result probability entropy in multiple training rounds exceeds the second threshold, determine a first proportion value in which the prediction result probability entropy in multiple training rounds exceeds the second threshold; when the first proportion value is greater than a third threshold, determine the text sample data as sample data to be amplified.
[0099] Optionally, the device also includes a signature verification module, which is used to: determine the text data to be verified in the text sample data, and the processed data obtained by processing the text data to be verified by the first text processing model meets the second set condition; based on the trained third text processing model, perform signature verification on the text data to be verified to obtain a target label of the text data to be verified; when the target label of the text data to be verified is inconsistent with the original label, update the original label based on the target label, and continue to train the first text processing model based on the text data to be verified and the target label of the text data to be verified.
[0100] Optionally, the signature verification module is further used to: pre-set original labels for the text sample data.
[0101] Optionally, the signature verification module is further used to: when the text sample label is amplified sample data, process the amplified sample data based on the first text processing model to obtain a prediction result, and use the prediction result as the original label of the amplified sample data.
[0102] Optionally, the signature verification module is also used to: input text sample data into the first text processing model to be trained to obtain processed data generated by the first text processing model to be trained in the process of processing the text sample data; the processed data is the input data corresponding to the output layer of the first text processing model to be trained; the processed data includes confidence data of the text sample data on multiple prediction results; based on the confidence data on multiple prediction results in the processed data, determine the prediction result probability entropy corresponding to the text sample data; when the prediction result probability entropy corresponding to the text sample data is less than a fourth threshold, determine the text sample data as text data to be verified.
[0103] Optionally, the signature verification module is also used to: obtain the prediction result probability entropy of the text sample data in multiple training rounds, and determine the number of rounds in which the prediction result probability entropy in the multiple training rounds is less than a fifth threshold; based on the total number of training rounds and the number of rounds in which the prediction result probability entropy in the multiple training rounds is less than the fifth threshold, determine a second proportion value in which the prediction result probability entropy in the multiple training rounds is less than the fifth threshold; when the second proportion value is greater than the sixth threshold, determine the text sample data as the text data to be verified.
[0104] The text processing model training device provided in the embodiment of the present invention can execute the text processing model training method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0105] Embodiment 4
[0106] Figure 6 1 is a schematic diagram of the structure of an electronic device provided in Embodiment 4 of the present invention. The electronic device 10 is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.
[0107] like Figure 6As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. The input / output (I / O) interface 15 is also connected to the bus 14.
[0108] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0109] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as the training method of the text processing model.
[0110] In some embodiments, the training method of the text processing model may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the training method of the text processing model described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to execute the training method of the text processing model in any other appropriate manner (e.g., by means of firmware).
[0111] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0112] The computer programs for implementing the training method of the text processing model of the present invention can be written in any combination of one or more programming languages. These computer programs can be provided to a processor of a general-purpose computer, a special-purpose computer or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program can be executed entirely on the machine, partially on the machine, partially on the machine as a stand-alone software package and partially on a remote machine, or entirely on a remote machine or server.
[0113] Embodiment 5
[0114] Embodiment 5 of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to execute a training method for a text processing model, the method comprising:
[0115] A sample set is obtained, which includes text sample data; a first text processing model to be trained is trained based on the text sample data in the sample set, and sample data to be amplified in the text sample data is determined; the processed data obtained by processing the sample data to be amplified by the first text processing model meets a first set condition; the sample data to be amplified is amplified by a trained second text processing model to obtain at least one amplified sample data, and the sample set is updated based on the amplified sample data; the first text processing model is continuously trained based on the updated sample set until a trained first text processing model is obtained.
[0116] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, device, or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0117] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0118] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0119] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0120] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0121] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A training method for a text processing model, characterized in that: include: Acquire a sample set, wherein the sample set includes text sample data; Based on the text sample data in the sample set, a first text processing model to be trained is trained, and sample data to be amplified in the text sample data is determined; the processed data obtained by processing the sample data to be amplified by the first text processing model satisfies a first set condition; Performing amplification processing on the sample data to be amplified by using a trained second text processing model to obtain at least one amplified sample data, and updating the sample set based on the amplified sample data; The first text processing model is continuously trained based on the updated sample set until a trained first text processing model is obtained.
2. The text processing model training method according to claim 1, characterized in that: The determining of the sample data to be amplified in the text sample data includes: Input the text sample data into the first text processing model to be trained, and obtain processed data generated by the first text processing model to be trained in the process of processing the text sample data, wherein the processed data is the input data corresponding to the output layer of the first text processing model to be trained; the processed data includes confidence data of the text sample data on multiple prediction results; Determining the prediction result probability entropy corresponding to the text sample data based on the confidence data on the multiple prediction results in the processed data; When the prediction result probability entropy corresponding to the text sample data is greater than a first threshold, the text sample data is determined as the sample data to be augmented.
3. The text processing model training method according to claim 2, characterized in that: The method further comprises: Obtaining prediction result probability entropy of the text sample data in multiple training rounds, and determining the number of rounds in which the prediction result probability entropy in the multiple training rounds exceeds a second threshold; Determine a first proportion value of the number of training rounds in which the probability entropy of the prediction results exceeds the second threshold based on the total number of training rounds and the number of rounds in which the probability entropy of the prediction results in the multiple training rounds exceeds the second threshold; When the first ratio value is greater than a third threshold, the text sample data is determined as the sample data to be augmented.
4. The text processing model training method according to claim 1, characterized in that: The text sample data is provided with an original label; The method further comprises: Determining text data to be verified in the text sample data, where processed data obtained by processing the text data to be verified by the first text processing model satisfies a second set condition; Based on the trained third text processing model, the text data to be verified is processed to obtain a target label of the text data to be verified; When the target label of the text data to be verified is inconsistent with the original label, the original label is updated based on the target label, and the first text processing model is continuously trained based on the text data to be verified and the target label of the text data to be verified.
5. The text processing model training method according to claim 4, characterized in that: The original label of the text sample data may be preset, or, In the case where the text sample label is the augmented sample data, the augmented sample data is processed based on the first text processing model to obtain a prediction result, and the prediction result is used as the original label of the augmented sample data.
6. The text processing model training method according to claim 4, characterized in that: The determining of the text data to be signed in the text sample data includes: Input the text sample data into the first text processing model to be trained, and obtain the processed data generated by the first text processing model to be trained in the process of processing the text sample data; the processed data is the input data corresponding to the output layer of the first text processing model to be trained; the processed data includes the confidence data of the text sample data on multiple prediction results; Determining the prediction result probability entropy corresponding to the text sample data based on the confidence data on the multiple prediction results in the processed data; When the prediction result probability entropy corresponding to the text sample data is less than a fourth threshold, the text sample data is determined as the text data to be signed.
7. The text processing model training method according to claim 6, characterized in that: The method further comprises: Obtaining prediction result probability entropy of the text sample data in multiple training rounds, and determining the number of rounds in which the prediction result probability entropy in the multiple training rounds is less than a fifth threshold; Determine a second proportion value in which the probability entropy of the prediction results in the multiple training rounds is less than the fifth threshold value based on the total number of training rounds and the number of rounds in which the probability entropy of the prediction results in the multiple training rounds is less than the fifth threshold value; When the second ratio value is greater than a sixth threshold, the text sample data is determined as the text data to be signed.
8. A training device for a text processing model, characterized in that: include: A sample set acquisition module, used to acquire a sample set, wherein the sample set includes text sample data; a sample data to be augmented determining module, used for training a first text processing model to be trained based on the text sample data in the sample set, and determining the sample data to be augmented in the text sample data; The processed data obtained by processing the sample data to be amplified by the first text processing model satisfies a first set condition; A sample set updating module, configured to perform amplification processing on the sample data to be amplified by using a trained second text processing model to obtain at least one amplified sample data, and update the sample set based on the amplified sample data; The first text processing model training module is used to continue training the first text processing model based on the updated sample set until a trained first text processing model is obtained.
9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the training method of the text processing model described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the training method of the text processing model described in any one of claims 1 to 7 when executed.
Citation Information
Patent Citations
Weak supervised text classification method and device based on active learning
CN109960800A
Text classification model training method and device, computer equipment and storage medium
CN112100378A
Object detection method and device, computer readable storage medium and processor
CN114064958A
Sample screening method and device, storage medium and computer equipment
CN115204271A
Dynamic data selection method for improving model training efficiency
CN118709739A