Text data processing method, device, computer equipment and storage medium
Through multiple splitting and model training of text data sets, the text data is automatically cleaned using the difference between predicted labels and label information, which solves the problems of low cleaning quality and low efficiency in the existing technology and improves the quality inspection of training data. and cleaning speed ensure the accuracy of the model.
Patent Information
- Application Number
- CN202110381793.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-04-09
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2041-04-09
AI Technical Summary
In the existing technology, the cleaning quality and efficiency of training corpus are low, resulting in insufficient model generalization ability, rule cleaning is prone to excessive cleaning, and manual cleaning is time-consuming and inefficient.
By obtaining the text data set, splitting it into multiple training sets and test sets, training multiple recognition models, and using these models to obtain predicted labels for the test set, the text data is processed based on the difference between the predicted labels and label information. Automatically filter out incorrect annotations to improve cleaning speed and quality.
It achieves fast and efficient text data cleaning, ensures the quality of training data, avoids model inaccuracies due to incorrect labeling, and provides guarantee for subsequent model training.
Smart Images

Figure CN113807096B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of natural language processing, and in particular to a method, apparatus, computer device and storage medium for processing text data. Background Art
[0002] In the field of natural language processing, most tasks require corresponding training corpus to train the model, such as the Named Entity Recognition (NER) task. However, the quality of the training corpus is an important factor affecting the model effect. Therefore, in practical applications, the original training corpus needs to be quality checked and cleaned to improve the model effect.
[0003] At present, the cleaning of training corpus is mainly achieved through two methods: rule cleaning and manual quality inspection cleaning. Among them, rule cleaning is to manually set cleaning rules according to the characteristics of the training corpus to remove or verify low-quality training corpus. This method has low cleaning quality and will cause excessive cleaning, resulting in insufficient generalization ability of the model. The manual cleaning method is to manually clean the corpus one by one. This method is time-consuming and has low cleaning efficiency. Summary of the invention
[0004] The present application aims to solve one of the technical problems in the related art at least to some extent.
[0005] The present application proposes a text data processing method, apparatus, computer equipment and storage medium to realize automatic cleaning of annotated text data, by processing a text data set to obtain multiple training sets and corresponding multiple test sets, training multiple recognition models, and obtaining predicted labels for each training model to identify the corresponding test set, and then processing the text data according to the degree of difference between the predicted labels and the label information, which can quickly screen out incorrect annotations in the training text data, improve the speed and efficiency of quality inspection and cleaning of the training text data, and ensure the quality of text data cleaning, and try to avoid the problem of model inaccuracy caused by incorrectly annotated text data, provide a guarantee for the effect of subsequent model training, and solve the technical problems of low cleaning quality and excessive cleaning caused by rule cleaning methods and low cleaning efficiency caused by manual cleaning methods in the prior art.
[0006] The first embodiment of the present application proposes a method for processing text data, including:
[0007] Acquire a text data set, wherein the text data set includes a plurality of text data and label information corresponding to each text data;
[0008] Processing the text data set to obtain N training sets and corresponding N test sets, wherein the N training sets and the N test sets are different from each other, and the N test sets constitute the text data set, and N is an integer greater than 1;
[0009] Using the N training sets to train N recognition models respectively;
[0010] Using each of the recognition models respectively, recognize the text data in the corresponding test set to determine the predicted label corresponding to each of the text data in the text data set;
[0011] The text data in the text data set are processed according to the degree of difference between the predicted label corresponding to each of the text data and the label information.
[0012] The second aspect of the present application provides a text data processing device, including:
[0013] An acquisition module, used to acquire a text data set, wherein the text data set includes a plurality of text data and label information corresponding to each text data;
[0014] A splitting module, used for processing the text data set to obtain N training sets and corresponding N test sets, wherein the N training sets and the N test sets are different from each other, and the N test sets constitute the text data set, and N is an integer greater than 1;
[0015] A training module, used to train N recognition models respectively using the N training sets;
[0016] A recognition module, used to recognize the text data in the corresponding test set using each of the recognition models respectively, so as to determine the predicted label corresponding to each of the text data in the text data set;
[0017] The cleaning module is used to process the text data in the text data set according to the difference between the predicted label corresponding to each of the text data and the label information.
[0018] The third aspect embodiment of the present application proposes a computer device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, the text data processing method proposed in the first aspect embodiment of the present application is implemented.
[0019] The fourth aspect embodiment of the present application proposes a non-temporary computer-readable storage medium on which a computer program is stored, characterized in that when the program is executed by a processor, it implements the text data processing method proposed in the first aspect embodiment of the present application.
[0020] The fifth aspect embodiment of the present application proposes a computer program product. When the instructions in the computer program product are executed by a processor, the text data processing method proposed in the first aspect embodiment of the present application is performed.
[0021] The text data processing method, device, computer equipment and storage medium proposed in this application can produce the following beneficial effects:
[0022] By obtaining a text data set, the text data set includes multiple text data and label information corresponding to each text data, processing the text data set to obtain N training sets and corresponding N test sets, wherein the N training sets and the N test sets are different from each other, and the N test sets constitute the text data set, and N is an integer greater than 1, using the N training sets to train N recognition models respectively, and using each recognition model respectively, to recognize the text data in the corresponding test set to determine the predicted label corresponding to each text data in the text data set, and then processing the text data in the text data set according to the difference between the predicted label and the label information corresponding to each text data. Thus, by processing the text data set to obtain multiple training sets and corresponding multiple test sets, training multiple recognition models, and obtaining the predicted label that each training model recognizes for the corresponding test set, and then processing the text data according to the difference between the predicted label and the label information, it is possible to quickly screen out the wrong annotations in the training text data, improve the speed and efficiency of the quality inspection and cleaning of the training text data, and ensure the quality of the text data cleaning, and try to avoid the problem of model inaccuracy caused by the wrongly annotated text data, and provide a guarantee for the effect of subsequent model training.
[0023] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:
[0025] Figure 1 A flowchart of a method for processing text data provided in Example 1 of the present application;
[0026] Figure 2 This is an example diagram of the split results of multiple splits of the original text dataset;
[0027] Figure 3 A flowchart of a method for processing text data provided in Example 2 of the present application;
[0028] Figure 4A flowchart of a method for processing text data provided in Embodiment 3 of the present application;
[0029] Figure 5 A flowchart of a method for processing text data provided in Embodiment 4 of the present application;
[0030] Figure 6 A schematic diagram of the structure of a text data processing device provided in Embodiment 5 of the present application;
[0031] Figure 7 A schematic diagram of the structure of a text data processing device provided in Example 6 of the present application;
[0032] Figure 8 A schematic diagram of the structure of a text data processing device provided in Embodiment 7 of the present application;
[0033] Fig. 9 A schematic diagram of the structure of a text data processing device provided in Embodiment 8 of the present application;
[0034] Fig.10 A block diagram of an exemplary computer device suitable for implementing embodiments of the present application is shown. DETAILED DESCRIPTION
[0035] Embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present application, and should not be construed as limiting the present application.
[0036] The following describes the text data processing method, device, equipment and storage medium of the embodiments of the present application with reference to the accompanying drawings.
[0037] Figure 1 A flowchart of the text data processing method provided in Example 1 of the present application.
[0038] The embodiment of the present application takes the text data processing method as an example in which the text data processing device is configured. The text data processing device can be applied to any computer device so that the computer device can execute the text data processing function.
[0039] The computer device may be a personal computer (PC), a server, a cloud device, a mobile device, etc. The mobile device may be, for example, a mobile phone, a tablet computer, a personal digital assistant, a wearable device, etc.
[0040] like Figure 1 As shown, the text data processing method may include the following steps:
[0041] Step 101: Acquire a text data set, wherein the text data set includes a plurality of text data and label information corresponding to each text data.
[0042] The label information corresponding to each text data may be manually annotated when the text data is acquired to ensure the accuracy of the label information.
[0043] In this embodiment, multiple text data can be obtained from multiple ways to form a text data set. For example, a number of sentences containing named entities can be extracted from online articles and news content as text data to form a text data set, and the label information contained in the text data set is the named entity. The named entity can be one or more types of entity references such as person names, place names, institution names, company names, and organization names.
[0044] Step 102, processing the text data set to obtain N training sets and corresponding N test sets, wherein the N training sets and the N test sets are different from each other, and the N test sets constitute the text data set, and N is an integer greater than 1.
[0045] In an embodiment of the present application, the acquired text data set can be copied into multiple copies, and for each text data set, a splitting rule is used to split the text data set into a training set and a test set, wherein the splitting rules used for each text data set are different, so that the multiple training sets obtained by splitting are different from each other, and the multiple test sets obtained by splitting are also different from each other. In addition, in this embodiment, the splitting rule used should ensure that the multiple test sets obtained by splitting the text data set multiple times do not intersect with each other, and the sum of all test sets is equal to the original text data set.
[0046] As an example, assuming that the text data set contains ten text data, when splitting the text data set, the original text data set can be split five times, as follows: Figure 2 The order shown is split into training, validation, and test sets. Figure 2 In the figure, each rectangular box represents a piece of text data, where a white rectangular box represents training text data. All training text data belonging to the same text dataset constitute the training set corresponding to the text dataset, and the training set is used to train the recognition model; a black rectangular box represents verification text data. All verification text data belonging to the same text dataset constitute the verification set corresponding to the text dataset, and the verification set is used to verify the trained recognition model; a gray rectangular box represents test text data. All test text data belonging to the same text dataset constitute the test set corresponding to the text dataset, and the test set is used to obtain the prediction label. Figure 2It can be seen that all test sets obtained by multiple splits do not intersect with each other, and the sum of all test sets is equal to the original text dataset.
[0047] Step 103: Use the N training sets to train N recognition models respectively.
[0048] In an embodiment of the present application, after the text data set is split multiple times according to different splitting rules to obtain corresponding N training sets and N test sets, each training set can be used to train a corresponding recognition model. Thus, using the N training sets, N recognition models can be trained, and each training set corresponds to a recognition model.
[0049] Step 104 , using each recognition model to recognize the text data in the corresponding test set, so as to determine the predicted label corresponding to each text data in the text data set.
[0050] In the embodiment of the present application, after N training sets are used to train the corresponding N recognition models, each recognition model can be used to recognize the text data in the corresponding test set to obtain the predicted label of each text data in the test set by the recognition model. Among them, the predicted label of each text data can be expressed in probability, and the recognition model outputs the probability that the text data belongs to each label. The greater the probability, the greater the possibility that the text data belongs to the label.
[0051] Since a training set and a corresponding test set can be obtained after splitting the text data set once, and the N test sets obtained by multiple splits are different from each other, and the N test sets constitute the text data set, each recognition model is used to recognize the corresponding test set, and the prediction label corresponding to each text data in the original text data set can be obtained. In the embodiment of the present application, the text data set is split multiple times to obtain N training sets and N test sets, and multiple recognition models are trained, which ensures that each text data in the text data set can participate in the training of the model as training text data, and each text data can obtain a prediction result as test text data, thereby avoiding the problem of inaccurate model caused by incorrectly labeled samples as much as possible.
[0052] Step 105 , processing the text data in the text data set according to the degree of difference between the predicted label and the label information corresponding to each text data.
[0053] In this embodiment, after identifying the predicted label corresponding to each text data in the text data set, the degree of difference between the predicted label and the label information of the same text data can be determined based on the predicted label corresponding to each text data and the label information corresponding to the text data, and then the text data in the text data set can be processed according to the degree of difference, such as cleaning the text data in the text data set.
[0054] As an example, we can compare whether the predicted label and label information are consistent, determine the text data with inconsistent predicted label and label information as incorrectly labeled text data, and complete the cleaning of text data in the text data set. Furthermore, the determined incorrectly labeled text data can be manually verified and corrected. Since the number of incorrectly labeled text data is much smaller than the total text data, manual verification of incorrectly labeled text data can not only improve the verification and cleaning speed, but also ensure the quality of text data cleaning, providing a strong guarantee for the effect of subsequent model training.
[0055] The text data processing method of the embodiment of the present application obtains a text data set, which includes multiple text data and label information corresponding to each text data, processes the text data set to obtain N training sets and corresponding N test sets, wherein the N training sets and the N test sets are different from each other, and the N test sets constitute the text data set, N is an integer greater than 1, uses the N training sets to train N recognition models respectively, and uses each recognition model to recognize the text data in the corresponding test set to determine the predicted label corresponding to each text data in the text data set, and then processes the text data in the text data set according to the degree of difference between the predicted label corresponding to each text data and the label information. Therefore, by processing the text data set to obtain multiple training sets and corresponding multiple test sets, training multiple recognition models, and obtaining the predicted labels for each training model to identify the corresponding test set, and then processing the text data according to the degree of difference between the predicted labels and the label information, it is possible to quickly screen out incorrect annotations in the training text data, improve the speed and efficiency of quality inspection and cleaning of the training text data, and ensure the quality of text data cleaning, and try to avoid the problem of model inaccuracy caused by incorrectly labeled text data, thereby providing a guarantee for the effect of subsequent model training.
[0056] In order to more clearly illustrate the specific implementation process of processing the text data in the text data set according to the difference between the prediction result and the annotation result corresponding to each text data in the above embodiment, the following is combined with the attached Figure 3 Provide detailed explanation.
[0057] Figure 3 This is a flow chart of a method for processing text data provided in Example 2 of this application. Figure 3 As shown, in Figure 1 Based on the illustrated embodiment, step 105 may include the following steps:
[0058] Step 201 : determining the predicted label corresponding to each character in each text data according to the label distribution probability matrix corresponding to each text data.
[0059] The label distribution probability matrix corresponding to each piece of text data is obtained by identifying and predicting the text data through the recognition model. The dimension of the label distribution probability matrix is: the number of labels × the number of characters in the text data. For the convenience of description, the label distribution probability matrix can be expressed as PS[i][j], where i represents the ID of the label and j represents the sequence number of the character in the text data (starting from 0).
[0060] For ease of understanding, the following example uses the label as a named entity. In this example, the named entity contains only one type, namely the name of a company, organization or institution, collectively referred to as COMPANY. The general NER annotation method is BIE and BI. In this example, BIE is used for illustration. Since it only contains one entity type, the number of labels is 4, namely: B-COMPANY, I-COMPANY, E-COMPANY, O. Among them, B- I- E- represent the start position, middle position and end position of the NER entity respectively, and O represents OTHER. Set the correspondence between its label and ID as follows:
[0061]
[0062] For the text data "So far, Guangdong XX Group has no related valve business.", a single character is used as the tokenization unit, and its token list, label, label ID and corresponding NER entity are shown in Table 1:
[0063] Table 1
[0064]
[0065] The above text data is predicted by the recognition model, and the label distribution probability matrix obtained is shown in Table 2:
[0066] Table 2
[0067]
[0068] In this embodiment, the predicted label corresponding to each character in each text data can be determined according to the label distribution probability matrix corresponding to each text data. For example, the label with the highest probability can be determined as the predicted label of the corresponding character in the text data.
[0069] In the above example, as shown in Table 2, PS[i=0][j=1]=0.72 indicates that the probability of predicting the 1st token ("to") as O is 0.72, PS[i=1][j=1]=0.08 indicates that the probability of predicting the 1st token ("to") as B-COMPANY is 0.08, PS[i=2][j=1]=0.1 indicates that the probability of predicting the 1st token ("to") as I-COMPANY is 0.1, and PS[i=3][j=1]=0.1 indicates that the probability of predicting the 1st token ("to") as E-COMPANY is 0.1. Then, the predicted label of the character "to" in this text data is O.
[0070] Step 202: Determine the confidence of each text data according to the number of characters in each text data whose predicted labels are different from the label information.
[0071] In this embodiment, after determining the predicted label corresponding to each character in each text data, for each character, the predicted label of this character in the text data can be compared with its corresponding label information (i.e., the manual label in Table 2), the number of characters in the text data whose predicted labels are different from the label information is counted, and the confidence of each text data is determined.
[0072] Among them, the smaller the proportion of the number of characters in the text data whose predicted labels are different from the label information to the total number of characters in the text data, the higher the confidence of the text data.
[0073] As an example, the confidence of each text data can be determined as: the ratio of the number of characters in the text data whose predicted labels are different from the label information to the total number of characters included in the text data.
[0074] Step 203: Determine the text data with a confidence less than the threshold as mislabeled text data.
[0075] Among them, the threshold can be set manually in advance. The larger the threshold, the more text data in the text dataset is determined as mislabeled text data, and the greater the cleaning intensity of the text data.
[0076] In this embodiment, after determining the confidence of each text data in the text dataset, the confidence of each text data can be compared with the pre-set threshold, it is judged whether the confidence of each text data is less than the threshold, and the text data with a confidence less than the threshold is determined as mislabeled text data.
[0077] The text data processing method of the present embodiment determines the predicted label corresponding to each character in each text data according to the label distribution probability matrix corresponding to each text data, determines the confidence of each text data according to the number of characters whose predicted labels are different from the label information contained in each text data, and then determines the text data with a confidence less than a threshold as incorrectly labeled text data, thereby realizing automatic screening of incorrectly labeled text data, and by pre-setting a threshold, comparing the confidence of each text data with the threshold to screen out the incorrectly labeled text data, and can flexibly adjust the cleaning intensity of the text data by changing the size of the threshold, which has strong flexibility.
[0078] In a possible implementation of the present application, the predicted label corresponding to each text data is a label distribution probability matrix corresponding to each text data, wherein the element in the i-th row and j-th column of the label distribution probability matrix represents the probability value of the j-th character in the text data belonging to the i-th category label, and i and j are natural numbers. Then, in this embodiment, if Figure 4 As shown, in Figure 1 On the basis of the illustrated embodiment, processing the text data in the text data set according to the difference between the prediction result and the annotation result corresponding to each text data may include the following steps:
[0079] Step 301, determining the confidence threshold corresponding to each type of label according to the label distribution probability matrix and label information corresponding to each text data.
[0080] In order to conveniently obtain the confidence threshold corresponding to each type of label, in this embodiment, after obtaining the label distribution probability matrix of each text data, the label distribution probability matrices of all text data can be arranged in sequence according to the length of the token list of each text data, and summarized together. The summarized label distribution probability matrix is represented by P[i][j], and correspondingly, the label information of all text data is also arranged in sequence according to the length of the token list of each text data, and summarized together. The summarized label distribution probability matrix is represented by A[j] to form an overall joint matrix.
[0081] For example, as shown in Table 3, Table 3 is the label distribution probability matrix of all text data and the overall joint matrix obtained by summarizing label information. Due to page limitations, Table 3 only shows part of the text data "So far, Guangdong XX Group has no related valve business.", "xy responded that Logo owed 12.2 billion: It was a promotional behavior" and "ZW Health was successfully listed yesterday" and the corresponding label distribution probability.
[0082] Table 3
[0083]
[0084] In the above example, L[k] can be used to record the length of the token list of each text, where k represents the index of each text (starting with 0). For example, L[k=0]=19 means that the length of the token list of the first text "So far, Guangdong XXXX Group has no related valve business." is 19. Then P[i=1][j=19]=0.8 means that the probability that the first token ("x") of the second text is predicted to be B-COMPANY is 0.8, and its corresponding manual label ID is A[j=19]=0.
[0085] In this embodiment, the confidence threshold corresponding to each type of label can be determined based on the label distribution probability matrix and label information corresponding to each text data. The calculation process of the confidence threshold corresponding to each type of label is as follows: according to the label distribution probability matrix corresponding to each text data, determine each candidate character corresponding to any type of label; in response to the label information corresponding to any candidate character being any type of label, determine any candidate character as the target character corresponding to any type of label; according to each target character corresponding to any type of label and the predicted probability value of each target character under any type of label, determine the confidence threshold corresponding to any type of label.
[0086] Among them, when determining the confidence threshold corresponding to any type of label based on the target characters corresponding to any type of label and the predicted probability value of each target character under any type of label, the average value of the predicted probability value of the target character can be calculated as the confidence threshold, or the maximum probability value and the minimum probability value can be removed and then the average value can be calculated as the confidence threshold, or the intermediate value can be taken as the confidence threshold, and this application does not impose any restrictions on this.
[0087] Taking the calculation of the average value of the predicted probability value of the target character as the confidence threshold as an example, combined with the summarized overall joint matrix, the calculation process of the confidence threshold of each type of label can be summarized as follows:
[0088] (1) Select the set of all elements whose predicted label ID is i from the overall joint matrix, that is, select the i-th row element in P[i][j]; (2) Select the set of elements whose label information (that is, the artificial label in Table 3) is also i from the result of step (1); (3) Calculate the average value of the set of elements in step (2), that is, the average probability t[i] under the artificial label ID i, and use this average probability t[i] as the confidence threshold of the i-th category label.
[0089] For ease of understanding, the overall joint matrix shown in Table 3 is used as an example to illustrate the calculation process of the confidence threshold of each type of label. For i=2, it means that the manual label ID is 2, and the corresponding label is I-COMPANY, then t[i=2] is calculated as follows:
[0090] (1) Select the set of predicted probabilities P[i][j] where i=2, i.e., P[i=2][j]. For quick calculation and ease of understanding, ignore the part with ellipsis. The same treatment is also applied in the following examples in this application.
[0091] (2) Select the part corresponding to A[j]=2 in P[i=2][j], which corresponds to 0.8 and 0.7.
[0092] (3) Calculate the average value of the elements selected in step (2), and we get t[i=2]=(0.8+0.7) / 2=0.75, that is, the confidence threshold of label i=2 is 0.75. Similarly, we can calculate:
[0093] t[i=0]=(0.8+0.72+0.4+0.1+0.1+0.6+0.6+0.7+0.9) / 9=0.55
[0094] t[i=1]=0.8
[0095] t[i=3]=0.7
[0096] It should be noted that the above-described aggregation of the label distribution probability matrix of each text data to obtain an overall joint matrix is only for the convenience of explaining the calculation process of determining the confidence threshold corresponding to each type of label. It is not a necessary processing step. It should be understood that the confidence threshold corresponding to each type of label can also be determined without summarizing the label distribution probability matrix.
[0097] Step 302: Determine the predicted label corresponding to each character in each text data according to the confidence threshold corresponding to each type of label and the label distribution probability matrix corresponding to each text data.
[0098] As an example, for each character in each piece of text data, a label with the largest label distribution probability and not less than a confidence threshold of the label of this type may be determined as the predicted label of the character.
[0099] For example, as shown in Table 3, the probability that the label ID of the character "Z" is predicted to be 0 is 0.1, the probability that it is predicted to be 1 is 0.8, the probability that it is predicted to be 2 is 0.05, and the probability that it is predicted to be 3 is 0.05. According to the above calculation, the confidence thresholds of label IDs 0 to 3 are 0.55, 0.8, 0.75 and 0.7 respectively. By comparing the confidence thresholds of various labels and the probability that the character "Z" is predicted to be each type of label, it can be determined that the predicted label ID of the character "Z" is 1, that is, the predicted label of the character "Z" is B-COMPANY.
[0100] Step 303: Determine the confidence level of each text data according to the number of characters whose predicted labels are different from the label information contained in each text data.
[0101] In this embodiment, the predicted label is different from the label information, which not only includes that the predicted label and label information of the same character are inconsistent, but also includes that the corresponding predicted label cannot be determined according to the confidence threshold corresponding to each type of label and the label distribution probability matrix corresponding to each text data.
[0102] As an example, the confidence of each text data can be determined as: the ratio of the number of characters whose predicted labels are different from the label information contained in the text data to the total number of characters contained in the text data. The smaller the proportion of the number of characters whose predicted labels are different from the label information contained in the text data to the total number of characters in the text data, the higher the confidence of the text data.
[0103] Step 304: determine the text data with a confidence level less than a threshold as incorrectly labeled text data.
[0104] The threshold value may be manually set in advance. The larger the threshold value is, the more text data in the text data set is determined to be incorrectly labeled text data, and the greater the intensity of text data cleaning.
[0105] In this embodiment, after determining the confidence of each text data in the text data set, the confidence of each text data can be compared with a preset threshold to determine whether the confidence of each text data is less than the threshold, and the text data with a confidence less than the threshold is determined as incorrectly labeled text data.
[0106] The text data processing method of the present embodiment determines the confidence threshold corresponding to each type of label according to the label distribution probability matrix and label information corresponding to each text data, determines the predicted label corresponding to each character in each text data according to the confidence threshold corresponding to each type of label and the label distribution probability matrix corresponding to each text data, and then determines the confidence of each text data according to the number of characters whose predicted labels are different from the label information contained in each text data, and determines the text data with a confidence less than the threshold as incorrectly labeled text data. In this way, the incorrectly labeled text data in the text data set can be automatically screened out, and the predicted label of each character is determined by calculating the confidence threshold of each type of label, which is conducive to improving the accuracy of the prediction result and thus improving the quality of text data cleaning.
[0107] In a possible implementation of the present application, the predicted label corresponding to each text data is a label distribution probability matrix corresponding to each text data, wherein the element in the i-th row and j-th column of the label distribution probability matrix represents the probability value of the j-th character in the text data belonging to the i-th category label, and i and j are natural numbers. Then, in this embodiment, if Figure 5 As shown, in Figure 1On the basis of the illustrated embodiment, processing the text data in the text data set according to the difference between the prediction result and the annotation result corresponding to each text data may include the following steps:
[0108] Step 401, determining the confidence threshold corresponding to each type of label according to the label distribution probability matrix and label information corresponding to each text data.
[0109] In this embodiment, the description of step 401 may refer to the description of step 301 in the above embodiment, and will not be repeated here to avoid repetition.
[0110] Step 402, based on the confidence threshold corresponding to each type of label, the label distribution probability matrix corresponding to each text data and the label information, determine the counting matrix corresponding to the text data set, wherein the count value in the kth row and the vth column in the counting matrix represents the number of characters in the text data set whose predicted label is k and whose label information is v, and k and v are natural numbers.
[0111] In this embodiment, the rows and columns of the counting matrix are the number of label information and the number of predicted labels, respectively. For the count value of the element in the kth row and vth column in the counting matrix, the number of all characters whose label information corresponding to the characters is v and whose predicted label is k in all characters included in the text data set can be counted as the count value of the element in the kth row and vth column.
[0112] Among them, the predicted label corresponding to the character is the category label with the largest probability value in the label category.
[0113] Furthermore, in a possible implementation of the embodiment of the present application, the count value of each element in the count matrix can also be determined in combination with the confidence threshold corresponding to each type of label. Specifically, an initial count matrix can be generated first according to the number of labels contained in the label information and the number of labels contained in the predicted label, wherein the value of each element in the initial count matrix is zero. Next, the label information, predicted label and probability value corresponding to the predicted label corresponding to each character in the text data set are counted, and in response to the label information corresponding to any character being v, the predicted label being k, and the probability value corresponding to the predicted label k being greater than the confidence threshold corresponding to the k-type label, the count value of the k-th row and the v-th column in the initial count matrix is added by 1. That is, for the count value of the k-th row and the v-th column in the count matrix finally determined, the count value is determined by the number of characters whose label information corresponding to the character is v, the predicted label is k, and the probability value corresponding to the predicted label k is greater than the confidence threshold corresponding to the k-type label among all the characters contained in the text data set. If the probability value of the predicted label k corresponding to any character is not greater than the confidence threshold corresponding to the k-type label, the character is discarded so that it does not participate in the calculation of the count matrix.
[0114] Taking the text dataset shown in Table 3 and the corresponding label distribution probability matrix as an example, both the number of label information and predicted labels is 4. Then the dimension of the counting matrix (denoted as C[k][v]) is 4×4, and the initialized counting matrix is shown in Table 4:
[0115] Table 4
[0116]
[0117] As shown in Table 3, for j = 0, that is, the 0th token ("cut"), the probability values predicted by the model are 0.8, 0, 0.1, 0.1. Select the maximum value 0.8, corresponding to label i = 0, that is, P[i = 0][j = 0]. Its value is greater than t[i = 0]=0.75, so the predicted label ID is 0. For j = 2, that is, the second token ("eye"), the probability values predicted by the model are 0.4, 0.2, 0.3, 0.1. Select the maximum probability value 0.4, corresponding to label i = 0, that is, P[i = 0][j = 0]. Its value is less than t[i = 0]=0.75, so it is discarded and does not participate in the calculation of the subsequent counting matrix element value, and can be marked with ×. Finally, according to the probability values and the confidence threshold of each type of label, the determined predicted label IDs are shown in the bold black part of Table 5.
[0118] Table 5
[0119]
[0120] Based on the statistics in Table 5, the count values of each element in the counting matrix are obtained. For example, C[k = 3][v = 0] represents the number of tokens with the manual label ID of 0 and the predicted label ID of 3 by the model, and its value is 1. Since the second token ("eye") is discarded and does not participate in the counting calculation, only 12 tokens participate in the counting calculation. The finally determined counting matrix is shown in Table 6:
[0121] Table 6
[0122]
[0123] Step 403, perform standardization and normalization processing on the counting matrix to generate a processed matrix.
[0124] In some embodiments of the present application, when the confidence threshold participates in the determination of the counting matrix, some tokens are discarded and do not participate in the calculation of the counting matrix. This makes the number of samples included in the counting matrix not equal to the actual number of tokens. Therefore, it is necessary to perform standardization processing on the counting matrix so that the total count is the same as the total number of manually marked tokens.
[0125] In a possible implementation of the embodiment of the present application, when the count matrix is normalized, the number of predicted characters corresponding to each type label can be determined based on each count value in the count matrix, and the number of annotated characters corresponding to each type label can be determined based on the label information corresponding to each text data, and then the count values in the count matrix are normalized based on the predicted number of characters and the number of annotated characters to generate a normalized matrix. The normalization formula can be described as the following formula (1):
[0126] (1)
[0127] Among them, AL[v] represents the number of annotated characters with ID v of the label information type, and M represents the number of predicted label types.
[0128] For example, for the token v=0 in the count matrix, the actual number of manual annotations is 9, but only 8 are involved in the calculation of the count matrix. Therefore, the part with v=0 needs to be standardized. Using the above formula (1), we can get:
[0129] C[k=0][v=0]= (C[k=0][v=0] / 8) ×9=(6 / 8)×9=6.75
[0130] The final standardized results are shown in Table 7.
[0131] Table 7
[0132]
[0133] Next, for the count matrix after the normalization process, the total number of characters corresponding to the count matrix can be determined according to each count value in the count matrix, and the normalized matrix can be normalized according to the total number of characters to generate a processed matrix. The normalization process formula is shown in formula (2).
[0134] (2)
[0135] For example, Q[k=0][v=0]=C[k=0][v=0] / 13=6.75 / 13=0.519, and so on. The processed matrix is shown in Table 8:
[0136] Table 8
[0137]
[0138] Step 404, in response to the count value of the kth row and vth column in the processed matrix being non-zero, and k and v are different, obtaining each candidate character corresponding to the count value of the kth row and vth column.
[0139] In this embodiment, after the processed count matrix is generated, the candidate characters corresponding to the non-zero non-diagonal cells in the count matrix are found.
[0140] As shown in Table 8, the non-zero non-diagonal cells in the count matrix are C[k=1][v=0] and C[k=3][v=0]. For C[k=1][v=0], that is, the token set ["x"] whose label information ID is 0 and the model predicts that the label ID is 1, is used as a candidate character for the incorrectly labeled token.
[0141] Step 405, determining the difference between the first probability value of the predicted label k corresponding to each candidate character in each candidate character and the second probability value of the predicted label v.
[0142] Taking the incorrectly labeled candidate character "x" as an example, the token ID corresponding to "x" is 19. The difference between the first probability value of the predicted label k=1 and the second probability value of the predicted label v=0 corresponding to "x" is P[i=19][j=1]- P[i=19][j=0]=0.8-0.1=0.7.
[0143] Step 406, selecting a target character from each candidate character according to the difference values corresponding to each candidate character.
[0144] In a possible implementation method of the embodiment of the present application, when selecting target characters, the target number of target characters to be selected can be determined based on the product of the count value in the kth row and the vth column and the total number of characters corresponding to the calculation matrix, and then the target number of target characters can be selected from each candidate character in order from large to small according to the difference values corresponding to each candidate character.
[0145] Continuing with the above example, the target number of target characters to be selected is N*Q[k=1][v=0]=13*0.086≈1, and finally arranged from large to small according to the probability difference, as follows:
[0146] Candidate token set: ["x"]
[0147] Probability difference set: [0.7]
[0148] The first token in the probability difference set, i.e. “x”, is selected as the incorrectly labeled token.
[0149] Step 407: Determine whether each text data is an incorrectly marked text data according to the number of target characters contained in each text data.
[0150] For NER text data, one text data contains multiple tokens. In this embodiment, the number of wrong tokens contained in the text data is normalized to obtain the error labeling probability of each NER text data, and a suitable threshold is set. The threshold can be set manually. When the error labeling probability is greater than the threshold, the text data is considered to be error-labeled text data and sent for manual verification and cleaning. Among them, the error labeling probability of any text data can be calculated by formula (3).
[0151] (3)
[0152] in, represents the number of target characters contained in the w-th text data, that is, the number of incorrectly labeled tokens; represents the probability that the wth text data is labeled incorrectly; Indicates the total number of characters contained in the w-th text data.
[0153] The text data processing method of the present embodiment determines the confidence threshold corresponding to each type of label according to the label distribution probability matrix and label information corresponding to each text data, determines the count matrix corresponding to the text data set according to the confidence threshold corresponding to each type of label, the label distribution probability matrix and label information corresponding to each text data, standardizes and normalizes the count matrix to generate a processed matrix, and in response to the count value of the kth row and vth column in the processed matrix being non-zero and k and v being different, obtains each candidate character corresponding to the count value of the kth row and vth column, determines the difference between the first probability value of the predicted label k and the second probability value of the predicted label v corresponding to each candidate character in each candidate character, selects the target character from each candidate character according to the difference corresponding to each candidate character, and determines whether each text data is an incorrectly labeled text data according to the number of target characters contained in each text data. Thus, automatic identification of incorrectly labeled text data is realized, and there is no need to manually check the incorrect text data, which saves manpower and improves the efficiency of text data cleaning.
[0154] With the above Figures 1 to 5 Corresponding to the text data processing method provided in the embodiment, the present application also provides a text data processing device. Since the text data processing device provided in the embodiment of the present application is similar to the above-mentioned Figures 1 to 5 The text data processing method provided in the embodiment corresponds to the text data processing method, so the implementation method of the text data processing method is also applicable to the text data processing device provided in the embodiment of the present application, and will not be described in detail in the embodiment of the present application.
[0155] Figure 6 This is a schematic diagram of the structure of the text data processing device provided in Example 5 of the present application.
[0156] like Figure 6 As shown, the text data processing device 100 may include: an acquisition module 110 , a splitting module 120 , a training module 130 , a recognition module 140 and a cleaning module 150 .
[0157] The acquisition module 110 is used to acquire a text data set, wherein the text data set includes a plurality of text data and label information corresponding to each text data.
[0158] The splitting module 120 is used to process the text data set to obtain N training sets and corresponding N test sets, wherein the N training sets and the N test sets are different from each other, and the N test sets constitute the text data set, and N is an integer greater than 1.
[0159] The training module 130 is used to train N recognition models respectively using the N training sets.
[0160] The recognition module 140 is used to recognize the text data in the corresponding test set by using each of the recognition models respectively, so as to determine the predicted label corresponding to each of the text data in the text data set.
[0161] The cleaning module 150 is used to process the text data in the text data set according to the difference between the predicted label corresponding to each of the text data and the label information.
[0162] Furthermore, in a possible implementation of the embodiment of the present application, as Figure 7 As shown, in Figure 6 Based on the illustrated embodiment, the cleaning module 150 includes:
[0163] The first determining unit 151 is used to determine the predicted label corresponding to each character in each of the text data according to the label distribution probability matrix corresponding to each of the text data.
[0164] The second determining unit 152 is configured to determine the confidence level of each of the text data according to the number of characters whose predicted labels are different from the label information contained in each of the text data.
[0165] The third determining unit 153 is used to determine text data with a confidence level less than a threshold as incorrectly labeled text data.
[0166] Furthermore, in a possible implementation of the embodiment of the present application, the predicted label corresponding to each of the text data is a label distribution probability matrix corresponding to each of the text data, wherein the element in the i-th row and j-th column of the label distribution probability matrix represents the probability value that the j-th character in the text data belongs to the i-th category label, and i and j are natural numbers respectively, such as Figure 8 As shown, in Figure 6 Based on the illustrated embodiment, the cleaning module 150 includes:
[0167] The fourth determining unit 154 is used to determine the confidence threshold corresponding to each type of label according to the label distribution probability matrix and label information corresponding to each of the text data.
[0168] In a possible implementation of the embodiment of the present application, the fourth determination unit 154 is specifically used to: determine each candidate character corresponding to any class of labels according to the label distribution probability matrix corresponding to each of the text data; in response to the label information corresponding to any candidate character being any class of labels, determine the any candidate character as the target character corresponding to the any class of labels; determine the confidence threshold corresponding to the any class of labels according to the target characters corresponding to the any class of labels and the predicted probability value of each of the target characters under the any class of labels.
[0169] The fifth determining unit 155 is used to determine the predicted label corresponding to each character in each of the text data according to the confidence threshold corresponding to each type of label and the label distribution probability matrix corresponding to each of the text data.
[0170] The sixth determining unit 156 is configured to determine the confidence level of each of the text data according to the number of characters whose predicted labels are different from the label information contained in each of the text data.
[0171] The seventh determination unit 157 is used to determine the text data with a confidence level less than a threshold as incorrectly labeled text data.
[0172] Furthermore, in a possible implementation of the embodiment of the present application, the predicted label corresponding to each of the text data is a label distribution probability matrix corresponding to each of the text data, wherein the element in the i-th row and j-th column of the label distribution probability matrix represents the probability value that the j-th character in the text data belongs to the i-th category label, and i and j are natural numbers respectively. Fig. 9 As shown, in Figure 6 Based on the embodiment shown, the cleaning module 150 includes:
[0173] The threshold determination unit 1501 is used to determine the confidence threshold corresponding to each type of label according to the label distribution probability matrix and label information corresponding to each of the text data.
[0174] The counting matrix determination unit 1502 is used to determine the counting matrix corresponding to the text data set according to the confidence threshold corresponding to each type of label, the label distribution probability matrix corresponding to each of the text data and the label information, wherein the count value of the kth row and vth column in the counting matrix represents the number of characters in the text data set whose predicted label is k and whose label information is v, and k and v are natural numbers.
[0175] In a possible implementation of an embodiment of the present application, the counting matrix determination unit 1502 is specifically used to: generate an initial counting matrix based on the number of labels contained in the label information and the number of labels contained in the predicted labels, wherein the value of each element in the initial counting matrix is zero; perform statistics on the label information, predicted labels and probability values corresponding to the predicted labels corresponding to each character in the text data set, and in response to the label information corresponding to any character being v, the predicted label being k, and the probability value corresponding to the predicted label k being greater than the confidence threshold corresponding to the k-type label, then add 1 to the count value in the k-th row and v-th column in the initial counting matrix.
[0176] The processing unit 1503 is used to standardize and normalize the counting matrix to generate a processed matrix.
[0177] In a possible implementation of an embodiment of the present application, the processing unit 1503 is specifically used to: determine the predicted number of characters corresponding to each type label according to each count value in the count matrix; determine the number of annotated characters corresponding to each type label according to the label information corresponding to each of the text data; standardize each count value in the count matrix according to the predicted number of characters and the number of annotated characters to generate a standardized matrix; determine the total number of characters corresponding to the count matrix according to each count value in the count matrix; and normalize the standardized matrix according to the total number of characters to generate the processed matrix.
[0178] The acquisition unit 1504 is used for acquiring each candidate character corresponding to the count value of the kth row and vth column in response to the count value of the kth row and vth column in the processed matrix being non-zero and k is different from v.
[0179] The difference determination unit 1505 is used to determine the difference between the first probability value of the predicted label k corresponding to each of the candidate characters and the second probability value of the predicted label v.
[0180] The selection unit 1506 is used to select a target character from the candidate characters according to the difference values respectively corresponding to the candidate characters.
[0181] In a possible implementation method of an embodiment of the present application, the selection unit 1506 is specifically used to: determine the target number of target characters to be selected based on the product of the count value in the kth row and the vth column and the total number of characters corresponding to the calculation matrix; and select the target number of target characters from the candidate characters in order from large to small according to the difference values corresponding to each candidate character.
[0182] The determination unit 1507 is configured to determine whether each of the text data is an incorrectly marked text data according to the number of the target characters contained in each of the text data.
[0183] The text data processing device of the embodiment of the present application obtains a text data set, which includes multiple text data and label information corresponding to each text data, processes the text data set to obtain N training sets and corresponding N test sets, wherein the N training sets and the N test sets are different from each other, and the N test sets constitute the text data set, N is an integer greater than 1, uses the N training sets to train N recognition models respectively, and uses each recognition model to recognize the text data in the corresponding test set to determine the predicted label corresponding to each text data in the text data set, and then processes the text data in the text data set according to the degree of difference between the predicted label corresponding to each text data and the label information. Therefore, by processing the text data set to obtain multiple training sets and corresponding multiple test sets, training multiple recognition models, and obtaining the predicted labels for each training model to identify the corresponding test set, and then processing the text data according to the degree of difference between the predicted labels and the label information, it is possible to quickly screen out incorrect annotations in the training text data, improve the speed and efficiency of quality inspection and cleaning of the training text data, and ensure the quality of text data cleaning, and try to avoid the problem of model inaccuracy caused by incorrectly labeled text data, thereby providing a guarantee for the effect of subsequent model training.
[0184] In order to implement the above embodiments, the present application also proposes a computer device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the text data processing method proposed in any of the aforementioned embodiments of the present application is implemented.
[0185] In order to implement the above embodiments, the present application also proposes a non-temporary computer-readable storage medium on which a computer program is stored, characterized in that when the program is executed by a processor, a text data processing method proposed in any of the aforementioned embodiments of the present application is implemented.
[0186] In order to implement the above embodiments, the present application also proposes a computer program product. When the instructions in the computer program product are executed by a processor, the text data processing method proposed in any of the above embodiments of the present application is executed.
[0187] Fig.10 A block diagram of an exemplary computer device suitable for implementing embodiments of the present application is shown. Fig.10 The computer device 12 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0188] like Fig.10 As shown, the computer device 12 is in the form of a general-purpose computing device. The components of the computer device 12 may include, but are not limited to: one or more processors or processing units 16, a system memory 28, and a bus 18 that connects various system components (including the system memory 28 and the processing unit 16).
[0189] The bus 18 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration port, a processor, or a local bus using any of a variety of bus structures. For example, these architectures include but are not limited to Industry Standard Architecture (hereinafter referred to as: ISA) bus, Micro Channel Architecture (hereinafter referred to as: MAC) bus, Enhanced ISA bus, Video Electronics Standards Association (hereinafter referred to as: VESA) local bus and Peripheral Component Interconnection (hereinafter referred to as: PCI) bus.
[0190] The computer device 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by the computer device 12, including volatile and non-volatile media, removable and non-removable media.
[0191] The memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. The computer device 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 34 may be used to read and write non-removable, non-volatile magnetic media ( Fig.10 not shown, usually called a "hard drive"). Although Fig.10 Not shown in the figure, a disk drive for reading and writing a removable non-volatile disk (such as a "floppy disk"), and an optical disk drive for reading and writing a removable non-volatile optical disk (such as a compact disc read only memory (hereinafter referred to as: CD-ROM), a digital versatile disc read only memory (hereinafter referred to as: DVD-ROM) or other optical media) can be provided. In these cases, each drive can be connected to the bus 18 through one or more data medium interfaces. The memory 28 may include at least one program product, which has a set (for example, at least one) of program modules, which are configured to perform the functions of each embodiment of the present application.
[0192] A program / utility 40 having a set (at least one) of program modules 42 may be stored, for example, in the memory 28, such program modules 42 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. The program modules 42 generally perform the functions and / or methods of the embodiments described herein.
[0193] The computer device 12 may also communicate with one or more external devices 14 (e.g., keyboard, pointing device, display 24, etc.), one or more devices that enable a user to interact with the computer device 12, and / or any device that enables the computer device 12 to communicate with one or more other computing devices (e.g., network card, modem, etc.). Such communication may be performed through an input / output (I / O) interface 22. Furthermore, the computer device 12 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) through a network adapter 20. Fig.10 As shown, the network adapter 20 communicates with other modules of the computer device 12 via the bus 18. It should be understood that although Fig.10 Not shown, other hardware and / or software modules may be used in conjunction with computer device 12, including but not limited to microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0194] The processing unit 16 executes various functional applications and data processing by running the programs stored in the system memory 28, such as implementing the text data processing method mentioned in the above embodiment.
[0195] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.
[0196] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In the description of this application, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0197] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, fragment or portion of code comprising one or more executable instructions for implementing the steps of a custom logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present application belong.
[0198] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or in combination with these instruction execution systems, devices or apparatuses. For the purposes of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in combination with these instruction execution systems, devices or apparatuses. More specific examples (non-exhaustive list) of computer-readable media include the following: an electrical connection with one or more wires (electronic device), a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium and then editing, interpreting or processing in other suitable ways if necessary, and then stored in a computer memory.
[0199] It should be understood that the various parts of the present application can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0200] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.
[0201] In addition, each functional unit in each embodiment of the present application may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.
[0202] The storage medium mentioned above may be a read-only memory, a magnetic disk or an optical disk, etc. Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limiting the present application. A person of ordinary skill in the art may change, modify, replace and modify the above embodiments within the scope of the present application.
Claims
1. A method for processing text data, It is characterized in that include: Acquire a text data set, wherein the text data set includes a plurality of text data and label information corresponding to each text data; Processing the text data set to obtain N training sets and corresponding N test sets, wherein the N training sets and the N test sets are different from each other, and the N test sets constitute the text data set, and N is an integer greater than 1; Using the N training sets to train N recognition models respectively, wherein each training set corresponds to a recognition model; Using each of the recognition models respectively, recognize the text data in the corresponding test set to determine the predicted label corresponding to each of the text data in the text data set; Processing the text data in the text data set according to the degree of difference between the predicted label corresponding to each of the text data and the label information; The predicted label corresponding to each of the text data is a label distribution probability matrix corresponding to each of the text data, wherein the element in the i-th row and j-th column of the label distribution probability matrix represents the probability value that the j-th character in the text data belongs to the i-th category label, and i and j are natural numbers respectively. The text data in the text data set are processed according to the degree of difference between the predicted label corresponding to each of the text data and the label information, including: Determine the confidence threshold corresponding to each type of label according to the label distribution probability matrix and label information corresponding to each of the text data; Determine the predicted label corresponding to each character in each of the text data according to the confidence threshold corresponding to each type of label and the label distribution probability matrix corresponding to each of the text data; Determining the confidence of each of the text data according to the number of characters whose predicted labels and label information are different contained in each of the text data; Text data with a confidence level less than a threshold is determined as incorrectly labeled text data.
2. The method according to claim 1, It is characterized in that The processing of the text data in the text data set according to the degree of difference between the predicted label corresponding to each of the text data and the label information includes: Determine the predicted label corresponding to each character in each of the text data according to the label distribution probability matrix corresponding to each of the text data; Determining the confidence of each of the text data according to the number of characters whose predicted labels and label information are different contained in each of the text data; Text data with a confidence level less than a threshold is determined as incorrectly labeled text data.
3. The method according to claim 1, It is characterized in that Determining the confidence threshold corresponding to each type of label according to the label distribution probability matrix and label information corresponding to each of the text data includes: Determine candidate characters corresponding to any type of label according to the label distribution probability matrix corresponding to each of the text data; In response to the label information corresponding to any candidate character being any of the class labels, determining the any candidate character to be the target character corresponding to any of the class labels; The confidence threshold corresponding to any one of the labels is determined according to each of the target characters corresponding to any one of the labels and the predicted probability value of each of the target characters under any one of the labels.
4. The method according to claim 1, It is characterized in that The predicted label corresponding to each of the text data is a label distribution probability matrix corresponding to each of the text data, wherein the element in the i-th row and j-th column of the label distribution probability matrix represents the probability value that the j-th character in the text data belongs to the i-th category label, and i and j are natural numbers respectively. The text data in the text data set are processed according to the difference between the predicted label corresponding to each of the text data and the label information, including: Determine the confidence threshold corresponding to each type of label according to the label distribution probability matrix and label information corresponding to each of the text data; Determine the count matrix corresponding to the text data set according to the confidence threshold corresponding to each type of label, the label distribution probability matrix corresponding to each of the text data, and the label information, wherein the count value in the kth row and vth column in the count matrix represents the number of characters in the text data set whose predicted label is k and whose label information is v, and k and v are natural numbers; Standardizing and normalizing the count matrix to generate a processed matrix; In response to the count value of the k-th row and the v-th column in the processed matrix being non-zero, and k and v are different, obtaining each candidate character corresponding to the count value of the k-th row and the v-th column; Determine the difference between a first probability value with a predicted label k and a second probability value with a predicted label v corresponding to each of the candidate characters; Selecting a target character from each of the candidate characters according to the difference values respectively corresponding to each of the candidate characters; According to the number of the target characters contained in each of the text data, it is determined whether each of the text data is an error-labeled text data.
5. The method according to claim 4, It is characterized in that Determining the count matrix corresponding to the text data set according to the confidence threshold corresponding to each type of label, the label distribution probability matrix corresponding to each of the text data, and the label information includes: Generate an initial count matrix according to the number of labels included in the label information and the number of labels included in the predicted labels, wherein the value of each element in the initial count matrix is zero; The label information, predicted label and probability value corresponding to the predicted label corresponding to each character in the text data set are counted. In response to the label information corresponding to any character being v, the predicted label being k, and the probability value corresponding to the predicted label k being greater than the confidence threshold corresponding to the k-type label, the count value in the k-th row and v-th column in the initial counting matrix is increased by 1.
6. The method according to claim 5, It is characterized in that The step of standardizing and normalizing the count matrix to generate a processed matrix includes: Determine the number of predicted characters corresponding to each type label according to each count value in the count matrix; Determine the number of annotated characters corresponding to each type of label according to the label information corresponding to each of the text data; According to the predicted number of characters and the marked number of characters, each count value in the count matrix is normalized to generate a normalized matrix; Determine the total number of characters corresponding to the counting matrix according to each counting value in the counting matrix; The standardized matrix is normalized according to the total number of characters to generate the processed matrix.
7. The method according to any one of claims 4 to 6, It is characterized in that The step of selecting a target character from each candidate character according to the difference values respectively corresponding to each candidate character comprises: Determine the target number of target characters to be selected according to the product of the count value in the kth row and the vth column and the total number of characters corresponding to the calculation matrix; According to the difference values respectively corresponding to the candidate characters, the target number of target characters are selected from the candidate characters in descending order.
8. A text data processing device, It is characterized in that include: An acquisition module, used to acquire a text data set, wherein the text data set includes a plurality of text data and label information corresponding to each text data; A splitting module, used for processing the text data set to obtain N training sets and corresponding N test sets, wherein the N training sets and the N test sets are different from each other, and the N test sets constitute the text data set, and N is an integer greater than 1; A training module, used to train N recognition models respectively using the N training sets, wherein each training set corresponds to a recognition model; A recognition module, used to recognize the text data in the corresponding test set using each of the recognition models respectively, so as to determine the predicted label corresponding to each of the text data in the text data set; A cleaning module, used for processing the text data in the text data set according to the difference between the predicted label corresponding to each of the text data and the label information; The predicted label corresponding to each of the text data is a label distribution probability matrix corresponding to each of the text data, wherein the element in the i-th row and j-th column of the label distribution probability matrix represents the probability value that the j-th character in the text data belongs to the i-th category label, i and j are natural numbers respectively, and the cleaning module includes: A fourth determining unit, configured to determine a confidence threshold corresponding to each type of label according to a label distribution probability matrix and label information corresponding to each of the text data; A fifth determining unit, used to determine a predicted label corresponding to each character in each of the text data according to a confidence threshold corresponding to each type of label and a label distribution probability matrix corresponding to each of the text data; a sixth determining unit, configured to determine the confidence level of each of the text data according to the number of characters whose predicted labels are different from the label information contained in each of the text data; The seventh determination unit is used to determine the text data with a confidence level less than a threshold as incorrectly labeled text data.
9. The device as claimed in claim 8, It is characterized in that The cleaning module comprises: A first determining unit, configured to determine a predicted label corresponding to each character in each of the text data according to a label distribution probability matrix corresponding to each of the text data; A second determining unit, configured to determine the confidence of each of the text data according to the number of characters whose predicted labels are different from the label information contained in each of the text data; The third determination unit is used to determine the text data with a confidence level less than a threshold as incorrectly labeled text data.
10. The device according to claim 8, It is characterized in that The fourth determining unit is specifically configured to: Determine candidate characters corresponding to any type of label according to the label distribution probability matrix corresponding to each of the text data; In response to the label information corresponding to any candidate character being any of the class labels, determining the any candidate character to be the target character corresponding to any of the class labels; The confidence threshold corresponding to any one of the labels is determined according to each of the target characters corresponding to any one of the labels and the predicted probability value of each of the target characters under any one of the labels.
11. The device according to claim 8, It is characterized in that The predicted label corresponding to each of the text data is a label distribution probability matrix corresponding to each of the text data, wherein the element in the i-th row and j-th column of the label distribution probability matrix represents the probability value that the j-th character in the text data belongs to the i-th category label, i and j are natural numbers respectively, and the cleaning module comprises: A threshold determination unit, used to determine the confidence threshold corresponding to each type of label according to the label distribution probability matrix and label information corresponding to each of the text data; A counting matrix determining unit, used to determine the counting matrix corresponding to the text data set according to the confidence threshold corresponding to each type of label, the label distribution probability matrix corresponding to each of the text data and the label information, wherein the count value of the k-th row and the v-th column in the counting matrix represents the number of characters in the text data set whose predicted label is k and whose label information is v, and k and v are natural numbers; A processing unit, used for standardizing and normalizing the count matrix to generate a processed matrix; an acquisition unit, configured to acquire each candidate character corresponding to the count value of the kth row and the vth column in response to the count value of the kth row and the vth column in the processed matrix being non-zero and k being different from v; A difference determination unit, used to determine the difference between a first probability value with a predicted label k corresponding to each of the candidate characters and a second probability value with a predicted label v; A selection unit, configured to select a target character from each of the candidate characters according to the difference values respectively corresponding to each of the candidate characters; The determination unit is used to determine whether each of the text data is an error-labeled text data according to the number of the target characters contained in each of the text data.
12. The device according to claim 11, It is characterized in that The counting matrix determination unit is specifically used for: Generate an initial count matrix according to the number of labels included in the label information and the number of labels included in the predicted labels, wherein the value of each element in the initial count matrix is zero; The label information, predicted label and probability value corresponding to the predicted label corresponding to each character in the text data set are counted. In response to the label information corresponding to any character being v, the predicted label being k, and the probability value corresponding to the predicted label k being greater than the confidence threshold corresponding to the k-type label, the count value in the k-th row and v-th column in the initial counting matrix is increased by 1.
13. The device according to claim 12, It is characterized in that The processing unit is specifically used for: Determine the number of predicted characters corresponding to each type label according to each count value in the count matrix; Determine the number of annotated characters corresponding to each type of label according to the label information corresponding to each of the text data; According to the predicted number of characters and the marked number of characters, each count value in the count matrix is normalized to generate a normalized matrix; Determine the total number of characters corresponding to the counting matrix according to each counting value in the counting matrix; The standardized matrix is normalized according to the total number of characters to generate the processed matrix.
14. The device according to any one of claims 11 to 13, It is characterized in that The selection unit is specifically used for: Determine the target number of target characters to be selected according to the product of the count value in the kth row and the vth column and the total number of characters corresponding to the calculation matrix; According to the difference values respectively corresponding to the candidate characters, the target number of target characters are selected from the candidate characters in descending order.
15. A computer device, It is characterized in that The invention comprises a memory, a processor and a computer program stored in the memory and executable on the processor. When the processor executes the program, the text data processing method as claimed in any one of claims 1 to 7 is implemented.
16. A non-transitory computer-readable storage medium having stored thereon a computer program, It is characterized in that When the program is executed by a processor, the text data processing method as described in any one of claims 1 to 7 is implemented.
17. A computer program product, It is characterized in that When the instructions in the computer program product are executed by a processor, the text data processing method according to any one of claims 1 to 7 is performed.
Citation Information
Patent Citations
Named entity recognition method and device, computer equipment and storage medium
CN110704633A
Text classification method and device, electronic equipment and computer readable storage medium
CN110717039A
