A text error correction method and device

The pinyin feature information is set through text feature information and error probability, and the error correction model is used to correct the ASR results, which solves the problem of wrong words in the speech recognition results and improves the accuracy and accuracy of error correction.

CN114154485BActive Publication Date: 2025-06-24BEIJING SOGOU TECHNOLOGY DEVELOPMENT CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202111305897.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-05
Publication Date
2025-06-24
Estimated Expiration
2041-11-05

AI Technical Summary

Technical Problem

In ASR technology, the speech recognition results are caused by user accents, environmental noise, etc., resulting in the generated text containing incorrect words, affecting the user experience and the application of downstream tasks.

Method used

A text error correction method is proposed. By obtaining the text to be corrected, the text feature information and error probability of the words are determined, the pinyin feature information is set, and the error correction method is corrected based on the error correction model.

Benefits of technology

The accuracy of the error correction model is improved, and the recall set is limited by combining text feature information and pinyin feature information, which enhances the accuracy of error correction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114154485B_ABST
    Figure CN114154485B_ABST
Patent Text Reader

Abstract

An embodiment of the present application provides a text error correction method and apparatus. The method includes: obtaining the text to be error-corrected; determining the text feature information of each word in the text to be error-corrected; determining the error probability of each word; setting the pinyin feature information for the word according to the error probability of the word; and correcting the incorrect words in the text to be error-corrected based on the error correction model according to the text feature information of the word and the pinyin feature information of the word, so as to limit the recall set of the incorrect words by the error correction model, thereby improving the accuracy of the error correction model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of natural language processing technologies, and particularly to a text error correction method and a text error correction device. Background Art

[0002] ASR (Automatic Speech Recognition) refers to the technology of recognizing speech as text. Due to problems such as the user's accent, environmental noise, and the recognition rate itself in the directly translated text of speech, the generated text may contain incorrect characters, making the sentence difficult to understand, resulting in a poor user experience and making it difficult to normally apply the speech recognition result to downstream tasks.

[0003] Therefore, it is necessary to use an automatic error correction technology to automatically correct the speech recognition result by machine, automatically correcting incorrect words or characters to make the sentence in the speech recognition easier to read. Summary of the Invention

[0004] In view of the above problems, embodiments of this application are proposed to provide a text error correction method and a corresponding text error correction device that overcome the above problems or at least partially solve the above problems.

[0005] To solve the above problems, embodiments of this application disclose a text error correction method, including:

[0006] Obtain the text to be error-corrected;

[0007] Determine the text feature information of each word in the text to be error-corrected;

[0008] Determine the error probability of each word;

[0009] Set the pinyin feature information for the word according to the error probability of the word;

[0010] Based on an error correction model, correct the incorrect words in the text to be error-corrected according to the text feature information of the word and the pinyin feature information of the word.

[0011] Optionally, the setting the pinyin feature information for the word according to the error probability of the word includes:

[0012] Determine the pinyin feature vector corresponding to each word, and generate a corresponding pinyin mask vector for each word;

[0013] Multiply the pinyin feature vector corresponding to the word by the error probability P, multiply the pinyin mask vector by (1 - P), and add them to obtain the target pinyin vector of the word, where the value range of P is 0 - 100%.

[0014] Optionally, determining the text feature information of each word in the text to be corrected includes:

[0015] Determining the text feature vectors of each word in the text to be corrected, and generating corresponding text mask vectors for each word;

[0016] Multiplying the text feature vector of the word by (1 - P), multiplying the text mask vector by P, and adding them to obtain the target text vector of the word.

[0017] Optionally, the correcting the incorrect words in the text to be corrected based on the corresponding pinyin according to the text feature information of the words and the pinyin feature information of the words by the correction model includes:

[0018] Correcting the incorrect words in the text to be corrected based on the corresponding pinyin according to the target text vectors and target pinyin vectors of each word by the correction model.

[0019] Optionally, determining the error probability of each word includes:

[0020] Determining the error probability of each word based on the text feature vectors of each word by the error detection model.

[0021] Optionally, the error detection model and the correction model are trained in the following manner:

[0022] Obtaining a correction corpus training text; the correction corpus training text includes an incorrect text and a corrected text;

[0023] Determining the text feature vector corresponding to the incorrect text and the error detection labels corresponding to each character of the incorrect text;

[0024] Using the text feature vector corresponding to the incorrect text and the error detection labels corresponding to each character of the incorrect text as the input of the error detection model, and using the probability that each character of the incorrect text is in error as the output;

[0025] Determining the text feature vector of the incorrect text, the correction labels corresponding to each character of the corrected text, and the target pinyin vector corresponding to the incorrect text;

[0026] Using the text feature vector of the incorrect text, the correction labels corresponding to each character of the corrected text, the probability that each character of the incorrect text is in error, and the target pinyin vector corresponding to the incorrect text as the input, and using the probability of the correction word corresponding to each character of the incorrect text as the output;

[0027] Jointly train the error detection model and the error correction model according to the loss function of the error detection model and the loss function of the error correction model.

[0028] An embodiment of the present application also discloses a text error correction device, including:

[0029] A text acquisition module, configured to acquire the text to be error-corrected;

[0030] A text feature determination module, configured to determine the text feature information of each word in the text to be error-corrected;

[0031] A probability determination module, configured to determine the error probability of each word;

[0032] A pinyin feature setting module, configured to set pinyin feature information for the word according to the error probability of the word;

[0033] An error correction module, configured to correct the wrong words in the text to be error-corrected based on the corresponding pinyin according to the text feature information of the word and the pinyin feature information of the word based on an error correction model.

[0034] Optionally, the pinyin feature setting module includes:

[0035] A first pinyin vector determination sub-module, configured to determine the pinyin feature vector corresponding to each word, and generate a corresponding pinyin mask vector for each word;

[0036] A second pinyin vector determination sub-module, configured to multiply the pinyin feature vector corresponding to the word by the error probability P, multiply the pinyin mask vector by (1 - P), and add them to obtain the target pinyin vector of the word, where the value range of P is 0 - 100%.

[0037] Optionally, the text feature determination module includes:

[0038] A first text vector determination sub-module, configured to determine the text feature vector of each word in the text to be error-corrected, and generate a corresponding text mask vector for each word;

[0039] A second text vector determination sub-module, configured to multiply the text feature vector of the word by (1 - P), multiply the text mask vector by P, and add them to obtain the target text vector of the word.

