Text error correction model training, text error correction method, device, equipment and medium

By segmenting training samples and labeling error categories during text error correction model training, and adjusting the loss function, the problem of poor error correction effects in the existing technology is solved, and more efficient error correction accuracy and training efficiency are achieved.

CN117743857BActive Publication Date: 2024-09-17BEIJING HAITAI FANGYUAN HIGH TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311864820.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-12-29
Publication Date
2024-09-17
Estimated Expiration
2043-12-29

AI Technical Summary

Technical Problem

Existing text error correction methods, especially the sequence-to-edit label method, in practical applications have difficulty in constructing training data due to the high error-free ratio, making it difficult to improve the model training effect and causing poor error correction effects.

Method used

By labeling the preset error correction categories in the training samples, the loss proportion of the correct category in the calculation loss function is reduced until the model reaches the convergence target, thereby improving the accuracy and efficiency of the error correction model. Specific methods include word segmentation of training samples, identifying and labeling incorrect categories, adjusting the loss function to reduce the impact of correct categories, and shortening training time.

Benefits of technology

It improves the accuracy and efficiency of the text error correction model, reduces the error correction rate, enhances the reliability and efficiency of error correction, simplifies the training process, and shortens the training time.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117743857B
    Figure CN117743857B
Patent Text Reader

Abstract

The embodiments of the present application relate to the technical field of text error correction, and specifically to a text error correction model training, a text error correction method, an apparatus, a computer device, and a storage medium. The text error correction model training method comprises: labeling each sample in the training sample set according to a preset error correction category to obtain a labeling result; the preset error correction category includes at least: a correct category and multiple error categories; a sample contains at least one error category; for each input sample input into the text error correction model during training, the output sample corresponding to each input sample is determined; if the input sample does not contain all error categories, the loss ratio of the correct category in the calculation process of the loss function is reduced until the text error correction model reaches the convergence target. Before the text error correction model is trained, the samples are identified and labeled with error categories, which can prevent miscorrections, reduce the miscorrection rate, and thus improve the accuracy, reliability, and efficiency of error correction.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of text error correction, and in particular, to a text error correction model training, a text error correction method, an apparatus, a computer device and a storage medium. Background Art

[0002] Text error types include: extra words, missing words, wrong words, wrong order, etc. The corresponding correction methods are: deletion, addition, replacement, movement, etc. The correct characters remain unchanged. The current typical text correction method is the sequence to editlabel method.

[0003] The sequence-to-edit label method defines several error correction labels such as K, D, A, R, and M for error-free (keep, K), extra words (del, D), missing words (add, A), wrong words (replace, R), and misorder (M), converting text error correction into a sequence labeling problem, and has achieved good error correction results. However, in practical applications, the proportions of various error correction labels vary greatly, especially the high proportion of error-free makes it difficult for the sequence-to-edit label method to construct training data, and it is difficult to improve the model training effect, resulting in poor actual application results.

[0004] Therefore, there is an urgent need for a text error correction method with better error correction effect. Summary of the invention

[0005] The embodiments of the present application provide a text error correction model training, a text error correction method, an apparatus, a computer device, and a storage medium.

[0006] A first aspect of an embodiment of the present application provides a text error correction model training method, comprising:

[0007] Label each sample in the training sample set according to a preset error correction category to obtain a labeling result; the preset error correction category includes at least: a correct category and multiple error categories; a sample contains at least one error category;

[0008] For each input sample in the text error correction model during training, determine the output sample corresponding to each input sample; wherein the output sample refers to the prediction result of the text error correction model for the input sample during each training;

[0009] For each of the output samples, if the input sample does not contain all of the error categories, the loss ratio of the correct category in the calculation process of the loss function is reduced until the text error correction model reaches the convergence target, and the current text error correction model is determined as the target text error correction model.

[0010] On the one hand, the embodiment of the present application identifies and labels the error categories of samples before training the text error correction model and before actual error correction, which can prevent miscorrection, reduce the miscorrection rate, and thus improve the accuracy, reliability and efficiency of error correction;

[0011] On the second aspect, in the embodiment of the present application, during the training process, when the input sample does not contain all the error categories, the loss ratio of the correct category in the calculation process of the loss function is reduced, which can effectively improve the accuracy of the error correction model;

[0012] Thirdly, in the embodiment of the present application, during the training process, when the input sample does not contain all the error categories, the loss ratio of the correct category in the calculation process of the loss function is reduced, that is, the influence of the correct sample on the model is reduced by improving the loss function Loss of the text error correction model, thereby improving the model accuracy;

[0013] Fourthly, the training sample set in the embodiment of the present application uses all wrong samples and does not use correct samples, which can reduce the amount of data processed by the text training model and shorten the training time.

