Text error correction method, system, electronic device and medium

Through the mask fine-tuning method, the problem of poor universality of text error correction models in multiple fields is solved, the generalization ability and universality of the model are improved, and more efficient error correction performance is achieved.

CN115983242BActive Publication Date: 2024-12-06BEIJING YOUZHUJU NETWORK TECH CO LTD
View PDF 9 Cites 0 Cited by

Patent Information

Application Number
CN202310149733.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-02-16
Publication Date
2024-12-06
Estimated Expiration
2043-02-16

AI Technical Summary

Technical Problem

Existing text error correction models are poorly versatile in multi-domain scenarios, making it difficult to learn unseen error patterns, resulting in poor performance on unseen data.

Method used

Using the mask fine-tuning (MFT) method, by randomly adding masks in the source sentence, training the model not only needs to correct typos, but also needs to restore the masked words according to the context, enhancing the generalization ability and universality of the model.

Benefits of technology

It improves the generalization ability and universality of the error correction model, can perform well on unseen errors without negatively affecting the distribution of the original data, and significantly improves the learning efficiency and performance of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115983242B_ABST
    Figure CN115983242B_ABST
Patent Text Reader

Abstract

The disclosed embodiments relate to a text error correction method, system, electronic device and medium. The method comprises: obtaining sample labels including source sentences and target sentences, and randomly adding masks to the source sentences in the sample labels to obtain source sentences with masks; inputting the source sentences with masks into a training model to obtain prediction results; calculating precision and recall rates according to the source sentences, target sentences and prediction results of the sample labels; calculating the average precision and average recall rates for the precision and recall rates of multiple sample labels, and calculating the harmonic mean F1 of the precision and recall rates according to the average precision and average recall rates; and adjusting the training model according to the harmonic mean F1, and using the adjusted training model as a text error correction model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the fields of machine learning and artificial intelligence, and in particular, to a text error correction method, system, electronic device, and medium. Background Art

[0002] Text error correction aims to objectively correct the user's text input, such as typos and irregular expressions. Through learning from big data, previous error correction models can effectively correct common errors, but it is difficult to learn error patterns that have not yet been seen. However, for a general error correction system that needs to serve multiple different fields, it is difficult for the model to see all types of errors during training due to the differences in related expressions and knowledge between fields. Summary of the invention

[0003] This summary is provided to introduce concepts in a brief form that will be described in detail in the detailed description below. This summary is not intended to identify key features or essential features of the claimed technical solution, nor is it intended to limit the scope of the claimed technical solution.

[0004] According to some embodiments of the present disclosure, a text correction method is provided, comprising: obtaining sample labels including source sentences and target sentences, and randomly adding masks to the source sentences in the sample labels to obtain source sentences with masks; inputting the source sentences with masks into a training model to obtain prediction results; calculating precision and recall based on the source sentences, target sentences and prediction results of the sample labels; calculating the average precision and average recall for the precision and recall of multiple sample labels, and calculating the harmonic mean F1 of the precision and recall based on the average precision and average recall; and adjusting the training model based on the harmonic mean F1, and using the adjusted training model as a text correction model.

[0005] According to some embodiments of the present disclosure, a text correction system is provided, comprising: a mask adding unit, configured to obtain sample labels including source sentences and target sentences, and randomly add masks to the source sentences in the sample labels to obtain source sentences with masks; a prediction unit, configured to input the source sentences with masks into a training model to obtain prediction results; a calculation unit, configured to calculate the precision and recall rate according to the source sentences, target sentences and prediction results of the sample labels, calculate the average precision and average recall rate for the precision and recall rates of multiple sample labels, and calculate the harmonic mean F1 of the precision and recall rate according to the average precision and average recall rate; and an adjustment unit, configured to adjust the training model according to the harmonic mean F1, and use the adjusted training model as a text correction model.

[0006] According to some embodiments of the present disclosure, an electronic device is provided, comprising: a memory; and a processor coupled to the memory, wherein the processor is configured to execute a method of any embodiment described in the present disclosure based on instructions stored in the memory.

[0007] According to some embodiments of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored. When the program is executed by a processor, the method of any embodiment described in the present disclosure is performed.

[0008] According to some embodiments of the present disclosure, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the method of any embodiment described in the present disclosure is performed.

[0009] Other features, aspects and advantages of the present disclosure will become apparent from the following detailed description of exemplary embodiments of the present disclosure with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0010] The preferred embodiments of the present disclosure are described below with reference to the accompanying drawings. The drawings described herein are used to provide a further understanding of the present disclosure. Each of the drawings together with the following detailed description is included in this specification and forms a part of the specification, and is used to explain the present disclosure. It should be understood that the drawings described below only relate to some embodiments of the present disclosure and do not constitute a limitation on the present disclosure. In the drawings:

[0011] Figure 1 A schematic diagram showing the comparison of the accuracy of the error correction model in the related art on EXC and on INC.

[0012] Figure 2 A schematic diagram showing the distribution difference of the original data distribution produced by the confusion set method represented by KL divergence is shown.