[0040] Optionally, the error correction module includes:

[0041] A model error correction sub-module, configured to correct the wrong words in the text to be error-corrected based on the corresponding pinyin according to the target text vector and the target pinyin vector of each word based on an error correction model.

[0042] Optionally, the probability determination module includes:

[0043] An error probability determination sub-module, configured to determine the error probability of each word based on an error detection model according to the text feature vectors of the respective words.

[0044] Optionally, the error detection model and the error correction model are obtained by training through the following modules:

[0045] A training text acquisition module, configured to acquire an error correction corpus training text; the error correction corpus training text includes an error text and a corrected text;

[0046] A label determination module, configured to determine the text feature vector corresponding to the error text and the error detection labels corresponding to each character of the error text;

[0047] A first model setting module, configured to use the text feature vector corresponding to the error text and the error detection labels corresponding to each character of the error text as the input of the error detection model, and use the probability of each character of the error text making an error as the output;

[0048] A parameter determination module, configured to determine the text feature vector of the error text, the error correction labels corresponding to each character of the corrected text, and the target pinyin vector corresponding to the error text;

[0049] A second model setting module, configured to use the text feature vector of the error text, the error correction labels corresponding to each character of the corrected text, the probability of each character of the error text making an error, and the target pinyin vector corresponding to the error text as the input, and use the probability of the corrected word corresponding to each character of the error text as the output;

[0050] A training module, configured to jointly train the error detection model and the error correction model according to the loss function of the error detection model and the loss function of the error correction model.

[0051] An embodiment of the present application also discloses an electronic device, including:

[0052] One or more processors; and

[0053] One or more machine-readable media having instructions stored thereon, which when executed by the one or more processors, cause the device to execute the text error correction method as described above.

[0054] An embodiment of the present application also discloses one or more machine-readable media having instructions stored thereon, which when executed by one or more processors, cause the processors to execute the text error correction method as described above.

[0055] The embodiments of the present application also disclose a computer program product, which includes a computer program or computer instructions. When the computer program or the computer instructions are executed by a processor, the method for text error correction described above is implemented.

[0056] The embodiments of the present application have the following advantages:

[0057] In the embodiments of the present application, according to the text feature information and error probability of each word in the text to be corrected, pinyin feature information can be set for the word. Based on the error correction model, according to the text feature information and pinyin feature information of the word, the wrong word in the text to be corrected can be corrected based on the corresponding pinyin. Since, based on the text feature information, pinyin feature information is selectively set for the word according to the error probability of the word, the accuracy of the error correction model can be improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0058] Figure 1 is a flowchart of the steps of a method for text error correction according to an embodiment of the present application;

[0059] Figure 2 is a flowchart of the steps of another method for text error correction according to an embodiment of the present application

[0060] Figure 3 is a schematic diagram of an ASR error correction system according to an embodiment of the present application;

[0061] Figure 4 is a flowchart of the steps of a training method for an error detection model and an error correction model according to an embodiment of the present application;

[0062] Figure 5 is a structural block diagram of a text error correction device according to an embodiment of the present application;

[0063] Figure 6 is a structural block diagram of an alternative embodiment of a text error correction device of the present application;

[0064] Figure 7 is a structural block diagram of an electronic device for display according to an exemplary embodiment;

[0065] Figure 8 is a schematic structural diagram of an electronic device for display according to another exemplary embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0066] To make the above objects, features, and advantages of the present application more obvious and understandable, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0067] ASR automatic error correction can be optimized specifically according to three types of possible errors in ASR recognition: substitution errors, insertion errors, and deletion errors. For substitution errors, for example, the ASR recognition result is: "I feel my ears hurt after wearing headphones for a long time", and the correct result is "I feel my ears ache after wearing headphones for a long time"; for insertion errors, for example, the ASR recognition result is: "The radical of the character 'zhai'", and the correct result is "The radical of the character 'zhai'"; for deletion errors, for example, the ASR recognition result is: "You don't have class this afternoon", and the correct result: "{Today, tomorrow, the day after tomorrow...} You don't have class this afternoon", here a character was missed before the word "day". The recognition results after ASR automatic error correction are more understandable to users and provide a better user experience.

[0068] The existing ASR error correction system can be the Softmasked-Macbert model based on character unit modeling. The error detection and error correction models of this model are within the same framework and combine the advantages of pre-trained language models. Existing Chinese pre-trained language models (Teacher models) such as Bert, GPT, ELECTRA and other Chinese models are all trained under the character-based modeling unit. The pre-trained language model uses a large model structure and a large amount of unsupervised training data in the pre-training stage to obtain a powerful basic model, and then achieves excellent results far beyond the existing models after being fine-tuned with ASR Chinese punctuation data. Using a pre-trained language model can provide more background information in the ASR automatic error correction task with a small amount of real data, and effectively improve the recall rate of the model. However, in the case of a high recall rate, the ASR error correction system cannot guarantee the accuracy.

[0069] In response to this, the embodiments of the present application provide a text error correction method, which can set pinyin feature information for words according to the probability of word errors, and correct the words with errors by combining text feature information and pinyin feature information, and limit the recall set, thereby improving the accuracy of error correction.

[0070] Referring to Figure 1 , a step flowchart of a text error correction method according to an embodiment of the present application is shown, which may specifically include the following steps:

[0071] Step 101, obtain the text to be error-corrected.

[0072] The text to be error-corrected can be the text obtained by the ASR recognition system for recognizing the user's speech.

[0073] Step 102, determine the text feature information of each word in the text to be error-corrected.

[0074] Since the model cannot directly process text, it is necessary to convert the text into feature information that is easy to calculate so that it can be input into the model for processing. The feature information may include text feature information, and the text feature information may be information that characterizes word features from the text dimension.

[0075] Step 103, determine the error probability of each of the words.

[0076] The probability P of a word error refers to the probability that each word makes an error during ASR recognition. Exemplarily, the error probability of each word in the text to be corrected can be determined by an error detection model.

[0077] Step 104, set pinyin feature information for the word according to the error probability of the word.

[0078] The pinyin feature information may be information that characterizes word features from the pinyin dimension. When setting the pinyin feature information for a word, the corresponding pinyin of the word can be determined, and the pinyin feature information can be set based on the corresponding pinyin of the word.

