Text error correction method, device, electronic device and storage medium

By integrating multiple error correction components in text correction and adopting the beam search method to generate and screen candidate text sets, the problem of poor error correction effect in the existing technology is solved, and higher error correction accuracy and user experience are achieved.

CN120297267BActive Publication Date: 2025-09-19JILIN KEXUN INFORMATION TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202510783046.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-06-12
Publication Date
2025-09-19
Estimated Expiration
2045-06-12

AI Technical Summary

Technical Problem

In the field of text error correction, the existing technology, especially in specific vertical fields such as English scientific literature, has poor error correction effects of general models, especially in spelling error detection, which has the problem of missed reports and leads to a decline in user experience.

Method used

A multi-model integration method based on beam search is adopted to integrate multiple error correction components, such as the GECToR error correction model, the T5 error correction model and the SymSpell error correction tool. By correcting words one by one, a candidate text set is generated, and the retained text is screened out through sentence perplexity to finally determine the recommended text.

Benefits of technology

It significantly improves the accuracy and recall of text error correction, enhances the user experience, and is especially more precise in spelling error detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120297267B_ABST
    Figure CN120297267B_ABST
Patent Text Reader

Abstract

The present invention provides a text correction method, device, electronic device, and storage medium, belonging to the field of artificial intelligence technology. The method comprises: inputting a target text into multiple correction components to obtain a set of results to be corrected; for any word to be corrected in the set of results to be corrected, using all correction recommendations for any word to be corrected to modify the target text to generate a set of candidate texts, thereby filtering out retained texts from the set of candidate texts; and continuously correcting each other word to be corrected in each retained text until all words to be corrected in the set of results to be corrected have been traversed, and determining a recommended text from the retained text obtained last. The present invention provides a text correction method based on beam search multi-model integration, which can maximize correction capabilities by integrating the advantages of multiple correction components.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a text error correction method, device, electronic device and storage medium. Background Art

[0002] Text error correction is a key area of ​​current natural language processing and a cutting-edge field in the artificial intelligence industry. While typical texts may contain errors such as omissions, redundancies, and improper word order, this feature allows users to directly correct these errors and generate correct recommendations. This saves users time spent proofreading and avoids errors caused by human error. This feature has significant practical value in fields such as education, healthcare, journalism, and law and politics.

[0003] Currently, text error correction primarily relies on models based on Neural Machine Translation (NMT). There are two general types of models: sequence-to-sequence (seq2seq) and sequence-to-edit (seq2edit). In specific vertical fields (such as English scientific literature), due to the high concentration of proper nouns and specific collocations in the corpus, using only these general models can result in poor error correction results.

[0004] Taking the error correction task of English text as an example, the most frequent error type in the text and the one that users pay the most attention to is spelling errors. However, due to the upper limit of the error correction ability of general models, miss-detection will occur when spelling errors occur, resulting in a decreased user experience. Summary of the Invention

[0005] The present invention provides a text error correction method, device, electronic device and storage medium to address the deficiency in the prior art that text error correction using only a single general model often cannot achieve the best effect. A text error correction method based on beam search error correction model integration is proposed to improve the precision and recall of text error correction.

[0006] The present invention provides a text error correction method, comprising the following steps:

[0007] Inputting a target text to be processed into at least two error correction components to obtain an error correction result set, wherein the error correction result set includes the words to be corrected output by each error correction component and at least one error correction recommendation corresponding to each word to be corrected;

[0008] For any word to be corrected in the set of results to be corrected, modify the target text using all correction recommendations for the word to be corrected to generate a set of candidate texts, so as to screen out a preset number of retained texts from the set of candidate texts;

[0009] Continue correcting another word to be corrected in each of the retained texts until all the words to be corrected in the result set to be corrected are traversed, and determine the recommended text from the retained text finally obtained.

[0010] According to a text error correction method provided by the present invention, the method comprises: modifying the target text using all error correction recommendations of any word to be corrected to generate a candidate text set, so as to screen out a preset number of retained texts from the candidate text set, including:

[0011] According to each of the error correction recommendations, a correction operation is performed on each of the words to be corrected in the target text, to generate a plurality of candidate texts having the same number as the error correction recommendations, wherein all the candidate texts constitute the candidate text set;

[0012] According to the sentence perplexity of each candidate text, the preset number of retained texts are screened out from the candidate text set, so as to utilize each retained text as the new target text.

[0013] According to a text error correction method provided by the present invention, the sentence perplexity of each candidate text is calculated based on the following steps:

[0014] According to the conditional probability of each word in the candidate text, the logarithmic probability sum of all words is obtained;

[0015] An average logarithmic probability is determined according to the logarithmic probability and the total number of words in the candidate text, so as to use the average logarithmic probability as the sentence perplexity of the candidate text.

[0016] According to a text error correction method provided by the present invention, the preset number is determined based on the computational complexity of the text error correction.

[0017] According to a text correction method provided by the present invention, the order of traversing all the words to be corrected in the result set to be corrected is determined according to the sentence order of each word to be corrected in the target text.

[0018] According to a text error correction method provided by the present invention, different error correction components recognize input text according to different error correction strategies and optimization goals;

[0019] The error correction strategy includes one or more of an editing operation-based strategy, a text generation-based strategy, and a spelling correction-based strategy; and the optimization objectives include precision, recall, and response speed.

[0020] According to a text error correction method provided by the present invention, the error correction component whose error correction strategy is based on the editing operation strategy is the GECToR error correction model, the error correction component whose error correction strategy is based on the text generation strategy is the Text-to-Text Transfer Transformer error correction model, and the error correction component whose error correction strategy is based on the spelling correction strategy is the SymSpell error correction tool.

[0021] A text error correction method provided by the present invention further includes:

[0022] Performing distillation learning on all the error correction components to generate a text error correction model;

[0023] The text error correction model is used to receive an input target text and output a recommended text after error correction is performed on the target text.

[0024] According to a text error correction method provided by the present invention, when the error correction component includes a first error correction component based on an editing operation strategy and a second error correction component based on a text generation strategy, distillation learning is performed on all the error correction components to generate a text error correction model, including:

[0025] For each text sample, perform error correction processing using the first error correction component and the second error correction component, respectively, to obtain a first soft label output by the first error correction component and a second soft label output by the second error correction component;

[0026] Performing beam search integration on the error correction results of the first error correction component and the second error correction component to obtain the integrated recommended text as a hard label;

[0027] Taking the text sample as an input sample, and taking the first soft label, the second soft label, and the hard label as labels of the input sample to form a training data set;

[0028] Using the training data set, all the error correction components are distilled using multiple alignment methods to obtain a text error correction model.

[0029] According to a text error correction method provided by the present invention, using the training data set, all the error correction components are subjected to multiple alignment distillation methods to obtain a text error correction model, specifically comprising:

[0030] Determine the pre-trained lightweight text error correction initial model as the student model;

[0031] Determining a first soft label, a second soft label, and a hard label corresponding to each text sample in the training data set;

[0032] The weights of the Kullback-Leibler divergence loss function, the Jensen-Shannon divergence loss function, and the cross entropy loss function are set to iteratively perform the following pre-training operation using each of the text samples in the training dataset until the pre-training results converge to obtain the text error correction model:

[0033] Aligning the output of the student model with the first soft label using the Kullback-Leibler divergence loss function to learn the error correction probability distribution of the first error correction component;

[0034] Aligning the output of the student model with the second soft label using the Jensen-Shannon divergence loss function to learn the error correction probability distribution of the second error correction component;

[0035] The cross entropy loss function is used to align the output of the student model with the hard label to learn the overall error correction capability of the integrated error correction component.

[0036] The present invention also provides a text error correction device, comprising the following units:

[0037] A pre-correction unit is configured to input a target text to be processed into at least two correction components to obtain a result set to be corrected, wherein the result set to be corrected includes the words to be corrected output by each correction component and at least one correction recommendation corresponding to each word to be corrected;

[0038] an error correction processing unit, for any word to be corrected in the error correction result set, using all error correction recommendations for any word to be corrected to modify the target text to generate a candidate text set, so as to screen out a preset number of retained texts from the candidate text set;

[0039] An iterative control unit is used to control the error correction processing unit to continue correcting another word to be corrected in each of the retained texts until all the words to be corrected in the result set to be corrected are traversed, and a recommended text is determined from the retained text finally obtained.

[0040] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, any of the above-described text error correction methods is implemented.

[0041] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which implements any of the above-mentioned text error correction methods when executed by a processor.

[0042] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements any of the above-mentioned text error correction methods.

[0043] The text error correction method, device, electronic device and storage medium provided by the present invention propose a text error correction method based on beam search multi-model integration, which can maximize the error correction capability by integrating the advantages of multiple error correction components. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] In order to more clearly illustrate the technical solutions in the present invention or the prior art, a brief introduction is given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0045] Figure 1 This is a schematic diagram of the model architecture of the existing GECToR error correction model.

[0046] Figure 2 This is a schematic diagram of the model architecture of the existing T5 error correction model.

[0047] Figure 3 This is one of the flow charts of the text error correction method provided by the present invention.

[0048] Figure 4 This is the second flow chart of the text error correction method provided by the present invention.

[0049] Figure 5 It is a structural schematic diagram of the text error correction device provided by the present invention.

[0050] Figure 6 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION

[0051] To make the objectives, technical solutions, and advantages of the present invention more clear, the technical solutions of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the embodiments described are only some of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts shall fall within the scope of protection of the present invention.

[0052] It should be noted that, in the description of the present invention, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or apparatus comprising the element.

[0053] The terms "first," "second," and the like in the present invention are used to distinguish similar objects, and are not used to describe a particular order or precedence. It should be understood that the terms used in this manner are interchangeable where appropriate, such that embodiments of the present invention can be implemented in orders other than those illustrated or described herein. Furthermore, the objects distinguished by "first," "second," and the like generally refer to a class of objects, and do not limit the number of objects. For example, the first object may be one or more.

[0054] Currently, the field of text error correction mainly uses NMT-based error correction models, which have the following advantages: 1) Directly learn the mapping from source text to target text without the need for complex feature engineering; 2) The powerful encoder of the deep neural network can effectively capture contextual information and obtain global information; 3) Even for sentences that do not appear in the sample training set, it can effectively correct errors and has good generalization ability.

[0055] There are currently two common solutions for NMT-based models:

[0056] The first type is based on the sequence-to-edit (seq2edit) model. The seq2edit model decomposes the task of correcting input text into a series of editing operations. Essentially a sequence labeling model, it generates corrected recommended text by predicting the edit operation at each position. Mainstream seq2edit models include PIE and GECToR.

[0057] Figure 1 This is a schematic diagram of the model architecture of the existing GECToR error correction model, which is a seq2edit model. Figure 1As shown in the figure, the GECToR error correction model can be deconstructed into a Bert-like encoder + a two-layer linear layer + Softmax. It is essentially a sequence labeling model. Its decoding space is editing operations such as insertion, deletion, and replacement. The four basic operations, keep (KEEP), delete (DEL), add (APPEND), replace (REPLACE) and custom operations (G-Transformations), are mapped to a multi-dimensional edit space. By predicting edits in parallel and applying them to the input text sentences, the GECToR error correction model can complete text error correction of variable length.

[0058] The second type is based on sequence-to-sequence (seq2seq) models. The seq2seq model is a model architecture that maps an input sequence to an output sequence and is widely used in tasks such as machine translation, text summarization, and text error correction. It typically consists of two parts: an encoder and a decoder. The encoder encodes the input sequence into a fixed-length context vector, and the decoder generates an output sequence based on this context vector. Mainstream seq2seq models include the Transformer architecture, such as the Text-to-Text Transfer Transformer (T5), the Bidirectional and Auto-Regressive Transformer (BART), and Transformers based on the Copy-Augment mechanism, such as the combination of Copy-Net and language model methods.

[0059] Figure 2 This is a schematic diagram of the model architecture of the existing T5 error correction model, such as Figure 2 As shown in the figure, the core concept of the T5 error correction model is to unify all natural language processing (NLP) tasks into a text-to-text format. That is, whether it is text classification, translation, summary generation, text error correction and other tasks, the input and output are represented as text sequences.

[0060] The T5 error correction model is based on the standard Transformer encoder-decoder architecture and consists of multiple layers of self-attention (T5SelfAttention) and feedforward neural networks (T5LayerFF). The encoder converts the input text into a set of hidden representations through multiple self-attention layers and feedforward layers. The decoder generates an output text sequence through multiple self-attention layers, cross-attention layers (T5CrossAttention), feedforward layers, and normalization layers (Add&T5LayerNorm) until the generation is completed or the maximum length limit is reached.

[0061] While general-purpose error correction models like GECToR and T5 have become mainstream models for text error correction tasks, and their variants have achieved or approached the state-of-the-art (SOTA) performance on the international standard test sets CoNLL-2014 and BEA-2019, in specific vertical fields (such as English scientific literature), using only these general-purpose error correction models can be ineffective due to the high number of proper nouns and specific collocations in the corpus.

[0062] To address this issue, a common approach is to construct a training set of samples from a specific vertical domain and then fine-tune the general domain error correction model to improve its error correction capabilities in that specific vertical domain. Experiments have shown that these methods can significantly improve evaluation results on error correction test sets in specific vertical domains.