[0014] In an optional embodiment of the present application, the reducing the loss ratio of the correct category in the process of calculating the loss function includes:

[0015] Calculating an initial loss function based on the category annotation set in the input sample and the proportion of each error category in the output sample;

[0016] For the initial loss function of each of the input samples, the proportion coefficient of the correct category is reduced to obtain the target loss.

[0017] During the training process, if the loss function Loss of the current text error correction model is less than or equal to the preset threshold, it means that the training has reached convergence, and the current text error correction model can be determined as the target text error correction model. The embodiment of the present application obtains the target loss by reducing the proportion coefficient of the correct category. The method is simple and fast, and can improve the efficiency of model training.

[0018] In an optional embodiment of the present application, the reducing the loss ratio of the correct category in the process of calculating the loss function includes:

[0019] Determine the category labels of a plurality of the correct categories adjacent to the wrong category in the input sample and the output sample to obtain feature correct category labels;

[0020] The correct category labels of the features in the input samples and the output samples are filtered out.

[0021] The embodiment of the present application improves the accuracy of model training by filtering out the correct category labels of the features in the input samples and the output samples, thereby increasing the loss ratio of incorrect category labels.

[0022] In an optional embodiment of the present application, determining the category labels of a plurality of correct categories adjacent to the wrong category in the input sample and the output sample to obtain the feature correct category label includes:

[0023] Determine category labels of a plurality of correct categories adjacent to the wrong category in the input sample to obtain a first feature set;

[0024] Determine category labels of a plurality of correct categories adjacent to the wrong category in the output sample to obtain a second feature set;

[0025] An intersection of the first feature set and the second feature set is determined as a correct category label of the feature.

[0026] In the embodiment of the present application, in each training process, a first feature set adjacent to the error category in the input sample and a second feature set adjacent to the error category in the output sample are respectively determined, and the intersection of the first feature set and the second feature set is determined as the correct category label of the feature. The training data is constructed more reasonably, and the training time can be effectively shortened and the training efficiency can be improved while ensuring the training effect.

[0027] In an optional embodiment of the present application, after labeling each sample in the training sample set according to a preset error correction category, the method further includes:

[0028] Calculating the number of category labels in each of the preset error correction categories respectively;

[0029] The loss ratio of each preset error correction category is determined according to the number of category annotations in each preset error correction category and the total number of category annotations in the training sample set.

[0030] The embodiment of the present application first calculates the number of category annotations in each preset error correction category, and then determines the loss ratio of each preset error correction category according to the number of category annotations in each preset error correction category and the number of category annotations in the training sample set. The loss ratio of sample annotations in each error correction category can be determined intuitively and specifically, which is convenient for subsequent proportional adjustments and more accurate adjustments.

[0031] In an optional embodiment of the present application, before respectively calculating the number of category labels in each of the preset error correction categories, the method further includes:

[0032] Performing word segmentation processing on each sample in the training sample set;

[0033] Correspondingly, labeling each sample in the training sample set according to a preset error correction category to obtain a labeling result includes:

[0034] Each word segment in each sample in the training sample set is labeled according to the preset error correction category to obtain the labeling result.

[0035] The embodiment of the present application first performs word segmentation processing on each sample in the training sample set, and then labels each word segment in each sample in the training sample set according to a preset error correction category, which can facilitate the subsequent statistics of the loss ratio of each error correction category, improve statistical efficiency, and further improve the efficiency of model training.

[0036] In an optional embodiment of the present application, the word segmentation in the word segmentation process is one or more characters.

[0037] The embodiment of the present application performs word segmentation processing on samples according to characters, the word segmentation is more precise, the error recognition effect is better, and the effect of model training can be further improved.

[0038] In an optional embodiment of the present application, the preset error correction category includes at least one of: extra words, missing words, and wrong words.

[0039] The embodiment of the present application replaces the traditional out-of-order error labels with error categories with more words and error categories with fewer words, and the modification method corresponding to the out-of-order errors is adjusted to deletion and addition, that is, the out-of-order error labels are cancelled, which reduces the computational complexity of error recognition and thereby improves the efficiency of model training.

[0040] A second aspect of the embodiments of the present application provides a text error correction method, comprising:

[0041] Determine whether there is a text error in the text to be corrected;

[0042] If there are text errors in the text to be corrected, the text to be corrected is corrected using the target text correction model as described in any of the above items.

[0043] The text correction method provided in the embodiment of the present application separates text error recognition from text correction, and identifies and labels the error category of the text before correction, which can prevent miscorrection, reduce the miscorrection rate, and thus improve the accuracy, reliability and efficiency of error correction.

[0044] A third aspect of the embodiments of the present application provides a text error correction model training device, comprising:

[0045] A labeling module is used to label each sample in the training sample set according to a preset error correction category to obtain a labeling result; the preset error correction category includes at least: a correct category and multiple error categories; a sample contains at least one error category;

[0046] A first training module, for determining, for each input sample in the text error correction model during training, an output sample corresponding to each input sample; wherein the output sample refers to the prediction result of the text error correction model for the input sample during each training;

[0047] The second training module is used to reduce the loss ratio of the correct category in the calculation process of the loss function for each of the output samples if the input sample does not contain all of the error categories, until the text error correction model reaches the convergence target, and then determine the current text error correction model as the target text error correction model.

[0048] In an optional embodiment of the present application, the second training module is specifically used to: calculate the initial loss function based on the category annotation set in the input sample and the proportion of each incorrect category in the output sample; for the initial loss function of each input sample, reduce the proportion coefficient of the correct category to obtain the target loss.

[0049] In an optional embodiment of the present application, the second training module is specifically used to: determine the category labels of multiple correct categories adjacent to the wrong category in the input sample and the output sample to obtain feature correct category labels; filter out the feature correct category labels in the input sample and the output sample.

[0050] In an optional embodiment of the present application, the second training module is specifically used to: determine the category labels of multiple correct categories adjacent to the wrong category in the input sample to obtain a first feature set; determine the category labels of multiple correct categories adjacent to the wrong category in the output sample to obtain a second feature set; and determine the intersection of the first feature set and the second feature set as the correct category label of the feature.

[0051] In an optional embodiment of the present application, the second training module is also used to: respectively calculate the number of category annotations in each of the preset error correction categories; determine the loss ratio of each of the preset error correction categories based on the number of category annotations in each of the preset error correction categories and the total number of category annotations in the training sample set.

[0052] In an optional embodiment of the present application, the second training module is further used to: perform word segmentation processing on each sample in the training sample set; label each word segment in each sample in the training sample set according to the preset error correction category to obtain the labeling result.

[0053] In an optional embodiment of the present application, the word segmentation in the word segmentation process is one or more characters.

[0054] In an optional embodiment of the present application, the preset error correction category includes at least one of: extra words, missing words, and wrong words.

[0055] A fourth aspect of the embodiments of the present application provides a text error correction device, including:

[0056] A recognition module, used to determine whether the text to be corrected contains text errors;

[0057] An error correction module is used to correct the text to be corrected by using the target text error correction model as described in any of the above items if there are text errors in the text to be corrected.

[0058] According to a fifth aspect of an embodiment of the present application, a computer device is provided, comprising: a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of any of the above methods when executing the computer program.

[0059] A sixth aspect of an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the steps of any of the above methods when executed by a processor.

[0060] The text error correction model training method provided in the embodiment of the present application separates sample preprocessing and error correction model training, first labels each sample in the training sample set according to a preset error correction category, and then after obtaining the initial training result during the training process, if the initial training result does not include all of the error categories, the category proportion of the correct category in the training result is reduced to obtain a corrected training result; the loss function is calculated based on the comparison result of the corrected training result and the labeled result until the text error correction model reaches the convergence target, and the current text error correction model is determined as the target text error correction model.

[0061] On the one hand, the embodiment of the present application identifies and labels the error categories of samples before training the text error correction model and before actual error correction, which can prevent miscorrection, reduce the miscorrection rate, and thus improve the accuracy, reliability and efficiency of error correction;

[0062] On the second hand, in the embodiment of the present application, the initial training results obtained in each training are adjusted during the training process, and the proportion of correct category samples in the initial training results is continuously reduced, which can effectively improve the accuracy of the error correction model;

[0063] In the third aspect, the embodiment of the present application calculates the loss function based on the comparison between the adjusted initial training results and the annotation results, that is, by improving the loss function Loss of the text error correction model to reduce the influence of the correct samples on the model and improve the model accuracy;

[0064] Fourthly, the training sample set in the embodiment of the present application uses all wrong samples and does not use correct samples, which can reduce the amount of data processed by the text training model and shorten the training time. BRIEF DESCRIPTION OF THE DRAWINGS

[0065] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0066] Figure 1 A flowchart of a text error correction model training method provided for one embodiment of the present application;

[0067] Figure 2 A flowchart of a text error correction model training method provided for one embodiment of the present application;

[0068] Figure 3 A flowchart of a text error correction model training method provided for one embodiment of the present application;

[0069] Figure 4 A flowchart of a text error correction model training method provided for one embodiment of the present application;

[0070] Figure 5 A flowchart of a text error correction model training method provided for one embodiment of the present application;

[0071] Figure 6 A flowchart of a text error correction method provided by an embodiment of the present application;