[0079] Exemplarily, according to the error probability of the word, the words that make errors can be determined, pinyin feature information can be set for the words that make errors, and pinyin feature information can be set for the words that do not make errors, so as to selectively set pinyin feature information for the words. For example, the error probability P can be a value in the range of [0 - 100%]. If the error probability P of a word is greater than or equal to 50%, it can be considered that the word makes an error, and pinyin feature information is set for the word; if the error probability P of a word is less than 50%, it can be considered that the word is accurate, and pinyin feature information is not set for the word. The above values are only examples, and those skilled in the art can set them according to actual needs.

[0080] Exemplarily, according to the magnitude of the error probability P of the word, pinyin feature information with corresponding amounts of information can be set for the word. The greater the error probability, the greater the amount of information of the pinyin feature information set for the word; the smaller the error probability, the smaller the amount of information of the pinyin feature information set for the word, so as to selectively set pinyin feature information for the word.

[0081] Step 105, based on the error correction model, correct the wrong words in the text to be corrected based on the corresponding pinyin according to the text feature information of the word and the pinyin feature information of the word.

[0082] The text feature information and the pinyin feature information can be input into the error correction model. The error correction model can correct the wrong words in the text to be corrected based on the corresponding pinyin according to the text feature information and the pinyin feature information, and recall the wrong words within the recall set corresponding to the pinyin of the word. Exemplarily, the error correction model can be a pre-trained model, and based on the pre-trained model, the recall rate of the model can be effectively provided.

[0083] In the embodiment of the present application, according to the text feature information and error probability of each word in the text to be corrected, the pinyin feature information can be set for the word. Based on the error correction model, according to the text feature information and pinyin feature information of the word, the incorrect word in the text to be corrected is corrected based on the corresponding pinyin. Since, based on the text feature information, the pinyin feature information is selectively set for the word, the recall set of the incorrect word by the error correction model is limited, thereby improving the accuracy of the error correction model.

[0084] Refer to Figure 2 , which shows a flowchart of the steps of another text error correction method according to the embodiment of the present application, and may specifically include the following steps:

[0085] Step 201, obtain the text to be corrected.

[0086] Step 202, determine the text feature vector of each word in the text to be corrected, and generate a corresponding text mask vector for each word.

[0087] In the embodiment of the present application, the text feature information for a word may include a text feature vector and a text mask vector.

[0088] The text mask vector may be a vector set for eliminating text information. After adding the text feature vector of the word and the text mask vector, some information provided by the text feature vector can be eliminated. Exemplarily, the text mask vector can be randomly generated, and the dimension of the text mask vector needs to be the same as the dimension of the text feature vector.

[0089] Exemplarily, the text feature vector can be represented by an embedding vector. Specifically, a text embedding matrix can be generated based on a preset text dictionary. Each word is recorded in the preset text dictionary in order of position, and each row in the text embedding matrix is a text feature vector corresponding to a word. The embedding vector can represent the index position of the word in the text dictionary, and the corresponding text feature vector can be indexed in the text embedding matrix according to the index position of the word in the preset text dictionary.

[0090] For example, assume that the size of the text dictionary is 6000, that is, the text dictionary includes 6000 words. The text dictionary consists of words and their position orders, such as {"you": 1, "hao": 2,......}. The corresponding size of the text embedding matrix is (6000, 100), indicating 6000 100-dimensional vectors. Assume that the positions of "you" and "hao" in the dictionary are 1 and 2 respectively. Finding the index 1 in the text embedding matrix corresponds to the first row, which is the text feature vector of "you"; finding the index 2 in the text embedding matrix corresponds to the second row, which is the text feature vector of "hao".

[0091] Step 203: Based on the error detection model, determine the error probability P of each word according to the text feature vectors of the words.

[0092] Exemplarily, the error detection model may include an input layer, a BiGRU (Bidirectional Gating Recurrent Unit) neural network layer, and a fully connected classification output layer. The input layer inputs text feature vectors, and the output layer may output an unnormalized label probability value vector. Of course, those skilled in the art may also use error detection models with other structures, and the present application does not limit this.

[0093] Step 204: Multiply the text feature vector of the word by (1 - P), multiply the text mask vector by P, and add them to obtain the target text vector of the word.

[0094] Assume that the text feature vector is V, the text mask vector is Vmask, and the target text vector can be [V * (1 - P) + Vmask * P]. When the error probability P is relatively large, the information provided by the text feature vector can be reduced; the information provided by the text mask vector can be increased, so as to further weaken the information provided by the text feature vector. When the error probability P is relatively small, the information provided by the text feature vector can be retained as much as possible; the information provided by the text mask vector can be reduced, so as to further retain the information provided by the text feature vector.

[0095] Step 205: Determine the pinyin feature vectors corresponding to the words, and generate corresponding pinyin mask vectors for the words.

[0096] In the embodiments of the present application, the pinyin feature information for words may include pinyin feature vectors and pinyin mask vectors.

[0097] The pinyin mask vector can be a vector set to eliminate pinyin information. After adding the pinyin feature vector of the word to the pinyin mask vector, some information provided by the pinyin feature vector can be eliminated. Exemplarily, the pinyin mask vector can be randomly generated, and the dimension of the pinyin mask vector needs to be the same as the dimension of the pinyin feature vector.

[0098] Exemplarily, the pinyin feature vector can be represented by an embedding vector. Specifically, a pinyin embedding matrix can be generated based on a preset pinyin dictionary. The preset pinyin dictionary records the pinyin of each word in order of position. Each row in the pinyin embedding matrix is ​​a pinyin feature vector corresponding to a pinyin. The embedding vector can represent the index position of the pinyin in the pinyin dictionary. According to the index position of the pinyin in the preset pinyin dictionary, the corresponding pinyin feature vector can be indexed in the pinyin embedding matrix.

[0099] For example, the pinyin dictionary = {"I":"wo", "I":"shi", "China":"zhong", "country":"guo", "people":"ren",...}, a pinyin embedding matrix can be generated based on the pinyin dictionary, in which the pinyin "wo" of "I" can be determined and converted into a corresponding 100-dimensional pinyin feature vector through indexing.

[0100] Step 206, multiply the pinyin feature vector corresponding to the word by P, multiply the pinyin mask vector by (1-P), and add them together to obtain the target pinyin vector of the word.