[0063] However, error correction capabilities vary among error correction models with different architectures. For example, the GECToR error correction model, because it performs error correction based on editing operations, has a lower probability of error correction operations changing, but a higher accuracy, as reflected in the test metrics of high precision and low recall. The T5 error correction model, on the other hand, is essentially a network model based on text generation, so its error correction operations have a higher probability of changing, but correspondingly lower accuracy, as reflected in the test metrics of low precision and high recall.

[0064] Therefore, using only a single error correction model for text correction often fails to achieve optimal results. Furthermore, spelling errors are the most common and user-focused error type in English texts. However, due to the upper limits of general-purpose error correction models, they often misspell spelling errors, resulting in a poor user experience.

[0065] In view of the above problems, the present invention provides a text error correction method, device, electronic device and storage medium based on beam search, which can integrate the error correction capabilities of multiple general field error correction models and significantly improve the accuracy of text error correction. Figure 3-Figure 6 Provide detailed explanation.

[0066] Figure 3 This is one of the flow charts of the text error correction method provided by the present invention, such as Figure 3 As shown, including but not limited to the following steps:

[0067] Step 301: Input the target text to be processed into at least two error correction components to obtain an error correction result set, which includes the words to be corrected output by each error correction component and at least one error correction recommendation corresponding to each word to be corrected.

[0068] The target text refers to the text that needs to be corrected, such as an English sentence containing spelling errors, grammatical errors and / or inappropriate words.

[0069] An error correction component is a tool or model that can identify errors in a target text and provide correction suggestions. In this invention, at least two error correction components are used. These components can identify grammatical errors and word errors in the target text that require correction, and provide corresponding correction suggestions based on different correction strategies and optimization goals.

[0070] The result set to be corrected refers to the set of correction suggestions output by each correction component. Each correction component will output all the words to be corrected that it has identified and the correction recommendations corresponding to each word to be corrected.

[0071] Suppose the target text "The techer adviced his students to use them time wiseduring the exam, but much of them where too nervus to consentrate" is input into two error correction components (such as the GECToR error correction model and the T5 error correction model), each error correction component will output the identified words to be corrected and their correction recommendations.

[0072] Step 302 : for any word to be corrected in the set of results to be corrected, all correction recommendations for the word to be corrected are used to modify the target text to generate a candidate text set, so as to filter out a preset number of retained texts from the candidate text set.

[0073] The present invention adopts a word-by-word error correction method to modify possible errors in the target text, with the goal of obtaining the correct recommended text. The intermediate text obtained in each process is called the retained text.

[0074] First, a word to be corrected is selected from the result set to be corrected as the current processing object. The selection method can be based on the order of words in the target text, and the word to be corrected can be replaced from front to back or from back to front.

[0075] It should be noted that if multiple error correction components have different correction recommendations for the same word to be corrected, the input target text will be corrected according to each correction recommendation. This will result in a modified text corresponding to each correction recommendation, called a candidate text. In this way, for each word to be corrected, a candidate text set consisting of multiple candidate texts will be obtained during the error correction process.

[0076] Furthermore, a preset number of candidate texts can be selected from the candidate text set as retained texts according to a preset screening condition, and other candidate texts that have not been screened out are discarded. This is specifically described below with reference to an embodiment:

[0077] Assume that there are three error correction components, and all three error correction components (denoted as M1, M2, and M3) recognize that the k1th word in the target file is the word to be corrected, and give corresponding error correction recommendations for the k1th word: Assume that error correction component M1 gives 2 error correction recommendations, error correction component M2 gives 2 error correction recommendations, and error correction component M3 gives 3 error correction recommendations.

[0078] Assuming that there are two identical sets of correction recommendations among the total of 7 correction recommendations, we can take the union of the correction recommendations of all correction components to obtain 5 final correction recommendations for the k1th word, which are denoted as t1 to t5 respectively.

[0079] Furthermore, t1 to t5 can be used to replace the k1th word respectively, and the five corrected candidate texts are obtained to form a candidate text set.

[0080] Finally, a preset number of candidate texts (e.g., two) can be selected from the five candidate texts in the candidate text set as retained texts. As for how to select the retained texts from the candidate text set, the method can be to calculate the sentence perplexity of each candidate text and select a preset number of candidate texts with the lowest sentence perplexity rankings as the retained texts for the next step. Of course, other existing technical means can also be used to achieve this, and this embodiment does not specifically limit this.

[0081] Step 303 : Continue correcting another word to be corrected in each of the retained texts until all the words to be corrected in the result set to be corrected are traversed, and determine a recommended text from the retained text finally obtained.

[0082] The operation of step 302 is repeated for the next word to be corrected in each retained text to generate a new candidate text set, and the retained text for the next step of processing is re-screened.

[0083] The above steps are iterated, gradually processing all the words in the target text set, one at a time, and gradually optimizing the correction results using beam search. After all the words are processed, the optimal text is selected from the retained text as the recommended text. This recommended text is the high-quality corrected version of the target text after the correction process.

[0084] It should be noted that the number of retained texts obtained in the last step is still a preset number. At this time, the retained text with the smallest sentence perplexity can be used as the recommended text.

[0085] The text error correction method provided by the present invention proposes an error correction method based on beam search multi-model integration, which can maximize the error correction capability by integrating the advantages of multiple error correction components.

[0086] Based on the content of the above embodiment, as an optional embodiment, the target text is modified respectively by using all correction recommendations of any word to be corrected to generate a candidate text set, so as to screen out a preset number of retained texts from the candidate text set, including:

[0087] According to each of the error correction recommendations, a correction operation is performed on each of the words to be corrected in the target text, to generate a plurality of candidate texts having the same number as the error correction recommendations, wherein all the candidate texts constitute the candidate text set;

[0088] According to the sentence perplexity of each candidate text, the preset number of retained texts are screened out from the candidate text set, so as to utilize each retained text as the new target text.

[0089] The text correction method provided by the present invention performs correction replacement processing on each word to be corrected, one by one, according to the word order of the sentence in the target text. If there are multiple different correction recommendations for any word to be corrected (i.e., at the same word position in the sentence in the target text), each correction recommendation is used to perform correction replacement on the word to be corrected, and the corresponding candidate text is obtained. By calculating the sentence perplexity of each candidate text, a preset number of candidate texts with the lowest sentence perplexity are screened out (i.e., as retained texts), and then the same correction replacement is performed on the position of the next word to be corrected, until all words to be corrected are traversed.

[0090] Optionally, the preset number may be determined based on the computational complexity of the text error correction.

