Text error correction method and device, equipment, storage medium and product
By constructing training sets for different text error types and training error correction models, and combining knowledge data for serial or parallel error correction, the accuracy problem of large language models in handling multiple text errors is solved, the error correction effect is improved and resource utilization is optimized.
Patent Information
- Application Number
- CN202411693294.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-25
- Publication Date
- 2026-02-10
AI Technical Summary
Existing large language models fail to effectively distinguish and process different types of text errors, resulting in low error correction accuracy.
Training sets are constructed for each of the N types of text errors, and the large language model is trained using the N training sets to obtain the error correction model corresponding to each type of text error. Error correction is performed by combining knowledge data in a serial or parallel manner.
It effectively avoids interference between different text error types, improves error correction accuracy, and reduces the consumption or time required for graphics card resources.
Smart Images

Figure CN121503472A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of natural language processing technology, and in particular to a text error correction method, apparatus, device, storage medium, and product. Background Technology
[0002] Text correction is a common task in natural language processing, often used to identify and correct erroneous text in scenarios such as speech-to-text conversion and user input errors.
[0003] Currently, text correction is performed using Large Language Models (LLMs) trained on a unified dataset containing a mix of various text error types. However, existing techniques do not account for the interference between different text error types, resulting in low correction accuracy. Summary of the Invention
[0004] This application provides a text correction method, apparatus, device, storage medium, and product to solve the problem that the prior art does not take into account the mutual interference between different types of text errors, resulting in low correction accuracy.
[0005] To achieve the above objectives, embodiments of this application provide a text correction method, including:
[0006] For each of the N text error types, a training set is constructed for each text error type; where N is a positive integer.
[0007] The first language model is trained using N training sets respectively to obtain the text error correction model corresponding to each type of text error;
[0008] The text to be corrected is corrected using N of the aforementioned text correction models.
[0009] As an improvement to the above scheme, the step of using N text correction models to correct the text to be corrected includes:
[0010] Acquire knowledge data for each type of text error;
[0011] Using the knowledge data of the first text error type as background knowledge, and inputting it along with the text to be corrected into the text correction model corresponding to the first text error type, the text correction result output by the text correction model corresponding to the first text error type is obtained;
[0012] The knowledge data of the nth text error type is used as background knowledge. The text correction result output by the text correction model corresponding to the (n-1)th text error type is input into the text correction model corresponding to the nth text error type, and so on, until it is input into the text correction model corresponding to the Nth text error type to obtain the final text correction result; where n≤N, and n is a positive integer.
[0013] As an improvement to the above scheme, the step of using N text correction models to correct the text to be corrected includes:
[0014] Acquire knowledge data for each type of text error;
[0015] For each type of text error, the knowledge data of the text error type is used as background knowledge, and the text to be corrected is input into the text correction model corresponding to the text error type to obtain the text correction result output by the text correction model corresponding to the text error type.
[0016] The N text correction results are merged to obtain the final text correction result.
[0017] As an improvement to the above scheme, the step of constructing a training set for each of the N text error types includes:
[0018] For each text error type, perform the following steps:
[0019] Obtain annotation data for the text error type; the annotation data includes at least: first error text data containing the text error type, and text data obtained after correcting the text error type of the first error text data;
[0020] Record the annotation data into the annotation dataset of the text error type;
[0021] The training set is constructed based on the labeled dataset.
[0022] As an improvement to the above solution, after storing the annotation data into the annotation dataset of the text error type, the text correction method further includes:
[0023] Obtain knowledge data on the text error type;
[0024] Based on the labeled data and the knowledge data, prompt words are constructed;
[0025] The preset text data and the prompt word are input into the second language model to obtain the second error text data output by the second language model; the preset text data does not contain the text error type, while the second error text data does contain the text error type.
[0026] The preset text data and the second erroneous text data are recorded in the labeled dataset.
[0027] As an improvement to the above solution, the step of constructing prompt words based on the labeled data and the knowledge data includes:
[0028] The knowledge data is used as the background knowledge for the prompt words, and the labeled data is used as examples for the prompt words to construct the prompt words.
[0029] To achieve the above objectives, embodiments of this application also provide a text correction device, including:
[0030] The training set construction module is used to construct a training set for each of the N text error types; where N is a positive integer.
[0031] The model training module is used to train the first language model using N training sets respectively, so as to obtain the text error correction model corresponding to each type of text error.
[0032] The error correction module is used to correct the text to be corrected using N text error correction models.
[0033] To achieve the above objectives, embodiments of this application also provide a text correction device, including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor implements the text correction method as described above when executing the computer program.
[0034] To achieve the above objectives, embodiments of this application also provide a computer-readable storage medium, the computer-readable storage medium including a stored computer program; wherein, when the computer program is executed, it controls the device where the computer-readable storage medium is located to perform the text correction method as described above.
[0035] To achieve the above objectives, embodiments of this application also provide a computer program product, including a computer program / instruction, which, when executed by a processor, implements the text correction method as described above.
[0036] Compared with the prior art, the text correction method, apparatus, device, storage medium and product provided in this application embodiment constructs a training set for each of the N text error types; trains a first language model using the N training sets to obtain a text correction model corresponding to each text error type; and uses the N text correction models to correct the text to be corrected, avoiding mutual interference between different text error types, thereby improving the accuracy of error correction. Attached Figure Description
[0037] Figure 1 This is a flowchart of a text correction method provided in an embodiment of this application;
[0038] Figure 2 This is a structural block diagram of a text correction device provided in an embodiment of this application;
[0039] Figure 3 This is a structural block diagram of a text correction device provided in an embodiment of this application. Detailed Implementation
[0040] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.
[0041] See Figure 1 , Figure 1 This is a flowchart of a text correction method provided in an embodiment of this application. The text correction method includes:
[0042] S1. For N types of text errors, construct a training set for each type of text error; where N is a positive integer;
[0043] S2. Using N training sets respectively, train the first language model to obtain the text error correction model corresponding to each type of text error;
[0044] S3. Use N of the text correction models to correct the text to be corrected.
[0045] In this embodiment, a training set is constructed for each type of text error, and then a text correction fine-tuning training task corresponding to each text error type is constructed. The training objective is to identify whether a text error exists; if so, error correction is performed and the text correction result is returned; otherwise, the original input is directly returned. Each task can use the LoRA training method (Low-Rank Adaptation of Large Language Models, a low-rank parameterized update matrix training method for large language models), and fine-tuning training is performed on the same version of the large language model, ultimately obtaining the trained large language model, i.e., the text correction model, for each type of text error.
[0046] Specifically, the text correction result includes the location of the text error and / or the corrected text. In other words, the text correction model identifies the location of the text error, i.e., the position in the text that needs correction, and further, it can correct the text error location to obtain the corrected text.
[0047] This application improves error correction accuracy by constructing a corresponding training set for each type of text error, thus avoiding mutual interference between different text error types.
[0048] In one optional embodiment, the N types of text errors include at least one of the following: text error types for homophones or similar-sounding words, text error types for words with similar forms, and text error types for grammar or syntax.
[0049] For example, in this application embodiment, a training set for text error types involving homophones or similar-sounding words is constructed. This training set is then used to train a first language model to obtain a text correction model for these homophone or similar-sounding word error types. Using this text correction model, text containing homophone or similar-sounding word errors can be corrected.
[0050] This application embodiment addresses text error types related to similar-looking words by constructing a training set for that error type, and then using this training set to train a first language model to obtain a text correction model for similar-looking word text error types. This text correction model can then be used to correct text containing text error types related to similar-looking words.
[0051] This application embodiment constructs a training set for text error types related to syntax or grammar, and then uses this training set to train a first language model to obtain a text correction model for text error types related to syntax or grammar. Using this text correction model, text containing text error types related to syntax or grammar can be corrected.
[0052] The embodiments of this application comprehensively consider each type of text error, which can avoid mutual interference between each type of text error, thereby improving the accuracy of error correction.
[0053] In one optional embodiment, the step of using N text correction models to correct the text to be corrected includes:
[0054] Acquire knowledge data for each type of text error;
[0055] Using the knowledge data of the first text error type as background knowledge, and inputting it along with the text to be corrected into the text correction model corresponding to the first text error type, the text correction result output by the text correction model corresponding to the first text error type is obtained;
[0056] The knowledge data of the nth text error type is used as background knowledge. The text correction result output by the text correction model corresponding to the (n-1)th text error type is input into the text correction model corresponding to the nth text error type, and so on, until it is input into the text correction model corresponding to the Nth text error type to obtain the final text correction result; where n≤N, and n is a positive integer.
[0057] It is understandable that knowledge data for text error types refers to data that characterizes the text error type. For example, for text error types targeting homophones or similar-sounding words, the knowledge data is a list of homophones and similar-sounding words. Furthermore, to enrich the knowledge data, the list of homophones and similar-sounding words in the knowledge base can be expanded, using the expanded knowledge data as background knowledge. For text error types targeting words with similar forms, the knowledge data is a list of words with similar forms. Furthermore, to enrich the knowledge data, the list of words with similar forms in the knowledge base can be expanded, using the expanded knowledge data as background knowledge. For text error types targeting grammar or syntax, corresponding descriptions and instances can be collected as knowledge data. Among these, text error types related to grammar or syntax include, but are not limited to: improper collocation, incomplete components, redundant components, incorrect word order, mixed sentence structures, and improper use of conjunctions.
[0058] For example, regarding redundant elements, describing a subject with redundant elements, Example 1: We second-grade students can all listen attentively and abide by classroom discipline. Example 2: Because they all have clear learning goals, these students who have just entered university study very hard. These examples both contain textual errors where the subject has redundant elements.
[0059] The term "redundant elements" refers to redundant parts in the predicate. Examples include: 1. "It has been more than four months since I returned to my hometown." 2. "The problem of illegal occupation of farmland in this village has now been resolved." Both examples contain textual errors indicating redundant predicate elements.
[0060] This application embodiment is specifically designed for offline, non-real-time error correction tasks (such as document quality inspection and error correction scenarios). It employs a serial error correction method: Knowledge data of the first text error type is used as background knowledge, and input along with the text to be corrected into the text correction model corresponding to the first text error type, to obtain the text correction result output by the text correction model corresponding to the first text error type. Knowledge data of the nth text error type is used as background knowledge, and input along with the text correction result output by the text correction model corresponding to the (n-1)th text error type into the text correction model corresponding to the nth text error type, and so on, until input into the text correction model corresponding to the Nth text error type (i.e., the last text error type), to obtain the final text correction result. The serial method provided by this application embodiment can effectively reduce the consumption of graphics card resources while ensuring error correction accuracy.
[0061] For example, embodiments of this application train large language models for text error types of homophones or similar-sounding words, large language models for text error types of words with similar forms, and large language models for text error types of syntax or grammar. For these three large language models, let the text error type for homophones or similar-sounding words be the first text error type, the text error type for words with similar forms be the second text error type, and the text error type for syntax or grammar be the third text error type.
[0062] First, load the base model, set the adapter, and load the model parameters corresponding to the first text error type to obtain the text correction model corresponding to the first text error type. Use the knowledge data of the first text error type as background knowledge, and input it together with the text to be corrected into the text correction model to identify and correct text errors in the text to be corrected that target homophones or similar-sounding words.
[0063] Next, set up the adapter and load the model parameters corresponding to the second text error type to obtain the text correction model corresponding to the second text error type. Take the knowledge data of the second text error type as background knowledge and the output of the previous step as input to the text correction model to identify and correct text errors in the text output of the previous step for text error types of similar words.
[0064] Finally, the adapter is set up and the model parameters for the third text error type are loaded to obtain the text correction model corresponding to the third text error type. The knowledge data of the third text error type is used as background knowledge and the output of the previous step is used as input to the text correction model to identify and correct text errors related to syntax or grammar in the text output of the previous step. At this point, the correction of all text correction models is completed, and the output of the text correction model corresponding to the third text error type is the final text correction result.
[0065] In one optional embodiment, the step of using N text correction models to correct the text to be corrected includes:
[0066] Acquire knowledge data for each type of text error;
[0067] For each type of text error, the knowledge data of the text error type is used as background knowledge, and the text to be corrected is input into the text correction model corresponding to the text error type to obtain the text correction result output by the text correction model corresponding to the text error type.
[0068] The N text correction results are merged to obtain the final text correction result.
[0069] It is understandable that knowledge data on text error types refers to data that characterizes the types of text errors, as explained above, and will not be repeated here.
[0070] This application embodiment is particularly aimed at online real-time error correction tasks, and adopts a parallel error correction method: for each type of text error, the knowledge data of the text error type is used as background knowledge, and input along with the text to be corrected into the text error correction model corresponding to the text error type, to obtain the text error correction result output by the text error correction model corresponding to the text error type, that is, to obtain the text error correction result output by the text error correction model corresponding to N types of text error; the N text error correction results are merged to obtain the final text error correction result.
[0071] For example, N text correction models are loaded in parallel, and each model is input with the text to be corrected and the corresponding text error type knowledge data as background knowledge. The text correction results output by each model are obtained, and the results from the N models are merged to obtain the final text correction result. The parallel approach provided in this embodiment breaks down the complex error correction task, thereby reducing the difficulty of the task and achieving the goal of ensuring accuracy while reducing time consumption.
[0072] In addition, if there are conflicting error correction results, multiple final text correction results can be generated by merging them in a permutation and combination manner, and the best final text correction result can be selected from them, or the best final text correction result can be directly output through another major language model.
[0073] For example, regarding the text to be corrected, "Life is made up of small things and sobs":
[0074] Taking it and the knowledge data regarding the text error type of homophones or words with similar sounds as background knowledge, input them together into the corresponding text error correction model, and the output is "Life is composed of smiles and sobs"; this text error correction model only corrects the text error type of homophones or words with similar sounds, correcting "小" to "笑" and "辍" to "啜".
[0075] Taking it and the knowledge data regarding the text error type of words with similar forms as background knowledge, input them together into the corresponding text error correction model, and the output is "Life is composed of tiny and picking sobs"; this text error correction model only corrects the text error type of words with similar forms, correcting "辍" to "掇".
[0076] Regarding the conflict part "辍" in the text to be error-corrected, the two types of text error correction models output differently, and multiple final text error correction results can be combined and generated in a permutation and combination manner. For example, they can be combined into "Life is composed of smiles and sobs" and "Life is composed of smiles and picking sobs".
[0077] In an optional embodiment, for the N types of text error types, training sets for each type of text error type are respectively constructed, including:
[0078] For each type of text error type, the following steps are performed:
[0079] Obtain the annotation data of the text error type; the annotation data at least includes: the first error text data with the text error type, and the text data obtained after correcting the text error type of the first error text data;
[0080] Record the annotation data into the annotation data set of the text error type;
[0081] Construct the training set according to the annotation data set.
[0082] In the embodiment of the present application, the annotation data of each type of text error type can be obtained by manual annotation. Specifically, for the first error text data, if there is only one type of text error type in the first error text data (N = 1), then annotate the text data obtained after correcting the first error text data; if there is more than one type of text error type in the first error text data (N ≥ 2), then copy it N times, and for each copy, only annotate the text data obtained after correcting only one type of text error type of the first error text data. Then record it into the annotation data set of the corresponding text error type.
[0083] For example, the first erroneous text data, "Life is made up of tiny things and sobbing," contains two types of text errors: one for homophones or similar-sounding words, and the other for words with similar forms. Therefore, we duplicate the first erroneous text data twice. On one copy, we correct for homophones or similar-sounding words, resulting in the corrected text data, "Life is made up of smiles and sobbing." We then add "Life is made up of tiny things and sobbing" and its annotation, "Life is made up of smiles and sobbing," to the labeled dataset for text errors caused by homophones or similar-sounding words. On the other copy, we correct for words with similar forms, resulting in the corrected text data, "Life is made up of tiny things and sobbing." We then add both "Life is made up of tiny things and sobbing" and its annotation, "Life is made up of tiny things and sobbing," to the labeled dataset for text errors caused by words with similar forms.
[0084] In addition, the error type, error location, and text ID of the first erroneous text data can be labeled. Similarly, for existing text error types, there is more than one type (N≥2) of first erroneous text data; for each copy, only the text error type and text error location of one type of text error are labeled. Therefore, the labeled data can also include the text error type, the text error location of the text error type, and the text ID.
[0085] In this embodiment, the labeled data in the labeled dataset can be directly used as the training set. For example, the labeled dataset is divided into a training set, a test set, and a validation set. Correct data is mixed into the training set at a 1:4 ratio (the number of correct data sets is four times that of the labeled dataset), and correct data is mixed into the test set and validation set at a 1:1 ratio. The model is then trained using the training set, test set, and validation set.
[0086] In an optional embodiment, after storing the annotation data into the annotation dataset of the text error type, the text correction method further includes:
[0087] Obtain knowledge data on the text error type;
[0088] Based on the labeled data and the knowledge data, prompt words are constructed;
[0089] The preset text data and the prompt word are input into the second language model to obtain the second error text data output by the second language model; the preset text data does not contain the text error type, while the second error text data does contain the text error type.
[0090] The preset text data and the second erroneous text data are recorded in the labeled dataset.
[0091] In this embodiment of the application, in order to improve the accuracy of error correction, the labeled dataset is expanded to enrich the training set, thereby improving the accuracy of error correction.
[0092] Specifically, the prompt words are used to guide the model to generate output that meets the user's expectations. Here, the expected output is second error text data with corresponding text error types. By inputting the preset text data and the prompt words into the second language model, the second error text data output by the second language model is obtained. Then, the preset text data and the corresponding second error text data are recorded in the labeled dataset for selection by the training set.
[0093] Furthermore, the preset text data is preferably text data that does not contain any text error types, which can improve the quality of the output second erroneous text data.
[0094] In one optional embodiment, constructing prompt words based on the labeled data and the knowledge data includes:
[0095] The knowledge data is used as the background knowledge for the prompt words, and the labeled data is used as examples for the prompt words to construct the prompt words.
[0096] In this embodiment, using the knowledge data as background knowledge for the prompt words not only provides the model with necessary contextual information but also significantly improves the model's output quality and accuracy. The labeled data is used as examples of the prompt words to guide the model's output.
[0097] For example, the expansion of the labeled dataset for the first text error type involves: compiling a list of homophones and similar-sounding words, expanding this list using a third-party language model, and then manually proofreading and reviewing it to obtain the final list of homophones and similar-sounding words. Using this final list as background knowledge, prompt words are added (e.g., "If you are a Chinese language and literature expert, you should know about common homophones and similar-sounding words in Chinese. Common homophones and similar-sounding words include..."). M1 (preferably, M1≥3) entries are randomly selected from the labeled data of the first text error type as examples of prompt words. Then, unlabeled text data that does not belong to the first text error type (i.e., preset text data) is randomly selected and input into the second-party language model along with the prompt words to generate second-error text data that belongs to the first text error type. This preset text data and the second-error text data are then recorded in the labeled dataset for the first text error type. Furthermore, the preset text data and the second error text data are compared to obtain the text error location and text ID of the first text error type, and then recorded together with the preset text data and the second error text data into the annotation dataset of the first text error type.
[0098] To expand the labeled dataset for the second text error type: A vocabulary of similar-looking words was compiled and expanded using a third language model. After expansion, the vocabulary was manually proofread to obtain the final vocabulary of similar-looking words. Using this final vocabulary as background knowledge, prompt words were added (e.g., "If you are a Chinese language and literature expert, you should know about common similar-looking words in Chinese. Common similar-looking words include..."). M2 (preferably, M2≥3) entries from the labeled data of the second text error type were randomly selected as examples of prompt words. Then, unlabeled text data that does not belong to the second text error type (i.e., preset text data) was randomly selected and input into the second language model along with the prompt words to generate second-type error text data containing the second text error type. This preset text data and the second-type error text data were recorded in the labeled dataset for the second text error type. Furthermore, the preset text data and the second-type error text data were compared to obtain the text error location and text ID of the second text error type, which were then recorded together with the preset text data and the second-type error text data in the labeled dataset for the second text error type.
[0099] To expand the labeled dataset for the third text error type: Descriptions and corresponding examples of grammatical or syntactic text error types are compiled. Using these descriptions and examples as background knowledge, prompt words are added (e.g., "If you are a Chinese language and literature expert, you understand common grammatical and syntactic knowledge in Chinese. Common grammatical and syntactic errors include..."). M3 (preferably, M3≥3) entries from the labeled data of the third text error type are randomly selected as examples of prompt words. Then, unlabeled text data (i.e., preset text data) that does not contain the third text error type are randomly selected and input into the second language model along with the prompt words to generate second error text data containing the third text error type. This preset text data and the second error text data are then recorded in the labeled dataset for the third text error type. Furthermore, the preset text data and the second error text data are compared to obtain the text error location and text ID of the third text error type, which are then recorded in the labeled dataset for the third text error type along with the preset text data and the second error text data.
[0100] The first, second, and third language models in the embodiments of this application may be the same or different, and no specific limitation is made here.
[0101] The text correction method provided in this application involves constructing training sets for each of the N text error types; training a first language model using the N training sets to obtain a text correction model corresponding to each text error type; and using the N text correction models to correct the text to be corrected, thereby avoiding interference between different text error types and improving the accuracy of error correction.
[0102] See Figure 2 , Figure 2 This is a structural block diagram of a text correction device 10 provided in an embodiment of this application. The text correction device 10 includes:
[0103] Training set construction module 11 is used to construct training sets for each of the N text error types; where N is a positive integer;
[0104] The model training module 12 is used to train the first language model using N training sets respectively, so as to obtain the text error correction model corresponding to each type of text error.
[0105] Error correction module 13 is used to correct errors in the text to be corrected using N of the text error correction models.
[0106] Optionally, the error correction module 13 includes:
[0107] The first error correction unit is used to acquire knowledge data for each type of text error; it uses the knowledge data of the first text error type as background knowledge and inputs it, along with the text to be corrected, into the text correction model corresponding to the first text error type to obtain the text correction result output by the text correction model corresponding to the first text error type; it uses the knowledge data of the nth text error type as background knowledge and inputs it, along with the text correction result output by the text correction model corresponding to the (n-1)th text error type, into the text correction model corresponding to the nth text error type, and so on, until it is input into the text correction model corresponding to the Nth text error type to obtain the final text correction result; where n≤N, and n is a positive integer.
[0108] Optionally, the error correction module 13 includes:
[0109] The second error correction unit is used to acquire knowledge data for each type of text error; for each type of text error, the knowledge data of the text error type is used as background knowledge and input along with the text to be corrected into the text error correction model corresponding to the text error type to obtain the text error correction result output by the text error correction model corresponding to the text error type; the N text error correction results are merged to obtain the final text error correction result.
[0110] Optionally, the training set construction module 11 includes:
[0111] The training set construction unit is used to perform the following steps for each text error type: obtaining labeled data for the text error type; the labeled data includes at least: first erroneous text data containing the text error type, and text data obtained after correcting the text error type of the first erroneous text data; recording the labeled data into the labeled dataset for the text error type; and constructing the training set based on the labeled dataset.
[0112] Optionally, the training set construction module 11 further includes:
[0113] An expansion unit is used to acquire knowledge data of the text error type; construct prompt words based on the annotation data and the knowledge data; input the preset text data and the prompt words into a second language model to obtain the second error text data output by the second language model; the preset text data does not contain the text error type, while the second error text data does contain the text error type; and record the preset text data and the second error text data into the annotation dataset.
[0114] Optionally, constructing prompt words based on the labeled data and the knowledge data includes:
[0115] The knowledge data is used as the background knowledge for the prompt words, and the labeled data is used as examples for the prompt words to construct the prompt words.
[0116] It is worth noting that the working process of each module in the text correction device 10 described in this application embodiment can refer to the working process of the text correction method described in the above embodiment, and will not be repeated here.
[0117] The text correction device 10 provided in this application embodiment constructs a training set for each of the N text error types; trains a first language model using the N training sets to obtain a text correction model corresponding to each text error type; and uses the N text correction models to correct the text to be corrected, avoiding mutual interference between different text error types, thereby improving the accuracy of error correction.
[0118] Furthermore, this application also provides a computer-readable storage medium, which includes a stored computer program; wherein, when the computer program is executed, it controls the device where the computer-readable storage medium is located to perform the text correction method as described in any of the above embodiments.
[0119] Furthermore, this application also provides a computer program product, including a computer program / instruction, which, when executed by a processor, implements the text correction method as described in any of the above embodiments.
[0120] See Figure 3 , Figure 3 This is a structural block diagram of a text correction device 20 provided in an embodiment of this application. The text correction device 20 includes: a processor 21, a memory 22, and a computer program stored in the memory 22 and executable on the processor 21. When the processor 21 executes the computer program, it implements the steps in the above-described text correction method embodiments. Alternatively, when the processor 21 executes the computer program, it implements the functions of each module / unit in the above-described device embodiments.
[0121] For example, the computer program may be divided into one or more modules / units, which are stored in the memory 22 and executed by the processor 21 to complete this application. The one or more modules / units may be a series of computer program instruction segments capable of performing specific functions, which describe the execution process of the computer program in the text correction device 20.
[0122] The text correction device 20 may include, but is not limited to, a processor 21 and a memory 22. Those skilled in the art will understand that the schematic diagram is merely an example of the text correction device 20 and does not constitute a limitation on the text correction device 20. It may include more or fewer components than illustrated, or combine certain components, or different components. For example, the text correction device 20 may also include input / output devices, network access devices, buses, etc.
[0123] The processor 21 can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor. The processor 21 is the control center of the text correction device 20, connecting all parts of the text correction device 20 via various interfaces and lines.
[0124] The memory 22 can be used to store the computer programs and / or modules. The processor 21 implements various functions of the text correction device 20 by running or executing the computer programs and / or modules stored in the memory 22 and calling the data stored in the memory 22. The memory 22 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the mobile phone (such as audio data, phonebook, etc.). In addition, the memory 22 may include high-speed random access memory, and may also include non-volatile memory, such as hard disk, memory, plug-in hard disk, smart media card (SMC), secure digital card (SD) card, flash card, at least one disk storage device, flash memory device, or other volatile solid-state storage device.
[0125] If the modules / units integrated in the text correction device 20 are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by the processor 21, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc.
[0126] It should be noted that 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; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Furthermore, in the accompanying drawings of the device embodiments provided in this application, the connection relationships between modules indicate that they have communication connections, which can be specifically implemented as one or more communication buses or signal lines. Those skilled in the art can understand and implement this without any creative effort.
[0127] The above description is the preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications are also considered to be within the scope of protection of this application.
Claims
1. A text error correction method, characterized in that, include: For each of the N text error types, a training set is constructed for each text error type; where N is a positive integer. The first language model is trained using N training sets respectively to obtain the text error correction model corresponding to each type of text error; The text to be corrected is corrected using N of the aforementioned text correction models.
2. The text correction method as described in claim 1, characterized in that, The step of using N text correction models to correct the text to be corrected includes: Acquire knowledge data for each type of text error; Using the knowledge data of the first text error type as background knowledge, and inputting it along with the text to be corrected into the text correction model corresponding to the first text error type, the text correction result output by the text correction model corresponding to the first text error type is obtained; The knowledge data of the nth text error type is used as background knowledge. The text correction result output by the text correction model corresponding to the (n-1)th text error type is input into the text correction model corresponding to the nth text error type, and so on, until it is input into the text correction model corresponding to the Nth text error type to obtain the final text correction result; where n≤N, and n is a positive integer.
3. The text correction method as described in claim 1, characterized in that, The step of using N text correction models to correct the text to be corrected includes: Acquire knowledge data for each type of text error; For each type of text error, the knowledge data of the text error type is used as background knowledge, and the text to be corrected is input into the text correction model corresponding to the text error type to obtain the text correction result output by the text correction model corresponding to the text error type. The N text correction results are merged to obtain the final text correction result.
4. The text correction method as described in claim 1, characterized in that, The method involves constructing a training set for each of the N text error types, including: For each text error type, perform the following steps: Obtain annotation data for the text error type; the annotation data includes at least: first error text data containing the text error type, and text data obtained after correcting the text error type of the first error text data; Record the annotation data into the annotation dataset of the text error type; The training set is constructed based on the labeled dataset.
5. The text correction method as described in claim 4, characterized in that, After storing the annotation data into the annotation dataset of the text error type, the text correction method further includes: Obtain knowledge data on the text error type; Based on the labeled data and the knowledge data, prompt words are constructed; The preset text data and the prompt word are input into the second language model to obtain the second error text data output by the second language model; the preset text data does not contain the text error type, while the second error text data does contain the text error type. The preset text data and the second erroneous text data are recorded in the labeled dataset.
6. The text correction method as described in claim 5, characterized in that, The step of constructing prompt words based on the labeled data and the knowledge data includes: The knowledge data is used as the background knowledge for the prompt words, and the labeled data is used as examples for the prompt words to construct the prompt words.
7. A text correction device, characterized in that, include: The training set construction module is used to construct a training set for each of the N text error types; where N is a positive integer. The model training module is used to train the first language model using N training sets respectively, so as to obtain the text error correction model corresponding to each type of text error. The error correction module is used to correct the text to be corrected using N text error correction models.
8. A text correction device, characterized in that, The system includes a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor, when executing the computer program, implements the text correction method as described in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored computer program; wherein, when the computer program is executed, it controls the device on which the computer-readable storage medium is located to perform the text correction method as described in any one of claims 1 to 6.
10. A computer program product, characterized in that, It includes a computer program / instruction that, when executed by a processor, implements the text correction method as described in any one of claims 1 to 6.