[0101] Assuming that the pinyin feature vector is Q, the pinyin mask vector is Qmask, the target pinyin vector can be [Q*P+Vmask*(1-P)]. When the error probability P is large, the information provided by the pinyin feature vector can be increased; the information provided by the pinyin mask vector can be reduced, thereby further retaining the information provided by the pinyin feature vector. When the error probability P is small, the information provided by the pinyin feature vector can be reduced; the information provided by the pinyin mask vector can be increased, thereby further weakening the information provided by the pinyin feature vector.

[0102] Step 207, based on the error correction model and the target text vector and the target pinyin vector of each word, correct the erroneous words in the text to be corrected based on the corresponding pinyin.

[0103] The target text vector and target pinyin vector of each word can be input into the error correction model. The error correction model can correct the erroneous words in the correction text based on the corresponding pinyin according to the target text vector and target pinyin vector of the word, and recall the erroneous words in the recall set corresponding to the pinyin of the word.

[0104] Exemplarily, the error correction model may include an input layer, multiple self-attention layers, a feed-forward neural network (FNN) layer, and a fully-connected classification output layer. Of course, those skilled in the art may also use error detection models with other structures, and the present application does not limit this.

[0105] Exemplarily, the error correction model may be initialized using a pre-trained language model. For example, the pre-trained language model may be Bert, GPT, ELECTRA, etc.

[0106] In the embodiments of the present application, the text feature vectors of each word in the text to be error-corrected can be determined, and a corresponding text mask vector can be generated for each word. Based on the error detection model, the error probability P of each word can be determined according to the text feature vectors of each word; multiply the text feature vector of the word by (1 - P), multiply the text mask vector by P, and add them to obtain the target text vector of the word; determine the corresponding pinyin feature vector of each word, and generate a corresponding pinyin mask vector for each word; multiply the pinyin feature vector corresponding to the word by P, multiply the pinyin mask vector by (1 - P), and add them to obtain the target pinyin vector of the word; based on the error correction model, according to the target text vector and target pinyin vector of each word, correct the wrong words in the text to be error-corrected based on the corresponding pinyin. Since, based on the text feature information, the pinyin feature information of the word is selectively set based on the error probability P of the word, the recall set of the error correction model for the wrong words is limited, thereby improving the accuracy of the error correction model.

[0107] Refer to Figure 3 The following is a schematic diagram of the ASR error correction system in the embodiments of the present application. The ASR error correction system includes an error detection model and an error correction model. Among them, the input layer of the error detection model can be the text feature vectors of each word in the text to be error-corrected, and the output layer can represent the error probabilities of each word in the text to be error-corrected.

[0108] For example, the error text is: "I am a person from Zhongguo", the text feature vector corresponding to "I" is E1, the text feature vector corresponding to "am" is E2, the text feature vector corresponding to "Zhongguo" is E3, and the text feature vector corresponding to "person" is E4. Input the text feature vectors of each word in the error text into the error detection model. The error detection model outputs the error probabilities of each word, the error probability P1 corresponding to "I", the error probability P2 corresponding to "am", the error probability P3 corresponding to "Zhongguo", and the error probability P4 corresponding to "person".

[0109] The input layer of the error correction model may include a text input layer and a pinyin input layer. The text input layer may be composed of a text feature vector and a text mask vector. The text feature vector is multiplied by (1-P), the text mask vector is multiplied by P, and the target text vector is added to obtain the text input layer.

[0110] For example, for the words "I", "Is", "Many countries", and "People", the corresponding text mask vectors M1, M2, M3, and M4 are generated respectively. The text feature vector E1 corresponding to "I" is multiplied by (1-P1), and the corresponding text mask vector M1 is multiplied by P1; the text feature vector E2 corresponding to "Is" is multiplied by (1-P2), and the corresponding text mask vector M2 is multiplied by P2; the text feature vector E3 corresponding to "Many countries" is multiplied by (1-P3), and the corresponding text mask vector M3 is multiplied by P3; the text feature vector E4 corresponding to "People" is multiplied by (1-P4), and the corresponding text mask vector M4 is multiplied by P4, and the target text vector is [(E1*(1-P1)+M1*P1), (E2*(1-P2)+M2*P2), (E3*(1-P3)+M3*P3), (E4*(1-P4)+M4*P4)].

[0111] The pinyin input layer can be composed of a pinyin feature vector and a pinyin mask vector. The pinyin feature vector is multiplied by P, the pinyin mask vector is multiplied by (1-P), and the target pinyin vector is added to obtain the pinyin input layer. The output layer of the error correction model can represent the probabilities of multiple correction words corresponding to each character. According to the probabilities of multiple correction words corresponding to the character, one of the correction words can be determined as the output result corresponding to the character.

[0112] For example, the words "I", "is", "all countries" and "people" are "wo", "shi", "zhongguo" and "ren" respectively, and the corresponding pinyin feature vectors S1, S2, S3 and S4 are generated for the pinyin respectively; the corresponding pinyin mask vectors M′1, M′2, M′3 and M′4 are generated respectively.

[0113] Multiply the pinyin feature vector S1 corresponding to "wo" by (1-P1), and add the corresponding pinyin mask vector M′1 multiplied by P1; multiply the pinyin feature vector S2 corresponding to "shi" by (1-P2), and add the corresponding pinyin mask vector M′2 multiplied by P2; multiply the pinyin feature vector S3 corresponding to "zhongguo" by (1-P3), and add the corresponding pinyin mask vector M′3 multiplied by P3; multiply the pinyin feature vector S4 corresponding to "ren" by (1-P4), and add the corresponding pinyin mask vector M′4 multiplied by P4, and the target pinyin vector is [(S1*(1-P1)+M′1*P1), (S2*(1-P2)+M′2*P2), (S3*(1-P3)+M′3*P3), (S4*(1-P4)+M′4*P4)].

[0114] Exemplarily, a vector of (N, vocab_size) dimensions can be used as the output of the error correction model, where N represents the number of words in the output sentence, and vocab_size can indicate that each word output is a vector of the size of the dictionary, and each position of the vector represents the probability of each word in the dictionary corresponding to the input word. The probability corresponding to "I" is P'1, where P'1 can be a vector of the size of the dictionary, including the probabilities of each word in the dictionary; wherein the probability of the word "I" in the dictionary is the largest, so the word is output. The probability corresponding to "is" is P'2, where P'2 can be a vector of the size of the dictionary, including the probabilities of each word in the dictionary; wherein the probability of the word "is" in the dictionary is the largest, so the word is output. The probability corresponding to "all countries" is P'3, where P'3 can be a vector of the size of the dictionary, including the probabilities of each word in the dictionary; wherein the probability of the word "China" in the dictionary is the largest, so the word is output. The probability corresponding to "人" is P′4, where P′3 can be a vector of dictionary size dimension, including the probability of each word in the dictionary; among them, the word "人" has the largest probability in the dictionary, so this word is output.