[0091] The present invention effectively utilizes the output of the error correction component, gradually optimizing the error correction results through beam search and sentence perplexity ranking, ultimately generating high-quality recommended text. Furthermore, by setting the preset number, a balance can be achieved between computing resources and error correction accuracy. Generally speaking, a larger preset number increases error correction accuracy, but the computing resource requirements for the entire text error correction process increase exponentially. Therefore, the preset number needs to be set based on computing resource capabilities and error correction accuracy requirements. If computing resources are limited, a smaller preset number (e.g., 2) can be set to reduce the computational load; if computing resources are sufficient, a larger preset number (e.g., 5) can be selected to improve error correction accuracy.

[0092] Suppose the target text is “The techer advised his students to use them time wisely during the exam, but much of them where too nervus to consentrate”.

[0093] In step 301, the target text is input to the error correction component to obtain the result set to be corrected: the error correction component 1 outputs: techer->teacher (probability 0.9), techer->teachers (probability 0.05); the error correction component 2 outputs: techer->eacher (probability 0.7), techer->teachers (probability 0.2).

[0094] In step 302, the operation of generating a candidate text set is first performed, including:

[0095] (1) Change the first word to be corrected, techer, to teacher, and generate the first candidate text:

[0096] "The teacher advised his students to use them time wise during the exam, but much of them where too nervus to consentrate."

[0097] (2) Change the first word to be corrected, techer, to teachers, and generate the second candidate text:

[0098] "The teachers advised his students to use them time wise during the exam, but much of them where too nervus to consentrate."

[0099] Continue to calculate the sentence perplexity and filter the retained text, including:

[0100] Calculate the sentence perplexity of the first candidate text and the sentence perplexity of the second candidate text, assuming they are 10.5 and 12.3 respectively.

[0101] Determine the preset number. Assuming limited computing resources, set the beam width (i.e., the preset number) to 2. This means that at each step, only the two candidates with the lowest perplexity are retained to reduce the computational effort. This ensures that both the first and second candidates will be retained for the next step of error correction.

[0102] In step 303, the next word to be corrected is processed, and the above steps are repeated. Assuming that there are four correction recommendations for the next word to be corrected, four corresponding candidate texts will be obtained. At this time, it is necessary to select the two candidate texts with the lowest sentence perplexity from the four candidate texts as the new retained texts and continue to the next step of correction.

[0103] Iterate the above steps until all the words to be corrected in the result set are traversed, and the final recommended text is determined to be:

[0104] "The teacher advised his students to use their time wisely during the exam, but many of them were too nervous to concentrate."

[0105] The present invention collects the recognition results of sentence errors of the target text by each correction component to construct a result set to be corrected, and then performs text correction processing by replacing all the words to be corrected in the result set word by word until all the words to be corrected are traversed to obtain the final recommended text.

[0106] In the process of traversing all the words to be corrected one by one, the traversal order can be traversed from front to back according to the sentence order in the target text, or from back to front. Both traversal methods are determined according to the sentence order of each word to be corrected in the target text.

[0107] Optionally, the traversal order of all the words to be corrected in the result set to be corrected may be performed according to the severity of the errors of the words to be corrected, or according to the importance of the words to be corrected in the sentence structure.

[0108] The back-to-forward traversal process starts with the last word in the target text and works its way forward, recommending corrections for each word to be corrected. This approach has the advantage of leveraging the context of subsequent words when processing each word to be corrected, improving the accuracy of text corrections. Furthermore, for complex sentence structures, the back-to-forward traversal process can reduce the number of backtracking adjustments required.

[0109] Traversing the text by error severity means sorting each word based on its severity (e.g., spelling, grammar, semantics, etc.), prioritizing words with severe errors. This traversal method can improve the overall quality of the text more quickly. After addressing severe errors, subsequent fine-tuning can be simpler, reducing the overall computational effort.

[0110] Traversing the words to be corrected according to their importance in the sentence structure means sorting the words to be corrected according to their importance in the sentence structure (such as subject, predicate, object, etc.), and giving priority to errors in words to be corrected with high importance. This can better maintain the overall structure of the sentence and improve the overall correction effect.

[0111] Of course, the most commonly used traversal is from front to back, which means starting from the first word of the target text and gradually processing the correction recommendations for each word to be corrected. This traversal method is in line with the reading habits of natural language and is convenient for utilizing contextual information.

[0112] For the convenience of description, the subsequent embodiments will uniformly adopt a method of traversing from front to back to describe the embodiments, which is not regarded as a specific limitation on the scope of protection of the present invention.

[0113] The following describes in detail how to perform error correction on any word to be corrected to obtain a corresponding preset number of retained texts through an embodiment.

[0114] Figure 4 This is the second flow chart of the text error correction method provided by the present invention, such as Figure 4 As shown, as an optional embodiment, three error correction components are used, including the GECToR error correction model, the T5 error correction model, and the SymSpell error correction tool. The GECToR error correction model and the T5 error correction model have been described in detail in the previous embodiments and will not be repeated here. The SymSpell error correction tool uses a pre-built dictionary to correct spellings in text through dictionary indexing. By optimizing the edit distance (such as the Levenshtein distance) calculation, it can quickly find error correction recommendations that are similar to the word to be corrected.

[0115] Beam search is a heuristic search algorithm primarily used for sequence generation tasks in natural language processing (NLP), such as machine translation, text generation, and speech recognition. It is an extension of the greedy algorithm. At each search step, instead of selecting a single optimal candidate, it retains multiple optimal candidates (called the "beam width") and continues to expand these candidates in the next step, ultimately selecting the optimal candidate sequence as the output.

[0116] The text correction method provided by the present invention uses the principle of beam search. In the actual correction process, the optimal preset number of retained texts are selected from multiple candidate texts generated by different correction recommendations for each word to be corrected, and these retained texts are continued to be expanded in the next search until the optimal recommended text is obtained.

[0117] Assume that the target text to be processed (also called the original sentence) input to each error correction component is "The techer advised his students to use them time wise during the exam, but much of them where too nervus to consentrate".

[0118] The obtained result set to be corrected can be expressed as:

[0119] GECToR[[2,techer,teacher],[8,them,their],[15,much,many]];

[0120] T5[[2,techer,teachers],[3,adviced,advised],[8,them,themself],[10,wise,wisely],[15,much,more],[22,consentrate,consentrete]];

[0121] SymSpell[[2,techer,teacher],[20,nervus,nervous],[22,consentrate,concentrate]].

[0122] For the first word to be corrected, "techer," its word position in the target text is recorded as word position 2. There are three correction recommendations, including: techer->teacher, techer->teachers, and no replacement. Thus, we can obtain a set of candidate texts for the first word to be corrected, including three candidate texts:

[0123] "The teacher advised his students to use them time wise during the exam, but much of them where too nervus to consentrate";

[0124] "The teachers advised his students to use them time wise during the exam, but much of them where too nervus to consentrate";

[0125] "The techer advised his students to use them time wise during the exam, but much of them where too nervus to consentrate."