[0013] Figure 3 A schematic diagram showing parameter results obtained when the mask adding ratio attempts to take different values ​​according to an exemplary embodiment of the present disclosure is shown.

[0014] Figure 4 A schematic diagram showing a comparison of the distribution difference generated by the confusion set method on the original data distribution and the distribution difference generated by the MFT of the present invention on the original data distribution, expressed by KL divergence.

[0015] Figure 5 A schematic flowchart of a training method for a text error correction system according to an exemplary embodiment of the present disclosure is shown.

[0016] Figure 6 A schematic diagram comparing the recall of the MFT model and the finetune model is shown.

[0017] Figure 7 A schematic block diagram of a text error correction system according to an exemplary embodiment of the present disclosure is shown.

[0018] Figure 8 A schematic block diagram of an electronic device according to an exemplary embodiment of the present disclosure is shown.

[0019] Fig. 9 A block diagram illustrating an example structure of a computer system that may be employed in an exemplary embodiment according to the present disclosure.

[0020] It should be understood that, for ease of description, the sizes of the various parts shown in the drawings are not necessarily drawn according to the actual proportional relationship. The same or similar reference numerals are used in the various drawings to represent the same or similar parts. Therefore, once an item is defined in one drawing, it may not be further discussed in subsequent drawings. DETAILED DESCRIPTION

[0021] The following will be combined with the drawings in the embodiments of the present disclosure to clearly and completely describe the technical solutions in the embodiments of the present disclosure, but it is obvious that the described embodiments are only part of the embodiments of the present disclosure, rather than all the embodiments. The following description of the embodiments is actually only illustrative and is by no means intended to limit the present disclosure and its application or use. It should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments set forth herein.

[0022] It should be understood that the various steps recorded in the method embodiments of the present disclosure can be performed in different orders, and / or performed in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown in the execution. The scope of the present disclosure is not limited in this respect. Unless otherwise specifically stated, the relative arrangement, numerical expressions and numerical values ​​of the parts and steps set forth in these embodiments should be interpreted as being merely exemplary and do not limit the scope of the present disclosure.

[0023] The term "include" and its variations used in the present disclosure mean an open term including at least the following elements / features but not excluding other elements / features, i.e., "including but not limited to". In addition, the term "include" and its variations used in the present disclosure mean an open term including at least the following elements / features but not excluding other elements / features, i.e., "including but not limited to". Therefore, include is synonymous with include. The term "based on" means "based at least in part on".

[0024] References throughout this specification to "one embodiment," "some embodiments," or "an embodiment" mean that a particular feature, structure, or characteristic described in connection with the embodiment is included in at least one embodiment of the present disclosure. For example, the term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; and the term "some embodiments" means "at least some embodiments." Moreover, the appearances of the phrases "in one embodiment," "in some embodiments," or "in an embodiment" in various places throughout this specification do not necessarily all refer to the same embodiment, but may do so.

[0025] It should be noted that the concepts of "first", "second", etc. mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units. Unless otherwise specified, the concepts of "first", "second", etc. are not intended to imply that the objects described in this way must be in a given order in time, space, ranking, or any other manner.

[0026] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".

[0027] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.

[0028] The embodiments of the present disclosure are described in detail below in conjunction with the accompanying drawings, but the present disclosure is not limited to these specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. In addition, in one or more embodiments, specific features, structures or characteristics can be combined in any suitable manner that will be clear from the present disclosure by a person of ordinary skill in the art.

[0029] The problem of poor versatility of error correction models in related technologies in multiple fields can be attributed to the fact that previous error correction models can effectively correct common errors, but it is difficult to learn error patterns that have not yet been seen. For example, in the SIGHAN test set, 67% of the errors in the samples have appeared in the training set (this part is recorded as INC (inclusive)), and the remaining 33% of the samples have never appeared (this part is recorded as EXC (exclusive)).

[0030] Previous error correction models fit well to the edit points that appeared in the training set, but the accuracy on EXC is very low, such as Figure 1 As shown Figure 1 Among them, from left to right are Precision, Recall, and F1, all of which show a sharp drop on EXC. Among them, Precision is the proportion of correctly predicted positives among all predicted positives, Recall is the proportion of correctly predicted positives among all actual positives, and F1 is the harmonic mean of Precision and Recall. According to a preferred embodiment of the present disclosure, F1 can be calculated by the equation: to calculate F1. F1 takes into account both Precision and Recall, maximizing both and achieving a balance.

[0031] The above problem is called generalization ability, which refers to how well the model performs on unseen data.

[0032] The method of using a confusion set to generate a wider type of error and expand the original error correction training data can simply and effectively generate a relatively common error model, enabling the model to have better performance. Take a simple example, the target sentence: The weather is nice today. According to the confusion set, there is a certain probability that "错" will be written as "戳", and thus the source sentence is obtained by replacement: The weather is not bad today.

[0033] Data augmentation is a method to improve the learning efficiency of the error correction model. For error correction data, the error content in a sentence is very low (usually 0 - 1 error), so the model learning efficiency is low. A traditional way to augment error correction data is to use a confusion set to replace the characters in the sentence and increase the error content, such as "今田天气不戳。" → "今天天气不错。".