[0115] Reference Figure 4 The flowchart of the training method of the error detection model and the error correction model in the embodiment of the present application is shown, which may specifically include the following steps:

[0116] Step 401, obtaining error correction corpus training text; the error correction corpus training text includes error text and correction text.

[0117] The error correction corpus training text may include an error text and a correction text. The error text may be a text with an ASR recognition error, and the correction text may be a text after the error text is corrected.

[0118] For example, the incorrect text is: "I feel my ears hurt after wearing headphones for a long time", and the corresponding corrected text is: "I feel my ears hurt after wearing headphones for a long time".

[0119] Step 402: Determine the text feature vector corresponding to the error text and the error detection labels corresponding to each character of the error text.

[0120] The error detection labels corresponding to each character of the error text can be obtained in the following way: Perform character splitting on the error text, and convert each obtained character into an error detection label. The detection labels can include T and F. T can indicate that the character is correct and does not need to be corrected; F can indicate that the character is incorrect.

[0121] For example, after splitting the error text into characters, we get: "I feel my ears hurt after wearing headphones for a long time", and convert it into the corresponding error detection labels: "T T T T T F T T T T T".

[0122] Step 403: Use the text feature vector corresponding to the error text and the error detection labels corresponding to each character of the error text as the input of the error detection model, and use the probability of each character of the error text being incorrect as the output.

[0123] Use the text feature vector corresponding to the error text and the corresponding error detection labels as the input of the error detection model, and use the probability P of each character of the error text being incorrect as the output.

[0124] Exemplarily, a vector of dimension (N, 1) can be used as the output of the error detection model. N represents the number of characters in the output sentence, and 1 represents that each word outputs a floating point number, whose actual meaning is whether the position of the predicted word is incorrect. For example, if the selected value is greater than 50%, it represents that the position is incorrect; if it is less than 50%, it represents that the position is correct.

[0125] Step 404: Determine the text feature vector of the error text, the error correction labels corresponding to each character of the corrected text, and the target pinyin vector corresponding to the error text.

[0126] The error correction labels corresponding to each character of the corrected text can be obtained in the following way: Perform character splitting on the corrected text, and convert each obtained character into an error correction label, where the error correction label can be the character itself. For example, after splitting the corrected text into characters, we get: "I feel my ears hurt after wearing headphones for a long time", and convert it into the corresponding error correction labels as "I feel my ears hurt after wearing headphones for a long time".

[0127] The target pinyin vector corresponding to the error text can be obtained in the following way: Determine the pinyin feature vectors corresponding to each word of the error text, and generate corresponding pinyin mask vectors for each word of the error text; Multiply the pinyin feature vectors corresponding to each word of the error text by P, multiply the pinyin mask vectors corresponding to each word of the error text by (1 - P), and add them to obtain the target pinyin vectors for each word of the error text.

[0128] Step 405: Use the text feature vector of the error text, the error correction labels corresponding to each character of the corrected text, the probability of each character of the error text being incorrect, and the target pinyin vector corresponding to the error text as inputs, and use the probability of the correction word corresponding to each character of the error text as the output.

[0129] Exemplarily, a vector of dimension (N, vocab_size) can be used as the output of the error correction model. N represents the number of characters in the output sentence, and vocab_size represents that each word outputs a vector of the dictionary size. Each position of the vector represents the probability of the correction word corresponding to the input.

[0130] Step 406: Jointly train the error detection model and the error correction model according to the loss function of the error detection model and the loss function of the error correction model.

[0131] Exemplarily, the loss function detect-loss of the error detection model can be determined based on the probability P of each character being incorrect output by the error detection model and the error detection label. The loss function correct-loss of the error correction model can be determined according to the probability of the correction word corresponding to each character of the error text output by the error correction model and the error correction label. The target loss of the final overall model = detect-loss + correct-loss. The error detection model and the error correction model can be optimized using the target loss to obtain the result of the jointly trained model.

[0132] It should be noted that for the method embodiments, for the sake of simple description, they are all expressed as a series of action combinations. However, those skilled in the art should know that the embodiments of the present application are not limited by the described action sequence, because according to the embodiments of the present application, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required in the embodiments of the present application.

[0133] Referring to Figure 5 , a structural block diagram of a text error correction device according to an embodiment of the present application is shown, which may specifically include the following modules:

[0134] A text acquisition module 501, configured to acquire a text to be error-corrected;

[0135] A text feature determination module 502, configured to determine the text feature information of each word in the text to be error-corrected;

[0136] A probability determination module 503, configured to determine the error probability of each word;

[0137] A pinyin feature setting module 504 is configured to set pinyin feature information for the word according to the error probability of the word;

[0138] An error correction module 505 is configured to correct the wrong words in the text to be error-corrected based on the corresponding pinyin according to the text feature information of the word and the pinyin feature information of the word based on an error correction model.

[0139] Refer to Figure 6 , which shows a structural block diagram of an optional embodiment of a text error correction device of the present application. Among them, the pinyin feature setting module 504 may include:

[0140] A first pinyin vector determination sub-module 5041 is configured to determine the pinyin feature vector corresponding to each word, and generate a corresponding pinyin mask vector for each word;

[0141] A second pinyin vector determination sub-module 5042 is configured to multiply the pinyin feature vector corresponding to the word by the error probability P, multiply the pinyin mask vector by (1 - P), and add them to obtain the target pinyin vector of the word, where the value range of P is 0 - 100%.

[0142] In an optional embodiment of the present application, the text feature determination module 502 may include:

[0143] A first text vector determination sub-module 5021 is configured to determine the text feature vector of each word in the text to be error-corrected, and generate a corresponding text mask vector for each word;

[0144] A second text vector determination sub-module 5022 is configured to multiply the text feature vector of the word by (1 - P), multiply the text mask vector by P, and add them to obtain the target text vector of the word.