[0126] Furthermore, the sentence perplexity of the three candidate texts is calculated respectively, and the two with the smallest sentence perplexity are retained (that is, the preset number is set to 2) as the retained texts:

[0127] "The teacher advised his students to use them time wise during the exam, but much of them where too nervus to consentrate";

[0128] "The teachers advised his students to use them time wise during the exam, but much of them where too nervus to consentrate."

[0129] After completing the error correction for the first word to be corrected, the next word to be corrected in the retained text is corrected. The next word to be corrected can be selected as the word to be corrected "adviced" at word position 3 according to the traversal order.

[0130] There are two correction recommendations for the word "adviced" in word position 3: advised->advised and no replacement. This gives us four candidate texts for this round of correction (two candidate texts for each retained text):

[0131] "The teacher advised his students to use them time wise during the exam, but much of them where too nervus to consentrate";

[0132] "The teacher advised his students to use them time wise during the exam, but much of them where too nervus to consentrate";

[0133] "The teachers advised his students to use them time wise during the exam, but much of them where too nervus to consentrate";

[0134] "The teachers advised his students to use them time wise during the exam, but much of them where too nervus to consentrate."

[0135] Furthermore, the sentence perplexity of the four candidate texts is calculated, and only the two with the smallest sentence perplexity are retained as the retained texts, which is:

[0136] "The teacher advised his students to use them time wise during the exam, but much of them where too nervus to consentrate";

[0137] "The teachers advised his students to use them time wise during the exam, but much of them where too nervus to consentrate."

[0138] So far, the error correction process of the second word to be corrected for the error correction result set has been completed, and then the next word to be corrected continues to be corrected. The next word to be corrected at this moment is also selected according to the traversal order, i.e., the word to be corrected "them" in word position 8.

[0139] There are three correction recommendations for the word "them" to be corrected at word position 8, including: them->their, them->themself, and no replacement. This gives us six candidate texts for this round of correction (three for each retained text):

[0140] "The teacher advised his students to use their time wisely during the exam, but much of them where too nervus to consentrate";

[0141] "The teacher advised his students to use themselves time wise during the exam, but much of them where too nervus to consentrate";

[0142] “The teacher advised his students to use them time wise during the exam, but much of them where too nervus to consentrate”;

[0143] “The teachers advised his students to use their time wise during the exam, but much of them where too nervus to consentrate”;

[0144] “The teachers advised his students to use themself time wise during the exam, but much of them where too nervus to consentrate”;

[0145] “The teachers advised his students to use them time wise during the exam, but much of them where too nervus to consentrate”。

[0146] Furthermore, calculate the sentence perplexity of the above six candidate texts and retain the two with the smallest sentence perplexity as the retained texts, that is, we get:

[0147] “The teacher advised his students to use their time wise during the exam, but much of them where too nervus to consentrate”;

[0148] “The teachers advised his students to use their time wise during the exam, but much of them where too nervus to consentrate”。

[0149] Continue to correct each word to be corrected in the correction result set in the above manner until two retained texts are obtained after correcting the last word to be corrected. Then, the one with the smallest sentence perplexity among the two retained texts can be selected as the recommended text.

[0150] In this embodiment, the recommended text finally obtained is:

[0151] "The teacher advised his students to use their time wisely during the exam, but many of them were too nervous to concentrate."

[0152] As an optional embodiment, the sentence perplexity of each candidate text is calculated based on the following steps:

[0153] According to the conditional probability of each word in the candidate text, the logarithmic probability sum of all words is obtained;

[0154] An average logarithmic probability is determined according to the logarithmic probability and the total number of words in the candidate text, so as to use the average logarithmic probability as the sentence perplexity of the candidate text.

[0155] Sentence perplexity is a quantitative measure of the naturalness and rationality of generated sentences. The kenLM module can be used to calculate the probability distribution of generated sentences. Lower sentence perplexity values ​​indicate that the generated sentence more closely matches the kenLM module's probability distribution. This means that the kenLM module's prediction for the next sentence is more accurate, indicating a more natural and reasonable sentence. Conversely, higher sentence perplexity indicates that the sentence deviates from kenLM module's expectations.

[0156] Optionally, the calculation formula of the sentence perplexity can be expressed as:

[0157] ;

[0158] in, is the word sequence before the given Under the condition of i words probability; N is the total number of words in the sentence.

[0159] This paper uses a multi-model integration approach to error correction using beam search and sentence perplexity, enabling a more comprehensive exploration of potential correction candidates, improving both error correction accuracy and the fluency of generated text. Using sentence perplexity as an evaluation function ensures that the corrected text conforms more closely to standard writing conventions and linguistic conventions.

[0160] It should be noted that, in the text error correction method provided by the present invention, different error correction components recognize the input text according to different error correction strategies and optimization goals;

[0161] The error correction strategy includes one or more of an editing operation-based strategy, a text generation-based strategy, and a spelling correction-based strategy; and the optimization objectives include precision, recall, and response speed.

[0162] Specifically, in the text correction method provided by this invention, different correction components employ different correction strategies and optimization objectives to process the input text. The selection of these strategies and objectives depends on the specific correction requirements and application scenarios. By combining multiple strategies and optimization objectives, the advantages of different correction components can be combined to improve the overall correction effect.

[0163] Among them, the editing operation-based strategy refers to correcting errors in the text by defining a series of editing operations (such as insertion, deletion, replacement, etc.). This error correction strategy targets grammatical error correction and can accurately locate and correct errors.

[0164] The text generation-based strategy treats the error correction task as a text generation task and corrects errors by generating entire sentences or text fragments. This error correction strategy can effectively target scenarios where sentence structure needs to be rewritten and can handle complex grammatical and semantic errors.

[0165] The spelling correction strategy focuses on correcting spelling errors by finding candidate words similar to the incorrect word, which can effectively detect and correct spelling errors quickly.

[0166] Precision refers to the proportion of corrected errors in the error correction results, reflecting the accuracy of the corrections. Improving precision can reduce false corrections. Recall refers to the proportion of corrected errors among all actual errors, reflecting the coverage of the corrections. Improving recall can reduce missed corrections. Response speed refers to the time it takes the error correction component to process text and generate recommended text. Optimizing response speed can improve the real-time performance and efficiency of the system, making it suitable for application scenarios that require fast response.

[0167] The present invention selects different error correction components to recognize input text according to different error correction strategies and optimization goals. By combining multiple strategies and optimization goals, the advantages of different error correction components can be integrated to improve the overall error correction effect.

[0168] Optionally, in the error correction strategy, the error correction component based on the editing operation strategy can use the GECToR error correction model, the error correction component based on the text generation strategy can use the T5 error correction model, and the error correction component based on the spelling correction strategy can use the SymSpell error correction tool.