[0034] However, the confusion set will seriously change the original distribution of the data, resulting in uncontrollable training performance in multiple domains, thus bringing negative effects.

[0035] Next, the KL (Kullback–Leibler) divergence is used to measure the distribution difference between the training set and the test set before and after data augmentation. KL divergence is a statistic that measures the difference between two distributions, and the larger its value, the greater the difference.

[0036] Refer to Figure 2 , using KL to refer to KL divergence, it can be seen that the method using the confusion set will produce a large distribution difference in the original data distribution.

[0037] Based on this, the present disclosure proposes a masked fine-tuning (MFT: Masked Fine Tuning) error correction system, which can solve the problem of poor generalization ability of the error correction model and will not have any impact on the original data distribution. Among them, MFT is a training objective, that is, the optimization objective during model training.

[0038] The input of the training objective of traditional error correction, i.e., the source sentence (source), is the sentence that originally needs to be corrected. The error correction model needs to detect and correct the errors in the source sentence and output the result, i.e., the target sentence (target). For example, "Today's weather is not bad." → "Today's weather is good.", where the former is the source sentence and the latter is the target sentence.

[0039] According to an embodiment of the present disclosure, MFT randomly adds masks (such as [MASK]) to the source sentence, that is, randomly covers the words in the source sentence. Replacing the words in the source sentence with masks can also be regarded as a kind of data augmentation. The error correction model not only needs to correct misspelled words but also needs to restore the original words at these covered positions according to the context.

[0040] According to an embodiment of the present disclosure, randomly covering the words in the source sentence by MFT generally results in two situations. The first situation is covering the correct word. For example, "Today the sky [MASK] is not bad." → "Today's weather is good.", in this case, MFT needs to infer through the context that the position of [MASK] is "weather". The second situation is covering the wrong word, such as "Today's weather is not [MASK]." → "Today's weather is good.", in this case, MFT doesn't know if there are errors in the source sentence and needs to infer through the context that the position of [MASK] is "bad".

[0041] That is to say, MFT not only needs to learn to correct misspelled words but also needs to learn the context in the sentence to restore the randomly covered words. According to an embodiment of the present disclosure, MFT prefers to let the model correct errors through the context rather than by learning misspelled words. For example, "not bad" -> "good" in the above example. If the model overly memorizes this mapping of misspelled words, it will damage the final generality because the real situations are diverse. In some contexts, "not bad" does not need to be corrected. Therefore, what the model really needs to learn is to correct errors reasonably through the context. This enhances the generalization ability of the error correction model, making it more general.

[0042] According to an embodiment of the present disclosure, MFT is mainly applied to the fine-tuning stage of the pre-trained language model.

[0043] Regarding mask addition, special symbols and English letters should be excluded, and only pure text should be covered. However, judging whether a word at a position is pure text will reduce the running efficiency, and through experiments, it is found that the benefits brought by only covering pure text are very limited. Therefore, the embodiments of the present disclosure preferably adopt the simplest and fastest implementation method, uniformly selecting a certain ratio of words in the input sentence for covering, that is, replacing them with [MASK].

[0044] In the field of language error correction, the harmonic mean F1 of precision and recall is usually used to measure the quality of an error correction model. Based on this, this paper proposes the in-bag F1 (inclusive F1) and out-bag F1 (exclusive F1), which can be abbreviated as I-F1 and E-F1 respectively. Among them, I-F1 refers to the F1 of the model on the errors that have been seen during training, and the key point is "the model has seen it". E-F1 refers to the F1 of the model on the errors that have not been seen during training, and the key point is "the model has not seen it". By using I-F1 and E-F1 to represent, the generalization ability of the error correction model can be better measured.

[0045] Regarding the ratio of mask addition, the present disclosure has tried different values ​​(0.1, 0.2, 0.3, 0.4, 0.5). Figure 3 As shown in the figure, when the mask addition ratio is 0.3, F1, I-F1 and E-F1 are the highest. When the ratio is too high, such as when the ratio is 0.4 or 0.5, the performance will drop significantly because too many masks will destroy the context and make the model unable to predict correctly.

[0046] However, if Figure 3 As shown in the figure, when the FPR exceeds 0.2, the false negative rate (FPR) will increase significantly. The false negative rate is the rate at which the model considers a correct word as wrong. In practical applications, the false negative rate needs to be relatively low.

[0047] Therefore, on the whole, the comprehensive performance of F1 and FPR is best when the mask addition ratio is 0.2.

[0048] Although Figure 3 Although not shown in the figure, the present disclosure also experiments on the parameters when the mask adding ratio is 0.15, and obtains F1=75.6, I-F1=83.1, E-F1=64.8, FPR=13.5 at 0.15. It can be seen that the F1, I-F1 and E-F1 values ​​are all lower than those at 0.2, but the FPR is higher than that at 0.2. Therefore, the performance of each parameter is not as good as that at 0.2.