[0145] In an optional embodiment of the present application, the error correction module 505 may include:

[0146] A model error correction sub-module 5051 is configured to correct the wrong words in the text to be error-corrected based on the corresponding pinyin according to the target text vector and the target pinyin vector of each word based on an error correction model.

[0147] In an optional embodiment of the present application, the probability determination module 503 may include:

[0148] An error probability determination sub-module 5031 is configured to determine the error probability of each word based on a error detection model according to the text feature vector of each word.

[0149] In an optional embodiment of the present application, the error detection model and the error correction model are trained through the following modules:

[0150] A training text acquisition module 506, configured to acquire an error correction corpus training text; the error correction corpus training text includes an error text and a corrected text;

[0151] A label determination module 507, configured to determine a text feature vector corresponding to the error text and error detection labels corresponding to each character of the error text;

[0152] A first model setting module 508, configured to use the text feature vector corresponding to the error text and the error detection labels corresponding to each character of the error text as inputs of the error detection model, and use the probability of each character of the error text being incorrect as an output;

[0153] A parameter determination module 509, configured to determine the text feature vector of the error text, error correction labels corresponding to each character of the corrected text, and a target pinyin vector corresponding to the error text;

[0154] A second model setting module 510, configured to use the text feature vector of the error text, the error correction labels corresponding to each character of the corrected text, the probability of each character of the error text being incorrect, and the target pinyin vector corresponding to the error text as inputs, and use the probability of the corrected word corresponding to each character of the error text as an output;

[0155] A training module 511, configured to jointly train the error detection model and the error correction model according to the loss function of the error detection model and the loss function of the error correction model.

[0156] For the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple. For related parts, please refer to the corresponding description in the method embodiment.

[0157] Figure 7 FIG. is a block diagram of an electronic device 700 for text error correction shown according to an exemplary embodiment. For example, the electronic device 700 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, a smart wearable device, etc.

[0158] Referring to Figure 7 , the electronic device 700 may include one or more of the following components: a processing component 702, a memory 704, a power component 706, a multimedia component 708, an audio component 710, an input / output (I / O) interface 712, a sensor component 714, and a communication component 716.

[0159] The processing component 702 generally controls the overall operation of the electronic device 700, such as operations associated with display, telephone calls, data communication, camera operations, and recording operations. The processing element 702 may include one or more processors 720 to execute instructions to complete all or part of the steps of the above methods. In addition, the processing component 702 may include one or more modules to facilitate the interaction between the processing component 702 and other components. For example, the processing component 702 may include a multimedia module to facilitate the interaction between the multimedia component 708 and the processing component 702.

[0160] The memory 704 is configured to store various types of data to support the operation of the electronic device 700. Examples of such data include instructions for any application or method operating on the electronic device 700, contact data, phone book data, messages, pictures, videos, and the like. The memory 704 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disks, or optical disks.

[0161] The power component 706 provides power to the various components of the electronic device 700. The power component 706 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the electronic device 700.

[0162] The multimedia component 708 includes a screen that provides an output interface between the electronic device 700 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen can be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensors can not only sense the boundaries of touch or swipe actions but also detect the duration and pressure associated with the touch or swipe operations. In some embodiments, the multimedia component 708 includes a front camera and / or a rear camera. When the electronic device 700 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera can receive external multimedia data. Each of the front camera and the rear camera can be a fixed optical lens system or have a focal length and optical zoom capabilities.

[0163] The audio component 710 is configured to output and / or input audio signals. For example, the audio component 710 includes a microphone (MIC) that is configured to receive external audio signals when the electronic device 700 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signal can be further stored in the memory 704 or transmitted via the communication component 716. In some embodiments, the audio component 710 further includes a speaker for outputting audio signals.

[0164] The I / O interface 712 provides an interface between the processing component 702 and peripheral interface modules, and the peripheral interface modules may be a keyboard, a click wheel, buttons, etc. These buttons may include, but are not limited to: a home button, a volume button, a power button, and a lock button.

[0165] The sensor component 714 includes one or more sensors for providing an assessment of various aspects of the state of the electronic device 700. For example, the sensor component 714 can detect the on / off state of the electronic device 700, the relative positioning of components, such as the display and keypad of the electronic device 700. The sensor component 714 can also detect a change in the position of the electronic device 700 or a component of the electronic device 700, the presence or absence of user contact with the electronic device 700, the orientation or acceleration / deceleration of the electronic device 700, and a change in the temperature of the electronic device 700. The sensor component 714 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor component 714 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor component 714 may further include an acceleration sensor, a gyro sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.

[0166] The communication component 716 is configured to facilitate communication between the electronic device 700 and other devices in a wired or wireless manner. The electronic device 700 can access a wireless network based on communication standards, such as WiFi, 2G, or 3G, or a combination thereof. In an exemplary embodiment, the communication component 714 receives broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 714 further includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.

[0167] In an exemplary embodiment, the electronic device 700 may be implemented by one or more application specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors or other electronic components for performing the above method.

[0168] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 704 including instructions, and the above instructions can be executed by a processor 720 of the electronic device 700 to complete the above method. For example, the non-transitory computer-readable storage medium may be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

[0169] A non-transitory computer-readable storage medium, when the instructions in the storage medium are executed by a processor of an electronic device, enables the electronic device to execute a text error correction method, and the method includes:

[0170] Obtain the text to be error-corrected;

[0171] Determine the text feature information of each word in the text to be error-corrected;

[0172] Determine the error probability of each word;

[0173] Set the pinyin feature information for the word according to the error probability of the word;

[0174] Based on an error correction model, correct the wrong words in the text to be error-corrected according to the text feature information of the word and the pinyin feature information of the word.

[0175] Optionally, the setting the pinyin feature information for the word according to the error probability of the word includes:

[0176] Determine the pinyin feature vector corresponding to each word, and generate a corresponding pinyin mask vector for each word;

[0177] Multiply the pinyin feature vector corresponding to the word by the error probability P, multiply the pinyin mask vector by (1 - P), and add them to obtain the target pinyin vector of the word, where the value range of P is 0 - 100%.

[0178] Optionally, the determining the text feature information of each word in the text to be error-corrected includes:

[0179] Determine the text feature vector of each word in the text to be error-corrected, and generate a corresponding text mask vector for each word;