[0169] Since the GECToR error correction model adopts an editing operation-based strategy, it focuses on high-precision grammatical error correction. In addition, the T5 error correction model adopts a text generation-based strategy, which is suitable for handling complex grammatical and semantic errors. The SymSpell error correction tool adopts a spelling correction-based strategy, which can quickly detect and correct spelling errors. By combining these different error correction strategies and optimization goals, the advantages of different error correction components can be integrated to improve the overall error correction effect.

[0170] The present invention utilizes a multi-model (including error correction tools) integration approach to achieve optimal error correction results. However, considering that simultaneously invoking multiple models / error correction tools requires significant CPU and GPU space, and also slows down execution, the present invention, based on the above-mentioned embodiments, proposes a further text error correction method, including:

[0171] Performing distillation learning on all the error correction components to generate a text error correction model;

[0172] The text error correction model is used to receive an input target text and output a recommended text after error correction is performed on the target text.

[0173] In order to overcome the problems of high computing resource consumption and slow running speed caused by multi-model integration, the present invention proposes a text error correction model generation method based on knowledge distillation. By distilling the capabilities of multiple error correction components into a smaller and more efficient text error correction model, the consumption of computing resources can be significantly reduced while maintaining efficient error correction capabilities.

[0174] First, a lightweight model is selected as the student model, such as BART-small. The selected student model has a small number of parameters and is suitable for running in a resource-constrained environment.

[0175] Use multiple correction components (such as GECToR, T5, SymSpell, and other correction models or tools) to correct a large number of text samples and record the output of each correction component. These outputs are combined into a training dataset, including the input text sample, soft labels (the probability distribution recommended by the correction component), and hard labels (the optimal correction result). Distillation learning is performed on the student model using the training dataset. The student model's parameters are adjusted through various alignment methods to enable it to learn the capabilities of multiple correction components.

[0176] Through this operation, in the subsequent actual detection process, it is only necessary to directly input the target text into the text correction model generated by distillation learning. It can then use the learned knowledge to analyze and process the target text and generate corrected recommended text, effectively integrating the capabilities of multiple correction components into a smaller, more efficient model while maintaining efficient correction capabilities.

[0177] As an optional embodiment, in the text error correction method provided by the present invention that uses a small model for distillation using multiple alignment methods, the student model can use the general-purpose BART-small error correction model. The BART-small error correction model combines the advantages of the BERT model and the GPT model. It uses a standard Transformer encoder-decoder architecture. The encoder is similar to the BERT model and can encode context in both directions, while its decoder is similar to the GPT model and is autoregressive. In addition, the BART model handles a large number of text perturbation tasks during the pre-training phase and is particularly suitable for processing complex sentences that require rewriting. Its generation quality is high and it can maintain sentence fluency while ensuring grammatical correctness. In addition, because the BART model is more inclined to rewrite sentences and generates hallucinations more seriously than T5, it is difficult to fully converge the BART model using only a general paired error correction training set. This is also the reason why the T5 error correction model is generally used when using a single Seq2Seq model for error correction. However, precisely because the BART model has a stronger sentence rewriting ability and a stronger ability to learn complex error correction operations, it is convenient for learning the error correction capabilities of multi-model integration.

[0178] In order to enable the BART-small error correction model to better learn the multi-model integrated error correction capability, the present invention adopts a distillation learning method that combines multiple alignment methods.

[0179] Specifically, when the error correction component includes a first error correction component based on an editing operation strategy and a second error correction component based on a text generation strategy, performing distillation learning on all the error correction components to generate a text error correction model includes:

[0180] For each text sample, perform error correction processing using the first error correction component and the second error correction component, respectively, to obtain a first soft label output by the first error correction component and a second soft label output by the second error correction component;

[0181] Performing beam search integration on the error correction results of the first error correction component and the second error correction component to obtain the integrated recommended text as a hard label;

[0182] Taking the text sample as an input sample, and taking the first soft label, the second soft label, and the hard label as labels of the input sample to form a training data set;

[0183] Using the training data set, all the error correction components are subjected to multiple alignment distillation learning to obtain a text error correction model.

[0184] The first error correction component can be a GECToR error correction model, and the second error correction component can be a T5 error correction model. The following uses this as an example to introduce the specific implementation method of distillation learning.

[0185] Distillation learning methods are generally categorized into hard alignment and soft alignment. Hard alignment involves directly comparing the output of the student model with the output of the teacher model. This is implemented similarly to general learning from a training set: the teacher model's output is constructed as new training data pairs, and the student model directly compares the predicted and true values ​​for backpropagation to adjust model parameters. Soft alignment involves comparing the student model's output with the teacher model's soft labels. Soft labels are the probability distribution output by the teacher model, typically containing information about the teacher model's confidence level between different categories. The goal of soft alignment is to enable the student model to learn not only the final category decision but also how the teacher model allocates uncertainty.

[0186] First, we use different error correction components to process the same text sample and obtain the results of multiple error correction strategies, providing rich training data for subsequent distillation learning, including:

[0187] A text sample is selected and corrected using the GECToR error correction model. The corresponding correction recommendation and its confidence score are output as the first soft label. The T5 error correction model is then used to correct the text sample and output the corresponding correction recommendation and its confidence score as the second soft label. Furthermore, the beam search and sentence perplexity methods described in the previous examples are combined to obtain the final recommended text as the hard label.

[0188] Thus, a training sample consisting of a text sample, a first soft label, a second soft label, and a hard label corresponding to a text sample can be obtained, which can be expressed as:

[0189] [Text samples, GECToR’s correction recommendations and their confidence, T5’s correction recommendations and their confidence, recommended text].

[0190] By repeating the above steps to process multiple text samples, a complete training dataset can be constructed.

[0191] Finally, the constructed training dataset is used to perform multiple alignment distillations on all error correction components to obtain a text error correction model.

[0192] As an optional embodiment, the above-mentioned distillation of all the error correction components using the constructed training dataset in multiple alignment modes to obtain a text error correction model may include but is not limited to the following steps:

[0193] Determine the pre-trained lightweight text error correction initial model as the student model;

[0194] Determining a first soft label, a second soft label, and a hard label corresponding to each text sample in the training data set;

[0195] The weights of the Kullback-Leibler divergence loss function (KL divergence loss function for short), the Jensen-Shannon divergence loss function (JS divergence loss function for short), and the cross-entropy loss function are set to iteratively perform the following pre-training operation using each of the text samples in the training dataset until the pre-training results converge to obtain the text error correction model:

[0196] Using the KL divergence loss function, aligning the output of the student model with the first soft label to learn the error correction probability distribution of the first error correction component;

[0197] Using the JS divergence loss function, aligning the output of the student model with the second soft label to learn the error correction probability distribution of the second error correction component;

[0198] The cross entropy loss function is used to align the output of the student model with the hard label to learn the overall error correction capability of the integrated error correction component.