[0072] Figure 7 A schematic diagram of the structure of a text error correction model training device provided in one embodiment of the present application;

[0073] Figure 8 A schematic diagram of the structure of a text error correction device provided in one embodiment of the present application;

[0074] Fig. 9 A schematic diagram of the computer device structure provided for one embodiment of the present application. DETAILED DESCRIPTION

[0075] In the process of implementing the present application, the inventor discovered that there is an urgent need for a text error correction method with better error correction effect.

[0076] In response to the above problems, a text error correction model training method is provided in an embodiment of the present application to improve the efficiency and error correction effect of text error correction.

[0077] The solutions in the embodiments of the present application can be implemented in various computer languages, for example, object-oriented programming languages ​​​​Python, Java and interpreted scripting languages ​​​​JavaScript, etc.

[0078] In order to make the technical solutions and advantages in the embodiments of the present application more clearly understood, the exemplary embodiments of the present application are further described in detail below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present application, rather than an exhaustive list of all the embodiments. It should be noted that the embodiments in the present application and the features in the embodiments can be combined with each other without conflict.

[0079] The text error correction model training method provided in the embodiment of the present application can be applied to any electronic device with computing functions, such as servers, computers, laptops, mobile phones, etc., which are not exhaustive here. The text error correction model training method provided in the embodiment of the present application is described in detail below with reference to specific examples. Figure 1 The text error correction model training method provided in the embodiment of the present application includes the following steps 101 to 103:

[0080] Step 101: label each sample in the training sample set according to a preset error correction category to obtain a labeling result;

[0081] The preset error correction categories include at least: correct categories and multiple error categories; at least one error category is included in one sample; at least one error category is included in one sample. The training sample set can be flexibly adjusted according to different fields or different scenarios, for example, different training sample sets are set for the news field, the medical field, etc. The error categories of the samples in the training sample set and the number and proportion corresponding to each error category can be flexibly adjusted and set according to empirical statistics, and the embodiments of the present application are not specifically limited. It needs to be explained that in order to improve the training effect. Each sample in the training sample set in the embodiment of the present application contains at least one error category, that is, each sample has at least one text error, and there is no completely correct sample. In other words, there may be one error category or multiple error categories in one sample. Among them, the preset error correction categories include at least: correct categories and error categories, the correct category means that the text is error-free, and the error categories include, for example: more words, fewer words, wrong words and sequence errors, etc., which are not specifically limited here and can be flexibly adjusted according to actual conditions. It needs to be further explained that the sample in the embodiment of the present application can be a sentence or a word, etc., and the label annotation is to annotate the individual characters in the sentence or the word, for example: XX formula is a company that is respected and cared for by people. The annotation process is to annotate each character or word with the wrong category, for example, "formula", "respect", "carer" all belong to the wrong category, and other words or characters belong to the correct category. The annotation result is a sample set or any other form containing the wrong category and the correct category annotation mark.

[0082] Step 102: for each input sample in the input text error correction model during training, determine the output sample corresponding to each input sample;

[0083] Among them, the input sample refers to the sample extracted from the training sample and input into the text error correction model. The input sample can include two sets. The first set is the text sample set, for example: xi = [XX formula is a company that is respected and cared for], and the second set is the error correction annotation set yi = [k, k, k, r1, k, k, k, r2, k, k, k, k, k, r3, k, k, k], which respectively correspond to the error category of each word in the text sample set. The output sample refers to the prediction result of the text error correction model on the input sample during each training. The prediction result is the set after the error correction category of each sample is determined. It needs to be explained that when the training reaches the ideal level, the error correction model reaches convergence; the text error correction model can be obtained by training based on the Transformer's Bert series, GPT and other series of pre-training models, which are not exhaustive here. The training result is the prediction result,

[0084] Step 103: For each of the output samples, if the input sample does not contain all of the error categories, the loss ratio of the correct category in the calculation process of the loss function is reduced until the text error correction model reaches the convergence target, and the current text error correction model is determined as the target text error correction model.

[0085] For example, the error categories include error category 1, error category 2, and error category 3, wherein a certain input sample only includes error category 1 and error category 2, and there is no error category 3, that is, error category 3 is a missing error category. That is, the proportion of the first category of the correct category samples in the initial training results can be reduced according to the set ratio. The reduction method can be achieved by reducing the correct category or by increasing the error category. The embodiment of the present application is not specifically limited and can be flexibly adjusted according to actual conditions. The set ratio can be flexibly adjusted according to the type and number of missing error categories. The more types of missing error categories and the greater the number, the higher the reduction ratio of the correct category. On the contrary, the fewer types of missing error categories and the smaller the number, the lower the reduction ratio of the correct category.