[0180] Multiply the text feature vector of the word by (1 - P), multiply the text mask vector by P, and add them to obtain the target text vector of the word.

[0181] Optionally, the error correction model corrects the incorrect words in the text to be error-corrected based on the corresponding pinyin according to the text feature information of the words and the pinyin feature information of the words, including:

[0182] Based on the error correction model, correct the incorrect words in the text to be error-corrected based on the corresponding pinyin according to the target text vectors and target pinyin vectors of the respective words.

[0183] Optionally, determining the error probability P of the respective words includes:

[0184] Based on the error detection model, determine the error probability P of the respective words according to the text feature vectors of the respective words.

[0185] Optionally, the error detection model and the error correction model are trained in the following manner:

[0186] Obtain an error correction corpus training text; the error correction corpus training text includes an error text and a corrected text;

[0187] Determine the text feature vector corresponding to the error text and the error detection labels corresponding to each character of the error text;

[0188] Use the text feature vector corresponding to the error text and the error detection labels corresponding to each character of the error text as the input of the error detection model, and use the probability of each character of the error text being incorrect as the output;

[0189] Determine the text feature vector of the error text, the error correction labels corresponding to each character of the corrected text, and the target pinyin vector corresponding to the error text;

[0190] Use the text feature vector of the error text, the error correction labels corresponding to each character of the corrected text, the probability of each character of the error text being incorrect, and the target pinyin vector corresponding to the error text as the input, and use the probability of the corrected word corresponding to each character of the error text as the output;

[0191] According to the loss function of the error detection model and the loss function of the error correction model, jointly train the error detection model and the error correction model.

[0192] Figure 8FIG. 0 is a schematic structural diagram of an electronic device 800 for text error correction according to another exemplary embodiment of the present application. The electronic device 800 may be a server, which may vary greatly due to configuration or performance, and may include one or more central processing units (CPUs) 822 (for example, one or more processors) and a memory 832, and one or more storage media 830 (for example, one or more mass storage devices) storing application programs 842 or data 844. Among them, the memory 832 and the storage media 830 may be transient storage or persistent storage. The program stored in the storage media 830 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations on the server. Further, the central processor 822 may be configured to communicate with the storage media 830 and execute a series of instruction operations in the storage media 830 on the server.

[0193] The server may further include one or more power supplies 826, one or more wired or wireless network interfaces 850, one or more input / output interfaces 858, one or more keyboards 856, and / or one or more operating systems 841, such as Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.

[0194] In an exemplary embodiment, the server is configured to execute one or more programs by one or more central processors 822, including instructions for performing the following operations:

[0195] Obtain the text to be corrected;

[0196] Determine the text feature information of each word in the text to be corrected;

[0197] Determine the error probability of each word;

[0198] Set the pinyin feature information for the word according to the error probability of the word;

[0199] Based on the error correction model, correct the incorrect words in the text to be corrected according to the text feature information of the word and the pinyin feature information of the word.

[0200] Optionally, setting the pinyin feature information for the word according to the error probability of the word includes:

[0201] Determine the pinyin feature vector corresponding to each word, and generate a corresponding pinyin mask vector for each word;

[0202] Multiply the pinyin feature vector corresponding to the word by the error probability P, multiply the pinyin mask vector by (1 - P), and add them to obtain the target pinyin vector of the word, where the value range of P is 0 - 100%.

[0203] Optionally, determining the text feature information of each word in the text to be corrected includes:

[0204] Determine the text feature vector of each word in the text to be corrected, and generate a corresponding text mask vector for each word;

[0205] Multiply the text feature vector of the word by (1 - P), multiply the text mask vector by P, and add them to obtain the target text vector of the word.

[0206] Optionally, based on the error correction model, according to the text feature information of the word and the pinyin feature information of the word, correcting the wrong word in the text to be corrected based on the corresponding pinyin includes:

[0207] Based on the error correction model, according to the target text vector and target pinyin vector of each word, correct the wrong word in the text to be corrected based on the corresponding pinyin.

[0208] Optionally, determining the error probability P of each word includes:

[0209] Based on the error detection model, according to the text feature vector of each word, determine the error probability P of each word.

[0210] Optionally, the error detection model and the error correction model are trained in the following manner:

[0211] Obtain an error correction corpus training text; the error correction corpus training text includes an error text and a corrected text;

[0212] Determine the text feature vector corresponding to the error text and the error detection label corresponding to each character of the error text;

[0213] Use the text feature vector corresponding to the error text and the error detection label corresponding to each character of the error text as the input of the error detection model, and use the probability of each character of the error text making a mistake as the output;

[0214] Determine the text feature vector of the error text, the error correction label corresponding to each character of the corrected text, and the target pinyin vector corresponding to the error text;

[0215] Taking the text feature vector of the error text, the error correction labels corresponding to each character of the corrected text, the probability of each character of the error text being incorrect, and the target pinyin vector corresponding to the error text as inputs, and taking the probability of the correction word corresponding to each character of the error text as an output;

[0216] Jointly training the error detection model and the error correction model according to the loss function of the error detection model and the loss function of the error correction model.

[0217] Each embodiment in this specification is described in a progressive manner. Each embodiment focuses on the differences from other embodiments. For the same or similar parts among the embodiments, reference can be made to each other.

[0218] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a device, or a computer program product. Therefore, the embodiments of the present application can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the embodiments of the present application can take the form of a computer program product implemented on one or more machine-readable media (including but not limited to disk memory, CD-ROM, optical memory, etc.) containing computer-usable program code.

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

[0220] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing terminal device to work in a specific manner, so that the instructions stored in the computer-readable memory generate a manufactured product including an instruction device, and the instruction device implements in the process Figure 1 one process or multiple processes and / or blocks Figure 1 a device for the functions specified in one block or multiple blocks.

[0221] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device, so that a series of operation steps are executed on the computer or other programmable terminal device to generate a computer-implemented process, and thus the instructions executed on the computer or other programmable terminal device provide for implementing the process Figure 1 in one process or multiple processes and / or blocks Figure 1 steps for the functions specified in one block or multiple blocks.

[0222] Although the preferred embodiments of the embodiments of the present application have been described, those skilled in the art can make additional changes and modifications once they learn the basic creative concepts. Therefore, the appended claims are intended to be construed to include the preferred embodiments and all changes and modifications falling within the scope of the embodiments of the present application.