[0049] Figure 4 It is shown in Figure 2 The comparison after adding the MFT proposed in this disclosure. Figure 4 It can be seen that the method using the confusion set will produce a large distribution difference on the original data distribution, while the MFT disclosed in the present invention will not have any impact on the original data distribution.

[0050] This paper theoretically proves that the error correction language model is a replacement method under the distribution of the original language model, which is based on the general form of the confusion set method. In other words, the confusion set is an approximation of the MFT. The confusion set method generally assumes that the weights are uniform, that is, Where Vt is the confusion set. But from the perspective of the entire corpus, the weight is not Therefore, this is an approximation. Secondly, Vt is not equal to V, but much smaller than V (where V is the complete corpus, which is also an approximation).

[0051] Figure 5 A schematic flowchart 500 of a training method for a text error correction system according to an embodiment of the present disclosure is shown.

[0052] like Figure 5 As shown, at step S510, a sample label is obtained, and a mask is randomly added to the source sentence in the sample label to obtain a source sentence with a mask. Here, the sample label includes a source sentence and a target sentence.

[0053] According to an exemplary embodiment of the present disclosure, the source sentence is "Today's weather is not bad.", and the target sentence is "Today's weather is good." As previously described, the ratio of randomly adding a mask is preferably 0.2. "Today's weather is not bad" has a total of 6 characters, so a mask can be added. For example, the source sentence with a mask obtained by randomly adding a mask is "Today's weather [MASK] is not bad.".

[0054] At step S520, the source sentence with the mask is input into the training model to obtain a prediction result. The training model here can be a commonly used training model in the art.

[0055] Still using the above example to illustrate, we get the forecast result "Today's weather is good.".

[0056] In step S530, the precision and recall are calculated according to the source sentence, the target sentence and the prediction result of the sample label.

[0057] In the above example, the predicted result "The weather is nice today." is consistent with the target sentence "The weather is nice today.", and the precision P and recall R of the MFT error correction system are both 100%.

[0058] In another example, the source sentence of the sample label is "It's a nice day today.", and the target sentence is "It's a nice day today.". Based on the randomly added mask, the prediction result is "It's a nice day today.", then the precision P and recall R of the MFT error correction system are both 0.

[0059] In another example, the source sentence of the sample label is "Today is a nice day.", and the target sentence is "Today is a nice weather.". Based on the randomly added mask, the prediction result is "Today is a nice day." Then the precision P and recall R of the MFT error correction system are 0 and 100% respectively.

[0060] In step S540 , the average precision and average recall are calculated for the precision and recall of multiple sample labels, and F1 is calculated based on the average precision and average recall.

[0061] According to the embodiment of the present disclosure, according to the formula Calculate F1.

[0062] At step S550, the training model is adjusted according to F1, and the adjusted training model is used as a text error correction model. According to an embodiment of the present disclosure, the training model can be used as a text error correction model only when F1 is higher than a certain threshold. For example, the threshold value may be different when applied to different error correction benchmarks, and the threshold value may also be different when used in different fields (such as law, health care, official document writing, etc.). The user can set the threshold value according to the applied error correction benchmark and / or the applied field according to actual needs.

[0063] According to an embodiment of the present disclosure, after obtaining a text error correction model with F1 higher than a certain threshold, the source sentence to be corrected can be input into the text error correction model to obtain a corrected sentence.

[0064] According to a preferred embodiment of the present disclosure, the sample labels can be divided into two parts, one part is the errors that the training model has seen, and the other part is the errors that the training model has not seen. That is, whether the error in the source sentence appears for the training model for the first time, multiple sample labels are divided into two categories, the first category is the first time that the error in the source sentence appears for the training model, and the second category is the error in the source sentence that does not appear for the training model for the first time. The precision and recall of each sample label in these two categories are averaged respectively to obtain the average precision and average recall of the first category of sample labels and the average precision and average recall of the second category of sample labels. Then, E-F1 is calculated based on the average precision and average recall of the first category of sample labels, and I-F1 is calculated based on the average precision and average recall of the second category of sample labels, where E-F1 is the F1 of the training model on those errors that have not been seen during training, and I-F1 is the F1 of the training model on those errors that have been seen during training.

[0065] The masked fine-tuning error correction training learning method proposed in the present disclosure can greatly improve the learning efficiency of the model, thereby having stronger versatility. The masked fine-tuning error correction learning method in the present disclosure can be applied to the error correction model of any language.

[0066] Applying the MFT error correction training method in this disclosure to the commonly used Chinese error correction benchmarks, the Special Interest Group for Chinese Language Processing of the Association for Computational Linguistics (SIGHAN) and another Chinese error correction benchmark, Error Consistent Spelling (ECSpell), can achieve the highest performance levels. Applying the MFT error correction training method in this disclosure to few-shot (even zero-shot) learning also far exceeds the performance of the baseline model (BERT).

[0067] According to an exemplary embodiment of this disclosure, the MFT model of this disclosure is compared with the finetune model.