[0086] The text error correction model training method provided in the embodiment of the present application separates sample preprocessing and error correction model training, first labels each sample in the training sample set according to a preset error correction category, and then during the training process, for each input sample in the text error correction model input during training, determines the output sample corresponding to each input sample; for each output sample, if the input sample does not contain all the error categories, reduces the loss ratio of the correct category in the calculation process of the loss function until the text error correction model reaches the convergence target, and then determines the current text error correction model as the target text error correction model.

[0087] On the one hand, the embodiment of the present application identifies and labels the error categories of samples before training the text error correction model and before actual error correction, which can prevent miscorrection, reduce the miscorrection rate, and thus improve the accuracy, reliability and efficiency of error correction;

[0088] On the second aspect, in the embodiment of the present application, during the training process, when the input sample does not contain all the error categories, the loss ratio of the correct category in the calculation process of the loss function is reduced, which can effectively improve the accuracy of the error correction model;

[0089] Thirdly, in the embodiment of the present application, during the training process, when the input sample does not contain all the error categories, the loss ratio of the correct category in the calculation process of the loss function is reduced, that is, the influence of the correct sample on the model is reduced by improving the loss function Loss of the text error correction model, thereby improving the model accuracy;

[0090] Fourthly, the training sample set in the embodiment of the present application uses all wrong samples and does not use correct samples, which can reduce the amount of data processed by the text training model and shorten the training time.

[0091] See also Figure 2 In an optional embodiment of the present application, the above step 103, the reducing the loss ratio of the correct category in the process of calculating the loss function, includes the following steps 201-202:

[0092] Step 201: Calculate an initial loss function based on the category annotation set in the input sample and the proportion of each error category in the output sample;

[0093] Step 202: For the initial loss function of each input sample, reduce the proportion coefficient of the correct category to obtain a target loss.

[0094] The embodiment of the present application obtains the target loss by reducing the proportion coefficient of the correct category. The method is simple and fast and can improve the efficiency of model training.

[0095] See also Figure 3 In an optional embodiment of the present application, the above step 103, the process of reducing the loss ratio of the correct category in the process of calculating the loss function, includes the following steps 301-302:

[0096] Step 301: Determine the category labels of multiple correct categories adjacent to the wrong category in the input sample and the output sample to obtain feature correct category labels;

[0097] For example, the text set in the above input sample is xi = [XX formula is a company that is respected and cared for];

[0098] The set of labeled categories in the input sample yi = [k, k, k, r1, k, k, k, r2, k, k, k, k, k, r3, k, k, k]

[0099] Output sample set: y_hat = [k, a, k, rh, k, d, k, k, k, k, a, k, k, d, k, k, k]

[0100] Among them, k represents the category label of the correct category, and r represents the category label of the wrong category of the wrong word.

[0101] For example, take the category labels of the two correct categories adjacent to the wrong category,

[0102] For the first error category r1, its feature correct category is labeled as [k,k,k,k]; for the second error category r2, its feature correct category is labeled as [k,k,k,k]; for the third error category r3, its feature correct category is labeled as [k,k,k,k].

[0103] Step 302: Filter out the correct category labels of the features in the input sample and the output sample.

[0104] Then the new label category set yi_new in the new input sample is formed = [k, k, -, r1, -, k, k, r2, k, k, k, -, -, r3, -, -, k];

[0105] The new output sample set y_hat_new = [k, a, -, rh, -, d, k, k, k, k, a, -, -, d, -, -, k].

[0106] The embodiment of the present application improves the accuracy of model training by filtering out the correct category labels of the features in the input samples and the output samples, thereby increasing the loss ratio of incorrect category labels.

[0107] See also Figure 4 In an optional embodiment of the present application, the above step 301, determining the category labels of multiple correct categories adjacent to the wrong category in the input sample and the output sample to obtain the feature correct category label, includes the following steps 401-403:

[0108] Step 401: Determine the category labels of a plurality of correct categories adjacent to the wrong category in the input sample to obtain a first feature set;

[0109] Step 402: Determine the category labels of a plurality of correct categories adjacent to the wrong category in the output sample to obtain a second feature set;

[0110] Step 403: determine the intersection of the first feature set and the second feature set as the correct category label of the feature.

[0111] As above, the text set in the input sample is xi = [XX formula is a company that is respected and cared for];

[0112] The set of labeled categories in the input sample yi = [k, k, k, r1, k, k, k, r2, k, k, k, k, k, r3, k, k, k]

[0113] According to yi and yhat processing: for the first wrong label r1, the training sample set takes the front and back 2 k characters A1[k,k,k,k]; for the input sample rh, take the front and back 2 k characters B1[a,k,k,d], and when calculating the loss function Loss, both the sample and the prediction are k characters, that is, the intersection of A1 and B1 sets, and the intersection is masked.