[0199] The F0.5 value is a common evaluation metric for error correction tasks. Precision is more important than recall. Based on this evaluation metric, and to help the initial text error correction model better learn error correction integration capabilities, this paper uses a distillation learning method with multiple alignment methods. For the GECToR error correction model, a soft alignment method using the KL divergence loss function is used; for the T5 error correction model, a soft alignment method using the JS divergence loss function is used; and for overall integration capabilities, a hard alignment method using the cross-entropy loss function is used.

[0200] KL divergence, also known as relative entropy, is an asymmetric measure used to measure the difference between two probability distributions. and , they are in the same event space As defined above, KL divergence is arrive is defined as:

[0201] ;

[0202] in: is the true distribution, is an approximate distribution, To measure each Point, distribution right Approximate situation.

[0203] KL divergence is asymmetric and is mainly affected by the distribution when used as a loss function. Influence, the purpose of KL divergence is to make the distribution Try to get as close to the distribution as possible The GECToR error correction model is characterized by high precision and low recall, and its error correction probability distribution needs to be learned through distillation learning. Therefore, the present invention adopts KL divergence as the loss function for aligning the GECToR error correction model, so that the text error correction initial model can learn the error correction probability distribution of the GECToR error correction model as completely as possible.

[0204] The JS divergence is defined by calculating the KL divergence between each of the two probability distributions and their mean distribution. and , the JS divergence is defined as:

[0205] ;

[0206] in, is a probability distribution P and Q The average distribution of and are measured separately P and Q With average distribution M The KL divergence between .

[0207] Unlike KL divergence, JS divergence is symmetric, that is, , as a loss function, is also affected by the distribution and The purpose of KL divergence is to make the distribution Try to get as close to the distribution as possible and The T5 error correction model is characterized by high recall and low precision. The present invention adopts JS divergence as the loss function for distillation alignment of the T5 error correction model to comprehensively analyze the error correction probability distribution in the English literature field and the general field, which can minimize the low precision problem caused by hallucination.

[0208] Cross-entropy is used to calculate the difference between the output sequence generated by the model and the true target sequence. For generative models, cross-entropy loss measures the difference between the model's predicted distribution and the target distribution, which is defined as:

[0209] ;

[0210] in, T is the length of the target sequence, The target sequence is The true label of each position (usually one-hot encoded), The model is The probability distribution of the prediction at each position, The model is The logarithm of the probability distribution of the prediction at each position.

[0211] The present invention uses cross entropy as the hard alignment loss function for the overall error correction integration result, allowing the initial text error correction model to learn the beam search integration capability of multiple error correction components. The loss function of the text error correction model distillation learning can be set as:

[0212] ;

[0213] in 、 、 are the weights of KL divergence, JS divergence, and cross entropy respectively.

[0214] After experimental adjustment, it was determined 、 、 When the values ​​are 0.16, 0.22, and 0.62 respectively, the text error correction model obtained has the best error correction effect.

[0215] During a distillation learning process, the present invention constructs a training data set of 40 million sentences, of which 30 million are from the English literature field and 10 million are from the general field.

[0216] After testing on a dedicated test set in the English literature field, the F0.5 value of the GECToR error correction model alone was 0.6340, the F0.5 value of the T5 error correction model alone was 0.5589, the F0.5 value of the error correction integration algorithm was 0.7580, and the F0.5 value of the text error correction model after distillation learning was 0.7108. It can be seen that the error correction integration algorithm of the present invention can significantly improve the error correction capability in the field of English scientific literature, and the distillation algorithm can retain 93.8% of the error correction capability of the original integration algorithm.

[0217] Figure 5 Schematic diagram of the structure of the text error correction device provided by the present invention. Figure 5 As shown, mainly including but not limited to:

[0218] The pre-correction unit 51 is mainly used to input the target text to be processed into at least two correction components to obtain a set of results to be corrected, wherein the set of results to be corrected includes the words to be corrected output by each correction component and the correction recommendations corresponding to each word to be corrected;

[0219] The error correction processing unit 52 mainly modifies the target text using all the error correction recommendations for any word to be corrected in the error correction result set to generate a candidate text set, so as to screen out a preset number of retained texts from the candidate text set;

[0220] The iterative control unit 53 is mainly used to control the error correction processing unit 52 to continue correcting another word to be corrected in each of the retained texts until all the words to be corrected in the result set to be corrected are traversed, and the recommended text is determined from the retained text finally obtained.

[0221] It should be noted that the text error correction device provided by the present invention can execute the text error correction method described in any of the above embodiments during specific operation, which will not be described in detail in this embodiment.

[0222] The text error correction device provided by the present invention adopts a text error correction method based on beam search multi-model integration, which can maximize the error correction capability by integrating the advantages of multiple error correction components.

[0223] Figure 6 Schematic diagram of the structure of the electronic device provided by the present invention, such as Figure 6 As shown, the electronic device may include: a processor 610, a communication interface 620, a memory 630, and a communication bus 640, wherein the processor 610, the communication interface 620, and the memory 630 communicate with each other via the communication bus 640. The processor 610 may call logic instructions in the memory 630 to execute a text correction method, which includes: inputting a target text to be processed into at least two correction components to obtain a result set to be corrected, wherein the result set to be corrected includes words to be corrected output by each correction component and correction recommendations corresponding to each word to be corrected; for any word to be corrected in the result set to be corrected, using all correction recommendations for the word to be corrected, modifying the target text to generate a candidate text set, thereby screening a preset number of retained texts from the candidate text set; and continuing to correct another word to be corrected in each retained text until all words to be corrected in the result set to be corrected are traversed, and determining a recommended text from the retained text obtained last.

[0224] Furthermore, the logic instructions in the aforementioned memory 630 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the portion that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, a mobile hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0225] On the other hand, the present invention also provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute the text correction method provided by the above-mentioned embodiments, the method including: inputting the target text to be processed into at least two correction components to obtain a result set to be corrected, the result set to be corrected collecting the words to be corrected output by each correction component and the correction recommendations corresponding to each word to be corrected; for any word to be corrected in the result set to be corrected, using all the correction recommendations of any word to be corrected to modify the target text respectively to generate a candidate text set, so as to filter out a preset number of retained texts from the candidate text set; continuing to correct another word to be corrected in each of the retained texts until all the words to be corrected in the result set to be corrected are traversed, and determining the recommended text from the retained text finally obtained.

[0226] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the text correction method provided by the above-mentioned embodiments, the method comprising: inputting the target text to be processed into at least two correction components to obtain a result set to be corrected, the result set to be corrected collecting the words to be corrected output by each of the correction components and the correction recommendations corresponding to each of the words to be corrected; for any word to be corrected in the result set to be corrected, using all the correction recommendations of any word to be corrected to modify the target text respectively to generate a candidate text set, so as to filter out a preset number of retained texts from the candidate text set; continuing to correct another word to be corrected in each of the retained texts until all the words to be corrected in the result set to be corrected are traversed, and determining the recommended text from the retained text finally obtained.

