Text error correction model training method, device, electronic device and storage medium
By processing preset transformation rules for standard corpus, the incorrect corpus and its error types are generated, the problem of low training efficiency of existing text error correction models is solved, and the training efficiency and accuracy of the model are improved.
Patent Information
- Application Number
- CN201911219137.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-12-02
- Publication Date
- 2024-12-17
- Estimated Expiration
- 2039-12-02
AI Technical Summary
The existing text error correction model training methods are inefficient and rely on manual annotation, resulting in low training efficiency.
By obtaining the initial training sample set, the standard corpus is transformed using preset transformation rules to generate erroneous corpus and its error types, reducing manual annotation work, and improving training efficiency and accuracy.
It realizes efficient training of text error correction models, reduces manual annotation work, and improves the accuracy and training efficiency of the model.
Smart Images

Figure CN111859919B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of text processing technology, and in particular to a text error correction model training method, device, electronic device and storage medium. Background Art
[0002] Text error correction is an important research direction in computer natural language processing. Computer algorithms can be used to correct errors caused by human factors in text, such as typos, incorrect word order, etc. Taking the intelligent customer service system as an example, text error correction is applied to the intelligent customer service system. By correcting the text input by the user, the customer service can accurately judge the customer's needs.
[0003] When existing text correction methods are based on text correction models, manual labeling methods are generally used to mark training samples for use in training text correction models.
[0004] Therefore, the existing methods require manual labeling, so the efficiency of model training is low. Summary of the invention
[0005] The purpose of this application is to provide a text error correction model training method, device, electronic device and storage medium to address the deficiencies in the above-mentioned prior art, which can solve the technical problem of low efficiency of text error correction model training in the prior art.
[0006] To achieve the above purpose, the technical solution adopted in the embodiment of the present application is as follows:
[0007] In a first aspect, an embodiment of the present application provides a method for training a text error correction model, comprising: obtaining an initial training sample set, the initial training sample set comprising a plurality of standard corpora; using preset transformation rules to transform elements in each standard corpus, to obtain a plurality of transformed erroneous corpora and the error type corresponding to each erroneous corpus; and training and obtaining a text error correction model based on the initial training sample set and the corresponding erroneous corpora.
[0008] Optionally, the above-mentioned using preset transformation rules to transform elements in each standard corpus to obtain multiple transformed erroneous corpora and error types corresponding to each erroneous corpus includes using one or more of the following preset transformation rules to transform elements in each standard corpus to obtain multiple transformed erroneous corpora and error types corresponding to each erroneous corpus: using a preset corpus to obtain replaceable elements whose similarity to elements in the standard corpus meets preset conditions, and using the replaceable elements to replace elements in the standard corpus; deleting one or more elements in the standard corpus; inserting one or more elements in the standard corpus; adjusting the order of elements in the standard corpus.
[0009] Optionally, the above-mentioned deleting one or more elements in the standard corpus includes: for each element in the standard corpus, deleting one or more elements according to a first preset probability; inserting one or more elements in the standard corpus includes: for each position between elements in the standard corpus, inserting elements at one or more positions according to a second preset probability; adjusting the order of elements in the standard corpus includes: for any adjacent elements in the standard corpus, adjusting the order according to a third preset probability.
[0010] Optionally, the method further includes: obtaining a sentence to be corrected; correcting the sentence to be corrected using a text correction model, and outputting the corrected sentence.
[0011] Optionally, the above-mentioned text correction model is used to correct the sentence to be corrected and output the corrected sentence, including: mapping the sentence to be corrected to a multidimensional vector space to obtain a corresponding multidimensional vector; encoding the multidimensional vector to obtain an encoded multidimensional vector, the encoded multidimensional vector includes semantic information in the sentence to be corrected; obtaining the attention weight of each vector in the encoded multidimensional vector to generate a vector of a fixed length, the vector of a fixed length includes the semantic information of the entire sentence to be corrected; decoding the fixed-length vector to obtain a decoded target sequence; generating a corrected sentence according to the decoded target sequence.
[0012] Optionally, the above-mentioned training and acquiring a text error correction model based on the initial training sample set and the corresponding erroneous corpus includes: mapping the initial training sample set and the corresponding erroneous corpus to a multidimensional vector space to obtain corresponding multidimensional vector samples; encoding the multidimensional vector samples to obtain encoded multidimensional vector samples, the encoded multidimensional vector samples including semantic information in the initial training sample set and the corresponding erroneous corpus; obtaining the attention weight of each vector sample in the encoded multidimensional vector samples to generate a fixed-length vector sample, the fixed-length vector sample including the semantic information of each sample in the initial training sample set and the corresponding erroneous corpus; decoding the fixed-length vector samples to obtain decoded target sequence samples; and training and acquiring a text error correction model based on the decoded target sequence samples.
[0013] In a second aspect, an embodiment of the present application provides a text error correction model training device, including: a first acquisition module, a transformation module and a training module.
[0014] The first acquisition module is used to obtain an initial training sample set, which includes multiple standard corpora; the transformation module is used to transform the elements in each standard corpus using preset transformation rules to obtain multiple transformed erroneous corpora and the error type corresponding to each erroneous corpus; the training module is used to train and acquire a text error correction model based on the initial training sample set and the corresponding erroneous corpora.
[0015] Optionally, the above-mentioned transformation module is specifically used to transform the elements in each standard corpus using one or more of the following preset transformation rules to obtain multiple transformed erroneous corpora and the error type corresponding to each erroneous corpus: using a preset corpus to obtain replaceable elements whose similarity to the elements in the standard corpus meets preset conditions, and using the replaceable elements to replace the elements in the standard corpus; deleting one or more elements in the standard corpus; inserting one or more elements in the standard corpus; adjusting the order of elements in the standard corpus.
[0016] Optionally, the above-mentioned transformation module is specifically used to delete one or more elements for each element in the standard corpus according to a first preset probability; insert elements at one or more positions for each position between elements in the standard corpus according to a second preset probability; and adjust the order of any adjacent elements in the standard corpus according to a third preset probability.
[0017] Optionally, the above-mentioned device also includes: a second acquisition module and an error correction module; the second acquisition module is specifically used to acquire the sentence to be corrected; the error correction module is specifically used to correct the sentence to be corrected using a text error correction model and output the corrected sentence.
[0018] Optionally, the above-mentioned error correction module is specifically used to map the sentence to be corrected to a multidimensional vector space to obtain the corresponding multidimensional vector; encode the multidimensional vector to obtain the encoded multidimensional vector, and the encoded multidimensional vector includes the semantic information in the sentence to be corrected; obtain the attention weight of each vector in the encoded multidimensional vector to generate a vector of fixed length, and the vector of fixed length includes the semantic information of the entire sentence to be corrected; decode the fixed-length vector to obtain the decoded target sequence; generate a corrected sentence according to the decoded target sequence.
[0019] Optionally, the above-mentioned training module is specifically used to map the initial training sample set and the corresponding erroneous corpus to a multidimensional vector space to obtain corresponding multidimensional vector samples; encode the multidimensional vector samples to obtain encoded multidimensional vector samples, and the encoded multidimensional vector samples include the semantic information in the initial training sample set and the corresponding erroneous corpus; obtain the attention weight of each vector sample in the encoded multidimensional vector samples to generate a fixed-length vector sample, and the fixed-length vector sample includes the semantic information of each sample in the initial training sample set and the corresponding erroneous corpus; decode the fixed-length vector sample to obtain the decoded target sequence sample; and train and obtain the text error correction model based on the decoded target sequence sample.
[0020] In a third aspect, an embodiment of the present application provides an electronic device comprising: a processor, a storage medium and a bus, wherein the storage medium stores machine-readable instructions executable by the processor. When the electronic device is running, the processor and the storage medium communicate through the bus, and the processor executes the machine-readable instructions to perform the steps of the text error correction model training method of the first aspect mentioned above.
[0021] In a fourth aspect, an embodiment of the present application provides a storage medium having a computer program stored thereon. When the computer program is executed by a processor, steps of the text error correction model training method of the first aspect are executed.
[0022] The beneficial effects of this application are:
[0023] In a text error correction model training method, device, electronic device and storage medium provided in an embodiment of the present application, an initial training sample set is obtained, the initial training sample set includes multiple standard corpora, and preset transformation rules are used to transform elements in each standard corpus to obtain multiple transformed erroneous corpora and error types corresponding to each erroneous corpus. Then, the erroneous corpora can be self-labeled according to the error type, thereby reducing the work of manual labeling. When a text error correction model is obtained by training based on the initial training sample set and the corresponding erroneous corpora, the training efficiency of the text error correction model can be improved. In addition, by performing transformation according to preset transformation rules, the error types can also be labeled more accurately, thereby improving the accuracy of the model. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0025] Figure 1 A flowchart of a text error correction model training method provided in an embodiment of the present application;
[0026] Figure 2 A flowchart of another text error correction model training method provided in an embodiment of the present application;
[0027] Figure 3 A flowchart of another text error correction model training method provided in an embodiment of the present application;
[0028] Figure 4 A structural diagram of a text error correction model provided in an embodiment of the present application;
[0029] Figure 5A flowchart of another text error correction model training method provided in an embodiment of the present application;
[0030] Figure 6 A flowchart of a text error correction model training method provided in an embodiment of the present application;
[0031] Figure 7 A flowchart of another text error correction model training method provided in an embodiment of the present application;
[0032] Figure 8 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0033] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various different configurations.
[0034] Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the present application for which protection is sought, but merely represents selected embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.
[0035] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.
[0036] Figure 1 A flowchart of a text error correction model training method provided in an embodiment of the present application, the execution subject of the method can be a computer, server, processor, mobile terminal or other device that can perform data processing, such as Figure 1 As shown, the method includes:
[0037] S101, obtaining an initial training sample set, where the initial training sample set includes a plurality of standard corpora.
[0038] Among them, the standard corpus is the corpus that the user considers correct, which can be a long / short sentence, a phrase, a paragraph of text, etc. The standard corpus can be obtained by crawling various web pages (web) through various data crawling methods (for example, crawlers, etc.), or it can be a standard corpus written by humans. Of course, this application does not limit the acquisition method here, and the standard corpus in the relevant scenario can be obtained according to the actual application scenario. For example, when the application scenario is a dining scenario, the relevant standard corpus in the dining scenario is obtained.
[0039] S102: using preset transformation rules to transform elements in each standard corpus, and obtaining a plurality of transformed erroneous corpora and error types corresponding to each erroneous corpus.
[0040] Among them, an element can refer to the smallest divisible unit in the corpus, such as a word, character, phrase, letter, number, etc.
[0041] The preset transformation rules are used to transform multiple standard corpora in the initial training sample set. Since the transformation operation of the elements in each standard corpus is known when the transformation is performed, when multiple transformed erroneous corpora are obtained, whether the erroneous corpora have errors, and the corresponding error type can be known according to the preset transformation rules, and then each erroneous corpus can be automatically annotated to mark the existence of errors and the type of errors, eliminating the need for manual annotation of training samples and improving annotation efficiency. Of course, it should be noted that according to the setting of the preset transformation rules, in addition to the above-mentioned error types, the error position information of the elements in each erroneous corpus can also be obtained, and this application is not limited here.
[0042] S103: training a text error correction model based on the initial training sample set and the corresponding erroneous corpus.
[0043] After obtaining the above-mentioned erroneous corpus, the initial training sample set and the corresponding erroneous corpus can be used as the entire training sample set to train a text error correction model, so that the trained text error correction model can be used to correct the text to be corrected.
[0044] To summarize, in the text error correction model training method provided in the embodiment of the present application, an initial training sample set is obtained, the initial training sample set includes multiple standard corpora, and preset transformation rules are used to transform the elements in each standard corpus to obtain multiple transformed erroneous corpora and the error type corresponding to each erroneous corpus. Then, the erroneous corpora can be self-labeled according to the error type, thereby reducing the work of manual labeling. When the text error correction model is trained and obtained according to the initial training sample set and the corresponding erroneous corpora, the training efficiency of the text error correction model can be improved. In addition, by transforming according to preset transformation rules, the error type can also be labeled more accurately, thereby improving the accuracy of the model.
[0045] Optionally, the above-mentioned elements in each standard corpus are transformed using a preset transformation rule to obtain a plurality of transformed incorrect corpora and the corresponding error types of each incorrect corpus, including transforming the elements in each standard corpus using one or more of the following preset transformation rules to obtain a plurality of transformed incorrect corpora and the corresponding error types of each incorrect corpus:
[0046] Obtain replaceable elements whose approximation degrees to the elements in the standard corpus meet preset conditions using a preset corpus, and replace the elements in the standard corpus with the replaceable elements; delete one or more elements in the standard corpus; insert one or more elements in the standard corpus; adjust the order of the elements in the standard corpus.
[0047] For the replacement operation, each element in the standard corpus can correspond to a preset corpus, and the preset corpus can include a plurality of replaceable elements that are similar in syllable or glyph to the element. Each replaceable element can correspond to an approximation degree, and the approximation degree can represent the similarity between the element and the replaceable element. When performing the replacement, the element in the standard corpus can be replaced according to the replaceable element whose approximation degree meets the preset conditions, that is, the element in the standard corpus is replaced with the replaceable element.
[0048] For example, if the element in the standard corpus is "朗" (lang), optionally, the corresponding preset corpus can include the following replaceable elements such as "郎" (lang), "浪" (lang), "琅" (lang), etc. The approximation degrees corresponding to each replaceable element can be 80%, 60%, and 40% respectively. Then, when performing the replacement operation, if the preset condition is 70%, the replaceable element "郎" (lang) can be used to replace the element "朗" (lang) in the standard corpus. Of course, word replacement or sentence replacement can also be performed to obtain the replaced incorrect corpus, which can be selected according to actual applications. This application does not make any limitations here. Optionally, the replacement transformation rule can be set with reference to the user's input habits, etc., but not limited to this.
[0049] For the deletion transformation, each element or multiple elements can be randomly deleted, or deleted according to the deletion probability of each element in the standard corpus. This application does not make any limitations here.
[0050] For example, the standard corpus is "Today's weather is good". Optionally, when the deletion transformation is performed, the erroneous corpus that may be obtained may be "Today's weather is good", "Today's weather is good", "Today's weather is good". Of course, the present application is not limited here. According to the actual application scenario, corresponding deletions can be performed to obtain the transformed erroneous corpus. It should be noted that when each standard corpus is transformed, the erroneous corpus corresponding to each standard corpus may be one or more. For example, a standard corpus can be deleted in multiple ways to obtain multiple erroneous corpora after deletion. Of course, the present application does not limit the number here. According to actual needs, a corresponding number of erroneous corpora can be selected as training samples.
[0051] For insertion transformation, one or more elements may be inserted at any position in the standard corpus. Optionally, the insertion transformation rule may be set with reference to the user's input habits, usage habits, etc., but is not limited thereto.
[0052] For example, if the standard corpus is "I like traveling", then after the insertion transformation, the incorrect corpus that may be obtained may be "I like traveling", "I like traveling", "I like traveling swimming", etc., but it is not limited to this.
[0053] The adjustment transformation may be an adjustment of the order of elements in the standard corpus, and the adjustment may be an adjustment of adjacent elements, spaced elements, etc. Optionally, the adjustment rules corresponding to the adjustment transformation may be adjusted according to the user's usage habits, input habits, etc.
[0054] For example, if the standard corpus is "I like traveling", then after adjustment and transformation, the erroneous corpus that may be obtained may be "I like traveling", "I like traveling", etc., but it is not limited to this.
[0055] Optionally, deleting one or more elements in the standard corpus includes: for each element in the standard corpus, deleting one or more elements according to a first preset probability;
[0056] Optionally, each element in the standard corpus may correspond to a deletion probability. When deleting, the element may be deleted based on the deletion probability corresponding to each element and the first preset probability. For example, when deleting, if the deletion probability corresponding to an element is greater than the first preset probability, the element may be deleted, but this is not limited to this.
[0057] For example, the standard corpus is "Today's weather is nice", where the deletion probabilities of each element are 20%, 60%, 70%, 30%, 45%, 40%, and 45%, respectively. Optionally, if the first preset probability is 50%, then when performing the deletion transformation, the erroneous corpus that may be obtained may be: "Today's weather is nice", "Today's weather is nice", etc., but it is not limited to this. Different deletion methods can be set according to the actual application scenario to obtain the erroneous corpus after the deletion transformation.
[0058] Inserting one or more elements into the standard corpus includes: for each position between elements in the standard corpus, inserting elements at one or more positions according to a second preset probability;
[0059] Optionally, when performing the insertion transformation, one or more elements may be inserted between the elements, and the one or more elements may correspond to corresponding insertion probabilities. Optionally, when performing the insertion transformation, the insertion probability corresponding to a certain element may be compared with a second preset probability. If the insertion probability corresponding to a certain element is greater than the second preset probability, the element may be inserted into the element in the standard corpus, thereby obtaining the erroneous corpus after the insertion transformation.
[0060] For example, the standard corpus is "Today's weather is good", where the element "today" is taken as an example. Optionally, the elements inserted after the element "today" may include "after", "tomorrow", "day", "day and month", and the insertion probabilities corresponding to each inserted element are 80%, 70%, 60%, and 30% respectively. If the second preset probability is 50%, then after the insertion transformation, the erroneous corpus that may be obtained may be "The weather will be good the day after tomorrow", "The weather today and tomorrow will be good", "The weather today will be good", but not limited to this.
[0061] Adjusting the order of elements in the standard corpus includes: adjusting the order of any adjacent elements in the standard corpus according to a third preset probability.
[0062] Optionally, when performing an adjustment transformation, an adjustment probability may correspond to any adjacent elements in the standard corpus. Then, when performing the adjustment, the adjustment may be performed based on the adjustment probability corresponding to each element and the third preset probability. For example, when performing the adjustment, if the adjustment probability corresponding to an adjacent element is greater than the third preset probability, the adjacent element may be adjusted, and the order of the adjacent elements in the standard corpus may be adjusted, but this is not limited to this.
[0063] For example, the standard corpus is "I like traveling", the adjustment probability of replacing the adjacent element "I like" with "I like" is 20%, the adjustment probability of replacing the adjacent element "like" with "happy" is "80%", and the adjustment probability of replacing the adjacent element "travel" with "travel" is "60%". If the third preset probability is 50%, then after the adjustment and transformation, the erroneous corpus that may be obtained may be "I like traveling" or "I like travel", but is not limited to this.
[0064] Of course, it should be noted that, according to the actual application scenario, the methods for transforming the elements in each standard corpus are not limited to the above methods, and may also include other types of transformation methods.
[0065] In summary, through the above-mentioned preset transformation rules, the elements in each standard corpus are transformed to obtain multiple transformed erroneous corpora. Since it is known which transformation is performed during the transformation, the standard corpus can be recorded and automatically marked during the transformation process, or, after the transformation, each transformed erroneous corpus can be automatically marked according to the recorded transformation records. The marking includes but is not limited to whether there is an error, the type of error, the position of the erroneous element, etc., avoiding the process of manual marking, improving the efficiency of obtaining training samples, and thus improving the training efficiency of the text error correction model. In addition, by performing the transformation according to the preset transformation rules, the error type can also be marked more accurately, improving the accuracy of the model.
[0066] Of course, this application does not limit the application scenarios of the text correction model trained above. It can be used in an intelligent customer service system. The text correction model can be used to judge the text input by the user. Through the judgment, the user's intention can be accurately known, thereby improving the service experience. Figure 2 A flowchart of another text error correction model training method provided in an embodiment of the present application. Optionally, Figure 2 As shown, the above method also includes:
[0067] S201, obtaining a statement to be corrected.
[0068] The sentence to be corrected is a sentence that needs to be corrected, which can be a sentence manually typed by the user, converted by the user's voice, etc. This application does not limit this, and there can be multiple ways to obtain it according to the actual application scenario. Of course, this application does not limit the cause of the error in the sentence to be corrected, which can be a typo, wrong word order, wrong insertion, etc., but is not limited to this.
[0069] S202: Use a text error correction model to correct the sentence to be corrected, and output the corrected sentence.
[0070] The sentences to be corrected can be corrected through the text correction model, and the error elements in the corrected sentences can be corrected to output the corrected sentences. When the meaning of the sentences is obtained based on the corrected sentences, the meaning to be expressed can be clearly known, thereby improving the user experience.
[0071] Figure 3 A flowchart of another text error correction model training method provided in an embodiment of the present application is provided. Figure 4 A structural diagram of a text error correction model provided in an embodiment of the present application. Optionally, Figure 3 As shown, the above text error correction model is used to correct the error-corrected sentence, and the corrected sentence is output, including:
[0072] S301, mapping the sentence to be corrected to a multi-dimensional vector space to obtain a corresponding multi-dimensional vector.
[0073] Alternatively, if Figure 4 As shown in the figure, when performing error correction, the word embedding algorithm can be used to map the sentence to be corrected to a multidimensional vector space, and then obtain the multidimensional vector corresponding to the sentence to be corrected. Among them, word embedding is a vector representation of a word, and each word can be mapped to a vector, so that the similarity between individual words can be obtained by calculation, thereby effectively utilizing the information of semantic similarity. For example, for the sentence "ABACB FG", after the word embedding algorithm, the vector corresponding to A can be [0.1 0.6 -0.5], and the vector corresponding to B can be [-0.2 0.9 0.7]. According to this method, the sentence "ABACBFG" can be mapped to a multidimensional vector space to obtain the corresponding multidimensional vector.
[0074] S302: Encode the multidimensional vector to obtain an encoded multidimensional vector, where the encoded multidimensional vector includes semantic information in the sentence to be corrected.
[0075] Optionally, the encoding module in a sequence-to-sequence (seq2seq) model may be used to encode the multidimensional vector to obtain the encoded multidimensional vector, so that the encoded multidimensional vector may include contextual semantic information in the sentence to be corrected. Optionally, the encoding module may be implemented based on a neural network (Recurrent Neural Network RNN, RNN), but is not limited thereto.
[0076] S303, obtaining the attention weight of each vector in the encoded multidimensional vector, generating a vector of a fixed length, wherein the vector of the fixed length includes the semantic information of the entire sentence to be corrected.
[0077] Optionally, an attention mechanism can be added on the basis of the seq2seq model. The attention mechanism is used to obtain the attention weight of each vector in the encoded multidimensional vector to generate a fixed-length vector Sentence encoding. The fixed-length vector can include the semantic information of the entire sentence to be corrected. That is, the attention mechanism can fully obtain the semantic information of the context of the entire sentence to be corrected, so that the information of the entire sentence can be effectively utilized, making the correction more accurate and improving the correction ability.
[0078] Among them, since the encoding process may be a "lossy information compression" process, taking the encoding module as an example, when the encoding module is encoding, if the amount of information is larger, the loss of information caused by the process of converting the vector will be greater. At the same time, as the sequence length increases after encoding, it means that the sequence in the time dimension is very long, and the RNN model will also have gradient diffusion, which makes it impossible to directly pay attention to more details of the input information during decoding. The present application can solve this problem by introducing the attention mechanism, that is, it can effectively utilize the information of the entire sentence to make error correction more accurate.
[0079] S304: Decode the fixed-length vector to obtain a decoded target sequence.
[0080] Optionally, a decoding module in a seq2seq model may be used to decode the fixed-length vector to generate a decoded target sequence. Optionally, the decoding module may be implemented based on an RNN.
[0081] S305: Generate an error-corrected sentence according to the decoded target sequence.
[0082] After obtaining the target sequence after decoding, the corrected sentence can be obtained according to the target sequence. Since the information of the entire sentence is effectively used when correcting the error, the corrected sentence can be more accurate.
[0083] Figure 5 A flowchart of another text error correction model training method provided in an embodiment of the present application. Optionally, Figure 5 As shown, the training of the text error correction model based on the initial training sample set and the corresponding erroneous corpus may include:
[0084] S401, respectively mapping the initial training sample set and the corresponding erroneous corpus to a multidimensional vector space to obtain corresponding multidimensional vector samples.
[0085] S402: Encode the multidimensional vector sample to obtain the encoded multidimensional vector sample, where the encoded multidimensional vector sample includes the initial training sample set and the semantic information in the corresponding erroneous corpus.
[0086] S403, obtaining the attention weight of each vector sample in the encoded multidimensional vector sample, generating a vector sample of fixed length, wherein the vector sample of fixed length includes the initial training sample set and the semantic information of each sample in the corresponding erroneous corpus.
[0087] S404: Decode the vector samples of the fixed length to obtain decoded target sequence samples.
[0088] S405: training a text error correction model based on the decoded target sequence samples.
[0089] That is, the initial training sample set and the corresponding erroneous corpus can be used as the entire training sample set. Based on the entire training sample set, optionally, the entire training sample set can be mapped to a multidimensional vector space based on a word embedding algorithm, and then a multidimensional vector sample corresponding to the entire training sample set can be obtained; the encoding module in the seq2seq model is used to encode the multidimensional vector sample to obtain the encoded multidimensional vector sample; an attention mechanism is added to the seq2seq model, and the attention mechanism is used to obtain the attention weight of each vector sample in the encoded multidimensional vector sample to generate a vector sample of a fixed length; the deocding decoding module in the seq2seq model is used to decode the vector sample of the fixed length to generate a decoded target sequence sample, and then according to the target training sample, a text error correction model can be trained and obtained.
[0090] Figure 6 The following is a flowchart of a text error correction model training method provided in an embodiment of the present application. The basic principle and technical effects of the device are the same as those of the corresponding method embodiment described above. For the sake of brief description, the parts not mentioned in this embodiment can be referred to the corresponding contents in the method embodiment. Figure 6 As shown, the device includes: a first acquisition module 110, a transformation module 120 and a training module 130.
[0091] The first acquisition module 110 is used to acquire an initial training sample set, which includes multiple standard corpora; the transformation module 120 is used to transform the elements in each standard corpus using a preset transformation rule to obtain multiple transformed erroneous corpora and the error type corresponding to each erroneous corpus; the training module 130 is used to train and acquire a text error correction model based on the initial training sample set and the corresponding erroneous corpora.
[0092] Optionally, the above-mentioned transformation module 120 is specifically used to transform the elements in each standard corpus using one or more of the following preset transformation rules to obtain multiple transformed erroneous corpora and the error type corresponding to each erroneous corpus: using a preset corpus to obtain replaceable elements whose similarity to the elements in the standard corpus meets preset conditions, and using the replaceable elements to replace the elements in the standard corpus; deleting one or more elements in the standard corpus; inserting one or more elements in the standard corpus; adjusting the order of elements in the standard corpus.
[0093] Optionally, the above-mentioned transformation module 120 is specifically used to delete one or more elements for each element in the standard corpus according to a first preset probability; insert elements at one or more positions for each position between elements in the standard corpus according to a second preset probability; and adjust the order of any adjacent elements in the standard corpus according to a third preset probability.
[0094] Figure 7 A flowchart of another text error correction model training method provided in an embodiment of the present application. Optionally, Figure 7 As shown, the above-mentioned device also includes: a second acquisition module 140 and an error correction module 150; the second acquisition module 140 is specifically used to obtain the sentence to be corrected; the error correction module 150 is specifically used to correct the sentence to be corrected using a text error correction model and output the corrected sentence.
[0095] Optionally, the above-mentioned error correction module 150 is specifically used to map the sentence to be corrected to a multidimensional vector space to obtain a corresponding multidimensional vector; encode the multidimensional vector to obtain an encoded multidimensional vector, and the encoded multidimensional vector includes semantic information in the sentence to be corrected; obtain the attention weight of each vector in the encoded multidimensional vector to generate a vector of a fixed length, and the vector of a fixed length includes the semantic information of the entire sentence to be corrected; decode the fixed-length vector to obtain a decoded target sequence; and generate a corrected sentence according to the decoded target sequence.
[0096] Optionally, the above-mentioned training module 130 is specifically used to map the initial training sample set and the corresponding erroneous corpus to a multidimensional vector space to obtain corresponding multidimensional vector samples; encode the multidimensional vector samples to obtain encoded multidimensional vector samples, and the encoded multidimensional vector samples include the semantic information in the initial training sample set and the corresponding erroneous corpus; obtain the attention weight of each vector sample in the encoded multidimensional vector samples to generate a fixed-length vector sample, and the fixed-length vector sample includes the semantic information of each sample in the initial training sample set and the corresponding erroneous corpus; decode the fixed-length vector sample to obtain the decoded target sequence sample; and train and obtain the text error correction model based on the decoded target sequence sample.
[0097] The above-mentioned device is used to execute the method provided by the aforementioned embodiment, and its implementation principle and technical effect are similar, which will not be repeated here.
[0098] The above modules may be one or more integrated circuits configured to implement the above methods, such as one or more application specific integrated circuits (ASIC), or one or more microprocessors (DSP), or one or more field programmable gate arrays (FPGA). For another example, when a module is implemented in the form of a processing element scheduling program code, the processing element may be a general-purpose processor, such as a central processing unit (CPU) or other processor that can call program code. For another example, these modules may be integrated together and implemented in the form of a system-on-a-chip (SOC).
[0099] Figure 8 This is a schematic diagram of an electronic device structure provided in an embodiment of the present application. Figure 8 As shown, the electronic device may include: a processor 210, a storage medium 220 and a bus 230, the storage medium 220 stores machine-readable instructions executable by the processor 210, when the electronic device is running, the processor 210 and the storage medium 220 communicate through the bus 230, and the processor 210 executes the machine-readable instructions to perform the steps of the above method embodiment. The specific implementation method and technical effect are similar and will not be repeated here.
[0100] Optionally, the present application further provides a storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the above method embodiment are executed. The specific implementation method and technical effect are similar and will not be repeated here.
[0101] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the 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.
[0102] 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.
[0103] 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 hardware plus software functional units.
[0104] The above-mentioned integrated unit implemented in the form of a software functional unit can be stored in a computer-readable storage medium. The above-mentioned software functional unit is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor (English: processor) to perform some steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (English: Read-Only Memory, abbreviated: ROM), random access memory (English: Random Access Memory, abbreviated: RAM), disk or optical disk and other media that can store program codes.
[0105] It should be noted that, in this article, 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 terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0106] The above description is only the preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and transformations. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application. It should be noted that similar numbers and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. The above description is only the preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and transformations. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application.
Claims
1. A text error correction model training method, characterized in that: include: Acquire an initial training sample set, wherein the initial training sample set includes a plurality of standard corpora; Using a preset transformation rule to transform the elements in each of the standard corpora to obtain a plurality of transformed erroneous corpora and error types and error position information corresponding to each of the erroneous corpora, including: using the following preset transformation rules to transform the elements in each of the standard corpora to obtain a plurality of transformed erroneous corpora and error types and error position information corresponding to each of the erroneous corpora: Using a preset corpus to obtain replaceable elements whose similarity to elements in the standard corpus meets preset conditions, and using the replaceable elements to replace elements in the standard corpus; Deleting one or more elements in the standard corpus; Inserting one or more elements into the standard corpus; Adjusting the order of elements in the standard corpus; According to the initial training sample set and the corresponding erroneous corpus, a text error correction model is trained and obtained, including: Mapping the initial training sample set and the corresponding erroneous corpus to a multidimensional vector space to obtain corresponding multidimensional vector samples; Encoding the multidimensional vector sample to obtain the encoded multidimensional vector sample, wherein the encoded multidimensional vector sample includes the initial training sample set and the corresponding semantic information in the erroneous corpus; Obtaining an attention weight of each vector sample in the encoded multidimensional vector sample, and generating a vector sample of a fixed length based on the attention weight and the encoded multidimensional vector sample, wherein the vector sample of the fixed length includes the initial training sample set and the semantic information of each sample in the corresponding erroneous corpus; The fixed-length vector sample is decoded to obtain a decoded target sequence sample; and the text error correction model is trained and obtained according to the decoded target sequence sample.
2. The method according to claim 1, characterized in that: The deleting one or more elements in the standard corpus includes: For each element in the standard corpus, delete one or more elements according to a first preset probability; The inserting one or more elements into the standard corpus includes: For each inter-element position in the standard corpus, inserting an element at one or more positions according to a second preset probability; The adjusting the order of elements in the standard corpus includes: For any adjacent elements in the standard corpus, the order is adjusted according to a third preset probability.
3. The method according to claim 1, characterized in that: The method further comprises: Get the statement to be corrected; The text error correction model is used to correct the sentence to be corrected, and the corrected sentence is output.
4. The method according to claim 3, characterized in that: The step of using the text error correction model to correct the sentence to be corrected and outputting the corrected sentence includes: Mapping the sentence to be corrected to a multidimensional vector space to obtain a corresponding multidimensional vector; Encoding the multidimensional vector to obtain an encoded multidimensional vector, wherein the encoded multidimensional vector includes semantic information in the sentence to be corrected; Obtaining the attention weight of each vector in the encoded multidimensional vector to generate a vector of fixed length, wherein the vector of fixed length includes the semantic information of the entire sentence to be corrected; Decoding the fixed-length vector to obtain a decoded target sequence; Generate an error-corrected sentence based on the decoded target sequence.
5. A text error correction model training device, characterized in that: include: A first acquisition module, a transformation module and a training module; The first acquisition module is used to acquire an initial training sample set, wherein the initial training sample set includes a plurality of standard corpora; The transformation module is used to transform the elements in each of the standard corpora using a preset transformation rule to obtain a plurality of transformed erroneous corpora and error type and error position information corresponding to each of the erroneous corpora; The transformation module is further used to transform the elements in each of the standard corpora using a preset transformation rule to obtain a plurality of transformed erroneous corpora and error type and error position information corresponding to each of the erroneous corpora: Using a preset corpus to obtain replaceable elements whose similarity to elements in the standard corpus meets preset conditions, and using the replaceable elements to replace elements in the standard corpus; Deleting one or more elements in the standard corpus; Inserting one or more elements into the standard corpus; Adjusting the order of elements in the standard corpus; The training module is used to train and obtain a text error correction model based on the initial training sample set and the corresponding erroneous corpus, including: Mapping the initial training sample set and the corresponding erroneous corpus to a multidimensional vector space to obtain corresponding multidimensional vector samples; Encoding the multidimensional vector sample to obtain the encoded multidimensional vector sample, wherein the encoded multidimensional vector sample includes the initial training sample set and the corresponding semantic information in the erroneous corpus; Obtaining an attention weight of each vector sample in the encoded multidimensional vector sample, and generating a vector sample of a fixed length based on the attention weight and the encoded multidimensional vector sample, wherein the vector sample of the fixed length includes the initial training sample set and the semantic information of each sample in the corresponding erroneous corpus; The fixed-length vector sample is decoded to obtain a decoded target sequence sample; and the text error correction model is trained and obtained according to the decoded target sequence sample.
6. An electronic device, characterized in that: include: A processor, a storage medium and a bus, wherein the storage medium stores machine-readable instructions executable by the processor. When the electronic device is running, the processor communicates with the storage medium via the bus, and the processor executes the machine-readable instructions to perform the steps of the text error correction model training method as described in any one of claims 1-4.
7. A storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by the processor, the steps of the text error correction model training method as described in any one of claims 1 to 4 are executed.