[0068] As Figure 6 shown, for the same source sentences "Aunt Wu is old", "The new machine may have less noise", and "What about everyone's freedom and rights", the candidate words recalled by the MFT model and the finetune model of this disclosure are different.

[0069] The MFT model can recall multiple candidates that fit the current context, such as "age" and "sound", while the finetune model is more inclined to recall misspelled words, such as "year machine" (homophone) and "soundscape" (same form).

[0070] As shown in Tables 1 - 4 below, by comparing with various different models applied to different error correction benchmarks, it can be seen that by applying the MFT of this disclosure, various performances are not only significantly improved in E-F1, but also improved in I-F1, indicating that the training method proposed in this disclosure确实 improves the generalization ability of the model. Each parameter in Tables 1 - 4 is obtained on the basis of a mask addition ratio of 0.2.

[0071] Table 1: Comparison of Precision, Recall, and F1 Parameters

[0072]

[0073] Table 2: F1 Comparison in the Fields of Law, Healthcare, and Document Writing

[0074] ECSpell law Healthcare Official document writing BERT-finetune 40.2 26.9 26.7 MFT 76.8 63.8 62.9

[0075] Table 3: F1 Comparison in the Fields of Law, Healthcare, and Document Writing

[0076] Zero Sample law Healthcare Official document writing BERT-finetune 53.0 53.5 54.8 MFT 57.5 56.9 64.5

[0077] Table 4: Comparison of I-F1 and E-F1 in the fields of law, healthcare and official writing

[0078]

[0079] Figure 7 A block diagram of a text error correction system 700 according to an exemplary embodiment of the present disclosure is shown.

[0080] like Figure 7 As shown, the text error correction system 700 includes a mask adding unit 71, which is configured to obtain a sample label and randomly add a mask to the source sentence in the sample label to obtain a source sentence with a mask. Here, the sample label includes a source sentence and a target sentence. As previously described, preferably, the ratio of randomly adding a mask is 0.2.

[0081] like Figure 7 As shown, the text error correction system 700 further includes a prediction unit 72 configured to input the source sentence with the mask into the training model to obtain a prediction result.

[0082] like Figure 7 As shown, the text correction system 700 also includes a computing unit 73, which is configured to calculate the precision and recall rate according to the source sentence, the target sentence and the prediction result of the sample label, calculate the average precision and the average recall rate of the precision and the recall rate of multiple sample labels, and calculate F1 according to the average precision and the average recall rate.

[0083] like Figure 7 As shown, the text error correction system 700 further includes an adjustment unit 74 configured to adjust the training model according to F1 and use the adjusted training model as a text error correction model.

[0084] According to an embodiment of the present disclosure, the adjustment unit 74 compares F1 with a certain threshold value, and only when F1 is higher than the threshold value, the training model is used as a text error correction model. For example, the threshold value may be different when applied to different error correction benchmarks, and the threshold value may also be different when used in different fields (such as law, health care, official document writing, etc.). The user can set the threshold value according to the applied error correction benchmark and / or the applied field according to actual needs.

[0085] According to an embodiment of the present disclosure, after obtaining a text error correction model with F1 higher than a certain threshold, the prediction unit 72 may also be configured to input the source sentence to be corrected into the text error correction model to obtain a corrected sentence.

[0086] like Figure 7As shown, the text correction system 700 may also include a classification unit 75, which is configured to classify multiple sample labels into two categories according to whether the error in the source sentence appears for the training model for the first time, the first category being that the error in the source sentence appears for the training model for the first time, and the second category being that the error in the source sentence does not appear for the training model for the first time.

[0087] In addition, according to an embodiment of the present disclosure, the calculation unit 73 can also be configured to average the precision and recall of multiple sample labels in the first category and the second category, respectively, to obtain the average precision and average recall of the first category sample labels and the average precision and average recall of the second category sample labels, and to calculate E-F1 based on the average precision and average recall of the first category sample labels, and to calculate I-F1 based on the average precision and average recall of the second category sample labels. E-F1 is the F1 of the training model on those errors that have not been seen during training, and I-F1 is the F1 of the training model on those errors that have been seen during training.

[0088] The text error correction system provided by the embodiments of the present disclosure can implement the learning method of the masked fine-tuning error correction training provided by the above embodiments. Its implementation principle and technical effect are similar and will not be repeated here.

[0089] The masked fine-tuning Chinese error correction system disclosed in this application can serve various scenarios, such as chatting, news, game dialogues, and forums, to improve the quality of content.

[0090] Some embodiments of the present disclosure also provide an electronic device. Figure 8 The block diagram of some embodiments of the electronic device 8 of the present disclosure is shown. The electronic device can be used to implement the method described in any embodiment of the present disclosure.

[0091] For example, in some embodiments, the electronic device 8 can be various types of devices, such as, but not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. For example, the electronic device 8 can include a display panel for displaying data and / or execution results used in the scheme of the present disclosure. For example, the display panel can be in various shapes, such as a rectangular panel, an elliptical panel, or a polygonal panel. In addition, the display panel can be not only a flat panel, but also a curved panel, or even a spherical panel.