[0223] Finally, it should also be noted that in this text, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or terminal device comprising a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article or terminal device. Without further limitation, an element defined by the statement "comprising an..." does not exclude the presence of additional identical elements in the process, method, article or terminal device comprising the element.

[0224] The above has introduced in detail a text error correction method and a text error correction device provided by the present application. Specific examples are used in this text to elaborate on the principle and implementation manner of the present application. The description of the above embodiments is only used to help understand the method and its core idea of the present application; at the same time, for those of ordinary skill in the art, according to the idea of the present application, there will be changes in the specific implementation manner and application scope. In summary, the content of this specification should not be construed as a limitation to the present application.

Claims

1. A text error correction method, characterized in that, including: obtaining the text to be corrected; determining text feature vectors of each word in the text to be corrected, and generating corresponding text mask vectors for each word; determining the error probability P of each word; multiplying the text feature vector of the word by (1 - P), multiplying the text mask vector by P, and adding them to obtain the target text vector of the word; when the error probability is less than a predetermined probability threshold, correcting the incorrect words in the text to be corrected based on an error correction model according to the target text vector of the word; when the error probability is greater than or equal to the predetermined probability threshold, perform: determining the pinyin feature vectors corresponding to each word, and generating corresponding pinyin mask vectors for each word, the pinyin feature vectors are indexed from a pinyin embedding matrix in a preset pinyin dictionary according to the index positions of the pinyins corresponding to each word in the preset pinyin dictionary, each row in the pinyin embedding matrix is a pinyin feature vector corresponding to a pinyin, the information provided by the pinyin feature vector increases as the error probability of the word increases, and the information provided by the pinyin mask vector decreases as the error probability of the word increases; multiplying the pinyin feature vector corresponding to the word by P, multiplying the pinyin mask vector by (1 - P), and adding them to obtain the target pinyin vector of the word; correcting the incorrect words in the text to be corrected based on an error correction model according to the target text vector and the target pinyin vector of the word; 2. The method according to claim 1, wherein The determining the error probability of each word includes: determining the error probability of each word based on an error detection model according to the text feature vectors of each word; 3. The method according to claim 2, wherein The error detection model and the error correction model are trained as follows: obtaining an error correction corpus training text; the error correction corpus training text includes an incorrect text and a corrected text; determining the text feature vector corresponding to the incorrect text and the error detection labels corresponding to each character of the incorrect text; using the text feature vector corresponding to the incorrect text and the error detection labels corresponding to each character of the incorrect text as the input of the error detection model, and using the probability of each character of the incorrect text making an error as the output; determining the text feature vector of the incorrect text, the error correction labels corresponding to each character of the corrected text, and the target pinyin vector corresponding to the incorrect text; using the text feature vector of the incorrect text, the error correction labels corresponding to each character of the corrected text, the probability of each character of the incorrect text making an error, and the target pinyin vector corresponding to the incorrect text as the input, and using the probability of the corrected word corresponding to each character of the incorrect text as the output; jointly training the error detection model and the error correction model according to the loss function of the error detection model and the loss function of the error correction model; 4. A text error correction device, characterized in that, including: a text acquisition module for obtaining the text to be corrected; a feature and mask vector determination module for determining text feature vectors of each word in the text to be corrected, and generating corresponding text mask vectors for each word; A probability determination module for determining the error probability P of each of the words; A target text vector acquisition module for multiplying the text feature vector of the word by (1 - P), multiplying the text mask vector by P, and adding them to obtain the target text vector of the word; A first error correction module for, when the error probability is less than a predetermined probability threshold, correcting the incorrect words in the text to be error-corrected based on an error correction model according to the target text vector of the word; A second error correction module for, when the error probability is greater than or equal to the predetermined probability threshold, performing: determining the corresponding pinyin feature vectors of each of the words, and generating corresponding pinyin mask vectors for each of the words, where the pinyin feature vectors are indexed from a pinyin embedding matrix in a preset pinyin dictionary according to the index positions of the pinyins corresponding to each of the words in the preset pinyin dictionary, each row in the pinyin embedding matrix being a pinyin feature vector corresponding to a pinyin, the information provided by the pinyin feature vectors increasing as the error probability of the word increases, and the information provided by the pinyin mask vectors decreasing as the error probability of the word increases; multiplying the pinyin feature vector corresponding to the word by P, multiplying the pinyin mask vector by (1 - P), and adding them to obtain the target pinyin vector of the word; Based on the error correction model, correcting the incorrect words in the text to be error-corrected according to the target text vector and the target pinyin vector of the word.

5. The device according to claim 4, characterized in that, The probability determination module includes: An error probability determination sub-module for determining the error probability of each of the words based on a error detection model according to the text feature vectors of each of the words.

6. The device according to claim 5, characterized in that The error detection model and the error correction model are trained through the following modules: A training text acquisition module for acquiring an error correction corpus training text; the error correction corpus training text includes an incorrect text and a corrected text; A label determination module for determining the text feature vector corresponding to the incorrect text and the error detection labels corresponding to each character of the incorrect text; A first model setting module for using the text feature vector corresponding to the incorrect text and the error detection labels corresponding to each character of the incorrect text as the input of the error detection model, and using the probability of each character of the incorrect text being incorrect as the output; A parameter determination module for determining the text feature vector of the incorrect text, the error correction labels corresponding to each character of the corrected text, and the target pinyin vector corresponding to the incorrect text; A second model setting module for using the text feature vector of the incorrect text, the error correction labels corresponding to each character of the corrected text, the probability of each character of the incorrect text being incorrect, and the target pinyin vector corresponding to the incorrect text as the input, and using the probability of the corrected word corresponding to each character of the incorrect text as the output; A training module for jointly training the error detection model and the error correction model according to the loss function of the error detection model and the loss function of the error correction model.

7. An electronic device, characterized in that, Includes: One or more processors; And One or more machine-readable media storing instructions which, when executed by the one or more processors, cause the processors to perform the text error correction method according to any one of claims 1-3.

8. One or more machine-readable media storing instructions which, when executed by one or more processors, cause the processors to perform the method for text error correction according to any one of claims 1-3.

9. A computer program product, characterized in that, The computer program product includes a computer program or computer instructions which, when executed by a processor, implement the method for text error correction according to any one of claims 1-3.

Citation Information

Patent Citations

  • Text error correction method and system, computer equipment and readable storage medium

    CN112287670A