[0114] For the second wrong label r2, take the two k characters A[k,k,k,k] before and after; the prediction result yhat is k, which is a non-wrong label, no processing is done, and the loss calculation is not adjusted.

[0115] For the third wrong label r3, take the 2 k characters before and after A3[k,k,k,k]; the prediction result yi is d, take the 2 k characters before and after B3[k,k,k,k], find the intersection of A3 and B3, and mask the intersection.

[0116] Then the new label category set yi_new in the new input sample is formed = [k, k, -, r1, -, k, k, r2, k, k, k, -, -, r3, -, -, k];

[0117] The new output sample set y_hat_new = [k, a, -, rh, -, d, k, k, k, k, a, -, -, d, -, -, k].

[0118] In the embodiment of the present application, in each training process, a first feature set adjacent to the error category in the input sample and a second feature set adjacent to the error category in the output sample are respectively determined, and the intersection of the first feature set and the second feature set is determined as the correct category label of the feature. The training data is constructed more reasonably, and the training time can be effectively shortened and the training efficiency can be improved while ensuring the training effect.

[0119] See also Figure 5 In an optional embodiment of the present application, after the above step 101, in which each sample in the training sample set is labeled according to a preset error correction category, the method further includes the following steps 501-502:

[0120] Step 501, respectively calculating the number of category labels in each of the preset error correction categories;

[0121] For example, a sample is: "XX formula is a company that is respected and cared for by others." Please see the following table (1). The sample word segments are "XX", "formula", "is", "received", "people", "respected", "received", "people", "cared for", "of", and "company".

[0122] Table (1)

[0123] Sample segmentation XX formula yes by people respect by people Gatekeeper of company Error correction category correct Typos correct correct correct Typos correct correct Typos correct correct

[0124] Among them, in the above samples: the total category markings are 11, the category markings of correct categories are 8, the category markings of wrong characters are 3, and the category markings of missing characters and extra characters are both 0.

[0125] Of course, this is only an example. Category annotation can also be segmented according to unit characters or fixed-length characters. This example does not constitute a specific limitation on the sample category annotation method.

[0126] Step 502: Determine the loss ratio of each preset error correction category according to the number of category annotations in each preset error correction category and the total number of category annotations in the training sample set.

[0127] As shown in the example above, in this sample, the loss of the correct category labeling accounts for 8 / 11, the loss of the wrong category labeling accounts for 3 / 11, and the loss of the few and many category labeling accounts for 0.

[0128] The embodiment of the present application first calculates the number of category annotations in each preset error correction category, and then determines the loss ratio of each preset error correction category according to the number of category annotations in each preset error correction category and the number of category annotations in the training sample set. The loss ratio of sample annotations in each error correction category can be determined intuitively and specifically, which is convenient for subsequent proportional adjustments and more accurate adjustments.

[0129] In an optional embodiment of the present application, before the above step 501, respectively calculating the number of category annotations in each of the preset error correction categories, the above text error correction model training method further includes the following steps:

[0130] Performing word segmentation processing on each sample in the training sample set;

[0131] As exemplified in the above steps, each sample may be segmented in the manner in the above table (1). Of course, it may also be segmented in other ways such as unit characters or fixed-length characters. This embodiment of the present application does not make any specific limitation and may be set according to actual conditions.

[0132] Correspondingly, step 101, labeling each sample in the training sample set according to a preset error correction category to obtain a labeling result, includes the following steps:

[0133] Each word segment in each sample in the training sample set is labeled according to the preset error correction category to obtain the labeling result.

[0134] Each word in each sample in the training sample set is labeled according to the preset error correction category to obtain a labeling result.

[0135] For example, in the example in Table (1) above, each word segment can be labeled according to the preset error correction category.

[0136] The embodiment of the present application first performs word segmentation processing on each sample in the training sample set, and then labels each word segment in each sample in the training sample set according to a preset error correction category, which can facilitate the subsequent statistics of the loss ratio of each error correction category, improve statistical efficiency, and further improve the efficiency of model training.

[0137] In an optional embodiment of the present application, the word segmentation in the above word segmentation process is one or more characters.

[0138] That is, the embodiment of the present application performs word segmentation processing on samples according to characters, the word segmentation is more precise, the error recognition effect is better, and the effect of model training can be further improved.

[0139] In an optional embodiment of the present application, the preset error correction category includes at least one of: extra words, missing words, and wrong words.

[0140] The embodiment of the present application replaces the traditional out-of-order error labels with error categories with more words and error categories with fewer words, and the modification method corresponding to the out-of-order errors is adjusted to deletion and addition, that is, the out-of-order error labels are cancelled, which reduces the computational complexity of error recognition and thereby improves the efficiency of model training.