[0227] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, i.e., they may be located in one location or distributed across multiple network units. Some or all of the modules may be selected based on actual needs to achieve the objectives of the present embodiment. Persons of ordinary skill in the art will be able to understand and implement the present invention without inventive effort.

[0228] Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented using software plus a necessary general-purpose hardware platform, or of course, hardware. Based on this understanding, the essence of the above technical solution, or the portion that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a magnetic disk, or an optical disk, and includes a number of instructions for causing a computer device (such as a personal computer, server, or network device) to execute the methods described in each embodiment or certain portions of the embodiments.

[0229] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention.

Claims

1. A text error correction method, characterized in that: include: Inputting a target text to be processed into at least two error correction components to obtain an error correction result set, wherein the error correction result set includes the words to be corrected output by each error correction component and at least one error correction recommendation corresponding to each word to be corrected; For any word to be corrected in the set of results to be corrected, the target text is modified respectively by using all correction recommendations for the word to be corrected to generate a candidate text set, so as to screen out a preset number of retained texts from the candidate text set, including: performing correction operations on any word to be corrected in the target text according to each correction recommendation, generating a plurality of candidate texts having the same number as the correction recommendations, all of which constitute the candidate text set; screening out the preset number of retained texts from the candidate text set according to the sentence perplexity of each candidate text, so as to use each retained text as the new target text; The sentence perplexity of each candidate text is calculated based on the following steps: obtaining the logarithmic probability sum of all words according to the conditional probability of each word in the candidate text; determining the average logarithmic probability according to the logarithmic probability sum and the total number of words in the candidate text, and using the average logarithmic probability as the sentence perplexity of the candidate text; Continue correcting another word to be corrected in each of the retained texts until all the words to be corrected in the result set to be corrected are traversed, and determine the recommended text from the retained text finally obtained.

2. The text error correction method according to claim 1, characterized in that: The preset number is determined based on the computational complexity of the text error correction.

3. The text error correction method according to any one of claims 1-2, characterized in that: The order of traversing all the words to be corrected in the result set to be corrected is determined according to the sentence order of each word to be corrected in the target text.

4. The text error correction method according to claim 3, characterized in that: Different error correction components recognize the input text according to different error correction strategies and optimization goals; The error correction strategy includes one or more of an editing operation-based strategy, a text generation-based strategy, and a spelling correction-based strategy; and the optimization objectives include precision, recall, and response speed.

5. The text error correction method according to claim 4, characterized in that: The error correction component whose error correction strategy is based on editing operation strategy is GECToR error correction model, the error correction component whose error correction strategy is based on text generation strategy is Text-to-Text Transfer Transformer error correction model, and the error correction component whose error correction strategy is based on spelling correction strategy is SymSpell error correction tool.

6. The text error correction method according to claim 1, characterized in that: Also includes: Performing distillation learning on all the error correction components to generate a text error correction model; The text error correction model is used to receive an input target text and output a recommended text after error correction is performed on the target text.

7. The text error correction method according to claim 6, characterized in that: In a case where the error correction component includes a first error correction component based on an editing operation strategy and a second error correction component based on a text generation strategy, performing distillation learning on all the error correction components to generate a text error correction model includes: For each text sample, perform error correction processing using the first error correction component and the second error correction component, respectively, to obtain a first soft label output by the first error correction component and a second soft label output by the second error correction component; Performing beam search integration on the error correction results of the first error correction component and the second error correction component to obtain the integrated recommended text as a hard label; Taking the text sample as an input sample, and taking the first soft label, the second soft label, and the hard label as labels of the input sample to form a training data set; Using the training data set, all the error correction components are distilled using multiple alignment methods to obtain a text error correction model.

8. The text error correction method according to claim 7, characterized in that: Using the training dataset, all the error correction components are distilled using multiple alignment methods to obtain a text error correction model, specifically including: Determine the pre-trained lightweight text error correction initial model as the student model; Determining a first soft label, a second soft label, and a hard label corresponding to each text sample in the training data set; The weights of the Kullback-Leibler divergence loss function, the Jensen-Shannon divergence loss function, and the cross entropy loss function are set to iteratively perform the following pre-training operation using each of the text samples in the training dataset until the pre-training results converge to obtain the text error correction model: Aligning the output of the student model with the first soft label using the Kullback-Leibler divergence loss function to learn the error correction probability distribution of the first error correction component; Aligning the output of the student model with the second soft label using the Jensen-Shannon divergence loss function to learn the error correction probability distribution of the second error correction component; The cross entropy loss function is used to align the output of the student model with the hard label to learn the overall error correction capability of the integrated error correction component.

9. A text error correction device, characterized in that: include: A pre-correction unit is configured to input a target text to be processed into at least two correction components to obtain a result set to be corrected, wherein the result set to be corrected includes the words to be corrected output by each correction component and at least one correction recommendation corresponding to each word to be corrected; The error correction processing unit, for any word to be corrected in the set of results to be corrected, uses all the correction recommendations of any word to be corrected to modify the target text respectively to generate a candidate text set, so as to screen out a preset number of retained texts from the candidate text set, including: performing an error correction operation on any word to be corrected in the target text according to each of the error correction recommendations, generating a plurality of candidate texts with the same number as the error correction recommendations, and all the candidate texts constituting the candidate text set; screening out the preset number of retained texts from the candidate text set according to the sentence perplexity of each candidate text, so as to use each retained text as the new target text; the sentence perplexity of each candidate text is calculated based on the following steps: obtaining the logarithmic probability sum of all words according to the conditional probability of each word in the candidate text; determining an average logarithmic probability according to the logarithmic probability sum and the total number of words in the candidate text, so as to use the average logarithmic probability as the sentence perplexity of the candidate text; An iterative control unit is used to control the error correction processing unit to continue correcting another word to be corrected in each of the retained texts until all the words to be corrected in the result set to be corrected are traversed, and a recommended text is determined from the retained text finally obtained.

10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the text error correction method according to any one of claims 1 to 8 is implemented.

11. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the text error correction method according to any one of claims 1 to 8 is implemented.

12. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the text error correction method according to any one of claims 1 to 8 is implemented.

Citation Information

Patent Citations

  • Speech text error correction method, system and equipment based on vertical field and medium

    CN110210029A

  • Text error correction method and related equipment

    CN114330303A

  • Chinese grammar error diagnosis method based on multi-stage training and editing level voting

    CN115034218A

  • Iterative pruning optimization method based on dynamic double-teacher multi-stage distillation

    CN119940454A