[0092] like Figure 8 As shown, the electronic device 8 of this embodiment includes: a memory 81 and a processor 82 coupled to the memory 81. It should be noted that Figure 8The components of the electronic device 8 shown are only exemplary and non-restrictive. The electronic device 8 may also have other components according to actual application requirements. The processor 82 may control other components in the electronic device 8 to perform desired functions.

[0093] In some embodiments, the memory 81 is used to store one or more computer-readable instructions. When the processor 82 is used to execute the computer-readable instructions, the computer-readable instructions are executed by the processor 82 to implement the method according to any of the above embodiments. For the specific implementation of each step of the method and the related explanation content, please refer to the above embodiments, and the repetition will not be repeated here.

[0094] For example, the processor 82 and the memory 81 may communicate with each other directly or indirectly. For example, the processor 82 and the memory 81 may communicate with each other through a network. The network may include a wireless network, a wired network, and / or any combination of a wireless network and a wired network. The processor 82 and the memory 81 may also communicate with each other through a system bus, which is not limited by the present disclosure.

[0095] For example, the processor 82 may be embodied as various appropriate processors, processing devices, etc., such as a central processing unit (CPU), a graphics processing unit (GPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The central processing unit (CPU) may be an X86 or ARM architecture, etc. For example, the memory 81 may include any combination of various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The memory 81 may include, for example, a system memory, which may store, for example, an operating system, an application, a boot loader, a database, and other programs. Various applications and various data may also be stored in the storage medium.

[0096] In addition, according to some embodiments of the present disclosure, various operations / processes according to the present disclosure, when implemented by software and / or firmware, can be transmitted from a storage medium or a network to a computer system having a dedicated hardware structure, such as Fig. 9 The computer system 900 shown is installed with the programs constituting the software. When the various programs are installed, the computer system can execute various functions, including the functions described above. Fig. 9 A block diagram showing an example structure of a computer system that may be employed in an embodiment according to the present disclosure.

[0097] exist Fig. 9In the embodiment, a central processing unit (CPU) 901 performs various processes according to a program stored in a read-only memory (ROM) 902 or a program loaded from a storage section 908 to a random access memory (RAM) 903. In the RAM 903, data required when the CPU 901 performs various processes, etc., is also stored as needed. The central processing unit is merely exemplary, and it may also be other types of processors, such as the various processors described above. The ROM 902, the RAM 903, and the storage section 908 may be various forms of computer-readable storage media, as described below. It should be noted that although Fig. 9 ROM 902, RAM 903 and storage device 908 are shown separately in the figure, but one or more of them may be combined or located in the same or different memory or storage modules.

[0098] The CPU 901, the ROM 902, and the RAM 903 are connected to one another via a bus 904. An input / output interface 905 is also connected to the bus 904.

[0099] The following components are connected to the input / output interface 905: an input section 906, such as a touch screen, a touch pad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output section 907, including a display, such as a cathode ray tube (CRT), a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage section 908, including a hard disk, a magnetic tape, etc.; and a communication section 909, including a network interface card such as a LAN card, a modem, etc. The communication section 909 allows communication processing to be performed via a network such as the Internet. It is easy to understand that although Fig. 9 The various devices or modules in the computer system 900 shown in the figure communicate via the bus 904, but they may also communicate via a network or other means, wherein the network may include a wireless network, a wired network, and / or any combination of a wireless network and a wired network.

[0100] A drive 910 is also connected to the input / output interface 905 as needed. A removable medium 911 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory or the like is mounted on the drive 910 as needed so that a computer program read therefrom is installed into the storage section 908 as needed.

[0101] In the case where the above-described series of processing is realized by software, a program constituting the software can be installed from a network such as the Internet or a storage medium such as the removable medium 911 .

[0102] According to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device 909, or installed from a storage device 908, or installed from a ROM 902. When the computer program is executed by the CPU 901, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.

[0103] It should be noted that in the context of the present disclosure, a computer-readable medium may be a tangible medium that may contain or store a program for use by an instruction execution system, device or equipment or used in combination with an instruction execution system, device or equipment. A computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. A computer-readable storage medium may be, for example, but not limited to: an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium that contains or stores a program that may be used by an instruction execution system, device or device or used in combination with it. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, device, or device. The program code contained on the computer-readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.

[0104] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.

[0105] In some embodiments, a computer program is further provided, comprising: instructions, which, when executed by a processor, cause the processor to execute any of the methods of the above embodiments. For example, the instructions may be embodied as computer program codes.

[0106] In embodiments of the present disclosure, computer program codes for performing the operations of the present disclosure may be written in one or more programming languages ​​or combinations thereof, including but not limited to object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" language or similar programming languages. The program code may be executed entirely on a user's computer, partially on a user's computer, as an independent software package, partially on a user's computer, partially on a remote computer, or entirely on a remote computer or server. In situations involving a remote computer, the remote computer may be connected to the user's computer via any type of network (including a local area network (LAN) or a wide area network (WAN)), or may be connected to an external computer (e.g., using an Internet service provider to connect via the Internet).

[0107] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0108] The modules, components or units involved in the embodiments described in the present disclosure may be implemented by software or hardware, wherein the names of the modules, components or units do not, in some cases, limit the modules, components or units themselves.

