Text error detection model training method, text error detection method and device
By acquiring error labels from test texts and iteratively training a text error detection model using a target sample set, the problem of insufficient accuracy in text error detection caused by manual rule setting in existing technologies is solved, achieving higher text error detection precision.
Patent Information
- Application Number
- CN202210461630.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-28
- Publication Date
- 2026-01-13
- Estimated Expiration
- 2042-04-28
AI Technical Summary
Existing text error detection methods based on rule matching require the manual setting of a large number of rules, resulting in poor accuracy in text error detection.
By acquiring unlabeled test texts from the test set, the model generates error labels using pre-trained labels, expanding the training data of the initial text error detection model. The initial text error detection model is then iteratively trained using the target sample set to optimize model parameters and improve accuracy.
This improved the accuracy of the text error detection model and enhanced the precision of text error detection.
Smart Images

Figure CN114782958B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer, in particular to a text error detection model training method. The present application also relates to a text error detection model training device, a text error detection method, a text error detection device, a computing device and a computer readable storage medium. BACKGROUND
[0002] With the development of Internet technology, more and more text error detection in daily office relies on the Internet. Text error detection is intelligent detection of text to obtain error data in the text, which can effectively improve office efficiency.
[0003] Currently, a rule matching based method is usually used for text error detection: a large number of wrong words and correct words are collected manually to construct a rule library, and the to-be-processed text is matched with the pre-constructed rule library to obtain the wrong words in the to-be-processed text. However, in the above rule matching based method, a large number of rules need to be set manually, and manual setting will inevitably introduce uncertain factors, resulting in poor accuracy of text error detection. SUMMARY
[0004] Therefore, the embodiments of the present application provide a text error detection model training method and a text error detection method to solve the technical defects in the prior art. The embodiments of the present application also provide a text error detection model training device, a text error detection device, a computing device and a computer readable storage medium.
[0005] According to a first aspect of the embodiments of the present application, a text error detection model training method is provided, comprising:
[0006] obtaining a test set, wherein the test set comprises a plurality of unlabeled test texts;
[0007] inputting each test text into a pre-trained label determination model to obtain an error label corresponding to each test text;
[0008] generating a target sample set according to each test text and the error label corresponding to each test text;
[0009] iteratively training an initial text error detection model using the target sample set to obtain a trained text error detection model.
[0010] Optionally, the training method of the label determination model comprises:
[0011] obtaining an initial sample set, wherein the initial sample set comprises a plurality of sample texts and error labels corresponding to each sample text;
[0012] extracting a first sample text, inputting the first sample text into the initial label determination model to obtain first predicted error information of the first sample text, wherein the first sample text is any sample text in the initial sample set;
[0013] calculating a first loss value according to the first predicted error information and an error label corresponding to the first sample text;
[0014] If the first loss value is greater than a first preset threshold, adjusting model parameters of the initial label determination model, and returning to execute the step of extracting the first sample text, inputting the first sample text into the initial label determination model to obtain the first predicted error information of the first sample text;
[0015] If the first loss value is less than or equal to the first preset threshold, stopping training and obtaining the trained label determination model.
[0016] Optionally, the step of generating the target sample set according to each test text and an error label corresponding to each test text comprises:
[0017] adding each test text and the error label corresponding to each test text in the initial sample set to generate the target sample set.
[0018] Optionally, the step of obtaining the initial sample set comprises:
[0019] obtaining a plurality of sample texts;
[0020] respectively performing picture conversion on the plurality of sample texts to obtain sample pictures corresponding to the plurality of sample texts respectively;
[0021] recognizing text content of each sample picture;
[0022] For any sample picture, comparing the text content of the sample picture with a sample text corresponding to the sample picture to determine an error label corresponding to the text content of the sample picture;
[0023] generating the initial sample set according to the text content of each sample picture and the error label corresponding to the text content of each sample picture.
[0024] Optionally, the step of obtaining the initial sample set comprises:
[0025] obtaining a plurality of sample texts;
[0026] using a preset audio conversion tool to convert the plurality of sample texts into corresponding sample audios respectively;
[0027] recognizing text content of each sample audio;
[0028] For any sample audio, compare the text content of the sample audio with the sample text corresponding to the sample audio to determine an error label corresponding to the text content of the sample audio;
[0029] According to the text content of each sample audio and the error label corresponding to the text content of each sample audio, an initial sample set is generated.
[0030] Optionally, the step of obtaining the initial sample set comprises:
[0031] Obtaining a plurality of sample texts;
[0032] Matching the plurality of sample texts with a preset error database, and respectively performing random wrong word replacement on the plurality of sample texts to generate a wrong word replacement text corresponding to each sample text;
[0033] For any sample text, compare the sample text with the wrong word replacement text corresponding to the sample text to determine an error label corresponding to the wrong word replacement text;
[0034] According to each wrong word replacement text and the error label corresponding to each wrong word replacement text, an initial sample set is generated.
[0035] Optionally, the initial text error detection model is obtained by pruning the initial label determination model.
[0036] Optionally, the step of iteratively training the initial text error detection model using the target sample set to obtain the trained text error detection model comprises:
[0037] Extracting a second sample text from the target sample set, inputting the second sample text into the initial text error detection model to obtain second predicted error information of the second sample text, wherein the second sample text is any text in the target sample set;
[0038] According to the second predicted error information and the error label corresponding to the second sample text, a second loss value is calculated;
[0039] If the second loss value is greater than a second preset threshold, the model parameters of the initial text error detection model are adjusted, and the step of extracting the second sample text from the target sample set and inputting the second sample text into the initial text error detection model to obtain the second predicted error information of the second sample text is executed again;
[0040] If the second loss value is less than or equal to the second preset threshold, the training is stopped, and a trained text error detection model is obtained.
[0041] According to a second aspect of the embodiments of the present application, a text error detection method is provided, comprising:
[0042] Obtaining a text to be processed;
[0043] input the text to be processed into the text error detection model trained by the method provided in the first aspect of the embodiment of the present application, to obtain an error detection result of the text to be processed.
[0044] According to a third aspect of the embodiment of the present application, a text error detection model training device is provided, comprising:
[0045] a test set acquisition module configured to acquire a test set, wherein the test set comprises a plurality of unlabeled test texts;
[0046] an error label generation module configured to input each test text into a pre-trained label determination model, to obtain an error label corresponding to each test text;
[0047] a target sample set generation module configured to generate a target sample set according to each test text and the error label corresponding to each test text;
[0048] a model generation module configured to iteratively train an initial text error detection model using the target sample set, to obtain a trained text error detection model.
[0049] Optionally, the device further comprises:
[0050] a label determination model training module configured to acquire an initial sample set, wherein the initial sample set comprises a plurality of sample texts and error labels corresponding to each sample text;
[0051] extract a first sample text, input the first sample text into the initial label determination model, and obtain first predicted error information of the first sample text, wherein the first sample text is any sample text in the initial sample set;
[0052] calculate a first loss value according to the first predicted error information and the error label corresponding to the first sample text;
[0053] if the first loss value is greater than a first preset threshold, adjust the model parameters of the initial label determination model, and return to the step of extracting the first sample text, inputting the first sample text into the initial label determination model, and obtaining the first predicted error information of the first sample text;
[0054] if the first loss value is less than or equal to the first preset threshold, stop training, and obtain a trained label determination model.
[0055] Optionally, the target sample set generation module is further configured to add each test text and the error label corresponding to each test text in the initial sample set, to generate the target sample set.
[0056] Optionally, the label determination model training module is further configured to acquire a plurality of sample texts.
[0057] respectively, to obtain a plurality of sample pictures corresponding to the plurality of sample texts respectively;
[0058] text contents of the sample pictures are recognized;
[0059] For any sample picture, the text content of the sample picture is compared with the sample text corresponding to the sample picture to determine an error label corresponding to the text content of the sample picture;
[0060] According to the text contents of the sample pictures and the error labels corresponding to the text contents of the sample pictures, an initial sample set is generated.
[0061] Optionally, the label determination model training module is further configured to obtain a plurality of sample texts;
[0062] The plurality of sample texts are respectively converted into corresponding sample audios by using a preset audio conversion tool;
[0063] text contents of the sample audios are recognized;
[0064] For any sample audio, the text content of the sample audio is compared with the sample text corresponding to the sample audio to determine an error label corresponding to the text content of the sample audio;
[0065] According to the text contents of the sample audios and the error labels corresponding to the text contents of the sample audios, an initial sample set is generated.
[0066] Optionally, the label determination model training module is further configured to obtain a plurality of sample texts;
[0067] The plurality of sample texts and a preset error database are matched, and the plurality of sample texts are respectively randomly replaced with wrong words to generate wrong word replacement texts corresponding to the plurality of sample texts respectively;
[0068] For any sample text, the sample text is compared with the wrong word replacement text corresponding to the sample text to determine an error label corresponding to the wrong word replacement text;
[0069] According to the wrong word replacement texts and the error labels corresponding to the wrong word replacement texts, an initial sample set is generated.
[0070] Optionally, the initial text error detection model is obtained by pruning the initial label determination model.
[0071] Optionally, the model generation module is further configured to extract a second sample text from the target sample set, input the second sample text into the initial text error detection model, and obtain second predicted error information of the second sample text, wherein the second sample text is any text in the target sample set.
[0072] According to the second prediction error information and the error label corresponding to the second sample text, a second loss value is calculated;
[0073] If the second loss value is greater than a second preset threshold, the model parameters of the initial text error detection model are adjusted, and the step of extracting the second sample text from the target sample set, inputting the second sample text into the initial text error detection model, and obtaining the second prediction error information of the second sample text is performed again;
[0074] If the second loss value is less than or equal to the second preset threshold, the training is stopped, and the trained text error detection model is obtained.
[0075] According to a fourth aspect of the embodiments of the present application, a text error detection device is provided, comprising:
[0076] A to-be-processed text acquisition module is configured to acquire to-be-processed text;
[0077] An error detection result generation module is configured to input the to-be-processed text into the text error detection model trained by the method provided in the first aspect of the present application, to obtain an error detection result of the to-be-processed text.
[0078] According to a fifth aspect of the embodiments of the present application, a computing device is provided, comprising:
[0079] A memory and a processor;
[0080] The memory is configured to store computer executable instructions, and the processor is configured to execute the computer executable instructions to implement the steps of the method provided in the first aspect or the second aspect of the present application.
[0081] According to a sixth aspect of the embodiments of the present application, a computer readable storage medium is provided, which stores computer executable instructions, and the instructions are executed by a processor to implement the steps of the method provided in the first aspect or the second aspect of the present application.
[0082] According to a seventh aspect of the embodiments of the present application, a chip is provided, which stores a computer program, and the computer program is executed by the chip to implement the steps of the method provided in the first aspect or the second aspect of the present application.
[0083] The text error detection model training method provided in the application, obtains a test set, wherein the test set includes a plurality of unlabeled test texts, inputs each test text into a pre-trained label determination model to obtain an error label corresponding to each test text, generates a target sample set according to each test text and the error label corresponding to each test text, iteratively trains an initial text error detection model using the target sample set to obtain a trained text error detection model, and expands the training data of the initial text error detection model by generating the target sample set according to each test text and the error label corresponding to each test text, improves the accuracy of the text error detection model obtained through training, and further improves the accuracy of text error detection based on the text error detection model. BRIEF DESCRIPTION OF DRAWINGS
[0084] Figure 1 is a processing flowchart of a text error detection system provided by an embodiment of the application;
[0085] Figure 2 is a flowchart of a text error detection model training method provided by an embodiment of the application;
[0086] Figure 3 is a flowchart of a training method of a label determination model provided by an embodiment of the application;
[0087] Figure 4 is a flowchart of a first text error detection model training method provided by an embodiment of the application;
[0088] Figure 5 is a flowchart of a second text error detection model training method provided by an embodiment of the application;
[0089] Figure 6 is a flowchart of a third text error detection model training method provided by an embodiment of the application;
[0090] Figure 7 is a flowchart of a fourth text error detection model training method provided by an embodiment of the application;
[0091] Figure 8 is a flowchart of a fifth text error detection model training method provided by an embodiment of the application;
[0092] Figure 9 is a flowchart of a text error detection method provided by an embodiment of the application;
[0093] Figure 10 is a flowchart of a text error detection model training method and a text error detection method provided by an embodiment of the application;
[0094] Figure 11is a structural schematic diagram of a text error detection model training device provided by an embodiment of the present application.
[0095] Figure 12 is a structural schematic diagram of a text error detection device provided by an embodiment of the present application.
[0096] Figure 13 is a structural block diagram of a computing device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0097] In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present application. However, the present application can be practiced without the specific details. In other instances, well-known methods, procedures, components, and circuits have not been described in detail so as not to obscure the present application.
[0098] The terminology used in this disclosure is for the purpose of describing particular embodiments only and is not intended to be limiting of one or more embodiments of the present application. As used in this disclosure and the appended claims, the singular forms "a," "an" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will also be understood that the term "and / or" as used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items.
[0099] It will be understood that, although the terms first, second, etc. can be used herein to describe various information, these terms are not intended to denote a temporal or chronological order. Rather, these terms are used solely to distinguish one from another only. For example, a first item could be termed a second item, and, similarly, a second item could be termed a first item without departing from the scope of one or more embodiments of the present application.
[0100] First, the noun terms related to one or more embodiments of the present application are explained.
[0101] Optical Character Recognition (OCR): refers to the process by which an electronic device (such as a scanner or digital camera) examines printed characters on paper, determines their shape by detecting light and dark patterns, and then translates the shape into computer text using character recognition methods; that is, for printed characters, an optical method is used to convert the characters in a paper document into a black and white dot matrix image file, and the characters in the image are converted into text format through recognition software, for further editing and processing by word processing software.
[0102] BERT model: BERT (Bidirectional Encoder Representations from Transformers) is a pre-trained language representation model. It emphasizes that the traditional one-way language model or the method of shallowly splicing two one-way language models is no longer used for pre-training, but a new masked language model (MLM, masked language model) is used to generate deep bidirectional language representations.
[0103] ELECTRA model: ELECTRA (Efficiently Learning an Encoder that Classifies Token Replacements Accurately) is an efficient encoder that accurately classifies token replacements.
[0104] In the present application, a text error detection model training method and a text error detection method are provided. The present application also relates to a text error detection model training device, a text error detection device, a computing device, and a computer-readable storage medium, which are described in detail in the following embodiments.
[0105] Figure 1 A processing flowchart of a text error detection system according to an embodiment of the present application is shown.
[0106] The present application can be divided into two execution subjects, a server and an application terminal. The pre-trained label determination model and the initial text error detection model run in the server.
[0107] The server obtains a test set provided by the application terminal, inputs a plurality of unlabeled test texts in the test set into the pre-trained label determination model respectively, obtains error labels corresponding to each test text, generates a target sample set according to each test text and the error labels corresponding to each test text, iteratively trains the initial text error detection model using the target sample set, generates a trained text error detection model, and sends the trained text error detection model to the application terminal.
[0108] It should be noted that the initial text error detection model is a text error detection model containing initial model parameters. The initial text error detection model is iteratively trained using the target sample set to adjust the initial model parameters in the initial text error detection model, and a trained text error detection model can be generated. That is, the initial text error detection model is an untrained text error detection model, and the trained text error detection model is a text error detection model obtained by optimizing and adjusting the model parameters in the initial text error detection model.
[0109] The application terminal not only provides the test set to the server, but also receives the trained text error detection model sent by the server, inputs the to-be-processed text into the trained text error detection model, and obtains the error detection result of the to-be-processed text.
[0110] By using the scheme of the embodiment of the application, the test set is obtained, the test set includes a plurality of test texts without labels, each test text is input into the pre-trained label determination model, the error label corresponding to each test text is obtained, the target sample set is generated according to each test text and the error label corresponding to each test text, the initial text error detection model is iteratively trained by using the target sample set, and the trained text error detection model is obtained. The training data of the initial text error detection model is expanded by generating the target sample set according to each test text and the error label corresponding to each test text, the accuracy of the text error detection model obtained by training is improved, and the accuracy of text error detection based on the text error detection model is further improved.
[0111] Figure 2 A flowchart of a text error detection model training method according to an embodiment of the application is shown, and specifically includes the following steps:
[0112] S202: Obtain a test set, wherein the test set includes a plurality of test texts without labels.
[0113] In the embodiment of the application, the plurality of test texts without labels in the test set refer to texts without error detection, and the text types include but are not limited to text file types and picture file format types. The formats of the text file types include but are not limited to txt, doc, and docx. The test texts can be texts in various languages, such as Chinese texts and English texts. Generally, the test set can be obtained by manually inputting a large number of test texts, or the test set can be obtained by reading a large number of test texts from other data acquisition devices or databases. The manner of obtaining the test set is selected according to actual conditions, and the embodiment of the application does not make any limitation in this regard.
[0114] In actual application, since the test texts include various text types, different text types need to be converted into the same text type when the test texts are processed subsequently, so as to adapt to the pre-trained label determination model. Therefore, if the test text is a picture file format type and the identification type of the pre-trained label determination model is a text file type, the test text in the picture file format can be subjected to OCR identification to obtain a text file of the test text. Of course, other picture identification methods can also be used to obtain the text file of the test text, and the embodiment of the application does not make any limitation in this regard.
[0115] S204: Each test text is input into a pre-trained label determination model, and an error label corresponding to each test text is obtained.
[0116] In an embodiment of the present application, after obtaining a test set including multiple unlabeled test texts, in order to obtain the error labels corresponding to each test text, each test text needs to be input into a pre-trained label determination model respectively. Generally, the label determination model is a model trained based on a small number of training texts, and the text error detection ability of this label determination model is weak. The label determination model includes, but is not limited to, the BERT model and the ELECTRA model. The embodiments of the present application do not make any limitations in this regard.
[0117] In practical applications, the training method of the label determination model can be referred to Figure 3 , Figure 3 shows a flowchart of a training method for a label determination model according to an embodiment of the present application, which specifically includes the following steps:
[0118] S302: Obtain an initial sample set, where the initial sample set includes multiple sample texts and the error labels corresponding to each sample text.
[0119] In an embodiment of the present application, when training the label determination model, it is necessary to obtain multiple sample texts and the error labels corresponding to each sample text. The error labels corresponding to each sample text are used to represent the positions of the wrong characters in each sample text. Generally, the method of obtaining the initial sample set can be a large number of sample texts input manually to form the initial sample set, or a large number of sample texts read from other data acquisition devices or databases to form the initial sample set. The error labels corresponding to each sample text can be pre-annotated by staff, and specific selection is made according to the actual situation. The embodiments of the present application do not make any limitations in this regard.
[0120] For example, the sample text is "我们去池饭" (Let's go to eat at the pond), and its corresponding error label is "000F 0". "0" indicates that the character at the corresponding position is correct. A character is a general term for various characters and symbols, including national characters, punctuation marks, graphic symbols, numbers, etc. "F" indicates that the character at the corresponding position is incorrect. According to the error label "000F 0" corresponding to the sample text "我们去池饭", it can be known that the fourth character in this sample text is incorrect, that is, the corresponding character "池" (pond) is incorrect.
[0121] S304: Extract the first sample text, input the first sample text into the initial label determination model, and obtain the first predicted error information of the first sample text, where the first sample text is any sample text in the initial sample set.
[0122] In the embodiment of the present application, the initial label determination model is a label determination model containing initial model parameters, the initial label determination model containing the initial model parameters can be iteratively trained, the initial model parameters in the initial label determination model are adjusted, and a trained label determination model is generated; that is, the initial label determination model is an untrained label determination model, and the trained label determination model is a label determination model obtained by optimizing and adjusting the model parameters in the initial label determination model.
[0123] Specifically, after obtaining the initial sample set, the first sample text is extracted, and the first sample text is any sample text in the initial sample set. The first sample text is input into the initial label determination model to obtain the first prediction error information of the first sample text. The initial label determination model refers to a model capable of performing character recognition and analysis on text, including but not limited to a BERT model and an ELECTRA model, and the present application does not make any limitation on this.
[0124] S306: According to the first prediction error information and the error label corresponding to the first sample text, a first loss value is calculated.
[0125] S308: If the first loss value is greater than a first preset threshold, the model parameters of the initial label determination model are adjusted.
[0126] And return to step S304.
[0127] S310: If the first loss value is less than or equal to the first preset threshold, the training is stopped, and a trained label determination model is obtained.
[0128] It should be noted that the first loss value can be calculated based on the first prediction error information and the error label corresponding to the first sample text. The error label corresponding to the first sample text indicates the position of the error character in the first sample text, and the error label also represents the result that the initial label determination model actually wants to output, that is, the error character position represented by the error label corresponding to the first sample text is the real result, and the first prediction error information output by inputting the first sample text into the initial label determination model is the prediction result of the initial label determination model. When the difference between the prediction result and the real result is small enough, that is, the first loss value is small enough, it indicates that the prediction result is close enough to the real result, and at this time the initial label determination model is trained, and a trained label determination model is obtained.
[0129] In the embodiment of the present application, the difference between the prediction result and the real result of the initial label determination model can be intuitively shown by calculating the first loss value. Subsequently, the initial label determination model can be trained based on the difference, the parameters of the initial label determination model are adjusted, and the rate and effect of the initial label determination model training can be effectively improved.
[0130] In a possible implementation, whether to stop the training can be determined based on a relationship between the first loss value and the first preset threshold. Specifically, if the first loss value is greater than the first preset threshold, it indicates that the difference between the first predicted error information and the error label corresponding to the first sample text is large, and the error detection capability of the initial label determination model is poor. At this time, the model parameters of the initial label determination model can be adjusted, and the step of extracting the first sample text, inputting the first sample text into the initial label determination model, and obtaining the first predicted error information of the first sample text is performed again, and the training of the initial label determination model is continued until the first loss value is less than or equal to the first preset threshold, which indicates that the difference between the first predicted error information and the error label corresponding to the first sample text is small, and the training is stopped, and the trained label determination model is obtained.
[0131] The first preset threshold is a critical value of the first loss value. In a case where the first loss value is greater than the first preset threshold, it indicates that there is still a certain deviation between the prediction result of the initial label determination model and the true result, and the model parameters of the initial label determination model still need to be adjusted, and the sample texts in the initial sample set are obtained to continue training the initial label determination model. In a case where the first loss value is less than or equal to the first preset threshold, it indicates that the closeness between the prediction result of the initial label determination model and the true result is sufficient, and the training can be stopped. The value of the first preset threshold is selected according to actual conditions, and the embodiments of the present application do not make any limitation in this regard.
[0132] In another possible implementation, in addition to comparing the relationship between the first loss value and the first preset threshold, the number of iterations can also be combined to determine whether the current initial label determination model is trained. Specifically, if the first loss value is less than or equal to the first preset threshold, it indicates that the difference between the first predicted error information and the error label corresponding to the first sample text is small, and the training is stopped, and the trained label determination model is obtained. That is, when the first loss value is less than or equal to the first preset threshold, the training can be stopped to obtain the trained label determination model without combining the number of iterations. If the first loss value is greater than the first preset threshold, it is determined whether the number of iterations at this moment reaches the first preset number of iterations. If the number of iterations at this moment does not reach the first number of iterations, the model parameters of the initial label determination model are adjusted, and the step of extracting the first sample text, inputting the first sample text into the initial label determination model, and obtaining the first predicted error information of the first sample text is performed again, and the training of the initial label determination model is continued. Until the first preset number of iterations is reached, the iteration is stopped, and the trained label determination model is obtained.
[0133] The first preset iteration number is set according to actual conditions, and the embodiment of the present application does not make any limitation on this. When the number of training reaches the first preset iteration number, it indicates that the number of training of the initial label determination model is sufficient, and at this time, the closeness of the prediction result of the initial label determination model to the true result is sufficient, and the training can be stopped.
[0134] In the embodiment of the present application, the specific training situation of the initial label determination model can be judged according to the first loss value, and the model parameters of the initial label determination model can be adjusted in the reverse direction according to the first loss value in the case of unqualified training, so as to improve the fault detection capability of the model, the training rate is high, and the training effect is good.
[0135] In practical applications, there are many functions for calculating the first loss value, such as cross-entropy loss function, L1 norm loss function, maximum loss function, mean square error loss function, and logarithmic loss function. In the present application, the selection of the function for calculating the first loss value is not limited.
[0136] Preferably, the cross-entropy loss function can be used to calculate the first loss value, and the cross-entropy loss function is:
[0137]
[0138] Wherein, C represents the number of categories, p i is true, q i is prediction.
[0139] By using the cross-entropy loss function, the cross-entropy between the first prediction error information and the error label corresponding to the first sample text is calculated as the first loss value, which improves the efficiency and accuracy of calculating the first loss value, and makes the trained label determination model more accurate.
[0140] S206: generating a target sample set according to each test text and the error label corresponding to each test text.
[0141] It should be noted that after obtaining the error label corresponding to each test text, the target sample set can be generated according to each test text and the error label corresponding to each test text. The way of generating the target sample set is selected according to actual conditions, and the embodiment of the present application does not make any limitation on this.
[0142] In practical applications, the basic sample set can be obtained in advance. After obtaining the error label corresponding to each test text, each test text and the error label corresponding to each test text can be combined to form an expanded sample set. Then, the target sample set can be generated in combination with the expanded sample set and the basic sample set obtained in advance. In this way, the training data of the initial text fault detection model is expanded, the accuracy of the text fault detection model obtained by training is improved, and the accuracy of text fault detection based on the text fault detection model is further improved.
[0143] In a possible implementation, the pre-acquired basic sample set can be an initial sample set for training the initial label determination model, that is, the target sample set can be generated by adding each test text and the error label corresponding to each test text in the initial sample set.
[0144] In another possible implementation, the basic sample set and the initial sample set can be different, and the target sample set can be generated by adding each test text and the error label corresponding to each test text in the re-acquired basic sample set.
[0145] S208: iteratively training the initial text error detection model by using the target sample set to obtain a trained text error detection model.
[0146] It should be noted that in one case, the initial text error detection model and the initial label determination model can be two different models, in order to make the target sample set obtained by expansion more accurate and promote the training of the initial text error detection model, a initial label determination model with stronger error detection capability than the initial text error detection model can be adopted. For example, the initial label determination model is an ELECTRA model, and the initial text error detection model is a BERT model.
[0147] In another case, the initial text error detection model and the initial label determination model can also be two same models, but the model size can be different. Generally, the larger the model size, the better the model performance. That is, the model size of the initial text error detection model can be smaller than that of the initial label determination model. The model error detection capability of the label determination model trained by using the initial label determination model with a larger size is stronger, the expanded sample is more accurate, and the training of the initial text error detection model can be promoted. For example, the initial label determination model is an ELECTRA-base model, and the initial text error detection model is an ELECTRA-small model.
[0148] By applying the scheme of the embodiments of the present application, the test set is acquired, the test set includes a plurality of unlabeled test texts, each test text is input into the pre-trained label determination model to obtain the error label corresponding to each test text, the target sample set is generated according to each test text and the error label corresponding to each test text, the initial text error detection model is iteratively trained by using the target sample set to obtain the trained text error detection model, the training data of the initial text error detection model is expanded by generating the target sample set according to each test text and the error label corresponding to each test text, the accuracy of the text error detection model obtained by training is improved, and the accuracy of text error detection based on the text error detection model is further improved.
[0149] Figure 4A flowchart of a first text error detection model training method according to an embodiment of the present application is shown, and specifically includes the following steps:
[0150] S402: Obtain a test set, wherein the test set includes a plurality of unlabeled test texts.
[0151] S404: Input each test text into a pre-trained label determination model to obtain an error label corresponding to each test text.
[0152] S406: Generate a target sample set according to each test text and the error label corresponding to each test text.
[0153] S402, S404, and S406 are the same as S202, S204, and S206, and thus will not be described herein.
[0154] S408: Extract a second sample text from the target sample set, input the second sample text into an initial text error detection model, and obtain second predicted error information of the second sample text, wherein the second sample text is any text in the target sample set.
[0155] In the embodiment of the present application, after the target sample set is generated according to each test text and the error label corresponding to each test text, the second sample text is extracted, which is any sample text in the target sample set. The second sample text is input into the initial text error detection model to obtain the second predicted error information of the second sample text, wherein the initial text error detection model is obtained by pruning the initial label determination model.
[0156] It should be noted that, in general, the initial label determination model can be pruned by a human being according to experience to obtain the initial text error detection model, and the initial label determination model can also be pruned by using a vector angle analysis method.
[0157] The vector angle analysis method is to analyze the similarity of the output results of different hidden neurons at the same input sample, that is, to analyze the size of the vector angle to determine the similarity. Similar data indicates that the corresponding two hidden neurons extract similar features and have similar functions, and thus the two hidden neurons can be combined. Completely opposite data indicates that the results of the corresponding two hidden neurons cancel each other out, and thus the two hidden neurons can be deleted at the same time. The vector angle can be calculated by using the following formula:
[0158] angle(u,v)=arccos(u·v / (||u||·||v||)) (2)
[0159] Wherein, u and v represent the vectors output by the two hidden neurons to be compared.
[0160] In practical applications, after the vector angle is calculated, the optional processing rule is that two vectors with a vector angle less than 15 degrees are considered to have similar effects, that is, they satisfy linear correlation, so one of the two hidden neurons can be deleted and its parameters can be added to the other hidden neuron; two vectors with a vector angle greater than 165 degrees are considered to repel each other, and their effects cancel each other out in the calculation process, so the two hidden neurons can be directly deleted.
[0161] In the embodiment of the present application, the initial label determination model with a larger volume can be trained, so that the label determination model trained based on the initial label determination model can accurately identify the error label of each test text, providing accurate training samples for subsequent training of the text error detection model, thereby expanding the training samples of the text error detection model and improving the error detection capability of the text error detection model trained using the initial text error detection model. In addition, the text error detection model trained based on the initial text error detection model is the model used for final text error detection. If the text error detection model is relatively complex, it may affect the efficiency of text error detection. Therefore, the initial text error detection model with a smaller volume is selected to train the text error detection model for final text error detection, thereby improving the training efficiency of the text error detection model and the efficiency of subsequent text error detection.
[0162] S410: Calculate a second loss value according to the second predicted error information and the error label corresponding to the second sample text.
[0163] S412: If the second loss value is greater than a second preset threshold, adjust the model parameters of the initial text error detection model.
[0164] And return to step S408.
[0165] S414: If the second loss value is less than or equal to the second preset threshold, stop training and obtain the trained text error detection model.
[0166] It should be noted that the second loss value can be calculated based on the second predicted error information and the error label corresponding to the second sample text. The error label corresponding to the second sample text indicates the position of the error character in the second sample text. The error label also represents the result that the initial text error detection model actually wants to output, that is, the error character position represented by the error label corresponding to the second sample text is the real result. When the second sample text is input into the initial text error detection model, the second predicted error information output by the initial text error detection model is the prediction result. When the difference between the prediction result and the real result is small enough, that is, the second loss value is small enough, it means that the prediction result is close enough to the real result. At this time, the initial text error detection model is trained and the trained text error detection model is obtained.
[0167] In the embodiments of the present application, the difference between the prediction result of the initial text error detection model and the true result can be intuitively shown by calculating the second loss value, and the initial text error detection model can be trained based on the difference subsequently, the parameters of the initial text error detection model can be adjusted, and the training rate and the training effect of the initial text error detection model can be effectively improved.
[0168] In a possible implementation, whether to stop the training can be determined based on only the relationship between the second loss value and the second preset threshold. Specifically, if the second loss value is greater than the second preset threshold, it indicates that the difference between the second prediction error information and the error label corresponding to the second sample text is large, and the error detection capability of the initial text error detection model is poor. At this time, the model parameters of the initial text error detection model can be adjusted, and the step of extracting the second sample text, inputting the second sample text into the initial text error detection model to obtain the second prediction error information of the second sample text is returned to be executed, and the training of the initial text error detection model is continued until the second loss value is less than or equal to the second preset threshold, which indicates that the difference between the second prediction error information and the error label corresponding to the second sample text is small, and the training is stopped, and the trained text error detection model is obtained.
[0169] The second preset threshold is a critical value of the second loss value. In the case where the second loss value is greater than the second preset threshold, it indicates that there is still a certain deviation between the prediction result of the initial text error detection model and the true result, and the model parameters of the initial text error detection model still need to be adjusted, and the sample texts in the target sample set are obtained to continue training the initial text error detection model. In the case where the second loss value is less than or equal to the second preset threshold, it indicates that the closeness between the prediction result of the preset initial text error detection model and the true result is sufficient, and the training can be stopped. The value of the second preset threshold is selected according to actual conditions, and the embodiments of the present application do not make any limitation in this regard.
[0170] In another possible implementation, in addition to comparing the relationship between the second loss value and the second preset threshold, the number of iterations can be combined to determine whether the current initial text error detection model is trained. Specifically, if the second loss value is less than or equal to the second preset threshold, it indicates that the difference between the second predicted error information and the error label corresponding to the second sample text is small, the training is stopped, and the trained text error detection model is obtained. That is, when the first loss value is less than or equal to the first preset threshold, the training does not need to be stopped to obtain the trained label determination model in combination with the number of iterations; if the second loss value is greater than the second preset threshold, it is determined whether the number of iterations at this moment reaches the second preset number of iterations. If the number of iterations at this moment does not reach the second number of iterations, the model parameters of the initial text error detection model are adjusted, and the step of extracting the second sample text, inputting the second sample text into the initial text error detection model, and obtaining the second predicted error information of the second sample text is performed again. The initial text error detection model is continuously trained until the second preset number of iterations is reached, the iteration is stopped, and the trained text error detection model is obtained.
[0171] The second preset number of iterations is set according to actual conditions, and the present embodiment does not make any limitation on this. When the number of training reaches the second preset number of iterations, it indicates that the number of training of the initial text error detection model is sufficient. At this moment, the closeness between the prediction result of the initial text error detection model and the true result is sufficient, and the training can be stopped.
[0172] In the present embodiment, the specific training of the initial text error detection model can be determined according to the second loss value, and the model parameters of the initial text error detection model are adjusted in the reverse direction in the case of unqualified training, so as to improve the error detection capability of the model, the training rate is high, and the training effect is good.
[0173] In actual application, there are many functions for calculating the second loss value, such as cross-entropy loss function, L1 norm loss function, maximum loss function, mean square error loss function, and logarithmic loss function. In the present application, the selection of the function for calculating the second loss value is not limited.
[0174] Figure 5 A flowchart of a second text error detection model training method according to an embodiment of the present application is shown, which specifically includes the following steps:
[0175] S502: Obtain a test set, wherein the test set includes a plurality of test texts without labels.
[0176] S504: Input each test text into a pre-trained label determination model to obtain an error label corresponding to each test text.
[0177] The S502 and S504 are the same as the S202 and S204, and the present embodiment will not be described again.
[0178] S506: In the initial sample set, add each test text and the error label corresponding to each test text to generate a target sample set.
[0179] In the embodiment of the application, the initial sample set includes a plurality of sample texts and the error labels corresponding to each sample text. After obtaining the error label corresponding to each test text, each test text and the error label corresponding to each test text can be added to the initial sample set, the training data of the initial text error detection model is expanded, and the accuracy of the text error detection model is further improved.
[0180] For example, the initial sample set includes the sample text "we go to the pool" and the error label "0 0 0 F0" corresponding thereto, the sample text "I go to eat" and the error label "0 F 0 0 0" corresponding thereto. The test text "wear flow unceasingly" is input into the pre-trained label determination model, and the error label "F 0 0 0" corresponding to the test text is obtained. In the initial sample set, the test text "wear flow unceasingly" and the error label "F 0 0 0" corresponding thereto are added to generate a target sample set including three sample texts and the error labels corresponding to the three sample texts. Compared with the initial sample set, the target sample set has a larger amount of data than the initial sample set. Training the initial text error detection model with a large amount of sample data can improve the accuracy of the text error detection model.
[0181] S508: Iteratively train the initial text error detection model using the target sample set to obtain a trained text error detection model.
[0182] S508 is the same as S208, and the embodiment will not be described again.
[0183] Figure 6 A flowchart of a third text error detection model training method according to an embodiment of the application is shown, which specifically includes the following steps:
[0184] S602: Obtain a plurality of sample texts.
[0185] S604: Convert the plurality of sample texts into pictures respectively to obtain a plurality of sample pictures respectively corresponding to the plurality of sample texts.
[0186] S606: Recognize the text content of each sample picture.
[0187] S608: For any sample picture, compare the text content of the sample picture with the sample text corresponding to the sample picture to determine the error label corresponding to the text content of the sample picture.
[0188] S610: Generate an initial sample set according to the text content of each sample picture and the error label corresponding to the text content of each sample picture.
[0189] In the embodiments of the present application, there are many ways to obtain the initial sample set. Usually, multiple sample texts are manually labeled. For example, for the sample text "令人恐布", the incorrect character recognized manually is "布", and this sample text is labeled to obtain the error label "0 0 0 F" of this sample text.
[0190] In practical applications, the errors in the text include errors of similar-looking characters, such as "己" and "已", "七" and "匕". Since the amount of error data collected manually is large, multiple sample texts can be converted into pictures to obtain the sample pictures corresponding to each sample text respectively. Optical Character Recognition (OCR) is performed on each sample picture to obtain the text content of each sample picture. Then, the text content of each sample picture can be aligned with the sample text corresponding to each sample picture. Here, the alignment process refers to aligning the text content of the sample picture with the sample text corresponding to the sample picture character by character. The alignment process uses the dynamic programming algorithm to perform operations such as inserting a character, deleting a character, and replacing a character on the incorrect sentence. Each time an operation is performed, the cost is incremented by one, and the operation sequence with the minimum cost is found, and annotations are made at the corresponding positions to obtain the incorrect characters that cannot be aligned, the positions of these incorrect characters, and the corresponding correct characters. For example, when aligning "好好学习" and "好女子学习", it is determined that "女子" is the incorrect character that cannot be aligned. The positions of this incorrect character are the second and third characters in "好女子学习", and the corresponding correct characters are "好".
[0191] It should be noted that there are multiple ways to convert multiple sample texts into pictures to obtain the sample pictures corresponding to each sample text respectively, including but not limited to screenshotting, preset picture conversion tools, and specific selection is made according to the actual situation. The embodiments of the present application do not make any limitations in this regard.
[0192] For example, the sample text "preset threshold" is screenshot to obtain a corresponding picture, optical character recognition is performed on the picture to obtain the text content "preset threshold" of the picture, alignment is performed on "preset threshold" and "preset threshold" to obtain the error label "0 0 F 0" corresponding to the text content "preset threshold" of the picture. The sample text "dagger" is screenshot to obtain a corresponding picture, optical character recognition is performed on the picture to obtain the text content "seven poems", alignment is performed on "dagger" and "seven poems", and the error label "F 0" corresponding to the text content "seven poems" of the picture is obtained. The initial sample set is generated according to the text content "preset threshold" and the error label "0 0 F 0" corresponding to the text content, and the text content "seven poems" and the error label "F 0" corresponding to the text content.
[0193] S612: Extracting the first sample text, inputting the first sample text into the initial label determination model, and obtaining first predicted error information of the first sample text, wherein the first sample text is any sample text in the initial sample set.
[0194] S614: Calculating a first loss value according to the first predicted error information and the error label corresponding to the first sample text.
[0195] S616: If the first loss value is greater than a first preset threshold, adjusting the model parameters of the initial label determination model.
[0196] And returning to step S612.
[0197] S618: If the first loss value is less than or equal to the first preset threshold, stopping training and obtaining the trained label determination model.
[0198] S612, S614, S616 and S618 are the same as S304, S306, S308 and S310, and the present embodiment will not be described again.
[0199] According to the embodiments of the present application, by converting multiple sample texts into pictures, multiple sample pictures corresponding to the multiple sample texts are obtained, the text content of each sample picture is recognized, for any sample picture, the text content of the sample picture is aligned with the sample text corresponding to the sample picture, the error label corresponding to the text content (the text content with errors) of the sample picture is determined, the initial sample set is generated according to the text content of each sample picture and the error label corresponding to the text content of each sample picture, the initial label determination model is trained, and the trained label determination model is obtained, so that the label determination model can recognize similar character errors and improve the accuracy of model error detection.
[0200] Figure 7The flowchart of the fourth method for training a text error detection model provided by an embodiment of the present application is shown, which specifically includes the following steps:
[0201] S702: Obtain multiple sample texts.
[0202] S704: Use a preset audio conversion tool to convert the multiple sample texts into corresponding sample audios respectively.
[0203] S706: Identify the text content of each sample audio.
[0204] S708: For any sample audio, compare the text content of the sample audio with the sample text corresponding to the sample audio, and determine the error label corresponding to the text content of the sample audio.
[0205] S710: Generate an initial sample set according to the text content of each sample audio and the error label corresponding to the text content of each sample audio.
[0206] In practical applications, the errors in the text include errors of homophonic characters, such as "到" and "道", "气" and "汽". Since the amount of data for collecting these errors manually is large, therefore, a preset audio conversion tool can be used to convert multiple sample texts into corresponding sample audios respectively, and each sample audio can be recognized to obtain the text content of each sample audio. The text content of each sample audio can be aligned with the sample text corresponding to each sample audio. Among them, the alignment process is the same as that in Figure 6 , which will not be elaborated in this embodiment. The preset audio conversion tool refers to various tools that can convert text into audio. After obtaining the sample audio, a tool that can convert audio into text is used to recognize the text content of each sample audio. The specific implementation method is selected according to the actual situation, and the embodiments of the present application do not make any limitations in this regard.
[0207] Illustrate the alignment process by example: Use I to represent inserting a character, D to represent deleting a character, R to represent replacing a character, and 0 to represent that the character remains unchanged. Perform an alignment operation on the wrong sentence "我去池饭" and the correct sentence "我去吃饭". The situation of "0 0 DI 0" means deleting the character "池" and inserting "吃". At this time, two operations are performed, so the cost is 2; the situation of "0 0 R 0" means replacing the character "池" with "吃". At this time, one operation is performed, so the cost is 1. Comparing these two situations, the cost in the case of "0 0 R0" is the smallest, that is, the operation sequence of directly replacing the character "池" with "吃" is selected, and the position corresponding to "R" is marked as the position of the misaligned character. Therefore, "0 0 F 0" is used as the error label of the wrong sentence "我去池饭". It should be noted that data with a cost exceeding a preset ratio can be deleted. The specific implementation method is selected according to the actual situation, and the embodiments of the present application do not make any limitations in this regard.
[0208] For example, the sample text "I know you" is converted into corresponding audio by using the preset audio conversion tool, the audio is recognized to obtain the text content "I know you", the text "I know you" is aligned with the text "I know you" to obtain the error label "0 0 F 0" corresponding to the text content "I know you". The sample text "car" is converted into corresponding audio by using the preset audio conversion tool, the audio is recognized to obtain the text content "car", the text "car" is aligned with the text "car" to obtain the error label "F 0" corresponding to the text content "car", and the initial sample set is generated according to the text content "I know you" and the error label "0 0 F 0" corresponding to the text content, and the text content "car" and the error label "F 0" corresponding to the text content.
[0209] S712: extracting a first sample text, inputting the first sample text into the initial label determination model, and obtaining first predicted error information of the first sample text, wherein the first sample text is any sample text in the initial sample set.
[0210] S714: calculating a first loss value according to the first predicted error information and an error label corresponding to the first sample text.
[0211] S716: if the first loss value is greater than a first preset threshold, adjusting model parameters of the initial label determination model.
[0212] And returning to step S712.
[0213] S718: if the first loss value is less than or equal to the first preset threshold, stopping training, and obtaining the trained label determination model.
[0214] S712, S714, S716 and S718 are the same as S304, S306, S308 and S310, and the present embodiment will not be described again.
[0215] According to the embodiments of the present application, a plurality of sample texts are converted into corresponding sample audios by using the preset audio conversion tool, the text content of each sample audio is recognized, for any sample audio, the text content of the sample audio is compared with the sample text corresponding to the sample audio, the error label corresponding to the text content (the text content with dislocation) of the sample audio is determined, the initial sample set is generated according to the text content of each sample audio and the error label corresponding to the text content of each sample audio, the initial label determination model is trained, and the trained label determination model is obtained, so that the label determination model can recognize audio and character errors, and the accuracy of model error detection is improved.
[0216] Figure 8A flowchart of a fifth text error detection model training method according to an embodiment of the present application is shown, and specifically includes the following steps:
[0217] S802: Obtain a plurality of sample texts.
[0218] S804: Match the plurality of sample texts with a preset error database, and respectively perform random error word replacement on the plurality of sample texts to generate error word replacement texts corresponding to the sample texts respectively.
[0219] S806: For any sample text, compare the sample text with the error word replacement text corresponding to the sample text to determine an error label corresponding to the error word replacement text.
[0220] S808: Generate an initial sample set according to the error word replacement texts and the error labels corresponding to the error word replacement texts.
[0221] In actual application, the preset error database includes a large number of similar words, such as "qi-gui", "zuo-zuo", and "qing-qing". When performing random error word replacement on the plurality of sample texts, the words in the sample texts can be replaced with the similar words in the preset error database to generate the error word replacement texts corresponding to the sample texts.
[0222] For example, match the sample text "we are very happy" with the preset error database, replace 80% of the words in the sample text with similar words in the preset error database, and randomly select a different word to replace the remaining 20% of the words in the preset error database, i.e., replace "I" with the similar word "wu", "men" with the similar word "men", "very" with the similar word "hen", "happy" with the similar word "sin", and randomly select a different word "bang" from the preset error database to replace "fu", to obtain the error word replacement text "wu men hen sin bang". Compare "wu men hen sin bang" with "we are very happy" to obtain the error label "F F F F F" corresponding to "wu men hen sin bang", and generate the initial sample set according to "wu men hen sin bang" and "F F F F F".
[0223] S810: Extract a first sample text, input the first sample text into the initial label determination model, and obtain first predicted error information of the first sample text, wherein the first sample text is any sample text in the initial sample set.
[0224] S812: Calculate a first loss value according to the first predicted error information and the error label corresponding to the first sample text.
[0225] S814: If the first loss value is greater than a first preset threshold, adjust the model parameters of the initial label determination model, and return to step S810.
[0226] S816: If the first loss value is less than or equal to the first preset threshold, stop training, and obtain the trained label determination model.
[0227] S810, S812, S814, and S816 are the same as S304, S306, S308, and S310, and the embodiments of the present application will not be described again.
[0228] According to the embodiments of the present application, the plurality of sample texts and the preset error database are matched, the plurality of sample texts are respectively randomly replaced with wrong words, the wrong word replacement text corresponding to each sample text is generated, for any sample text, the sample text and the wrong word replacement text corresponding to the sample text are compared, the error label corresponding to the wrong word replacement text is determined, the initial sample set is generated according to each wrong word replacement text and the error label corresponding to each wrong word replacement text, the initial label determination model is trained, the trained label determination model is obtained, and the accuracy of model error detection is improved.
[0229] Figure 9 A flowchart of a text error detection method according to an embodiment of the present application is shown, which specifically includes the following steps:
[0230] S902: Obtain a to-be-processed text.
[0231] S904: Input the to-be-processed text into a text error detection model to obtain an error detection result of the to-be-processed text.
[0232] The text error detection model is trained by any text error detection model training method shown in the figure. Figures 2 to 8
[0233] Specifically, the text type of the to-be-processed text includes but is not limited to a text file type and a picture file format type, the format of the text file type includes but is not limited to txt, doc, and docx, the to-be-processed text can be a text in various languages, such as a Chinese text and an English text, and the selection is specifically made according to actual conditions, and the embodiments of the present application do not make any limitation on this.
[0234] In addition, the error detection result of the to-be-processed text is an error label of the to-be-processed text, for example, the to-be-processed text is "You are really bright today", the to-be-processed text is input into the text error detection model, and the error detection result of the to-be-processed text is "0 0 0 0 F 0".
[0235] It should be noted that the to-be-processed text can be input into the text error detection model trained by any text error detection model training method shown in the figure. Figures 2 to 8 In the text error detection model trained by any of the text error detection model training methods shown, an error detection result of the to-be-processed text is obtained. In this way, since the text error detection model is trained based on the expanded target sample set, the text error detection model has high accuracy in text error detection, and thus, when the to-be-processed text is input into the text error detection model, an accurate error detection result can be obtained, the accuracy of text error detection is improved, and user experience is further improved.
[0236] Figure 10 A flowchart of a text error detection model training method and a text error detection method according to an embodiment of the present application is shown, and specifically includes the following steps:
[0237] Training a label determination model: generating an initial sample set by using artificially labeled data, random error data, similar error data, and similar sound error data, iteratively training an initial label determination model by using the initial sample set, and obtaining a trained label determination model;
[0238] Generating error labels corresponding to each test text: inputting a plurality of unlabeled test texts into the trained label determination model to generate error labels corresponding to each test text;
[0239] Generating a target sample set: adding each test text and the error label corresponding to each test text in the initial sample set to generate a target sample set;
[0240] Training a text error detection model: iteratively training an initial text error detection model by using the target sample set to generate a trained text error detection model;
[0241] Text error detection: inputting a to-be-processed text into the trained text error detection model to generate an error detection result of the to-be-processed text.
[0242] By applying the scheme of the embodiments of the present application, the target sample set is generated according to each test text and the error label corresponding to each test text, the training data of the initial text error detection model is expanded, the accuracy of the text error detection model trained is improved, and the accuracy of text error detection based on the text error detection model is further improved.
[0243] Corresponding to the method embodiments described above, the present application also provides text error detection model training device embodiments, Figure 11 A structural diagram of a text error detection model training device according to an embodiment of the present application is shown.
[0244] As Figure 11 shown, the device includes:
[0245] The test set acquisition module 1102 is configured to acquire a test set, wherein the test set includes a plurality of unlabeled test texts;
[0246] The error label generation module 1104 is configured to input each test text into a pre-trained label determination model to obtain an error label corresponding to each test text.
[0247] The target sample set generation module 1106 is configured to generate a target sample set according to each test text and the error label corresponding to each test text.
[0248] The model generation module 1108 is configured to perform iterative training on the initial text fault detection model by using the target sample set to obtain a trained text fault detection model.
[0249] Optionally, the apparatus further comprises:
[0250] The label determination model training module is configured to obtain an initial sample set, wherein the initial sample set comprises a plurality of sample texts and an error label corresponding to each sample text; extract a first sample text, input the first sample text into an initial label determination model to obtain first predicted error information of the first sample text, wherein the first sample text is any sample text in the initial sample set; calculate a first loss value according to the first predicted error information and the error label corresponding to the first sample text; if the first loss value is greater than a first preset threshold, adjust a model parameter of the initial label determination model, and return to perform the step of extracting the first sample text, inputting the first sample text into the initial label determination model, and obtaining the first predicted error information of the first sample text; if the first loss value is less than or equal to the first preset threshold, stop training, and obtain a trained label determination model.
[0251] Optionally, the target sample set generation module 1106 is further configured to add each test text and the error label corresponding to each test text in the initial sample set to generate the target sample set.
[0252] Optionally, the label determination model training module is further configured to obtain a plurality of sample texts; perform picture conversion on the plurality of sample texts respectively to obtain a sample picture corresponding to each sample text; recognize text content of each sample picture; for any sample picture, compare the text content of the sample picture with a sample text corresponding to the sample picture to determine an error label corresponding to the text content of the sample picture; and generate the initial sample set according to the text content of each sample picture and the error label corresponding to the text content of each sample picture.
[0253] Optionally, the label determination model training module is further configured to obtain a plurality of sample texts; convert the plurality of sample texts into corresponding sample audios respectively by using a preset audio conversion tool; identify the text content of each sample audio; for any sample audio, compare the text content of the sample audio with the sample text corresponding to the sample audio to determine the error label corresponding to the text content of the sample audio; and generate an initial sample set according to the text content of each sample audio and the error label corresponding to the text content of each sample audio.
[0254] Optionally, the label determination model training module is further configured to obtain a plurality of sample texts; match the plurality of sample texts with a preset error database, randomly replace the plurality of sample texts with error words respectively to generate error word replacement texts corresponding to the plurality of sample texts respectively; for any sample text, compare the sample text with the error word replacement text corresponding to the sample text to determine the error label corresponding to the error word replacement text; and generate an initial sample set according to each error word replacement text and the error label corresponding to each error word replacement text.
[0255] Optionally, the initial text error detection model is obtained by pruning the initial label determination model.
[0256] Optionally, the model generation module 1108 is further configured to extract a second sample text from the target sample set, input the second sample text into the initial text error detection model to obtain second predicted error information of the second sample text, wherein the second sample text is any text in the target sample set; calculate a second loss value according to the second predicted error information and the error label corresponding to the second sample text; if the second loss value is greater than a second preset threshold, adjust the model parameters of the initial text error detection model, and return to execute the step of extracting the second sample text from the target sample set, inputting the second sample text into the initial text error detection model to obtain the second predicted error information of the second sample text; if the second loss value is less than or equal to the second preset threshold, stop training, and obtain the trained text error detection model.
[0257] By applying the scheme of the embodiments of the present application, a test set is obtained, wherein the test set includes a plurality of test texts without labels, each test text is input into the pre-trained label determination model to obtain the error label corresponding to each test text, a target sample set is generated according to each test text and the error label corresponding to each test text, the initial text error detection model is iteratively trained by using the target sample set to obtain the trained text error detection model, the training data of the initial text error detection model is expanded by generating the target sample set according to each test text and the error label corresponding to each test text, the accuracy of the text error detection model obtained by training is improved, and the accuracy of text error detection based on the text error detection model is further improved.
[0258] The above is a schematic scheme of the text error detection model training device of the embodiment. It should be noted that the technical scheme of the text error detection model training device and the technical scheme of the text error detection model training method described above belong to the same concept. The technical scheme of the text error detection model training device is not described in detail. The details can be referred to the description of the technical scheme of the text error detection model training method. In addition, each component in the device embodiment should be understood as a functional module that must be established to implement each step of the program flow or each step of the method. Each functional module is not an actual functional division or separation limitation. The device claim defined by such a group of functional modules should be understood as a functional module architecture for realizing the solution of the computer program mainly by the specification, and should not be understood as an entity device for realizing the solution mainly by hardware.
[0259] Corresponding to the method embodiment, the application also provides a text error detection device embodiment, Figure 12 The structure of a text error detection device provided by an embodiment of the application is shown. As shown in the figure, Figure 12 The device includes:
[0260] The text to be processed is obtained by the text to be processed acquisition module 1202.
[0261] The error detection result generation module 1204 is configured to input the text to be processed into the text error detection model to obtain the error detection result of the text to be processed, wherein the text error detection model is trained by using any of the text error detection model training methods described above.
[0262] By using the scheme of the embodiment of the application, the text to be processed is obtained, the text to be processed is input into the text error detection model trained by using the text error detection model training method, the error detection result of the text to be processed is obtained, the target sample set is generated according to each test text and the error label corresponding to each test text, the training data of the initial text error detection model is expanded, the accuracy of the text error detection model trained is improved, and the accuracy of the text error detection based on the text error detection model is further improved.
[0263] The above is a schematic scheme of the text error detection device of the embodiment. It should be noted that the technical scheme of the text error detection device and the technical scheme of the text error detection method described above belong to the same concept, and the details of the technical scheme of the text error detection device that are not described in detail can be referred to the description of the technical scheme of the text error detection method. In addition, each component in the device embodiment should be understood as a functional module that must be established to implement each step of the program flow or each step of the method. Each functional module is not limited by actual functional division or separation. The device claim defined by such a group of functional modules should be understood as a functional module architecture of the computer program for realizing the solution mainly by means of the specification, and should not be understood as an entity device for realizing the solution mainly by means of hardware.
[0264] Figure 13 A structural block diagram of a computing device according to an embodiment of the present application is shown. The components of the computing device 1300 include, but are not limited to, a memory 1310 and a processor 1320. The processor 1320 is connected to the memory 1310 through a bus 1330, and a database 1350 is used to save data.
[0265] The computing device 1300 also includes an access device 1340, which enables the computing device 1300 to communicate via one or more networks 1360. Examples of these networks include the Public Switched Telephone Network (PSTN), a Local Area Network (LAN), a Wide Area Network (WAN), a Personal Area Network (PAN), or a combination of communication networks such as the Internet. The access device 1340 can include one or more of any type of network interface (e.g., a Network Interface Card (NIC)) such as a IEEE 802.11 Wireless Local Area Networks (WLAN) wireless interface, a Worldwide Interoperability for Microwave Access (Wi-MAX) interface, an Ethernet interface, a Universal Serial Bus (USB) interface, a cellular network interface, a Bluetooth interface, a Near Field Communication (NFC) interface, and the like, either wired or wireless.
[0266] In an embodiment of the present application, the above components of the computing device 1300 and Figure 13Other components not shown can also be connected to each other in the system, such as through a bus. It should be understood that Figure 13 The illustrated computing device structural block diagram is merely for the purpose of example, and is not a limitation on the scope of the present application. Other components can be added or replaced by those skilled in the art as needed.
[0267] The computing device 1300 can be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., a tablet computer, a personal digital assistant, a laptop computer, a notebook computer, a netbook, etc.), a mobile phone (e.g., a smartphone), a wearable computing device (e.g., a smart watch, smart glasses, etc.), or other type of mobile device, or a stationary computing device such as a desktop computer or PC. The computing device 1300 can also be a mobile or stationary server.
[0268] The processor 1320 is configured to execute computer-executable instructions for implementing the text error detection model training method or the text error detection method described above.
[0269] The above is a schematic scheme of the computing device of the embodiment. It should be noted that the technical scheme of the computing device belongs to the same concept as the technical scheme of the text error detection model training method or the text error detection method described above, and the details of the technical scheme of the computing device that are not described in detail can be referred to the description of the technical scheme of the text error detection model training method or the text error detection method described above.
[0270] An embodiment of the present application also provides a computer readable storage medium storing computer instructions, which are executed by a processor to implement the text error detection model training method or the text error detection method described above.
[0271] The above is a schematic scheme of the computer readable storage medium of the embodiment. It should be noted that the technical scheme of the storage medium belongs to the same concept as the technical scheme of the text error detection model training method or the text error detection method described above, and the details of the technical scheme of the storage medium that are not described in detail can be referred to the description of the technical scheme of the text error detection model training method or the text error detection method described above.
[0272] An embodiment of the present application also provides a chip storing a computer program, which is executed by the chip to implement the steps of the text error detection model training method or the text error detection method described above.
[0273] The above-described embodiments of the application have several aspects, no single one of which is solely responsible for the application's desirable attributes. Without limiting the scope of the application as expressed by the claims which follow, some further embodiments make these aspects even more useful. Other embodiments can result in less desirable attributes.
[0274] The computer readable medium can include any entity or apparatus capable of carrying the computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signal, telecommunication signal, software distribution medium, etc.
[0275] It should be noted that, for the foregoing method embodiments, the acts described can be performed in a different order from the order described, and that certain acts can be performed in parallel or concurrently. In addition, some of the acts described above can be optional. Furthermore, those skilled in the art will appreciate that the acts really constitute only a selection of the embodiments of the present application. Accordingly, the acts described above are not intended to limit the scope of the application as described by the claims.
[0276] In the above embodiments, the description of each embodiment focuses on different aspects, and the parts not described in detail in a certain embodiment can be referred to the relevant description of other embodiments.
[0277] The preferred embodiments of the application disclosed above are only used to help explain the application. Alternative embodiments do not describe all the details, nor limit the application to only the specific embodiments described. Obviously, according to the content of the application, many modifications and changes can be made. The application selects and describes these embodiments in order to better explain the principles and practical applications of the application, so that those skilled in the art can well understand and utilize the application. The application is limited only by the claims and their full scope and equivalents.
Claims
1. A method for training a text error detection model, characterized in that, The method comprises the following steps: acquiring a test set comprising a plurality of unlabeled test texts; inputting each test text into a pre-trained label determination model to obtain an error label corresponding to the test text, wherein the label determination model is obtained by training an initial label determination model based on an initial sample set, and the initial sample set comprises text content obtained by recognizing sample audio corresponding to a plurality of sample texts and an error label corresponding to the text content, text content obtained by recognizing sample pictures corresponding to a plurality of sample texts and an error label corresponding to the text content, and error label corresponding to error word replacement text of a plurality of sample texts; generating a target sample set according to the initial sample set, the test texts, and the error labels corresponding to the test texts; iteratively training an initial text error detection model using the target sample set to obtain a trained text error detection model, wherein the initial text error detection model is obtained by pruning the initial label determination model.
2. The method of claim 1, wherein, The training method of the label determination model comprises the following steps: acquiring an initial sample set comprising a plurality of sample texts and error labels corresponding to the sample texts; extracting a first sample text and inputting the first sample text into an initial label determination model to obtain first predicted error information of the first sample text, wherein the first sample text is any sample text in the initial sample set; calculating a first loss value according to the first predicted error information and the error label corresponding to the first sample text; if the first loss value is greater than a first preset threshold, adjusting model parameters of the initial label determination model, and returning to the step of extracting a first sample text and inputting the first sample text into an initial label determination model to obtain first predicted error information of the first sample text; if the first loss value is less than or equal to the first preset threshold, stopping training and obtaining a trained label determination model.
3. The method of claim 2, wherein, The step of generating a target sample set according to the test texts and the error labels corresponding to the test texts comprises the following steps: adding the test texts and the error labels corresponding to the test texts in the initial sample set to generate a target sample set.
4. The method of claim 2, wherein, The step of acquiring an initial sample set comprises the following steps: acquiring a plurality of sample texts; performing picture conversion on the plurality of sample texts respectively to obtain sample pictures corresponding to the plurality of sample texts respectively; recognizing text content of each sample picture; for any sample picture, comparing the text content of the sample picture with a sample text corresponding to the sample picture to determine an error label corresponding to the text content of the sample picture; generating an initial sample set according to the text content of each sample picture and the error label corresponding to the text content of each sample picture.
5. The method of claim 2, wherein, The step of acquiring an initial sample set comprises the following steps: acquiring a plurality of sample texts; using a preset audio conversion tool to convert the plurality of sample texts into corresponding sample audios respectively; recognizing text content of each sample audio; For any sample audio, compare the text content of the sample audio with the sample text corresponding to the sample audio to determine an error label corresponding to the text content of the sample audio; According to the text content of each sample audio and the error label corresponding to the text content of each sample audio, generate an initial sample set.
6. The method of claim 2, wherein, The step of obtaining the initial sample set comprises: Obtaining a plurality of sample texts; Matching the plurality of sample texts with a preset error database, respectively performing random wrong word replacement on the plurality of sample texts to generate a wrong word replacement text corresponding to each sample text; For any sample text, compare the sample text with the wrong word replacement text corresponding to the sample text to determine an error label corresponding to the wrong word replacement text; According to each wrong word replacement text and the error label corresponding to each wrong word replacement text, generate an initial sample set.
7. The method of claim 2, wherein, The initial text error detection model is obtained by pruning the initial label determination model.
8. The method according to any one of claims 1 to 7, characterized in that, The step of using the target sample set to iteratively train the initial text error detection model to obtain a trained text error detection model comprises: Extracting a second sample text from the target sample set, inputting the second sample text into the initial text error detection model to obtain second predicted error information of the second sample text, wherein the second sample text is any text in the target sample set; According to the second predicted error information and the error label corresponding to the second sample text, calculate a second loss value; If the second loss value is greater than a second preset threshold, adjust the model parameters of the initial text error detection model, and return to execute the step of extracting a second sample text from the target sample set, inputting the second sample text into the initial text error detection model to obtain second predicted error information of the second sample text; If the second loss value is less than or equal to the second preset threshold, stop training and obtain a trained text error detection model.
9. A method of text error detection, the method comprising: Comprise: Obtaining a text to be processed; Inputting the text to be processed into the text error detection model trained by the method of any one of claims 1-8 to obtain an error detection result of the text to be processed.
10. A text error detection model training device, characterized in that, Comprise: A test set acquisition module configured to acquire a test set, the test set comprising a plurality of unlabeled test texts; An error label generation module configured to input each test text into a pre-trained label determination model to obtain an error label corresponding to each test text, wherein the label determination model is obtained by training an initial label determination model based on an initial sample set, and the initial sample set comprises text content and corresponding error labels obtained by recognizing sample audios corresponding to a plurality of sample texts, text content and corresponding error labels obtained by recognizing sample pictures corresponding to the plurality of sample texts, and wrong word replacement texts corresponding to the plurality of sample texts and corresponding error labels; A target sample set generation module configured to generate a target sample set according to the initial sample set, the test texts, and the error labels corresponding to the test texts. The model generation module is configured to iteratively train an initial text bug detection model by using the target sample set to obtain a trained text bug detection model, wherein the initial text bug detection model is obtained by pruning the initial label determination model.
11. A text error detection apparatus, characterized by comprising: The method comprises the following steps: The text to be processed is obtained by the text to be processed acquisition module. The bug detection result generation module inputs the text to be processed into the text bug detection model trained by the method of any one of claims 1-8 to obtain the bug detection result of the text to be processed.
12. A computing device, comprising: The method comprises the following steps: A memory and a processor are included. The memory is used to store computer executable instructions, and the processor is used to execute the computer executable instructions to realize the steps of the method of any one of claims 1-8 or claim 9.
13. A computer-readable storage medium storing computer instructions, wherein, The instructions are executed by the processor to realize the steps of the method of any one of claims 1-8 or claim 9.
Citation Information
Patent Citations
Voice recognition model training method and device, and voice recognition method and device
CN111754985A
Text error detection method and device, computer equipment and storage medium
CN112307749A
Named entity recognition model training method and device
CN112818691A
Error correction method for speech recognition text
CN113205813A
Character recognition model training method and device
CN113947773A