[0141] An embodiment of the present application provides a text error correction method, including the following steps 601-602:

[0142] Step 601: determine whether there is any text error in the text to be corrected;

[0143] The text recognition model can be trained using, for example, a classification language model CNN, RNN, or a Transformer-based Bert series model, a GPT model, etc. It only needs to be able to recognize sample errors, and the embodiments of this application are not specifically limited. It should be explained that the text to be corrected is the target of model application in actual applications, not the training sample used in the above embodiments.

[0144] Step 602: If there are text errors in the text to be corrected, the text to be corrected is corrected using any of the target text correction models described above.

[0145] The text correction method provided in the embodiment of the present application separates text error recognition from text correction, and identifies and labels the error category of the text before correction, which can prevent miscorrection, reduce the miscorrection rate, and thus improve the accuracy, reliability and efficiency of error correction.

[0146] It should be understood that, although the various steps in the flow chart are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear description in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the figure may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these sub-steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.

[0147] See also Figure 7 An embodiment of the present application provides a text error correction model training device 700, including: a labeling module 710, a first training module 720 and a second training module 730, wherein:

[0148] The labeling module 710 is used to label each sample in the training sample set according to a preset error correction category to obtain a labeling result; the preset error correction category at least includes: a correct category and multiple error categories; a sample contains at least one error category;

[0149] The first training module 720 is used to determine the output sample corresponding to each input sample in the text error correction model during training; wherein the output sample refers to the prediction result of the text error correction model on the input sample during each training;

[0150] The second training module 730 is used to reduce the loss ratio of the correct category in the calculation process of the loss function for each output sample if the input sample does not contain all the error categories, until the text error correction model reaches the convergence target, and then determine the current text error correction model as the target text error correction model.

[0151] In an optional embodiment of the present application, the second training module 730 is specifically used to calculate the initial loss function based on the category annotation set in the input sample and the proportion of each incorrect category in the output sample; for the initial loss function of each input sample, the proportion coefficient of the correct category is reduced to obtain the target loss.

[0152] In an optional embodiment of the present application, the second training module 730 is specifically used to determine the category labels of multiple correct categories adjacent to the wrong category in the input sample and the output sample to obtain feature correct category labels; and filter out the feature correct category labels in the input sample and the output sample.

[0153] In an optional embodiment of the present application, the labeling module 710 is specifically used to determine the category labels of multiple correct categories adjacent to the wrong category in the input sample to obtain a first feature set; determine the category labels of multiple correct categories adjacent to the wrong category in the output sample to obtain a second feature set; and determine the intersection of the first feature set and the second feature set as the correct category label of the feature.

[0154] In an optional embodiment of the present application, the labeling module 710 is also used to calculate the number of category labels in each of the preset error correction categories respectively; the second training module 730 is also used to determine the loss ratio of each of the preset error correction categories based on the number of category labels in each of the preset error correction categories and the total number of category labels in the training sample set.

[0155] In an optional embodiment of the present application, the labeling module 710 is also used to perform word segmentation processing on each sample in the training sample set; label each word segment in each sample in the training sample set according to the preset error correction category to obtain the labeling result.

[0156] In an optional embodiment of the present application, the word segmentation in the word segmentation process is one or more characters.

[0157] In an optional embodiment of the present application, the preset error correction category includes at least one of: extra words, missing words, and wrong words.

[0158] See also Figure 8 An embodiment of the present application provides a text error correction device 800, including: a recognition module 810 and an error correction module 820, wherein:

[0159] The identification module 810 is used to determine whether there is a text error in the text to be corrected;

[0160] The error correction module 820 is used to correct the text to be corrected by using any of the target text error correction models as described above if there are text errors in the text to be corrected.

[0161] For the specific limitations of the above-mentioned text error correction model training device 700 and text error correction device 800, please refer to the limitations of the text error correction model training method and text error correction method in the above text, which will not be repeated here. The various modules in the above-mentioned text error correction model training device 700 and text error correction device 800 can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0162] In one embodiment, a computer device is provided, the internal structure diagram of which can be as follows: Fig. 9 As shown. The computer device includes a processor, a memory, a network interface and a database connected via a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data. The network interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, a text error correction model training method and a text error correction method as described above are implemented. It includes: a memory and a processor, the memory stores a computer program, and when the processor executes the computer program, any step in the text error correction model training method and the text error correction method as described above is implemented.

[0163] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, any step in the above-mentioned text error correction model training method and text error correction method can be implemented.

[0164] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.

[0165] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0166] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0167] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0168] Although the preferred embodiments of the present application have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.