[0109] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chip (SOCs), complex programmable logic devices (CPLDs), and the like.

[0110] According to some embodiments of the present disclosure, a text correction method is provided, comprising: obtaining sample labels including source sentences and target sentences, and randomly adding masks to the source sentences in the sample labels to obtain source sentences with masks; inputting the source sentences with masks into a training model to obtain prediction results; calculating precision and recall based on the source sentences, target sentences and prediction results of the sample labels; calculating the average precision and average recall for the precision and recall of multiple sample labels, and calculating the harmonic mean F1 of the precision and recall based on the average precision and average recall; and adjusting the training model based on the harmonic mean F1, and using the adjusted training model as a text correction model.

[0111] According to some embodiments of the present disclosure, the harmonic mean

[0112] According to some embodiments of the present disclosure, the text error correction method also includes: dividing multiple sample labels into two categories according to whether the error in the source sentence appears for the training model for the first time, the first category being the error in the source sentence appears for the training model for the first time, and the second category being the error in the source sentence does not appear for the training model for the first time.

[0113] According to some embodiments of the present disclosure, the text error correction method also includes: averaging the precision and recall of multiple sample labels in the first category and the second category, respectively, to obtain the average precision and average recall of the sample labels of the first category and the average precision and average recall of the sample labels of the second category; and calculating E-F1 based on the average precision and average recall of the sample labels of the first category, and calculating I-F1 based on the average precision and average recall of the sample labels of the second category, wherein E-F1 is the harmonic mean F1 of the precision and recall of the training model on those errors that have not been seen during training, and I-F1 is the harmonic mean F1 of the precision and recall of the training model on those errors that have been seen during training.

[0114] According to some embodiments of the present disclosure, the ratio of randomly adding masks to source sentences is 0.1-0.3, preferably 0.2.

[0115] According to some embodiments of the present disclosure, the text correction method further includes: inputting the source sentence to be corrected into the text correction model to obtain a corrected target sentence.

[0116] According to some embodiments of the present disclosure, a text correction system is provided, comprising: a mask adding unit, configured to obtain sample labels including source sentences and target sentences, and randomly add masks to the source sentences in the sample labels to obtain source sentences with masks; a prediction unit, configured to input the source sentences with masks into a training model to obtain prediction results; a calculation unit, configured to calculate the precision and recall rate according to the source sentences, target sentences and prediction results of the sample labels, calculate the average precision and average recall rate for the precision and recall rates of multiple sample labels, and calculate the harmonic mean F1 of the precision and recall rate according to the average precision and average recall rate; and an adjustment unit, configured to adjust the training model according to the harmonic mean F1, and use the adjusted training model as a text correction model.

[0117] According to some embodiments of the present disclosure, the harmonic mean

[0118] According to some embodiments of the present disclosure, the text error correction system further includes: a classification unit, configured to divide multiple sample labels into two categories according to whether the error in the source sentence appears for the first time for the training model, the first category being that the error in the source sentence appears for the first time for the training model, and the second category being that the error in the source sentence does not appear for the first time for the training model.

[0119] According to some embodiments of the present disclosure, the computing unit is further configured to: respectively average the precision and recall of multiple sample labels in the first category and the second category to obtain the average precision and average recall of the sample labels of the first category and the average precision and average recall of the sample labels of the second category; and calculate E-F1 according to the average precision and average recall of the sample labels of the first category, and calculate I-F1 according to the average precision and average recall of the sample labels of the second category, wherein E-F1 is the harmonic mean F1 of the precision and recall of the training model on those errors that have not been seen during training, and I-F1 is the harmonic mean F1 of the precision and recall of the training model on those errors that have been seen during training.

[0120] According to some embodiments of the present disclosure, the ratio of randomly adding masks to source sentences is 0.1-0.3, preferably 0.2.

[0121] According to some embodiments of the present disclosure, the prediction unit is further configured to: input the source sentence to be corrected into the text correction model to obtain a corrected target sentence.

[0122] According to some embodiments of the present disclosure, an electronic device is provided, comprising: a memory; and a processor coupled to the memory, wherein instructions are stored in the memory, and when the instructions are executed by the processor, the electronic device executes a method of any embodiment described in the present disclosure.

[0123] According to some embodiments of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the method of any embodiment described in the present disclosure is performed.

[0124] According to some embodiments of the present disclosure, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the method of any embodiment described in the present disclosure is performed.

[0125] The above descriptions are only some embodiments of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, a technical solution formed by replacing the above features with the technical features with similar functions disclosed in the present disclosure (but not limited to).

[0126] In the description provided herein, many specific details are set forth. However, it is understood that embodiments of the present disclosure may be implemented without these specific details. In other cases, well-known methods, structures, and techniques are not presented in detail in order not to obscure the understanding of the description.

[0127] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.

