Text error correction method, device, terminal equipment and computer storage medium
By introducing the error correction label of the error correction decision model into the encoder-decoder model, the decoding process is regulated, which solves the problem of uncontrollable decoding process and frequent misjudgments of the encoder-decoder model, and improves the accuracy of text error correction. and efficiency.
Patent Information
- Application Number
- CN202010110410.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-02-21
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2040-02-21
AI Technical Summary
The decoding process in the encoder-decoder model is uncontrollable and can easily lead to misjudgments, causing some correct words to be misjudged as wrong words for error correction, or some wrong words to be misjudged as correct words for no correction.
Before decoding by the decoder, the error correction decision model is used to classify the input word vectors to obtain error correction labels, and the labels are input into the decoder to regulate the decoding process, reduce misjudgments, and improve error correction accuracy.
Through the introduction of error correction tags, the decoder can perform targeted error correction, significantly improve the accuracy of text error correction, reduce decoding calculation complexity, and reduce system performance loss.
Smart Images

Figure CN113297833B_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of artificial intelligence technology, and in particular, relates to a text error correction method, apparatus, terminal equipment and computer storage medium. Background Art
[0002] In the current field of text processing, encoder-decoder models are often used to implement text processing functions such as text error correction, text translation, document extraction, and question-answering systems.
[0003] In the encoder-decoder model, an encoder and a decoder are provided. When performing text error correction, the user can input the text to be corrected into the encoder of the encoder-decoder model, and the encoder converts the text input by the user into a semantic vector, and then the encoder transmits the semantic vector to the decoder of the encoder-decoder model, and the decoder decodes the semantic vector to obtain the corrected text and output it to the user.
[0004] However, in the current encoder-decoder model, the decoding process of the model is uncontrollable and prone to misjudgment. Some correct words may be misjudged as incorrect words and corrected, or some incorrect words may be misjudged as correct words and not corrected. Summary of the invention
[0005] The embodiments of the present application provide a text error correction method, apparatus, terminal device and computer storage medium, which can solve the problem that the decoding process of the current encoder-decoder model is uncontrollable and prone to misjudgment.
[0006] A first aspect of an embodiment of the present application provides a text error correction method, comprising:
[0007] The terminal device performs word vector conversion on the input text to obtain a word vector sequence corresponding to the input text, wherein the word vector sequence includes input word vectors corresponding to each word in the input text;
[0008] The terminal device inputs the word vector sequence into an encoder of an encoder-decoder model to obtain a semantic vector;
[0009] The terminal device inputs the word vector sequence into the error correction judgment model to obtain an error correction label corresponding to each input word vector;
[0010] The terminal device inputs the word vector sequence, the semantic vector, and the error correction labels corresponding to each input word vector into the decoder of the encoder-decoder model to obtain the error-corrected text.
[0011] It should be noted that before the decoder decodes, the terminal device first inputs the word vector sequence into the error correction judgment model for error correction judgment to obtain the error correction label corresponding to each word in the input text. The error correction label is used to indicate whether each word in the input text needs to be corrected.
[0012] During the decoding process, the decoder can perform targeted decoding based on the error correction labels of each word in the input text and regulate the decoding process, thereby reducing the decoder's misjudgment and improving the accuracy of text error correction.
[0013] In a possible implementation manner of the first aspect, the terminal device inputs the word vector sequence, the semantic vector, and the error correction label corresponding to each input word vector into a decoder of the encoder-decoder model, and obtaining the error-corrected text includes:
[0014] The terminal device sequentially inputs the input word vectors in the word vector sequence into the decoder of the encoder-decoder model;
[0015] After each time the input word vector is input into the decoder, the terminal device calculates the attention vector corresponding to the input word vector and the second hidden layer vector corresponding to the next input word vector according to the input word vector and the second hidden layer vector corresponding to the input word vector, wherein the second hidden layer vector is the hidden layer vector of the decoder, and the semantic vector is the second hidden layer vector corresponding to the first input word vector;
[0016] If the error correction label corresponding to the input word vector is a first label, the terminal device controls the decoder to use the word corresponding to the input word vector as the decoded word corresponding to the input word vector, wherein the error correction label includes a first label and a second label;
[0017] If the error correction label corresponding to the input word vector is the second label, the terminal device constructs a first vector according to the error correction label corresponding to the input word vector, the attention vector corresponding to the input word vector, and the second hidden layer vector corresponding to the input word vector;
[0018] The terminal device calculates the similarity between the first vector and the second vector corresponding to each word in the preset dictionary to obtain the first similarity corresponding to each word in the preset dictionary;
[0019] The terminal device determines a decoding word corresponding to the input word vector according to the first similarity;
[0020] The terminal device determines the error-corrected text based on the decoded words corresponding to each input word vector.
[0021] It should be noted that when the decoder uses the similarity comparison method for decoding, it can reduce the computational complexity of decoding, reduce the loss of system performance, and reduce the processing time.
[0022] In a possible implementation manner of the first aspect, the terminal device determining, according to the first similarity, a decoding word corresponding to the input word vector includes:
[0023] The terminal device uses the word with the highest first similarity in the preset dictionary as the decoding word corresponding to the input word vector.
[0024] It should be noted that the terminal device can directly use the word with the highest first similarity in the preset dictionary as the decoding word corresponding to the input word vector, thereby reducing the complexity of the decoding calculation.
[0025] In another possible implementation of the first aspect, the input word vector includes a pinyin word vector and a glyph word vector;
[0026] Correspondingly, the terminal device determines, according to the first similarity, a decoding word corresponding to the input word vector, including:
[0027] The terminal device calculates the similarity between the pinyin word vector in the input word vector and the pinyin word vector corresponding to each word in the preset dictionary to obtain the pinyin similarity corresponding to each word in the preset dictionary;
[0028] The terminal device calculates the similarity between the glyph word vector in the input word vector and the glyph word vector corresponding to each word in the preset dictionary to obtain the glyph similarity corresponding to each word in the preset dictionary;
[0029] The terminal device calculates the edit distance between the word corresponding to the input word vector and each word in the preset dictionary to obtain the edit distance corresponding to each word in the preset dictionary;
[0030] The terminal device respectively performs weighted summation on the first similarity, the pinyin similarity, the glyph similarity and the edit distance corresponding to each word in the preset dictionary to obtain the target similarity corresponding to each word in the preset dictionary;
[0031] The terminal device uses the word with the highest target similarity in the preset dictionary as the decoding word corresponding to the input word vector.
[0032] It should be noted that when the terminal device needs to improve the decoding accuracy, it can perform a comprehensive evaluation based on the first similarity, phonetic similarity, glyph similarity, edit distance and other field knowledge to obtain the target similarity.
[0033] Then, the terminal device uses the word with the highest target similarity in the preset dictionary as the decoding word corresponding to the above input word vector, thereby improving the decoding accuracy of the decoder.
[0034] In a possible implementation of the first aspect, the error correction determination model includes a bidirectional coding representation model and a binary classifier;
[0035] Correspondingly, the terminal device inputs the word vector sequence into the error correction judgment model, and obtains the error correction label corresponding to each input word vector, including:
[0036] The terminal device sequentially inputs each input word vector in the word vector sequence into the error correction judgment model to obtain a first output value corresponding to each input word vector;
[0037] The terminal device inputs the first output value corresponding to each input word vector into the binary classifier to obtain the error correction label corresponding to each input word vector.
[0038] It should be noted that the bidirectional coding representation model has the advantages of high accuracy, ease of use, and fast adjustment speed. The use of the bidirectional coding representation model and the binary classifier can reduce the difficulty of building and training the error correction judgment model.
[0039] A second aspect of an embodiment of the present application provides a text error correction device, comprising:
[0040] An embedding module, configured to perform word vector conversion on an input text to obtain a word vector sequence corresponding to the input text, wherein the word vector sequence includes input word vectors corresponding to each word in the input text;
[0041] A semantic module, used for inputting the word vector sequence into an encoder of an encoder-decoder model to obtain a semantic vector;
[0042] A label module, used to input the word vector sequence into the error correction judgment model to obtain an error correction label corresponding to each input word vector;
[0043] The error correction module is used to input the word vector sequence, the semantic vector and the error correction label corresponding to each input word vector into the decoder of the encoder-decoder model to obtain the error-corrected text.
[0044] In a possible implementation manner of the second aspect, the error correction module includes:
[0045] A vector input submodule, used to sequentially input the input word vectors in the word vector sequence into the decoder of the encoder-decoder model;
[0046] A hidden update submodule, configured to calculate an attention vector corresponding to the input word vector and a second hidden layer vector corresponding to a next input word vector according to the input word vector and the second hidden layer vector corresponding to the input word vector after each input of the input word vector to the decoder, wherein the second hidden layer vector is a hidden layer vector of the decoder, and the semantic vector is a second hidden layer vector corresponding to the first input word vector;
[0047] A first output submodule, configured to control the decoder to use the word corresponding to the input word vector as the decoded word corresponding to the input word vector if the error correction label corresponding to the input word vector is a first label, wherein the error correction label includes a first label and a second label;
[0048] A first vector submodule, configured to construct a first vector according to the error correction label corresponding to the input word vector, the attention vector corresponding to the input word vector, and the second hidden layer vector corresponding to the input word vector if the error correction label corresponding to the input word vector is the second label;
[0049] A first calculation submodule, configured to calculate a similarity between the first vector and a second vector corresponding to each word in a preset dictionary, to obtain a first similarity corresponding to each word in the preset dictionary;
[0050] A second output submodule, configured to determine a decoding word corresponding to the input word vector according to the first similarity;
[0051] The text integration submodule is used to determine the error-corrected text according to the decoded words corresponding to each input word vector.
[0052] In a possible implementation manner of the second aspect, the second output submodule is specifically configured to use the word with the highest first similarity in the preset dictionary as a decoding word corresponding to the input word vector.
[0053] In another possible implementation of the second aspect, the input word vector includes a pinyin word vector and a glyph word vector;
[0054] Correspondingly, the second output submodule includes:
[0055] A second calculation submodule is used to calculate the similarity between the pinyin word vector in the input word vector and the pinyin word vector corresponding to each word in the preset dictionary to obtain the pinyin similarity corresponding to each word in the preset dictionary;
[0056] A third calculation submodule is used to calculate the similarity between the glyph word vector in the input word vector and the glyph word vector corresponding to each word in the preset dictionary to obtain the glyph similarity corresponding to each word in the preset dictionary;
[0057] A fourth calculation submodule, configured to calculate the edit distance between the word corresponding to the input word vector and each word in the preset dictionary to obtain the edit distance corresponding to each word in the preset dictionary;
[0058] A target calculation submodule, used for performing weighted summation of the first similarity, the phonetic similarity, the glyph similarity and the edit distance corresponding to each word in the preset dictionary, to obtain a target similarity corresponding to each word in the preset dictionary;
[0059] The target output submodule is used to use the word with the highest target similarity in the preset dictionary as the decoding word corresponding to the input word vector.
[0060] In a possible implementation of the second aspect, the error correction determination model includes a bidirectional coding representation model and a binary classifier;
[0061] Accordingly, the label module includes:
[0062] A pre-error correction submodule, used to input each input word vector in the word vector sequence into the bidirectional encoding representation model in sequence to obtain a first output value corresponding to each input word vector;
[0063] The label classification submodule is used to input the first output value corresponding to each input word vector into the binary classifier respectively to obtain the error correction label corresponding to each input word vector.
[0064] A third aspect of an embodiment of the present application provides a terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the terminal device implements the steps of the above method.
[0065] A fourth aspect of an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, a terminal device implements the steps of the above method.
[0066] A fifth aspect of an embodiment of the present application provides a computer program product, which, when executed on a terminal device, enables the terminal device to implement the steps of the above method.
[0067] Compared with the prior art, the embodiments of the present invention have the following beneficial effects:
[0068] The embodiment of the present application provides a text error correction method. Before the decoder in the encoder-decoder model performs decoding, it is necessary to first use the error correction judgment model to classify the labels of each input word vector to obtain the error correction labels of each input word vector. The above error correction label is used to indicate whether the corresponding word needs to be corrected. After the terminal device obtains the error correction label corresponding to each input word vector in the input text, the error correction label corresponding to each input word vector is input into the above decoder, so that the decoder can perform targeted decoding according to the error correction label corresponding to each input word vector, and regulate the decoding process, thereby reducing the misjudgment of the decoder, improving the accuracy of text error correction, and solving the problem that the decoding process of the current encoder-decoder model is uncontrollable and prone to misjudgment. BRIEF DESCRIPTION OF THE DRAWINGS
[0069] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0070] Figure 1 It is a flowchart of a text error correction method provided by an embodiment of the present application;
[0071] Figure 2 It is a structural schematic diagram of a text error correction system provided in an embodiment of the present application;
[0072] Figure 3 It is a working schematic diagram of the word vector embedding model provided in the embodiment of the present application;
[0073] Figure 4 is a schematic diagram of the operation of the encoder provided in an embodiment of the present application;
[0074] Figure 5 It is a working schematic diagram of the error correction judgment model provided in the embodiment of the present application;
[0075] Figure 6 is a schematic diagram of a preset dictionary provided in an embodiment of the present application;
[0076] Figure 7 It is a structural schematic diagram of a text error correction device provided in an embodiment of the present application;
[0077] Figure 8 It is a schematic diagram of a terminal device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0078] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0079] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.
[0080] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0081] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.
[0082] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0083] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0084] The text error correction method provided in the embodiments of the present application can be applied to terminal devices such as mobile phones, tablet computers, wearable devices, vehicle-mounted devices, augmented reality (AR) / virtual reality (VR) devices, laptop computers, ultra-mobile personal computers (UMPC), netbooks, personal digital assistants (PDA), etc. The embodiments of the present application do not impose any restrictions on the specific types of terminal devices.
[0085] For example, the terminal device can be a station (STAION, ST) in a WLAN, a cellular phone, a cordless phone, a Session Initiation Protocol (SIP) phone, a Wireless Local Loop (WLL) station, a Personal Digital Assistant (PDA) device, a handheld device with wireless communication function, a computing device or other processing device connected to a wireless modem, a vehicle-mounted device, a vehicle networking terminal, a computer, a laptop computer, a handheld communication device, a handheld computing device, a satellite wireless device, a wireless modem card, a TV set top box (STB), a customer premises equipment (CPE) and / or other devices for communicating on a wireless system and a next-generation communication system, such as a mobile terminal in a 5G network or a mobile terminal in a future evolved Public Land Mobile Network (PLMN) network, etc.
[0086] In the current field of text processing, encoder-decoder models are often used to implement text processing functions such as text error correction, text translation, document extraction, and question-answering systems.
[0087] In the encoder-decoder model, an encoder and a decoder are provided. When performing text error correction, the user can input the text to be corrected into the encoder of the encoder-decoder model, and the encoder converts the text input by the user into a semantic vector, and then the encoder transmits the semantic vector to the decoder of the encoder-decoder model, and the decoder decodes according to the semantic vector and the input text to obtain the corrected text and output it to the user.
[0088] However, in the current encoder-decoder model, the decoding process of the model is uncontrollable and prone to misjudgment. Some correct words may be misjudged as incorrect words and corrected, or some incorrect words may be misjudged as correct words and not corrected.
[0089] In view of this, an embodiment of the present application provides a text error correction method. Before the decoder in the encoder-decoder model performs decoding, it is necessary to first use the error correction judgment model to classify the labels of each input word vector to obtain the error correction labels of each input word vector. The above error correction label is used to indicate whether the corresponding word needs to be corrected. After the terminal device obtains the error correction label corresponding to each input word vector in the input text, the error correction label corresponding to each input word vector is input into the above decoder, so that the decoder can perform targeted decoding according to the error correction label corresponding to each input word vector, and regulate the decoding process, thereby reducing the misjudgment of the decoder, improving the accuracy of text error correction, and solving the problem that the decoding process of the current encoder-decoder model is uncontrollable and prone to misjudgment.
[0090] Next, the improved text error correction method of this embodiment will be described from the perspective of the terminal device. Figure 1 A flowchart of the text error correction method, the method comprising:
[0091] S101, the terminal device performs word vector conversion on the input text to obtain a word vector sequence corresponding to the input text, wherein the word vector sequence includes input word vectors corresponding to each word in the input text;
[0092] See also Figure 2 The system diagram of the text error correction system shown in the figure may include a word vector embedding model 201, an encoder-decoder model 202 and an error correction judgment model 203.
[0093] Among them, the word vector embedding model 201 is used to convert the input text into a word vector. This process can also be called word vector embedding processing, which converts the input text from natural language into an input word vector of a first preset length.
[0094] The type of word vector embedding model 201 can be selected according to actual conditions. For example, assuming that the input text is Chinese text, the terminal device can select any one or more combinations of models such as pinyin word vector model, glyph word vector model, n-gram language model, etc. as the word vector embedding model 201.
[0095] Among them, the language model is a model used to calculate the probability of a sentence. Language models are widely used in fields such as machine translation, Chinese word segmentation and grammatical analysis. The language model currently used is the n-gram language model. The n in the n-gram language model is a preset value. In the n-gram language model, a word is most highly correlated with the n-1 words before it. When n is 1, the n-gram language model indicates that each word in the sentence is independent of the previous word and is independent of each other. When n is 2, it means that a word is only related to the word before it. When n is 3, it means that a word is only related to the two words before it.
[0096] In addition, the word vector embedding model 201 can be a single model, or the word vector embedding model 201 can also be a combination of multiple models.
[0097] For example, when the terminal device selects a combination of the three models of the pinyin word vector model, the glyph word vector model, and the n-gram language model as the word vector model, the input text can be input into the pinyin word vector model, the glyph word vector model, and the n-gram language model respectively to obtain the pinyin word vector, glyph word vector, and context word vector corresponding to each word in the input text. Then, the terminal device concatenates the pinyin word vector, glyph word vector, and context word vector corresponding to each word to obtain the input word vector of each word in the input text.
[0098] When the input word vector is obtained by combining multiple word vectors, the knowledge and domain features of different fields can be fully utilized to improve the accuracy of text error correction.
[0099] After determining the word vector embedding model 201, the terminal device can input the input text into the word vector embedding model 201 for embedding processing to obtain a word vector sequence corresponding to the input text. The word vector sequence includes the input word vectors of each word in the input text.
[0100] It should be understood that the tokens mentioned in the above description can be defined according to the language type of the input text and the content pre-configured by the user. For example, in Chinese text, the tokens mentioned above can be a single character as a token or a combination of multiple characters as a token; in English text, the tokens mentioned above can be a single word as a token or a phrase composed of multiple words as a token. This embodiment does not limit the way of defining tokens.
[0101] S102, the terminal device inputs the word vector sequence into the encoder 2021 of the encoder-decoder model 202 to obtain a semantic vector;
[0102] The encoder-decoder model 202 is a model applied to sequence to sequence (Seq2Seq) problems, and can be applied to text processing fields such as text translation, document extraction, and question-answering systems. In different text processing fields, the input and output of the encoder-decoder model 202 represent different meanings. For example, in the field of text translation, the input of the encoder-decoder model 202 is the text to be translated, and the output of the encoder-decoder model 202 is the translated text; in the field of question-answering systems, the input of the encoder-decoder model 202 is the question, and the output of the encoder-decoder model 202 is the answer.
[0103] In the encoder-decoder model 202, an encoder 2021 and a decoder 2022 are provided. The encoder 2021 is used to convert the input sequence into a vector of a fixed length, and the decoder 2022 is used to convert the fixed-length vector generated by the encoder 2021 into an output sequence.
[0104] The type of encoder 2021 and the type of decoder 2022 may be selected according to actual conditions.
[0105] For example, the type of encoder 2021 and the type of decoder 2022 can be any one of a recurrent neural network model (RNN), a long short-term memory (LSTM), a gated recurrent unit (GRU), a text convolutional neural network (TextCNN), a transformer model, and the like.
[0106] Furthermore, the type of the encoder 2021 may be consistent with the type of the decoder 2022 , or the type of the encoder 2021 may be inconsistent with the type of the decoder 2022 .
[0107] For example, the type of the encoder 2021 and the type of the decoder 2022 may both be LSTM models. Alternatively, the type of the encoder 2021 may be an LSTM model, and the type of the decoder 2022 may be a transformer model.
[0108] After obtaining the word vector sequence of the input text, the terminal device can input the input word vectors in the above word vector sequence into the encoder 2021 of the encoder-decoder model 202 in sequence to obtain a semantic vector.
[0109] In the process of the terminal device inputting the input word vectors in the word vector sequence into the encoder 2021 in sequence, each time an input word vector is input, the encoder 2021 will update the current first hidden layer vector according to the input word vector to obtain a new first hidden layer vector. The above-mentioned first hidden layer vector is the hidden layer vector of the encoder 2021. After the terminal device inputs the last input word vector into the encoder 2021, the encoder 2021 will update the first hidden layer vector for the last time according to the last input word vector to obtain a semantic vector.
[0110] S103, the terminal device inputs the word vector sequence into the error correction judgment model 203 to obtain an error correction label corresponding to each input word vector;
[0111] In the existing text correction scheme of the encoder-decoder model 202, after the encoder 2021 encodes the word vector sequence to obtain the semantic vector, the terminal device inputs the semantic vector output by the encoder 2021 and the above-mentioned word vector sequence into the decoder 2022. The decoder 2022 performs decoding operations based on the semantic vector and the word vector sequence, and outputs the corrected text.
[0112] However, in this decoding method, the decoding process is uncontrollable, that is, each word in the input text, whether it is a correct word or not, may be corrected. Therefore, in the current encoder-decoder model 202, the decoding process is uncontrollable and prone to misjudgment. Some words that do not need to be corrected may be corrected, and some words that need to be corrected may not be corrected.
[0113] In this regard, in the error correction method of this embodiment, before the decoder 2022 performs decoding, the word vector sequence is first input into the error correction judgment model 203 for error correction judgment to obtain the error correction label corresponding to each word in the input text.
[0114] The error correction determination model 203 is used to identify whether each word in the input text is a correct word, thereby determining which words in the input text need to be corrected and which words do not need to be corrected, and obtaining the error correction labels corresponding to each word in the input text.
[0115] The error correction label is used to indicate whether each word in the input text needs to be corrected. The error correction label may include a first label and a second label. The first label indicates that no error correction is required, and the second label indicates that error correction is required. The form of the error correction label can be set according to actual conditions. For example, in some embodiments, 0 can be used to represent the first label and 1 can be used to represent the second label.
[0116] The structure of the error correction decision model 203 can be set according to actual conditions. In some embodiments, a combination of a bidirectional encoder representation model (Bidirectional Encoder Representations from Transformers, Bert) and a binary classifier can be used as the error correction decision model 203.
[0117] The terminal device can input the input word vectors in the word vector sequence into the Bert model in sequence to obtain the first output value corresponding to each input word vector. Then, the terminal device inputs the first output value corresponding to each input word vector into the binary classifier for classification to obtain the error correction label corresponding to each input word vector in the input text. Among them, the first output value of the Bert model is in a one-to-one correspondence with the input word vector.
[0118] The Bert model has the advantages of high accuracy, ease of use, and fast adjustment speed. When the Bert model and a binary classifier are used to construct the error correction judgment model 203, the construction difficulty and training difficulty of the error correction judgment model 203 can be reduced.
[0119] In other embodiments, other models may be selected as the error correction determination model 203. For example, the terminal device may select an RNN model, an LSTM model, a GRU model, a TextCNN model, a transformer model, or the like to construct the error correction determination model 203. The specific structure of the error correction determination model 203 may be set according to actual conditions.
[0120] S104, the terminal device inputs the word vector sequence, the semantic vector and the error correction label corresponding to each input word vector into the decoder 2022 of the encoder-decoder model 202 to obtain the error-corrected text.
[0121] After obtaining the error correction label of each word in the input text, the terminal device can input the above word vector sequence, the above semantic vector and the error correction label of each word in the above input text into the decoder 2022 of the above encoder-decoder model 202, and the decoder 2022 will decode them.
[0122] During the decoding process, the decoder 2022 can perform targeted decoding according to the error correction label of each word in the input text, and regulate the decoding process, thereby reducing the misjudgment of the decoder and improving the accuracy of text error correction.
[0123] In addition, during the decoding process of the decoder 2022, a softmax function is usually used for decoding, which takes up more computing performance of the system and takes a long time to process. Therefore, in some possible implementations, the decoder 2022 can use a similarity comparison method for decoding to reduce the computational complexity of decoding, reduce the loss of system performance, and reduce the processing time.
[0124] During the decoding process, the terminal device can use the above semantic vector as the initial value of the second hidden layer vector of the decoder 2022. At this time, the semantic vector is the second hidden layer vector corresponding to the first input word vector. The second hidden layer vector is the hidden layer vector of the decoder 2022.
[0125] The terminal device inputs the input word vectors in the word vector sequence into the decoder 2022 in sequence, and calculates the attention vector corresponding to the input word vector and the second hidden layer vector corresponding to the next input word vector based on the above input word vector and the second hidden layer vector corresponding to the input word vector.
[0126] If the error correction label corresponding to the input word vector is the first label, indicating that the word corresponding to the input word vector does not need to be corrected, the terminal device controls the decoder 2022 to use the word corresponding to the input word vector as the decoding word corresponding to the input word vector, and the decoding word is the output value of the decoder.
[0127] If the error correction label corresponding to the input word vector is the second label, indicating that the word corresponding to the input word vector needs to be corrected, the terminal device constructs a first vector based on the error correction label corresponding to the input word vector, the attention vector corresponding to the input word vector, and the second hidden layer vector corresponding to the input word vector. The construction method of the first vector can be set according to actual conditions. For example, in some embodiments, the error correction label corresponding to the input word vector, the attention vector corresponding to the input word vector, and the second hidden layer vector corresponding to the input word vector can be directly spliced into a first vector.
[0128] The terminal device calculates the similarity between the first vector and the second vector corresponding to each word in the preset dictionary to obtain the first similarity corresponding to each word in the preset dictionary, and determines the decoding word corresponding to the above input word vector based on the first similarity.
[0129] In some possible implementations, the terminal device may directly control the decoder 2022 to determine the word with the highest first similarity in the preset dictionary as the decoded word corresponding to the above-mentioned input word vector.
[0130] In some other possible implementations, in order to improve the decoding accuracy, the terminal device may also perform a comprehensive comparison in combination with other domain knowledge to obtain a target similarity, and determine the decoded word corresponding to the input word vector according to the target similarity. The other domain knowledge may include one or more domain knowledge in the fields of pinyin similarity, glyph similarity, and edit distance.
[0131] For example, taking Chinese text as an example, assume that the input word vector includes pinyin word vector and glyph word vector.
[0132] The terminal device can perform similarity calculation based on the pinyin word vector in the input word vector and the pinyin word vector corresponding to each word in the preset dictionary to obtain the pinyin similarity corresponding to each word in the preset dictionary.
[0133] The terminal device can perform similarity calculation based on the glyph word vector and the glyph word vector corresponding to each word in the preset dictionary to obtain the glyph similarity corresponding to each word in the preset dictionary.
[0134] The terminal device calculates the edit distance (EditDistance) between the word corresponding to the above input word vector and each word in the preset dictionary to obtain the edit distance corresponding to each word in the preset dictionary.
[0135] Edit distance refers to the minimum number of edit operations required to transform one string into another. Edit distance has a wide range of applications, especially in similarity problems, such as text error correction and plagiarism detection.
[0136] Editing in the edit distance includes three operations: insertion, deletion, and substitution. The edit distance between two strings is usually calculated using a dynamic programming algorithm.
[0137] The terminal device performs weighted summation of the first similarity, pinyin similarity, glyph similarity and edit distance corresponding to each word in the preset dictionary to obtain the target similarity corresponding to each word in the preset dictionary. Among them, the first weight value corresponding to the first similarity, the second weight value corresponding to the pinyin similarity, the third weight value corresponding to the glyph similarity and the fourth weight value corresponding to the edit distance are all preset values.
[0138] It is understandable that in the similarity calculation process mentioned above, a suitable similarity algorithm can be selected for calculation according to the actual situation. For example, the similarity can be calculated by calculating the cosine distance; or the similarity can be calculated by calculating the Euclidean distance; or other similarity algorithms can be selected to calculate the similarity.
[0139] After calculating the target similarity, the terminal device can determine the word with the highest target similarity in the preset dictionary as the decoding word corresponding to the above input word vector.
[0140] After the terminal device obtains the decoded words corresponding to each input word vector, it determines the corrected text based on the decoded words corresponding to the above-mentioned input word vectors.
[0141] The text error correction method of this embodiment is described below in conjunction with a specific application scenario:
[0142] Assume that the text error correction system includes an encoder-decoder model, an error correction judgment model, and a word vector embedding model. In the encoder-decoder model, both the encoder and the decoder are LSTM models, the error correction judgment model is a Bert model followed by a classifier, and the word vector embedding model includes a pinyin word vector model, a glyph word vector model, and an n-gram language model.
[0143] Before performing text correction, the text correction system is trained using training corpus, which may include labeled text corpus collected after Automatic Speech Recognition (ASR), public data from newspapers, common entity vocabulary, and other public corpus, such as the Sighan Bakeoff corpus.
[0144] In the process of obtaining training corpus, the training corpus can be preprocessed, including:
[0145] 1.1. Collect and annotate corpus;
[0146] 1.2. Convert the traditional Chinese characters in the collected corpus into simplified Chinese characters;
[0147] 1.3. Convert Chinese characters into pinyin;
[0148] 1.4. Corpus quality screening and corpus analysis and statistics.
[0149] After the above preprocessing process, the quality of the training corpus can be improved. After that, the training corpus can be converted into training word vectors through the word vector embedding model, and the training word vectors can be used to train the encoder, decoder and error correction module.
[0150] In each round of training, the first loss value corresponding to the encoder, the second loss value corresponding to the decoder, and the third loss value corresponding to the error correction judgment module are calculated, the encoder is iteratively updated according to the first loss value, the decoder is iteratively updated according to the second loss value, and the error correction judgment model is iteratively updated according to the third loss value.
[0151] Repeat the training until the preset training termination condition is reached. The training termination condition can be set according to the actual situation. For example, the training termination condition can be that the number of training times reaches the preset number of iterations; or the training termination condition can be that the first loss value, the second loss value, and the third loss value are less than the preset loss threshold; or the training termination condition can also be other conditions.
[0152] After the training is completed, the trained text correction system can be used to perform text correction.
[0153] like Figure 3 As shown in the figure, assuming that the input text is "listen to the song before learning", take one character as a word, embed the input text into the word vector model, and get the word vector sequence corresponding to the error correction text. The word vector sequence includes the input word vector corresponding to each word (i.e. Figure 3 In the word vector A1 to word vector A6), each input word vector is obtained by concatenating the pinyin word vector, the glyph word vector and the context word vector.
[0154] The terminal device inputs the word vectors A1 to A6 into the encoder one by one. Each time the input word vector is input into the encoder, the encoder updates the first hidden layer vector of the encoder according to the input word vector.
[0155] like Figure 4 As shown, the initial value of the first hidden layer vector of the encoder is h0. After the terminal device inputs the word vector A1 into the encoder, the encoder updates h0 to h1 according to the word vector A1; after the terminal device inputs the word vector A2 into the encoder, the encoder updates h1 to h2 according to the word vector A2; and so on, after the terminal device inputs the word vector A6 into the encoder, the encoder updates h5 to h6 according to the word vector A6. The terminal device uses h6 as a semantic vector and controls the encoder to input h6 into the decoder as the initial value s1 of the second hidden layer vector of the decoder.
[0156] like Figure 5 As shown, the terminal device inputs the word vectors A1 to A6 one by one into the Bert model in the error correction judgment model, and the Bert model outputs the first output value corresponding to the word vectors A1 to A6, and inputs each first output value into the binary classifier to obtain the error correction label corresponding to the word vectors A1 to A6. Among them, the error correction label includes a first label and a second label, the value of the first label is 0, and the value of the second label is 1.
[0157] At this time, the error correction labels corresponding to word vector A1, word vector A5, and word vector A6 are 0, indicating that the words corresponding to word vector A1, word vector A5, and word vector A6 do not need error correction; the error correction labels corresponding to word vector A2, word vector A3, and word vector A4 are 1, indicating that the words corresponding to word vector A2, word vector A3, and word vector A4 need error correction.
[0158] After that, the terminal device inputs the word vectors A1 to A6 and the error correction labels corresponding to each input word vector into the decoder, and obtains the decoded words corresponding to each input word vector. The specific process is as follows:
[0159] 2.1. The terminal device inputs the word vector A1 and the error correction label corresponding to the word vector A1 into the decoder, and the decoder updates s1 to s2 according to the word vector A1. Since the error correction label corresponding to the word vector A1 is 0, the decoder outputs the word "listen" corresponding to the word vector A1.
[0160] 2.2. The terminal device inputs the word vector A2 and the error correction label corresponding to the word vector A2 into the decoder, and the decoder updates s2 to s3 according to the word vector A2. Since the error correction label corresponding to the word vector A2 is 1, the decoder calculates the attention vector b1 corresponding to the word vector A2 according to s2 and h1 to h6, and then constructs the first vector c1 corresponding to the word vector A2 according to the error correction label, s2 and b1 corresponding to the word vector A2.
[0161] As Figure 6 shown, assume that there are m words in the preset dictionary, and m is a preset positive integer. Then each word has a corresponding second vector. For example, "snow" corresponds to the second vector d1, "Xue" corresponds to the second vector d2, "sky" corresponds to the second vector d3, "Jing" corresponds to the second vector d4, and "split" corresponds to the second vector dm.
[0162] The terminal device calculates the similarity between the first vector c1 and the second vectors of each word in the preset dictionary, and obtains the first similarity corresponding to each word in the preset dictionary. At this time, the first similarity between the first vector c1 and the second vector d2 is the highest, and the decoder outputs the word "Xue" corresponding to the second vector d2.
[0163] 2.3. The terminal device inputs the word vector A3 and the error correction label corresponding to the word vector A3 into the decoder, and the decoder updates s3 to s4 according to the word vector A3. Since the error correction label corresponding to the word vector A3 is 1, the decoder calculates the attention vector b2 corresponding to the word vector A3 according to s3 and h1 to h6, and then constructs the first vector c2 corresponding to the word vector A3 according to the error correction label, s3 and b2 corresponding to the word vector A3.
[0164] The terminal device calculates the similarity between the first vector c2 and the second vectors of each word in the preset dictionary, and obtains the first similarity corresponding to each word in the preset dictionary. The decoder outputs the word "zhi" with the highest first similarity in the preset dictionary.
[0165] 2.4. The terminal device inputs the word vector A4 and the error correction label corresponding to the word vector A4 into the decoder. The decoder updates s4 to s5 according to the word vector A4. Since the error correction label corresponding to the word vector A4 is 1, the decoder calculates the attention vector b3 corresponding to the word vector A4 according to s4 and h1 to h6, and then constructs the first vector c3 corresponding to the word vector A4 according to the error correction label corresponding to the word vector A4, s4, and b3.
[0166] The terminal device calculates the similarity between the first vector c3 and the second vectors of each word in the preset dictionary, obtains the first similarity corresponding to each word in the preset dictionary, and the decoder outputs the word "Qian" with the highest first similarity in the preset dictionary.
[0167] 2.5. The terminal device inputs the word vector A5 and the error correction label corresponding to the word vector A5 into the decoder. The decoder updates s5 to s6 according to the word vector A5. Since the error correction label corresponding to the word vector A5 is 0, the decoder outputs the word "de" corresponding to the word vector A5.
[0168] 2.6. The terminal device inputs the word vector A6 and the error correction label corresponding to the word vector A6 into the decoder. The decoder updates s6 to s7 according to the word vector A6. Since the error correction label corresponding to the word vector A6 is 0, the decoder outputs the word "ge" corresponding to the word vector A6.
[0169] After the terminal device obtains the decoded words "ting", "Xue", "zhi", "Qian", "de", "ge" corresponding to the word vectors A1 to A6, it arranges the decoded words in order to obtain the corrected text, that is, "ting Xue Zhi Qian de ge".
[0170] In summary, the embodiment of the present application provides a text error correction method. Before the decoder in the encoder-decoder model performs decoding, it is necessary to first use an error correction determination model to classify the labels of each input word vector to obtain the error correction labels of each input word vector. The above error correction labels are used to indicate whether the corresponding words need to be corrected. After the terminal device obtains the error correction labels corresponding to each input word vector in the input text, it inputs the error correction labels corresponding to each input word vector into the above decoder, so that the decoder can perform targeted decoding according to the error correction labels corresponding to each input word vector, regulate the decoding process, thereby reducing the misjudgment situation of the decoder and improving the accuracy of text error correction, and solving the problem that the decoding process of the current encoder-decoder model is uncontrollable and prone to misjudgment.
[0171] After correcting the input text through the above text error correction method, the corrected text can be obtained. The corrected text can be widely applied to various downstream tasks, such as word segmentation tasks, part-of-speech tagging tasks, entity recognition tasks, intent classification tasks, slot filling tasks, dialogue management tasks, text generation tasks, etc.
[0172] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0173] See also Figure 7 , the embodiment of the present application provides a text error correction device. For the convenience of explanation, only the parts related to the present application are shown, such as Figure 7 As shown, the text error correction device includes:
[0174] The embedding module 701 is used to perform word vector conversion on the input text to obtain a word vector sequence corresponding to the input text, wherein the word vector sequence includes input word vectors corresponding to each word in the input text;
[0175] A semantic module 702, configured to input the word vector sequence into an encoder of an encoder-decoder model to obtain a semantic vector;
[0176] A label module 703 is used to input the word vector sequence into the error correction judgment model to obtain an error correction label corresponding to each input word vector;
[0177] The error correction module 704 is used to input the word vector sequence, the semantic vector and the error correction label corresponding to each input word vector into the decoder of the encoder-decoder model to obtain the error-corrected text.
[0178] Furthermore, it is characterized in that the error correction module 704 includes:
[0179] A vector input submodule, used to sequentially input the input word vectors in the word vector sequence into the decoder of the encoder-decoder model;
[0180] A hidden update submodule, configured to calculate an attention vector corresponding to the input word vector and a second hidden layer vector corresponding to a next input word vector according to the input word vector and the second hidden layer vector corresponding to the input word vector after each input of the input word vector to the decoder, wherein the second hidden layer vector is a hidden layer vector of the decoder, and the semantic vector is a second hidden layer vector corresponding to the first input word vector;
[0181] A first output submodule, configured to control the decoder to use the word corresponding to the input word vector as the decoded word corresponding to the input word vector if the error correction label corresponding to the input word vector is a first label, wherein the error correction label includes a first label and a second label;
[0182] A first vector submodule, configured to construct a first vector according to the error correction label corresponding to the input word vector, the attention vector corresponding to the input word vector, and the second hidden layer vector corresponding to the input word vector if the error correction label corresponding to the input word vector is the second label;
[0183] A first calculation submodule, configured to calculate a similarity between the first vector and a second vector corresponding to each word in a preset dictionary, to obtain a first similarity corresponding to each word in the preset dictionary;
[0184] A second output submodule, configured to determine a decoding word corresponding to the input word vector according to the first similarity;
[0185] The text integration submodule is used to determine the error-corrected text according to the decoded words corresponding to each input word vector.
[0186] Furthermore, the second output submodule is specifically configured to use the word with the highest first similarity in the preset dictionary as a decoding word corresponding to the input word vector.
[0187] Furthermore, the input word vector includes a pinyin word vector and a glyph word vector;
[0188] Correspondingly, the second output submodule includes:
[0189] A second calculation submodule is used to calculate the similarity between the pinyin word vector in the input word vector and the pinyin word vector corresponding to each word in the preset dictionary to obtain the pinyin similarity corresponding to each word in the preset dictionary;
[0190] A third calculation submodule is used to calculate the similarity between the glyph word vector in the input word vector and the glyph word vector corresponding to each word in the preset dictionary to obtain the glyph similarity corresponding to each word in the preset dictionary;
[0191] A fourth calculation submodule, configured to calculate the edit distance between the word corresponding to the input word vector and each word in the preset dictionary to obtain the edit distance corresponding to each word in the preset dictionary;
[0192] A target calculation submodule, used for performing weighted summation of the first similarity, the phonetic similarity, the glyph similarity and the edit distance corresponding to each word in the preset dictionary, to obtain a target similarity corresponding to each word in the preset dictionary;
[0193] The target output submodule is used to use the word with the highest target similarity in the preset dictionary as the decoding word corresponding to the input word vector.
[0194] Furthermore, the error correction determination model includes a bidirectional coding representation model and a binary classifier;
[0195] Accordingly, the label module 703 includes:
[0196] A pre-error correction submodule, used to input each input word vector in the word vector sequence into the bidirectional encoding representation model in sequence to obtain a first output value corresponding to each input word vector;
[0197] The label classification submodule is used to input the first output value corresponding to each input word vector into the binary classifier respectively to obtain the error correction label corresponding to each input word vector.
[0198] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0199] See also Figure 8 The embodiment of the present application further provides a terminal device, the terminal device 8 comprising: a processor 80, a memory 81, and a computer program 82 stored in the memory 81 and executable on the processor 80. When the processor 80 executes the computer program 82, the steps in the above-mentioned number privacy protection method embodiment are implemented, for example Figure 1 Alternatively, when the processor 80 executes the computer program 82, the functions of each module / unit in the above-mentioned device embodiments are realized, for example, Figure 7 Functions of modules 701 to 704 are shown.
[0200] Exemplarily, the computer program 82 may be divided into one or more modules / units, which are stored in the memory 81 and executed by the processor 80 to complete the present application. The one or more modules / units may be a series of computer program instruction segments capable of completing specific functions, which are used to describe the execution process of the computer program 82 in the terminal device 8. For example, the computer program 82 may be divided into an embedding module, a semantic module, a labeling module, and an error correction module, and the specific functions of each module are as follows:
[0201] An embedding module, configured to perform word vector conversion on an input text to obtain a word vector sequence corresponding to the input text, wherein the word vector sequence includes input word vectors corresponding to each word in the input text;
[0202] A semantic module, used for inputting the word vector sequence into an encoder of an encoder-decoder model to obtain a semantic vector;
[0203] A label module, used to input the word vector sequence into the error correction judgment model to obtain an error correction label corresponding to each input word vector;
[0204] The error correction module is used to input the word vector sequence, the semantic vector and the error correction label corresponding to each input word vector into the decoder of the encoder-decoder model to obtain the error-corrected text.
[0205] The terminal device 8 may be a computing device such as a desktop computer, a notebook, a PDA, or a cloud server. The terminal device may include, but is not limited to, a processor 80 and a memory 81. Those skilled in the art will appreciate that Figure 8 It is only an example of the terminal device 8 and does not constitute a limitation of the terminal device 8. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the terminal device may also include input and output devices, network access devices, buses, etc.
[0206] The processor 80 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0207] The memory 81 may be an internal storage unit of the terminal device 8, such as a hard disk or memory of the terminal device 8. The memory 81 may also be an external storage device of the terminal device 8, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the terminal device 8. Further, the memory 81 may also include both an internal storage unit and an external storage device of the terminal device 8. The memory 81 is used to store the computer program and other programs and data required by the terminal device. The memory 81 may also be used to temporarily store data that has been output or is to be output.
[0208] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0209] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0210] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0211] In the embodiments provided in the present application, it should be understood that the disclosed devices / terminal equipment and methods can be implemented in other ways. For example, the device / terminal equipment embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0212] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0213] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0214] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0215] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A text error correction method, characterized in that: include: The terminal device performs word vector conversion on the input text to obtain a word vector sequence corresponding to the input text, wherein the word vector sequence includes input word vectors corresponding to each word in the input text; The terminal device inputs the word vector sequence into an encoder of an encoder-decoder model to obtain a semantic vector; The terminal device inputs the word vector sequence into the error correction judgment model to obtain an error correction label corresponding to each input word vector; The terminal device inputs the word vector sequence, the semantic vector, and the error correction labels corresponding to each input word vector into the decoder of the encoder-decoder model to obtain the error-corrected text.
2. A text error correction method as claimed in claim 1, characterized in that: The terminal device inputs the word vector sequence, the semantic vector, and the error correction label corresponding to each input word vector into the decoder of the encoder-decoder model, and the error-corrected text obtained includes: The terminal device sequentially inputs the input word vectors in the word vector sequence into the decoder of the encoder-decoder model; After each time the input word vector is input into the decoder, the terminal device calculates the attention vector corresponding to the input word vector and the second hidden layer vector corresponding to the next input word vector according to the input word vector and the second hidden layer vector corresponding to the input word vector, wherein the second hidden layer vector is the hidden layer vector of the decoder, and the semantic vector is the second hidden layer vector corresponding to the first input word vector; If the error correction label corresponding to the input word vector is a first label, the terminal device controls the decoder to use the word corresponding to the input word vector as the decoded word corresponding to the input word vector, wherein the error correction label includes a first label and a second label; If the error correction label corresponding to the input word vector is the second label, the terminal device constructs a first vector according to the error correction label corresponding to the input word vector, the attention vector corresponding to the input word vector, and the second hidden layer vector corresponding to the input word vector; The terminal device calculates the similarity between the first vector and the second vector corresponding to each word in the preset dictionary to obtain the first similarity corresponding to each word in the preset dictionary; The terminal device determines a decoding word corresponding to the input word vector according to the first similarity; The terminal device determines the error-corrected text based on the decoded words corresponding to each input word vector.
3. A text error correction method as claimed in claim 2, characterized in that: The terminal device determines, according to the first similarity, a decoding word corresponding to the input word vector, including: The terminal device uses the word with the highest first similarity in the preset dictionary as the decoding word corresponding to the input word vector.
4. A text error correction method as claimed in claim 2, characterized in that: The input word vector includes a pinyin word vector and a glyph word vector; Correspondingly, the terminal device determines, according to the first similarity, a decoding word corresponding to the input word vector, including: The terminal device calculates the similarity between the pinyin word vector in the input word vector and the pinyin word vector corresponding to each word in the preset dictionary to obtain the pinyin similarity corresponding to each word in the preset dictionary; The terminal device calculates the similarity between the glyph word vector in the input word vector and the glyph word vector corresponding to each word in the preset dictionary to obtain the glyph similarity corresponding to each word in the preset dictionary; The terminal device calculates the edit distance between the word corresponding to the input word vector and each word in the preset dictionary to obtain the edit distance corresponding to each word in the preset dictionary; The terminal device respectively performs weighted summation on the first similarity, the pinyin similarity, the glyph similarity and the edit distance corresponding to each word in the preset dictionary to obtain the target similarity corresponding to each word in the preset dictionary; The terminal device uses the word with the highest target similarity in the preset dictionary as the decoding word corresponding to the input word vector.
5. A text error correction method as claimed in claim 1, characterized in that: The error correction judgment model includes a bidirectional coding representation model and a binary classifier; Correspondingly, the terminal device inputs the word vector sequence into the error correction judgment model, and obtains the error correction label corresponding to each input word vector, including: The terminal device sequentially inputs each input word vector in the word vector sequence into the error correction judgment model to obtain a first output value corresponding to each input word vector; The terminal device inputs the first output value corresponding to each input word vector into the binary classifier to obtain the error correction label corresponding to each input word vector.
6. A text error correction device, characterized in that: include: An embedding module, configured to perform word vector conversion on an input text to obtain a word vector sequence corresponding to the input text, wherein the word vector sequence includes input word vectors corresponding to each word in the input text; A semantic module, used for inputting the word vector sequence into an encoder of an encoder-decoder model to obtain a semantic vector; A label module, used to input the word vector sequence into the error correction judgment model to obtain an error correction label corresponding to each input word vector; The error correction module is used to input the word vector sequence, the semantic vector and the error correction label corresponding to each input word vector into the decoder of the encoder-decoder model to obtain the error-corrected text.
7. A text error correction device as claimed in claim 6, characterized in that: The error correction module comprises: A vector input submodule, used to sequentially input the input word vectors in the word vector sequence into the decoder of the encoder-decoder model; A hidden update submodule, configured to calculate an attention vector corresponding to the input word vector and a second hidden layer vector corresponding to a next input word vector according to the input word vector and the second hidden layer vector corresponding to the input word vector after each input of the input word vector to the decoder, wherein the second hidden layer vector is a hidden layer vector of the decoder, and the semantic vector is a second hidden layer vector corresponding to the first input word vector; A first output submodule, configured to control the decoder to use the word corresponding to the input word vector as the decoded word corresponding to the input word vector if the error correction label corresponding to the input word vector is a first label, wherein the error correction label includes a first label and a second label; A first vector submodule, configured to construct a first vector according to the error correction label corresponding to the input word vector, the attention vector corresponding to the input word vector, and the second hidden layer vector corresponding to the input word vector if the error correction label corresponding to the input word vector is the second label; A first calculation submodule, configured to calculate a similarity between the first vector and a second vector corresponding to each word in a preset dictionary, to obtain a first similarity corresponding to each word in the preset dictionary; A second output submodule, configured to determine a decoding word corresponding to the input word vector according to the first similarity; The text integration submodule is used to determine the error-corrected text according to the decoded words corresponding to each input word vector.
8. A text error correction device as claimed in claim 7, characterized in that: The second output submodule is specifically configured to use the word with the highest first similarity in the preset dictionary as a decoding word corresponding to the input word vector.
9. A text error correction device as claimed in claim 7, characterized in that: The input word vector includes a pinyin word vector and a glyph word vector; Correspondingly, the second output submodule includes: A second calculation submodule is used to calculate the similarity between the pinyin word vector in the input word vector and the pinyin word vector corresponding to each word in the preset dictionary to obtain the pinyin similarity corresponding to each word in the preset dictionary; A third calculation submodule is used to calculate the similarity between the glyph word vector in the input word vector and the glyph word vector corresponding to each word in the preset dictionary to obtain the glyph similarity corresponding to each word in the preset dictionary; A fourth calculation submodule, configured to calculate the edit distance between the word corresponding to the input word vector and each word in the preset dictionary to obtain the edit distance corresponding to each word in the preset dictionary; A target calculation submodule, used for performing weighted summation of the first similarity, the pinyin similarity, the glyph similarity and the edit distance corresponding to each word in the preset dictionary, to obtain a target similarity corresponding to each word in the preset dictionary; The target output submodule is used to use the word with the highest target similarity in the preset dictionary as the decoding word corresponding to the input word vector.
10. A text error correction device as claimed in claim 6, characterized in that: The error correction judgment model includes a bidirectional coding representation model and a binary classifier; Accordingly, the label module includes: A pre-error correction submodule, used to input each input word vector in the word vector sequence into the bidirectional encoding representation model in sequence to obtain a first output value corresponding to each input word vector; The label classification submodule is used to input the first output value corresponding to each input word vector into the binary classifier respectively to obtain the error correction label corresponding to each input word vector.
11. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the terminal device implements the steps of the method according to any one of claims 1 to 5.
12. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the terminal device implements the steps of the method according to any one of claims 1 to 5.