[0169] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.

Claims

1. A text error correction model training method, characterized in that: include: Label each sample in the training sample set according to the preset error correction category to obtain the labeling result; The preset error correction categories include at least: a correct category and multiple error categories; a sample contains at least one error category; For each input sample in the text error correction model during training, determine the output sample corresponding to each input sample; wherein the output sample refers to the prediction result of the text error correction model on the input sample during each training; For each of the output samples, if the input sample does not contain all of the error categories, the loss ratio of the correct category in the process of calculating the loss function is reduced until the text error correction model reaches a convergence target, and the current text error correction model is determined as the target text error correction model; wherein, reducing the loss ratio of the correct category in the process of calculating the loss function includes: Determining the category labels of multiple correct categories adjacent to the wrong category in the input sample and the output sample to obtain the feature correct category label, including: determining the category labels of multiple correct categories adjacent to the wrong category in the input sample to obtain a first feature set; determining the category labels of multiple correct categories adjacent to the wrong category in the output sample to obtain a second feature set; determining the intersection of the first feature set and the second feature set as the feature correct category label; The correct category labels of the features in the input samples and the output samples are filtered out.

2. The text error correction model training method according to claim 1, characterized in that: After labeling each sample in the training sample set according to a preset error correction category, the method further includes: Calculating the number of category labels in each of the preset error correction categories respectively; The loss ratio of each preset error correction category is determined according to the number of category annotations in each preset error correction category and the total number of category annotations in the training sample set.

3. The text error correction model training method according to claim 2, characterized in that: Before respectively calculating the number of category labels in each of the preset error correction categories, the method further includes: Performing word segmentation processing on each sample in the training sample set; Correspondingly, labeling each sample in the training sample set according to a preset error correction category to obtain a labeling result includes: Each word segment in each sample in the training sample set is labeled according to the preset error correction category to obtain the labeling result.

4. The text error correction model training method according to claim 3 is characterized in that: The word segmentation in the word segmentation process is one or more characters.

5. The text error correction model training method according to claim 1, characterized in that: The preset error correction category includes at least one of: extra words, missing words, and wrong words.

6. A text error correction method, characterized in that: include: Determine whether there is a text error in the text to be corrected; If there are text errors in the text to be corrected, the text to be corrected is corrected using the target text correction model as described in any one of claims 1 to 5.

7. A text error correction model training device, characterized in that: include: The labeling module is used to label each sample in the training sample set according to the preset error correction category to obtain the labeling result; The preset error correction categories include at least: a correct category and multiple error categories; a sample contains at least one error category; A first training module, for determining, for each input sample in the text error correction model during training, an output sample corresponding to each input sample; wherein the output sample refers to the prediction result of the text error correction model for the input sample during each training; The second training module is used for reducing the loss ratio of the correct category in the process of calculating the loss function for each of the output samples, if the input sample does not contain all the error categories, until the text error correction model reaches a convergence target, and then determining the current text error correction model as the target text error correction model; wherein, reducing the loss ratio of the correct category in the process of calculating the loss function includes: Determining the category labels of multiple correct categories adjacent to the wrong category in the input sample and the output sample to obtain the feature correct category label, including: determining the category labels of multiple correct categories adjacent to the wrong category in the input sample to obtain a first feature set; determining the category labels of multiple correct categories adjacent to the wrong category in the output sample to obtain a second feature set; determining the intersection of the first feature set and the second feature set as the feature correct category label; The correct category labels of the features in the input samples and the output samples are filtered out.

8. The text error correction model training device according to claim 7, characterized in that: The second training module is also used to: respectively calculate the number of category annotations in each of the preset error correction categories; determine the loss ratio of each of the preset error correction categories based on the number of category annotations in each of the preset error correction categories and the total number of category annotations in the training sample set.

9. The text error correction model training device according to claim 8, characterized in that: The labeling module is also used for: performing word segmentation processing on each sample in the training sample set; labeling each word segment in each sample in the training sample set according to the preset error correction category to obtain the labeling result.

10. The text error correction model training device according to claim 9, characterized in that: The word segmentation in word segmentation processing is one or more characters.

11. The text error correction model training device according to claim 7, characterized in that: The preset error correction category includes at least one of: extra words, missing words, and wrong words.

12. A text error correction device, characterized in that: include: A recognition module, used to determine whether the text to be corrected contains text errors; An error correction module is used to correct the text to be corrected by using the target text error correction model according to any one of claims 1 to 5 if there are text errors in the text to be corrected.

13. A computer device comprising: The method comprises a memory and a processor, wherein the memory stores a computer program, and wherein the processor implements the steps of the method according to any one of claims 1 to 6 when executing the computer program.

14. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.