[0128] Although some specific embodiments of the present disclosure have been described in detail by way of example, it should be understood by those skilled in the art that the above examples are for illustration only and are not intended to limit the scope of the present disclosure. It should be understood by those skilled in the art that the above embodiments may be modified without departing from the scope and spirit of the present disclosure. The scope of the present disclosure is defined by the appended claims.

Claims

1. A text error correction method, comprising: Obtain sample labels including source sentences and target sentences, and randomly add masks to the source sentences in the sample labels to obtain masked source sentences, wherein words in the masked source sentences are randomly covered by the masks; Input the masked source sentence into the training model and obtain the prediction result based on the context; Calculating precision and recall based on the source sentence, target sentence and prediction result of the sample label; Calculate the average precision and average recall of the precision and recall of multiple sample labels, and calculate the harmonic mean F1 of the precision and recall based on the average precision and average recall; as well as The training model is adjusted according to the harmonic mean F1, and the adjusted training model is used as a text error correction model. The training model not only corrects the wrong characters in the source sentence, but also restores the original characters in the obscured position in the source sentence based on the context.

2. The text error correction method according to claim 1, wherein the harmonic mean .

3. The text error correction method according to claim 1, further comprising: According to whether the error in the source sentence appears for the training model for the first time, multiple sample labels are divided into two categories. The first category is that the error in the source sentence appears for the training model for the first time, and the second category is that the error in the source sentence does not appear for the training model for the first time.

4. The text error correction method according to claim 3, further comprising: The precision and recall of multiple sample labels in the first category and the second category are averaged respectively to obtain the average precision and average recall of the sample labels in the first category and the average precision and average recall of the sample labels in the second category; as well as E-F1 is calculated according to the average precision and average recall of the first category of sample labels, and I-F1 is calculated according to the average precision and average recall of the second category of sample labels, where E-F1 is the harmonic mean F1 of the precision and recall of the training model on those errors that have not been seen during training, and I-F1 is the harmonic mean F1 of the precision and recall of the training model on those errors that have been seen during training.

5. The text error correction method according to any one of claims 1-4, wherein the ratio of randomly adding a mask to the source sentence is 0.1-0.

3.

6. The text error correction method according to any one of claims 1 to 4, further comprising: The source sentence to be corrected is input into the text correction model to obtain a corrected target sentence.

7. A text error correction system, comprising: A mask adding unit is configured to obtain a sample label including a source sentence and a target sentence, and randomly add a mask to the source sentence in the sample label to obtain a source sentence with a mask, wherein words in the source sentence with a mask are randomly covered by the mask; A prediction unit, configured to input the source sentence with the mask into the training model and obtain a prediction result according to the context; A calculation unit, configured to calculate the precision and recall rate according to the source sentence, the target sentence and the prediction result of the sample label, calculate the average precision and the average recall rate for the precision and the recall rate of multiple sample labels, and calculate the harmonic mean F1 of the precision and the recall rate according to the average precision and the average recall rate; as well as an adjusting unit, configured to adjust the training model according to the harmonic mean F1, and use the adjusted training model as a text error correction model, The training model not only corrects the wrong characters in the source sentence, but also restores the original characters in the obscured position in the source sentence based on the context.

8. The text error correction system according to claim 7, wherein the harmonic mean .

9. The text error correction system according to claim 7, further comprising: The classification unit is configured to classify multiple sample labels into two categories according to whether the error in the source sentence appears for the training model for the first time, the first category being that the error in the source sentence appears for the training model for the first time, and the second category being that the error in the source sentence does not appear for the training model for the first time.

10. The text error correction system according to claim 9, wherein the computing unit is further configured to: Averaging the precision and recall of multiple sample labels in the first category and the second category respectively to obtain the average precision and average recall of the sample labels in the first category and the average precision and average recall of the sample labels in the second category; and E-F1 is calculated according to the average precision and average recall of the first category of sample labels, and I-F1 is calculated according to the average precision and average recall of the second category of sample labels, where E-F1 is the harmonic mean F1 of the precision and recall of the training model on those errors that have not been seen during training, and I-F1 is the harmonic mean F1 of the precision and recall of the training model on those errors that have been seen during training.

11. The text error correction system according to any one of claims 7 to 10, wherein the ratio of randomly adding masks to the source sentence is 0.1-0.

3.

12. The text error correction system according to any one of claims 7 to 10, wherein the prediction unit is further configured to: The source sentence to be corrected is input into the text correction model to obtain a corrected target sentence.

13. An electronic device comprising: Memory; and A processor coupled to the memory, wherein the memory stores instructions, and when the instructions are executed by the processor, the electronic device executes the method according to any one of claims 1-6.

14. A computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the method according to any one of claims 1 to 6 when executed by a processor.

Citation Information

Patent Citations

  • Text error correction method, device and system

    CN111523305A

  • Text error correction method, device and system

    CN111523306A

  • Text error correction model training method and device and text error correction processing method and device

    CN111950292A

  • Building industry text error correction method based on transfer learning

    CN113836919A

  • Text error correction method and device

    CN114580382A