Data error correction method, device, equipment and storage medium based on BERT
By using the BERT-based mask language model to mask and sort abnormal data in fields such as question and answer robots, the problem of insufficient error correction accuracy is solved and a more efficient error correction effect is achieved.
Patent Information
- Application Number
- CN202110596473.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-05-28
- Publication Date
- 2024-08-27
- Estimated Expiration
- 2041-05-28
AI Technical Summary
The existing technology has insufficient error correction accuracy in fields such as question and answer robots, making it difficult to effectively correct input errors.
The BERT-based mask language model is used to mask abnormal data and generate candidate data sorting results to determine the final replacement data and improve error correction accuracy.
By sorting candidate data and accurately identifying and replacing abnormal data, error correction accuracy is significantly improved and the occurrence of error correction errors is reduced.
Smart Images

Figure CN113177405B
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a BERT-based data error correction method, device, equipment and storage medium. Background Art
[0002] With the rapid development of computer technology, technologies such as question-answering robots and dialogue systems are increasingly widely used in people's daily work or life. The input of these technologies is generally text or voice, and text input or voice input usually results in input errors. For example, for a question-answering robot, when a user inputs voice into the question-answering robot, the robot may make an error in recognizing the user's voice, which may result in a wrong word in the text finally input into the question-answering robot, or the user may enter a wrong word when the user inputs text into the question-answering robot. Therefore, in the field of error correction, how to improve the accuracy of error correction has become an urgent problem to be solved. Summary of the invention
[0003] The embodiments of the present application provide a BERT-based data error correction method, apparatus, device and storage medium. By implementing the above method, after obtaining the candidate data set corresponding to the abnormal data, the individual candidate data in the candidate data set can be sorted to determine the final replaceable data according to the sorting result, thereby improving the error correction accuracy.
[0004] In a first aspect, an embodiment of the present application discloses a data error correction method based on BERT, the method comprising:
[0005] Acquire source data to be corrected, identify abnormal data in the source data to be corrected, and determine a candidate data set corresponding to the abnormal data, wherein the candidate data set includes one or more candidate data;
[0006] Calling a BERT-based masked language model to perform mask processing on the abnormal data to obtain a candidate data ranking result corresponding to the abnormal data;
[0007] Determine replacement data corresponding to the abnormal data according to candidate data ranked first in the candidate data sorting result corresponding to the abnormal data;
[0008] The abnormal data is replaced according to the replacement data to obtain the target data of the source data to be corrected.
[0009] In a second aspect, an embodiment of the present application discloses a data error correction device, the device comprising:
[0010] An acquisition unit, configured to acquire source data to be corrected, identify abnormal data in the source data to be corrected, and determine a candidate data set corresponding to the abnormal data, wherein the candidate data set includes one or more candidate data;
[0011] A calling unit, configured to call a BERT-based masked language model to sort each candidate data in the candidate data set, and obtain a candidate data sorting result corresponding to the abnormal data;
[0012] a determining unit, configured to determine replacement data corresponding to the abnormal data according to candidate data ranked first in a ranking result of candidate data corresponding to the abnormal data;
[0013] A replacement unit is used to replace the abnormal data according to the replacement data to obtain target data of the source data to be corrected.
[0014] In a third aspect, an embodiment of the present application discloses a device, including a processor and a memory, wherein the memory is used to store a computer program, the computer program includes program instructions, and the processor is configured to call the program instructions to execute the method of the first aspect above.
[0015] In a fourth aspect, an embodiment of the present application discloses a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the processor executes the method of the first aspect.
[0016] In an embodiment of the present application, a device can obtain source data to be corrected to identify abnormal data in the source data to be corrected, and determine a candidate data set corresponding to the abnormal data, wherein the candidate data set includes one or more candidate data. Then, a masked language model based on BERT can be called to mask the abnormal data to obtain a candidate data sorting result corresponding to the abnormal data. Thus, the replacement data corresponding to the abnormal data can be determined based on the candidate data ranked first in the candidate data sorting result corresponding to the abnormal data. Further, the abnormal data can be replaced according to the replacement data to obtain the target data of the source data to be corrected. By implementing the above method, after obtaining the candidate data set corresponding to the abnormal data, each candidate data in the candidate data set can be sorted to determine the final replaceable word according to the sorting result, thereby improving the accuracy of error correction. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are 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.
[0018] Figure 1 It is a flowchart of a data error correction method based on BERT provided in an embodiment of the present application;
[0019] Figure 2 It is a flowchart of another BERT-based data error correction method provided in an embodiment of the present application;
[0020] Figure 3 It is a flowchart of another BERT-based data error correction method provided in an embodiment of the present application;
[0021] Figure 4 It is a flowchart of another BERT-based data error correction method provided in an embodiment of the present application;
[0022] Figure 5 It is a structural schematic diagram of a data error correction device provided in an embodiment of the present application;
[0023] Figure 6 It is a structural schematic diagram of a device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0024] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0025] See also Figure 1 , Figure 1 1 is a flow chart of a BERT-based data error correction method provided in an embodiment of the present application. The data error correction method described in this embodiment is applied to a device and can be executed by the device, wherein the device can be a server or a terminal. Figure 1 As shown, the data error correction method includes the following steps:
[0026] S101: Acquire source data to be corrected, identify abnormal data in the source data to be corrected, and determine a candidate data set corresponding to the abnormal data, wherein the candidate data set includes one or more candidate data.
[0027] In one implementation, the source data to be corrected may be obtained first. For example, the source data to be corrected may be a sentence. For example, a sentence input by a user in a question-answering robot may be obtained. The sentence may be a sentence input in text or a sentence input in voice and converted into text. After obtaining the source data to be corrected, the abnormal data in the source data to be corrected may be identified, and a candidate data set corresponding to the abnormal data may be obtained. After obtaining the candidate data, subsequent steps may be performed to sort each candidate data in the candidate data set, so as to determine replacement data for the abnormal data according to the candidate data sorting result. For example, if the source data to be corrected is a sentence, the abnormal data may refer to a wrong word in the sentence, and the candidate data set corresponding to the abnormal data may be a candidate word set, which may include one or more candidate words. Figure 2 FIG. 1 is a flow chart of another BERT-based data error correction method implemented in the present application. Figure 2 In the process, assuming that the source data to be corrected is a sentence to be corrected, the wrong word in the sentence to be corrected can be identified first, and after identifying the wrong word, the candidate word set corresponding to the wrong word can be determined, so that each candidate word in the candidate word set can be sorted to determine the replacement word for the wrong word according to the candidate word sorting result.
[0028] In one implementation, the specific implementation method of identifying abnormal data in the source data to be corrected and obtaining the candidate data set corresponding to the abnormal data is not limited in this application. For example, a deep neural network model can be used to identify abnormal data in the source data to be corrected and determine the candidate data set corresponding to the abnormal data. Among them, the deep neural network model can be, for example, a recurrent neural network (RNN) model, a conditional random field (CRF) model, a seq2seq (sequence to sequence) model, and other abnormal data identification models that can be used for abnormal data identification, and can also be other models, which are not limited in this application. It is understandable that when using the abnormal data recognition model for recognition, the abnormal data recognition model can be trained first to obtain the trained abnormal data recognition model, wherein the specific method of obtaining the training data set used for training the abnormal data recognition model can be as follows: a training data set for a target field can be collected, for example, the target field can be the field of education, the field of insurance, the field of academic seminars, etc., so that the trained abnormal data recognition model is for data error correction in the target field, then, when the abnormal data recognition model is applied to the target field and data error correction is implemented, the accuracy of abnormal data recognition can also be improved. Among them, the training data set can be a batch of relatively accurate training data, that is, the training data does not include abnormal data. After obtaining the training data set, the training data set can also be processed for abnormal data, and the training data set processed for abnormal data is the training data set used for training the abnormal data recognition model. Specifically, the abnormal data processing of the training data set can be after collecting the training data set, and then replace the correct data in the training data set with abnormal data with a random probability. For example, the training data set includes multiple training sentences. Assuming the random probability is 15%, 15% of the correct words in the training data set can be replaced by wrong words, where the replaced wrong words can be composed of homophones corresponding to the correct words and random wrong words. For example, 80% of the replaced wrong words are homophones corresponding to the correct words, and 20% are random wrong words. The training data set for the target field can also be obtained in other ways, which are not limited in this application.
[0029] S102: Calling a BERT-based masked language model to perform mask processing on the abnormal data to obtain a candidate data ranking result corresponding to the abnormal data.
[0030] In one implementation, Figure 2In the data error correction process shown, after obtaining the candidate data set, each candidate data in the candidate data set can be sorted to obtain the candidate data sorting result corresponding to the abnormal data. Specifically, the source data to be corrected can be input into the masked language model based on BERT to obtain the candidate data sorting result corresponding to the abnormal data according to the masked language model. The masked language model based on BERT is obtained by fine-tuning the initial masked language model according to the training data set of the target field. The target field can refer to a specific field, for example, the target field can be the field of education, the field of insurance, the field of academic seminars, etc. After obtaining the masked language model based on BERT, the masked language model based on BERT can be used to mask the abnormal data position corresponding to the abnormal data in the source data to be corrected to determine the probability of occurrence of each candidate data in the candidate data set at the abnormal data position. Then, after determining the probability of occurrence of each candidate data at the abnormal data position, the probability of occurrence of each candidate data in the candidate data set at the abnormal data position can be sorted in descending order, thereby obtaining the candidate data sorting result corresponding to the abnormal data.
[0031] S103: Determine replacement data corresponding to the abnormal data according to the candidate data ranked first in the ranking result of the candidate data corresponding to the abnormal data.
[0032] S104: Replace the abnormal data according to the replacement data to obtain target data of the source data to be corrected.
[0033] In step S103 and step S104, the candidate data ranked first in the candidate data sorting result of the abnormal data can be determined as the replacement data of the abnormal data, and the replacement data can be used to replace the abnormal data in the source data to be corrected to obtain the replaced source data to be corrected, and the replaced source data to be corrected is the target data of the source data to be corrected.
[0034] In one implementation, when correcting the source data to be corrected, the correct data in the source data to be corrected may be identified as abnormal data, that is, the correct data may be corrected later. Then, it can be considered to set some selection rules for replacement data. When the selection rules are met, the replacement data can be used to replace the abnormal data in the error correction statement. Specifically, the candidate data ranked first in the candidate data sorting result corresponding to the abnormal data can be first determined as the candidate replacement data for the abnormal data. After determining the candidate replacement data, it is detected whether the candidate replacement data meets the preset selection rules. When it is detected that the candidate replacement data meets the preset selection rules, the candidate replacement data can be determined as the replacement data corresponding to the abnormal data. And the replacement data is used to replace the abnormal data in the source data to be corrected to obtain the replaced source data to be corrected, and the replaced source data to be corrected is the target data.
[0035] In one implementation, the specific implementation of determining whether the candidate replacement data meets the preset selection rule can be described as follows: detecting whether the probability of occurrence of the candidate replacement data is greater than or equal to a preset probability threshold, and if it is detected that the probability of occurrence is greater than or equal to the preset probability threshold, it can be determined that the candidate replacement data meets the preset selection rule. The preset probability threshold can be preset.
[0036] In one implementation, a specific implementation method for determining whether the detected candidate replacement data satisfies the preset selection rule can be described as follows. The confidence of the abnormal data can be first determined based on the confidence set, wherein the method for determining the confidence of the abnormal data can refer to the above description and will not be repeated here. After determining the confidence of the abnormal data, it can be detected whether the difference between the probability of occurrence of the candidate replacement data and the confidence of the abnormal data is greater than or equal to a preset threshold. When it is detected that the difference between the probability of occurrence of the candidate replacement data and the confidence of the abnormal data is greater than or equal to the preset threshold, it can be determined that the detected candidate replacement data satisfies the preset selection rule. Among them, the preset threshold can be set in advance, and the larger the preset threshold, the higher the accuracy of the candidate replacement data as the replacement data, that is, the higher the accuracy of the target data obtained by replacing the abnormal data with the replacement data.
[0037] In one implementation, the specific implementation method of determining that the detected candidate replacement data satisfies the preset selection rule can also be described as follows: the confidences in the confidence set can be sorted in descending order to obtain the confidence sorting result, the confidence (probability of occurrence) of the candidate replacement data is determined to be in the first position of the confidence sorting result, and the confidence of the abnormal data is determined to be in the second position of the confidence sorting result. Among them, the method for determining the confidence of the abnormal data can refer to the above description and will not be repeated here. After determining the first position and the second position, it is detected whether the difference between the first position and the second position is greater than or equal to the preset position threshold, and when it is detected that the difference between the first position and the second position is greater than or equal to the preset position threshold, it can be determined that the detected candidate replacement data satisfies the preset selection rule. Among them, the preset position threshold can be pre-set, and when the preset position threshold is larger, the accuracy of the candidate replacement data as the replacement data is higher, that is, the accuracy of the target data obtained by replacing the abnormal data with the replacement data is higher.
[0038] Optionally, the specific implementation method of determining whether the detected candidate replacement data satisfies a preset selection rule may also include other methods, which are not limited in the present application.
[0039] In an embodiment of the present application, the device can obtain the source data to be corrected, identify the abnormal data in the source data to be corrected, and determine the candidate data set corresponding to the abnormal data, and the candidate data set may include one or more candidate data. Then, the masked language model based on BERT can be called to sort the candidate data in the candidate data set to obtain the candidate data sorting result corresponding to the abnormal data. And according to the candidate data ranked first in the candidate data sorting result corresponding to the abnormal data, the replacement data corresponding to the abnormal data is determined. Further, the abnormal data can be replaced according to the replacement data to obtain the target data of the source data to be corrected. By implementing the above method, after obtaining the candidate data set corresponding to the abnormal data, the probability of occurrence of each candidate data as the abnormal data position corresponding to the abnormal data can be determined, so as to sort the candidate data in the candidate data set according to the probability of occurrence, so that the final replaceable data can be determined according to the sorting result and the selection rule, thereby improving the accuracy of error correction.
[0040] See also Figure 3 , Figure 3 1 is a flow chart of another BERT-based data error correction method provided in an embodiment of the present application. The data error correction method described in this embodiment is applied to a device and can be executed by the device, wherein the device can be a server or a terminal. Figure 3 As shown, the data error correction method includes the following steps:
[0041] S301: Acquire source data to be corrected, identify abnormal data in the source data to be corrected, and determine a candidate data set corresponding to the abnormal data.
[0042] S302: Inputting the source data to be corrected into a BERT-based masked language model. The BERT-based masked language model is obtained by fine-tuning an initial masked language model according to a training data set of a target domain.
[0043] In one implementation, the initial mask language model may be a BERT model. The BERT model in this application is a pre-trained language model that has adopted a large number of training samples and completed pre-training. Considering that the training samples used to train the pre-trained language model are generally corpora in fields such as news, if the pre-trained language model is used as the above-mentioned mask language model and the mask language model is used in other business fields, then the model effect of the mask language model may be relatively poor. For example, assuming that the application scenario of the present application is a dialogue system, and the dialogue system is for a specific field, such as the education field, the insurance field, the academic seminar field, etc. It can be seen that the training samples used by the pre-trained language model are sentences in fields such as news, rather than sentences for specific fields, that is, many words in specific fields are missing in the training samples. Then, in this case, it can be considered to use the training samples related to the application scenario to fine-tune the pre-trained language model to obtain the BERT model in different application scenarios. In this application, a training data set of the target field can be obtained, and then the initial mask language model can be fine-tuned using the training data set to obtain a mask language model based on BERT. The training data set may include one or more training data, and the number of all abnormal data in the training data set may be controlled within a relatively small range to ensure the accuracy of the masked language model. The target field may be the education field, insurance field, academic seminar field, etc. described above. Then, the training data set of the target field is data related to the target field, that is, the data related to the target field will also contain vocabulary of the target field.
[0044] S303: Use a BERT-based masked language model to perform mask processing on the abnormal data position corresponding to the abnormal data in the source data to be corrected, and determine the occurrence probability of each candidate data in the candidate data set at the abnormal data position.
[0045] In one implementation, a masked language model based on BERT can be used to mask the position of abnormal data in the source data to be corrected, so as to obtain a confidence set corresponding to all reference data in the reference dictionary. The confidence set may include the confidence corresponding to each reference data in the reference dictionary. Then, after obtaining the confidence set, the confidence of each candidate data in the candidate data set can be determined from the confidence set. The reference dictionary contains a large number of reference data, and all reference data have a fixed order, that is, the position of each reference data in the reference dictionary is fixed, and the order of the confidences in the confidence set corresponding to each reference data in the reference dictionary obtained by the masked language model based on BERT is also consistent with the above fixed order, that is, after obtaining the confidence set by the masked language model, the confidence corresponding to each reference data can be determined according to the position corresponding to each confidence in the confidence set and the position of each reference data in the reference dictionary. Then, the specific implementation method of using the mask language model to determine the probability of occurrence of each candidate data in the candidate data set at the abnormal data position can be described as follows: for any candidate data in the candidate data set, each reference data in the reference dictionary can be matched with the candidate data to determine the specified position of the matched reference data in the reference dictionary, and after determining the specified position, the target position corresponding to the specified position is determined from the confidence set, then the confidence at the target position in the confidence set can be determined as the confidence of the candidate data. Through the above method, the confidence of each candidate data can be determined in the confidence set, and after determining the confidence of each candidate data, the confidence of each candidate data can be determined as the probability of occurrence of each candidate data at the abnormal data position.
[0046] For example, if the source data to be corrected is a sentence, the abnormal data can be understood as the wrong word, the candidate data corresponding to the wrong word can be understood as the candidate word, and the reference data in the reference dictionary can be understood as the reference word. Assume that the reference dictionary A is [A1, A2, ..., A k , …, A n ], the confidence set p is [p1, p2, …, p k ,…,p n ], where A n Indicates the reference words in the reference dictionary A. The subscript n indicates the reference word A. n In the reference dictionary A, that is, A n At the nth position of the reference dictionary A, p n Represents each confidence level in the confidence level set p, and the subscript n represents the confidence level p n At the position of confidence set p, that is, p nAt the nth position of the confidence set p. It can be understood that each reference character in the reference dictionary corresponds one-to-one to each confidence in the confidence set, that is, the confidence corresponding to the reference character at a certain position in the reference dictionary is the confidence at that position in the confidence set. For example, for the reference character A2 in the reference dictionary, it can be known that the position of the reference character in the reference dictionary is the second position. Then, when determining the confidence of the reference character from the confidence set, it is only necessary to determine the confidence at the second position in the confidence set, and the confidence at the second position is the confidence corresponding to the reference character, that is, the confidence of the reference character A2 is p2. Then, for any candidate character in the candidate data set, assuming that the candidate character is A k , you can first change the candidate word to A k Match with each reference word in the reference dictionary A. According to the reference dictionary A, A can be determined. k The specified position in the reference dictionary A is the kth position. Then, after determining the specified position, the target position corresponding to the specified position is determined from the confidence set p. The target position is the kth position in the confidence set p. The confidence p at the kth position in the confidence set p is k Can be determined as candidate character A k , then candidate word A k The probability of appearing at the wrong word position is p k .
[0047] S304: sorting the occurrence probability of each candidate data in the candidate data set at the abnormal data position in descending order to obtain the candidate data sorting result corresponding to the abnormal data.
[0048] In one implementation, the probability of occurrence of each candidate data in the candidate data set at the abnormal data position can be sorted in descending order to obtain the candidate data sorting result of the occurrence probability. After determining the candidate data sorting result of the occurrence probability, the candidate data sorting result corresponding to the abnormal data can be determined according to the corresponding relationship between the candidate data and the occurrence probability.
[0049] For example, suppose there are 7 candidate data in the candidate data set, namely candidate data 1, candidate data 2, candidate data 3, candidate data 4, candidate data 5, candidate data 6, and candidate data 7. The probability of each candidate data appearing in the abnormal data position is 0.25, 0.85, 0.5, 0.75, 0.80, 0.4, and 0.3, respectively. Then, the above occurrence probabilities are sorted in descending order, and the occurrence probability sorting results can be obtained as 0.85, 0.80, 0.75, 0.5, 0.4, 0.3, and 0.25. Each occurrence probability in the occurrence probability sorting result is matched with its corresponding candidate data, that is, the candidate data sorting results corresponding to the abnormal data can be obtained as candidate data 2 (0.85), candidate data 5 (0.80), candidate data 4 (0.75), candidate data 3 (0.5), candidate data 6 (0.4), candidate data 7 (0.3), and candidate data 1 (0.25).
[0050] S305: Determine replacement data corresponding to the abnormal data according to the candidate data ranked first in the ranking result of the candidate data corresponding to the abnormal data.
[0051] S306: Replace the abnormal data according to the replacement data to obtain target data of the source data to be corrected.
[0052] In one implementation, if there are multiple abnormal data in the sentence to be recognized, then when using the masked language model to mask the abnormal data positions corresponding to the abnormal data in the source data to be corrected, it is necessary to use the masked language model to mask the abnormal data positions corresponding to the multiple abnormal data, that is, multiple masks will appear when using the masked language model for processing. If multiple masks are processed at the same time, that is, the replacement data of each abnormal data in the multiple abnormal data is determined according to the masked language model at the same time, the model processing efficiency and model accuracy of the masked language model may be reduced. Then, when the number of abnormal data is at least two, an iterative method can be used to correct the abnormal data in the sentence to be recognized, that is, one mask is processed in one iteration. Figure 4 FIG. 1 is a flow chart of another BERT-based data error correction method provided by the present application. Figure 4 It mainly shows the process of implementing error correction by iteratively treating abnormal data in the error correction source data, such as Figure 4In the process shown, a training data set of the target domain can be collected first, and then the initial mask language model can be fine-tuned using the training data set to obtain a mask language model based on BERT. Further, an iterative method is adopted, and the mask language model is used to correct multiple abnormal data in the sentence to be recognized. Specifically, the error correction order corresponding to each abnormal data in the at least two abnormal data can be determined according to the abnormal data position of the at least two abnormal data in the source data to be corrected, wherein the order of the abnormal data position in the source data to be corrected can be the error correction order corresponding to each abnormal data. Then, after the error correction order corresponding to each abnormal data, the sentence to be recognized can be input into the mask language model to obtain the replacement data corresponding to the first abnormal data, and the first abnormal data can be replaced according to the replacement data corresponding to the first abnormal data to obtain the first error correction source data of the source data to be corrected, wherein the first abnormal data is the abnormal data with the first error correction order as the first. After obtaining the first error correction source data, the first error correction source data can be input into the mask language model to obtain the replacement data corresponding to the second abnormal data, and the second abnormal data can be replaced according to the replacement data corresponding to the second abnormal data to obtain the second error correction source data of the source data to be corrected, wherein the second abnormal data is the abnormal data with the second correction order. When the second error correction source data does not include any abnormal data of at least two abnormal data, the second error correction source data can be determined as the target data. It can be seen from the above steps that the number of masks in the source data to be corrected will become less and less, because each iteration replaces one abnormal data in the source data to be corrected, until there is no mask in the source data to be corrected, that is, when there is no abnormal data, the iterative cycle can be stopped, then each abnormal data in the source data to be corrected is corrected.
[0053] The specific implementation of steps S301, S305-S306 can refer to the specific description of steps S101, S103-S104 in the above embodiment, which will not be repeated here.
[0054] In an embodiment of the present application, a device can obtain source data to be corrected to identify abnormal data in the source data to be corrected, and determine a candidate data set corresponding to the abnormal data, which may include one or more candidate data. Then, the source data to be corrected is input into a masked language model based on BERT, so as to use the masked language model to mask the abnormal data position corresponding to the abnormal data in the source data to be corrected, thereby determining the probability of occurrence of each candidate data in the candidate data set at the abnormal data position. Then, the probability of occurrence of each candidate data in the candidate data set at the abnormal data position can be sorted in descending order to obtain the candidate data sorting result corresponding to the abnormal data, and then, according to the candidate data ranked first in the candidate data sorting result corresponding to the abnormal data, the replacement data corresponding to the abnormal data is determined. Furthermore, the abnormal data can be replaced according to the replacement data to obtain the target data of the source data to be corrected. By implementing the above method, after obtaining the candidate data set corresponding to the abnormal data, the probability of each candidate data being the abnormal data position corresponding to the abnormal data can be determined again, so as to sort the candidate data in the candidate data set according to the probability of occurrence, so that the final replaceable word can be determined according to the sorting result and the selection rule, thereby improving the error correction accuracy.
[0055] See also Figure 5 , Figure 5 : is a structural diagram of a data error correction device provided in an embodiment of the present application, the data error correction device comprising:
[0056] The acquisition unit 501 is used to acquire source data to be corrected, identify abnormal data in the source data to be corrected, and determine a candidate data set corresponding to the abnormal data, wherein the candidate data set includes one or more candidate data;
[0057] A calling unit 502 is used to call a BERT-based masked language model to perform masking on the abnormal data to obtain a candidate data ranking result corresponding to the abnormal data;
[0058] A determining unit 503 is configured to determine replacement data corresponding to the abnormal data according to the candidate data ranked first in the candidate data sorting result corresponding to the abnormal data;
[0059] The replacement unit 504 is used to replace the abnormal data according to the replacement data to obtain the target data of the source data to be corrected.
[0060] In one implementation, the calling unit 502 is specifically configured to:
[0061] Inputting the source data to be corrected into a BERT-based masked language model, wherein the BERT-based masked language model is obtained by fine-tuning an initial masked language model of a training data set in a target domain;
[0062] Using the BERT-based masked language model, masking is performed on the abnormal data position corresponding to the abnormal data in the source data to be corrected, and the occurrence probability of each candidate data in the candidate data set at the abnormal data position is determined;
[0063] The occurrence probability of each candidate data in the candidate data set at the abnormal data position is sorted in descending order to obtain a candidate data sorting result corresponding to the abnormal data.
[0064] In one implementation, the calling unit 502 is specifically configured to:
[0065] Using the BERT-based masked language model to perform masking on the abnormal data position in the source data to be corrected, a confidence set corresponding to all reference data in the reference dictionary is obtained, wherein the confidence set includes the confidence corresponding to each reference data in the reference dictionary;
[0066] Determining the confidence of each candidate data in the candidate data set from the confidence set;
[0067] The confidence of each candidate data is determined as the probability of occurrence of each candidate data at the abnormal data position.
[0068] In one implementation, the calling unit 502 is specifically configured to:
[0069] For any candidate data in the candidate data set, matching each reference data in the reference dictionary with the candidate data;
[0070] Determining a specified position of the matched reference data in the reference dictionary;
[0071] A target position of the designated position in the confidence set is determined, and the confidence of the target position in the confidence set is determined as the confidence of the candidate data.
[0072] In one implementation, the determining unit 503 is specifically configured to:
[0073] Determine the candidate data ranked first in the candidate data sorting result corresponding to the abnormal data as the candidate replacement data for the abnormal data;
[0074] Detecting whether the candidate replacement data satisfies a preset selection rule;
[0075] When it is detected that the candidate replacement data satisfies the preset selection rule, the candidate replacement data is determined as the replacement data corresponding to the abnormal data.
[0076] In one implementation, the determining unit 503 is further configured to:
[0077] Determining the confidence of the abnormal data according to the confidence set;
[0078] Detecting whether a difference between the occurrence probability of the candidate replacement data and the confidence level of the abnormal data is greater than or equal to a preset threshold;
[0079] When it is detected that the difference between the occurrence probability of the candidate replacement data and the confidence of the abnormal data is greater than or equal to the preset threshold, it is determined that the candidate replacement data meets the preset selection rule.
[0080] In one implementation, the number of the abnormal data is at least two; the calling unit 502 is further configured to:
[0081] Determine, according to the abnormal data positions of the at least two abnormal data in the source data to be corrected, an error correction order corresponding to each of the at least two abnormal data;
[0082] The first abnormal data is replaced according to the replacement data corresponding to the first abnormal data to obtain the first error correction source data of the source data to be corrected, wherein the first abnormal data is the abnormal data with the first position in the error correction order;
[0083] Inputting the first error correction source data into the BERT-based mask language model to obtain replacement data corresponding to the second abnormal data, and replacing the second abnormal data according to the replacement data corresponding to the second abnormal data to obtain second error correction source data of the source data to be corrected, wherein the second abnormal data is abnormal data with the second error correction order being the second one;
[0084] When the second error correction source data does not include any one of the at least two abnormal data, the second error correction source data is determined as the target data.
[0085] It is understandable that the functions of the functional units of the data error correction device described in the embodiment of the present application can be based on Figure 1 or Figure 3 The specific implementation process of the method in the method embodiment can be referred to Figure 1 or Figure 3 The relevant description of the method embodiment will not be repeated here.
[0086] In the embodiment of the present application, the acquisition unit 501 acquires the source data to be corrected, identifies the abnormal data in the source data to be corrected, and determines the candidate data set corresponding to the abnormal data, wherein the candidate data set includes one or more candidate data; the calling unit 502 calls the mask language model based on BERT to perform mask processing on the abnormal data to obtain the candidate data sorting result corresponding to the abnormal data; the determination unit 503 determines the replacement data corresponding to the abnormal data according to the candidate data ranked first in the candidate data sorting result corresponding to the abnormal data; the replacement unit 504 replaces the abnormal data according to the replacement data to obtain the target data of the source data to be corrected. By implementing the above method, the accuracy of data error correction can be improved.
[0087] See also Figure 6 , Figure 6 6 is a schematic diagram of a device provided in an embodiment of the present application. The device includes: a processor 601, a memory 602, and a network interface 603. The processor 601, the memory 602, and the network interface 603 can exchange data.
[0088] The processor 601 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.
[0089] The memory 602 may include a read-only memory and a random access memory, and provide program instructions and data to the processor 601. A portion of the memory 602 may also include a random access memory. When the processor 601 calls the program instructions, it is used to execute:
[0090] Acquire source data to be corrected, identify abnormal data in the source data to be corrected, and determine a candidate data set corresponding to the abnormal data, wherein the candidate data set includes one or more candidate data;
[0091] Calling a BERT-based masked language model to perform mask processing on the abnormal data to obtain a candidate data ranking result corresponding to the abnormal data;
[0092] Determine replacement data corresponding to the abnormal data according to candidate data ranked first in the candidate data sorting result corresponding to the abnormal data;
[0093] The abnormal data is replaced according to the replacement data to obtain the target data of the source data to be corrected.
[0094] In one implementation, the processor 601 is specifically configured to:
[0095] Inputting the source data to be corrected into a BERT-based masked language model, wherein the BERT-based masked language model is obtained by fine-tuning an initial masked language model according to a training data set of a target domain;
[0096] Using the BERT-based masked language model, masking is performed on the abnormal data position corresponding to the abnormal data in the source data to be corrected, and the occurrence probability of each candidate data in the candidate data set at the abnormal data position is determined;
[0097] The occurrence probability of each candidate data in the candidate data set at the abnormal data position is sorted in descending order to obtain a candidate data sorting result corresponding to the abnormal data.
[0098] In one implementation, the processor 601 is specifically configured to:
[0099] Using the BERT-based masked language model to perform masking on the abnormal data position in the source data to be corrected, a confidence set corresponding to all reference data in the reference dictionary is obtained, wherein the confidence set includes the confidence corresponding to each reference data in the reference dictionary;
[0100] Determining the confidence of each candidate data in the candidate data set from the confidence set;
[0101] The confidence of each candidate data is determined as the probability of occurrence of each candidate data at the abnormal data position.
[0102] In one implementation, the processor 601 is specifically configured to:
[0103] For any candidate data in the candidate data set, matching each reference data in the reference dictionary with the candidate data;
[0104] Determining a specified position of the matched reference data in the reference dictionary;
[0105] A target position of the designated position in the confidence set is determined, and the confidence of the target position in the confidence set is determined as the confidence of the candidate data.
[0106] In one implementation, the processor 601 is specifically configured to:
[0107] Determine the candidate data ranked first in the candidate data sorting result corresponding to the abnormal data as the candidate replacement data for the abnormal data;
[0108] Detecting whether the candidate replacement data satisfies a preset selection rule;
[0109] When it is detected that the candidate replacement data satisfies the preset selection rule, the candidate replacement data is determined as the replacement data corresponding to the abnormal data.
[0110] In one implementation, the processor 601 is further configured to:
[0111] Determining the confidence of the abnormal data according to the confidence set;
[0112] Detecting whether a difference between the occurrence probability of the candidate replacement data and the confidence level of the abnormal data is greater than or equal to a preset threshold;
[0113] When it is detected that the difference between the occurrence probability of the candidate replacement data and the confidence of the abnormal data is greater than or equal to the preset threshold, it is determined that the candidate replacement data meets the preset selection rule.
[0114] In one implementation, the number of the abnormal data is at least two; the processor 601 is further configured to:
[0115] Determine, according to the abnormal data positions of the at least two abnormal data in the source data to be corrected, an error correction order corresponding to each of the at least two abnormal data;
[0116] The first abnormal data is replaced according to the replacement data corresponding to the first abnormal data to obtain the first error correction source data of the source data to be corrected, wherein the first abnormal data is the abnormal data with the first position in the error correction order;
[0117] Inputting the first error correction sentence into the BERT-based masked language model to obtain replacement data corresponding to the second abnormal data, and replacing the second abnormal data according to the replacement data corresponding to the second abnormal data to obtain second error correction source data of the source data to be corrected, wherein the second abnormal data is abnormal data with the second correction order being the second one;
[0118] When the second error correction source data does not include any one of the at least two abnormal data, the second error correction source data is determined as the target data.
[0119] In a specific implementation, the processor 601 and the memory 602 described in the embodiment of the present application can execute the embodiment of the present application. Figure 1 or Figure 3 The implementation method described in the data error correction method provided can also be implemented in the embodiment of the present application Figure 5 The implementation method of the described data error correction device will not be described in detail here.
[0120] In an embodiment of the present application, the processor 601 can obtain source data to be corrected, identify abnormal data in the source data to be corrected, and determine a candidate data set corresponding to the abnormal data, wherein the candidate data set includes one or more candidate data; call a mask language model based on BERT to perform mask processing on the abnormal data to obtain a candidate data sorting result corresponding to the abnormal data; determine replacement data corresponding to the abnormal data according to the candidate data ranked first in the candidate data sorting result corresponding to the abnormal data; replace the abnormal data according to the replacement data to obtain the target data of the source data to be corrected. By implementing the above method, the accuracy of data error correction can be improved.
[0121] The present application also provides a computer-readable storage medium in which program instructions are stored. When the program is executed, it may include: Figure 1 or Figure 3 Part or all of the steps of the data error correction method in the corresponding embodiment.
[0122] It should be noted that, for the above-mentioned various method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that this application is not limited by the order of the actions described, because according to this application, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by this application.
[0123] A person skilled in the art may understand that all or part of the steps in the various methods of the above embodiments may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, and the storage medium may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0124] It should be emphasized that in order to further ensure the privacy and security of the above data, the above data can also be stored in a node of a blockchain. Among them, the blockchain referred to in this application is a new application mode of computer technologies such as distributed data storage, point-to-point transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. The blockchain can include the blockchain underlying platform, the platform product service layer, and the application service layer.
[0125] The above is a detailed introduction to a BERT-based data error correction method, device, equipment and storage medium provided in the embodiments of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for general technical personnel in this field, according to the ideas of the present application, there will be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A data error correction method based on BERT, characterized in that: include: Acquire source data to be corrected, identify abnormal data in the source data to be corrected, and determine a candidate data set corresponding to the abnormal data, wherein the candidate data set includes one or more candidate data; Calling a BERT-based mask language model to perform mask processing on the abnormal data to obtain a candidate data ranking result corresponding to the abnormal data; the result obtained by the mask processing also includes a confidence set corresponding to all reference data in the reference dictionary, and the confidence set includes the confidence corresponding to each reference data in the reference dictionary; The position of each reference data in the reference dictionary is fixed, and the position of the confidence of any reference data in the reference dictionary in the confidence set is consistent with the position of any reference data in the reference dictionary; The candidate data ranking result is determined based on the probability of each candidate data appearing at the abnormal data position, and the probability of any candidate data appearing at the abnormal data position is the confidence of any candidate data; Determine replacement data corresponding to the abnormal data according to candidate data ranked first in the candidate data sorting result corresponding to the abnormal data; The determining the replacement data corresponding to the abnormal data according to the candidate data ranked first in the candidate data sorting result corresponding to the abnormal data comprises: determining the candidate data ranked first in the candidate data sorting result corresponding to the abnormal data as the candidate replacement data for the abnormal data; detecting whether the candidate replacement data satisfies a preset selection rule; when it is detected that the candidate replacement data satisfies the preset selection rule, determining the candidate replacement data as the replacement data corresponding to the abnormal data; the detecting whether the candidate replacement data satisfies the preset selection rule comprises: detecting whether the occurrence probability of the candidate replacement data is greater than or equal to a preset probability threshold, or detecting whether the difference between the occurrence probability of the candidate replacement data and the confidence of the abnormal data is greater than or equal to a preset threshold, or detecting whether the difference between a first position and a second position is greater than or equal to a preset position threshold, the first position being the position of the confidence of the candidate replacement data in the confidence sorting result, and the second position being the position of the confidence of the abnormal data in the confidence sorting result; the confidence sorting result is obtained by sorting the confidences in the confidence set in descending order; The abnormal data is replaced according to the replacement data to obtain the target data of the source data to be corrected.
2. The method according to claim 1, characterized in that The calling of the BERT-based masked language model to perform mask processing on the abnormal data to obtain a candidate data ranking result corresponding to the abnormal data includes: Inputting the source data to be corrected into a BERT-based masked language model, wherein the BERT-based masked language model is obtained by fine-tuning an initial masked language model according to a training data set of a target domain; Using the BERT-based masked language model, masking is performed on the abnormal data position corresponding to the abnormal data in the source data to be corrected, and the occurrence probability of each candidate data in the candidate data set at the abnormal data position is determined; The occurrence probability of each candidate data in the candidate data set at the abnormal data position is sorted in descending order to obtain a candidate data sorting result corresponding to the abnormal data.
3. The method according to claim 2, characterized in that The using the BERT-based mask language model to perform masking on the abnormal data position in the source data to be corrected, and determining the occurrence probability of each candidate data in the candidate data set at the abnormal data position, includes: Using the BERT-based masked language model to perform masking on the abnormal data position in the source data to be corrected, a confidence set corresponding to all reference data in the reference dictionary is obtained, wherein the confidence set includes the confidence corresponding to each reference data in the reference dictionary; Determining the confidence of each candidate data in the candidate data set from the confidence set; The confidence of each candidate data is determined as the probability of occurrence of each candidate data at the abnormal data position.
4. The method according to claim 3, characterized in that: The step of determining the confidence of each candidate data in the candidate data set from the confidence set includes: For any candidate data in the candidate data set, matching each reference data in the reference dictionary with the candidate data; Determining a specified position of the matched reference data in the reference dictionary; A target position of the designated position in the confidence set is determined, and the confidence of the target position in the confidence set is determined as the confidence of the candidate data.
5. The method according to claim 1, characterized in that Before detecting that the candidate replacement data satisfies the preset selection rule, the method further includes: Determining the confidence of the abnormal data according to the confidence set; Detecting whether a difference between the occurrence probability of the candidate replacement data and the confidence level of the abnormal data is greater than or equal to a preset threshold; When it is detected that the difference between the occurrence probability of the candidate replacement data and the confidence of the abnormal data is greater than or equal to the preset threshold, it is determined that the candidate replacement data meets the preset selection rule.
6. The method according to claim 1, characterized in that The number of abnormal data is at least two; the method further comprises: Determine, according to the abnormal data positions of the at least two abnormal data in the source data to be corrected, an error correction order corresponding to each of the at least two abnormal data; The replacing the abnormal data according to the replacement data to obtain the target data of the source data to be corrected includes: The first abnormal data is replaced according to the replacement data corresponding to the first abnormal data to obtain the first error correction source data of the source data to be corrected, wherein the first abnormal data is the abnormal data with the first position in the error correction order; Inputting the first error correction source data into the BERT-based mask language model to obtain replacement data corresponding to the second abnormal data, and replacing the second abnormal data according to the replacement data corresponding to the second abnormal data to obtain second error correction source data of the source data to be corrected, wherein the second abnormal data is abnormal data with the second error correction order being the second one; When the second error correction source data does not include any one of the at least two abnormal data, the second error correction source data is determined as the target data.
7. A data error correction device, characterized in that: include: An acquisition unit, configured to acquire source data to be corrected, identify abnormal data in the source data to be corrected, and determine a candidate data set corresponding to the abnormal data, wherein the candidate data set includes one or more candidate data; A calling unit, configured to call a BERT-based masked language model to perform mask processing on the abnormal data to obtain a candidate data ranking result corresponding to the abnormal data; the result obtained by the mask processing also includes a confidence set corresponding to all reference data in a reference dictionary, and the confidence set includes a confidence corresponding to each reference data in the reference dictionary; The position of each reference data in the reference dictionary is fixed, and the position of the confidence of any reference data in the reference dictionary in the confidence set is consistent with the position of any reference data in the reference dictionary; The candidate data ranking result is determined based on the occurrence probability of each candidate data, and the occurrence probability of any candidate data is the confidence level of any candidate data; a determining unit, configured to determine replacement data corresponding to the abnormal data according to candidate data ranked first in a ranking result of candidate data corresponding to the abnormal data; The determining the replacement data corresponding to the abnormal data according to the candidate data ranked first in the candidate data sorting result corresponding to the abnormal data comprises: determining the candidate data ranked first in the candidate data sorting result corresponding to the abnormal data as the candidate replacement data for the abnormal data; detecting whether the candidate replacement data satisfies a preset selection rule; when it is detected that the candidate replacement data satisfies the preset selection rule, determining the candidate replacement data as the replacement data corresponding to the abnormal data; the detecting whether the candidate replacement data satisfies the preset selection rule comprises: detecting whether the occurrence probability of the candidate replacement data is greater than or equal to a preset probability threshold, or detecting whether the difference between the occurrence probability of the candidate replacement data and the confidence of the abnormal data is greater than or equal to a preset threshold, or detecting whether the difference between a first position and a second position is greater than or equal to a preset position threshold, the first position being the position of the confidence of the candidate replacement data in the confidence sorting result, and the second position being the position of the confidence of the abnormal data in the confidence sorting result; the confidence sorting result is obtained by sorting the confidences in the confidence set in descending order; A replacement unit is used to replace the abnormal data according to the replacement data to obtain a target sentence of the source data to be corrected.
8. A device, characterized in that The method comprises a processor and a memory, wherein the memory is used to store a computer program, the computer program comprises program instructions, and the processor is configured to call the program instructions to execute the method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the processor is caused to perform the method according to any one of claims 1 to 6.
