A method for obtaining text labels
The text is inferred and filtered through multiple trained label reasoning models, which solves the problem of incorrect or incomplete text annotation in the existing technology, achieves correct and comprehensive label acquisition of the text, and improves the accuracy and accuracy of the annotation. Model training effect.
Patent Information
- Application Number
- CN202410996649.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-24
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2044-07-24
AI Technical Summary
In the existing technology, when the number of labeled text samples is small or the labels are wrong, the text classification model obtained by training has poor reasoning ability, resulting in false or incomplete pseudo labels, making it difficult to obtain correct and comprehensive labels for the text.
By obtaining the text set of labels to be obtained, and using multiple trained label reasoning models to obtain and filter inference labels, combined with the semantic analysis results of multiple models, more comprehensive and correct labels are selected.
It achieves the acquisition of correct and comprehensive labels for text, improves labeling accuracy and label reasoning capabilities, and enhances the training effect of subsequent models.
Smart Images

Figure CN118520117B
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of electronic digital data processing, and in particular to a method for acquiring a text label. Background Art
[0002] When there are many texts to be labeled, the labels of the manually labeled texts may be labeled incorrectly or missed. For example, a text has 4 labels, but only 1, 2 or 3 of them are manually labeled; or a text has 2 labels, although 2 labels are also manually labeled, but 1 of the manually labeled labels is an incorrect label. Obtaining the correct and more comprehensive labels of the text can be used to later determine whether the manually labeled labels are correct, and can also be used to later train a neural network model with strong label reasoning ability. The prior art has disclosed a method for identifying text labels based on a trained neural network model. For example, a Chinese patent application with publication number CN117076672A discloses a training method, a text classification method and a device for a text classification model. In the patent application, a first text classification model is obtained by training a first text sample with a label. The performance of the first text classification model can meet certain requirements. On this basis, a second text sample without a label is input into the first text classification model to obtain a pseudo label corresponding to the second text sample.
[0003] The above patent application uses the labeled first text sample to train a first text classification model. The reasoning ability of the first text classification model depends on the number of labeled first text samples and the accuracy of annotation. If the number of labeled first text samples is small or the annotated labels are wrong or missing, the reasoning ability of the first text classification model obtained by training is also poor, resulting in errors or incompleteness in the pseudo-labels corresponding to the second text samples obtained above. Therefore, how to obtain correct and more comprehensive labels for texts is an urgent problem to be solved. Summary of the invention
[0004] The purpose of the present invention is to provide a method for obtaining text labels, so as to obtain correct and more comprehensive labels for texts.
[0005] According to the present invention, a method for obtaining a text label comprises the following steps:
[0006] F100, obtaining a text set tex of the labels to be obtained, tex including texts of several labels to be obtained, and each text of the label to be obtained corresponds to several original labels.
[0007] F200, according to the text of the first label to be obtained in tex 1A trained first label inference model set mode1 is obtained, where mode1 includes more than two trained first label inference models.
[0008] F300, get the text tex of the second label to be obtained in tex according to mode1 2 The inference label set qa of the text to be labeled 2 ,qa 2 Including tex 2 The inference label set of zn texts to be labeled, qa 2 Included tex 2 The inference label set of the erth text to be labeled is qa 2 er ,qa 2 er Include each trained first label inference model pair tex in mode1 2 The inference label set of the erth text to be labeled, each trained first label inference model in mode1 is used for tex 2 The inference label set of the erth text to be labeled includes several inference labels; the value range of er is 1 to zn, where zn is tex 2 The number of texts to be labeled in tex 2 Remove tex from tex 1 The text of the tag to be obtained.
[0009] F400, traverse qa 2 , for qa 2 er Filter and obtain the filtered inference label set nqa 2 er ;nqa 2 er Including QA 2 er Several inference labels remaining after filtering.
[0010] F500, nqa 2 er Determine as tex 2 The label of the erth text to be judged.
[0011] The present invention has at least the following beneficial effects:
[0012] Each text in the text tex to be labeled in the present invention corresponds to an original label, and these original labels may contain erroneous labels or incomplete labels. The present invention uses a part of the text tex in tex 1The corresponding original labels can obtain multiple trained first label inference models, each of which has the ability to infer labels. The present invention obtains another part of the text tex in tex according to the multiple trained first label inference models 2 inference labels; since the present invention uses multiple trained first label inference models to obtain inference labels for texts, different trained first label inference models have different semantic analysis capabilities, and the corresponding inference labels for the same text obtained when performing label inference on the same text may also be different, the present invention uses the inference labels obtained by multiple trained first label inference models for the same text as the inference labels for the text, so the inference labels for the text obtained by the present invention are more comprehensive; moreover, for the inference labels obtained according to the multiple trained first label inference models, the present invention also screens them to select the correct labels from the more comprehensive inference labels; thus, the present invention achieves the purpose of obtaining correct and more comprehensive labels for texts. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0014] Figure 1 A flowchart of a method for obtaining text labels provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0015] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0016] According to the present invention, a method for obtaining a text label is provided, such as Figure 1 As shown, including:
[0017] F100, obtaining a text set tex of the labels to be obtained, tex including texts of several labels to be obtained, and each text of the label to be obtained corresponds to several original labels.
[0018] In this embodiment, tex={tex1,tex2,…,tex ac ,…,tex ae},tex acis the text of the acth label to be obtained, the value range of ac is 1 to ae, ae is the number of texts of the label to be obtained; each tex ac Corresponding to several original labels.
[0019] In this embodiment, each tex ac The number of corresponding original labels is greater than or equal to 1, and the original label may be tex ac The corresponding correct label may also be tex ac The corresponding wrong label, and the proportion of correct labels in the original labels of all texts corresponding to tex is greater than the proportion of wrong labels in the original labels; as a specific implementation method, each tex ac The corresponding original labels are manually annotated labels.
[0020] F200, according to the text of the first label to be obtained in tex 1 A trained first label inference model set mode1 is obtained, where mode1 includes more than two trained first label inference models.
[0021] In this embodiment, mode1={mode 1,1 ,mode 1,2 ,…,mode 1,av ,…,mode 1,ax}, mode 1,av According to tex 1 Get the avth trained first label inference model, where av ranges from 1 to ax, and ax is the value of tex 1 The number of trained first-label inference models obtained; ax ≥ 2.
[0022] In this embodiment, the text to be obtained in the tex tag is divided into two parts, one of which is tex 1 , the other part is tex 2 ; optional, tex 1 The number of texts to be labeled in is 1 / 2 of the number of texts to be labeled in tex. 2 The number of texts to be labeled in is also 1 / 2 of the number of texts to be labeled in tex.
[0023] In this embodiment, each mode 1,av The training samples come from tex 1 , different modes 1,av There are differences in the corresponding training samples; as a specific implementation, F200 includes:
[0024] F210, tex 1Perform partitioning to obtain the partitioned text subset zc1, where zc1 includes ax text subsets, and ax is the number of trained first label inference models included in mode1.
[0025] In this embodiment, zc1 = {zc 1,1 , zc 1,2 , …, zc 1,av , …, zc 1,ax}, and zc 1,av is the av-th text subset obtained by partitioning tex 1 .
[0026] Optionally, divide tex 1 into ax equal text subsets.
[0027] F220, initialize the model variable ha to 1.
[0028] F230, select ax - 1 text subsets from zc1 except zc 1,ha as the ha-th training sample; zc 1,ha is the ha-th text subset obtained by partitioning tex 1 .
[0029] F240, use the ha-th training sample and the corresponding original label to train the ha-th first label inference model, and obtain the ha-th trained first label inference model mode 1,ha .
[0030] F250, if ha < ax, then ha = ha + 1, and repeat F230 - F240 until ha = ax.
[0031] Based on F210 - F250, when ha is 1, executing F230 - F240 can obtain the 1st trained first label inference model mode 1,1 ; when ha is 2, executing F230 - F240 can obtain the 2nd trained first label inference model mode 1,2 , and so on. When ha is ax, executing F230 - F240 can obtain the ax-th trained first label inference model mode 1,ax ; thus, ax trained first label inference models can be obtained after executing F210 - F250.
[0032] F300, obtain the inference label set qa 2 of the text with the second label to be obtained in tex 2 according to mode1, where qa 2 includes the text of tex 2The inference label set of zn texts to be labeled, qa 2 Included tex 2 The inference label set of the erth text to be labeled is qa 2 er ,qa 2 er Include each trained first label inference model pair tex in mode1 2 The inference label set of the erth text to be labeled, each trained first label inference model in mode1 is used for tex 2 The inference label set of the erth text to be labeled includes several inference labels; the value range of er is 1 to zn, where zn is tex 2 The number of texts to be labeled in tex 2 Remove tex from tex 1 The text of the tag to be obtained.
[0033] In this embodiment, qa 2 ={qa 2 1,qa 2 2,…,qa 2 er ,…,qa 2 zn}, qa 2 er For tex 2 The inference label set of the erth text to be labeled, qa 2 er ={qa 2 er,1 ,qa 2 er,2 ,…,qa 2 er,av ,…,qa 2 er,ax}, qa 2 er,av According to mode 1,av Get tex 2 The inference label set of the erth text to be labeled; each qa 2 er,av Includes several inference tags.
[0034] In this embodiment, tex 2 The text of the erth label to be obtained in is used as the input of the first trained first label inference model, and mode 1,1 Inferred tex 2 The inference label set qa of the erth text to be labeled 2er,1 ; 2 The text of the erth label to be obtained is used as the input of the second trained first label inference model, and mode 1,2 Inferred tex 2 The inference label set qa of the erth text to be labeled 2 er,2 ; And so on, tex 2 The text of the erth label to be obtained is used as the input of the axth trained first label inference model to get mode 1,ax Inferred tex 2 The inference label set qa of the erth text to be labeled 2 er,ax .
[0035] F400, traverse qa 2 , for qa 2 er Filter and obtain the filtered inference label set nqa 2 er ;nqa 2 er Including QA 2 er Several inference labels remaining after filtering.
[0036] In this embodiment, nqa 2 er ={nqa 2 er,1 ,nqa 2 er,2 ,…,nqa 2 er,bv ,…,nqa 2 er,bx}, nqa 2 er,bv For qa 2 er The bvth inference label remaining after screening, the value range of bv is 1 to bx, bx is the value of qa 2 er The number of inference labels remaining after filtering.
[0037] In this embodiment, qa 2 er The purpose of screening is to 2 er The wrong labels are filtered out and the correct labels are retained.
[0038] As a first preferred specific implementation, F400 includes:
[0039] F410, get qa 2 Each inference label that appears in qa 2 The number of times it appears in .
[0040] F420, if qa 2 A certain inference label appears in qa 2 If the number of occurrences in is greater than or equal to the preset threshold, qa 2 The inference label that appears in is determined as the inference label retained after screening; otherwise, qa 2 The inference label that appears in is determined to be the inference label that is filtered out after filtering.
[0041] In this embodiment, qa 2 The inference tags whose occurrence times in the list are greater than or equal to the preset threshold are judged as tex 2 The correct label of the text to be labeled in er is qa 2 The inference tags whose occurrence times are less than the preset threshold are judged as tex 2 The wrong label of the text of the erth label to be obtained in . Optionally, the preset number of times threshold is ax / 2.
[0042] Based on F410-F420, this embodiment realizes the 2 er Screening, since this embodiment will qa 2 The inference labels that appear more often in qa are judged as correct labels, while 2 The inference labels that appear more often in the above are consistent inference results of a large number of trained first label inference models. Therefore, the nqa obtained based on F410-F420 in this embodiment is 2 er The label is tex 2 The probability of the correct label of the erth text to be labeled is higher, which improves the accuracy of the label of the text finally obtained.
[0043] As a second preferred specific implementation, F400 includes:
[0044] F401, get qa 2 er The inference label set wqa appears in 2 er , wqa 2 er Includes cx reasoning labels, cx is qa 2 er The number of inference labels that appear in .
[0045] In this embodiment, wqa2 er ={wqa 2 er,1 ,wqa 2 er,2 ,…,wqa 2 er,cv ,…,wqa 2 er,cx}, wqa 2 er,cv For QA 2 er The cvth inference label that appears in , where cv ranges from 1 to cx.
[0046] In this embodiment, different wqa 2 er,cv corresponds to different inference labels; since different trained first-label inference models may infer the same or different inference labels, cx is less than or equal to qa 2 er Each qa in 2 er,av The sum of the number of included inference labels.
[0047] F402, traverse wqa 2 er , use the trained large language model to judge wqa 2 er,cv Is it tex 2 The label of the text to be obtained in the erth label; wqa 2 er,cv For QA 2 er The cvth inference label that appears in , where cv ranges from 1 to cx.
[0048] Those skilled in the art know that any large language model in the prior art falls within the protection scope of the present invention.
[0049] Preferably, the cue words based on the thought chain make the trained large language model judge wqa 2 er,cv Is it tex 2 The label of the erth text to be labeled is included in the prompt word, and several example texts of the thought chain related to the content to be judged are included. Therefore, the trained large language model can be used to better learn the thinking of judging whether the label is correct and improve the accuracy of the judgment result.
[0050] F403, if yes, then wqa 2 er,cv Append to the preset erth tag set; otherwise, do not append wqa 2er,cv Append to the preset erth tag set; the preset erth tag set is initialized to an empty set.
[0051] F404, determine the preset erth label set as nqa 2 er .
[0052] Based on F401-F404, this embodiment implements qa based on the trained large language model 2 er The screening of NQA is improved through the trained large language model 2 er The accuracy of the inference labels in .
[0053] F500, will nqa 2 er Determine as tex 2 The label of the erth text to be judged.
[0054] In this embodiment, each text in the text tex to be labeled corresponds to an original label, and these original labels may contain erroneous labels or incomplete labels. In this embodiment, a part of the text tex in tex is used. 1 The corresponding original labels can obtain multiple trained first label inference models, each of which has the ability to infer labels. This embodiment obtains another part of the text tex in tex according to the multiple trained first label inference models. 2 inference labels; since the present embodiment utilizes multiple trained first label inference models to obtain inference labels for texts, different trained first label inference models have different semantic analysis capabilities, and the corresponding inference labels for the texts obtained when performing label inference on the same text may also be different, the present embodiment uses the inference labels obtained by multiple trained first label inference models for the same text as the inference labels for the text, so the inference labels for the texts obtained by the present embodiment are more comprehensive; moreover, the present embodiment also screens the inference labels obtained according to the multiple trained first label inference models to select the correct labels from the more comprehensive inference labels; thus, the present embodiment achieves the purpose of obtaining correct and more comprehensive labels for the texts.
[0055] As an optional specific implementation, ax is an empirical value, for example, 3≤ax≤5.
[0056] As a preferred specific implementation, the method for obtaining ax includes:
[0057] F201, get tex 1 The number of texts to be obtained for the tags included1 .
[0058] F202, get the initial number of divisions hua0, hua0=floor(shu 1 / shu0), shu0 is the preset text quantity threshold, and floor() is rounding down.
[0059] In this embodiment, shu0 is an empirical value, which corresponds to the minimum number of training samples required to train a first label inference model into a model with an accuracy greater than or equal to a preset accuracy threshold.
[0060] F203, obtain the first division quantity hua1, hua1=min(max(hua0,hua min ),hua max ), min() is the minimum value, max() is the maximum value, min is the preset minimum number of divisions, max The maximum number of divisions that can be set.
[0061] In this embodiment, hua min and hua max All are experience values.
[0062] F204, from tex 1 The text of the to-be-acquired label with a ratio of (hua1-1) / hua1 and the corresponding original label are used to train the test label inference model to obtain a trained test label inference model.
[0063] F205, if the accuracy of the trained test label inference model is greater than or equal to a preset accuracy threshold, hua1 is determined as ax.
[0064] In this embodiment, if the accuracy of the trained test label inference model is less than the preset accuracy threshold, then 1 The text of the to-be-acquired label with the proportion of hua1 / (hua1+1) and the corresponding original label are used to train the test label inference model to obtain a trained test label inference model. If the accuracy of the trained test label inference model is greater than or equal to the preset accuracy threshold, hua1+1 is determined as ax; otherwise, tex 1 The text of the to-be-acquired label with a proportion of (hua1+1) / (hua1+2) and the corresponding original label are used to train the test label inference model to obtain a trained test label inference model. If the accuracy of the trained test label inference model is greater than or equal to the preset accuracy threshold, hua1+2 is determined as ax; otherwise, tex 1The text of the to-be-obtained label with a proportion of (hua1+2) / (hua1+3) and the corresponding original label are used to train the test label inference model to obtain a trained test label inference model; and so on, until the accuracy of the trained test label inference model is greater than or equal to the preset accuracy threshold, the corresponding number of divisions is determined as ax.
[0065] Based on the ax obtained from F201-F205, tex 1 Divide it so that tex 1 The number of texts corresponding to the proportion of (hua1-1) / hua1 is relatively large, which improves the subsequent tex-based 1 The accuracy of the first label inference model trained on text with a ratio of (hua1-1) / hua1 is conducive to improving the accuracy of the final text label.
[0066] As an optional specific implementation, after F500, the method for obtaining the text label further includes:
[0067] F600, traverse tex 2 The original label corresponding to the text of the erth label to be obtained in tex 2 The original label corresponding to the text of the erth label to be obtained in nqa 2 er If it exists in 2 The original label corresponding to the text of the erth label to be obtained is correct; otherwise, judge tex 2 The original label corresponding to the text of the erth label to be obtained is wrong.
[0068] Therefore, this embodiment is based on tex 2 The label nqa corresponding to the text of the erth label to be obtained 2 er Implemented the tex 2 Determine the original label corresponding to the text of the erth label to be obtained.
[0069] In this embodiment, tex is obtained 1 The method of obtaining the label of each text to be labeled is the same as the above method of obtaining the text 2 The method of obtaining the label of each text to be labeled is similar, except that: 1 In the process of labeling each text to be labeled, according to the tex 2 Get the trained second label inference model mode2, which includes several 2 Obtain the trained second label inference model; obtain tex according to mode21 The inference label qa of the text to be labeled in 1 ,qa 1 Includes all tex obtained by the trained second label inference model 1 The inference label of each text to be labeled; traverse qa 1 , for qa 1 er Filter and get the filtered inference label nqa 1 er ; will nqa 1 er Determine as tex 1 The label of the erth text to be judged in . Get tex 1 The specific process of obtaining the label of each text to be labeled is the same as the above-mentioned process of obtaining the text label of the tex 2 The specific process of labeling each text to be labeled is similar and will not be repeated here.
[0070] Although some specific embodiments of the present invention have been described in detail by way of example, it will be appreciated by those skilled in the art that the above examples are for illustration only and are not intended to limit the scope of the present invention. It will also be appreciated by those skilled in the art that various modifications may be made to the embodiments without departing from the scope and spirit of the present invention. The scope of the present invention is defined by the appended claims.
Claims
1. A method for obtaining a text label, characterized in that: Including the following steps: F100, obtain the text set tex of the tags to be obtained, where tex includes the texts of several tags to be obtained, and each text of the tag to be obtained corresponds to several original tags; F200, according to the text of the first label to be obtained in tex 1 Obtain a trained first label inference model set mode1, where mode1 includes more than two trained first label inference models; F300, get the text tex of the second label to be obtained in tex according to mode1 2 The inference label set qa of the text to be labeled 2 ,qa 2 Including tex 2 The inference label set of zn texts to be labeled, qa 2 Included tex 2 The inference label set of the erth text to be labeled is qa 2 er ,qa 2 er Include each trained first label inference model pair tex in mode1 2 The inference label set of the erth text to be labeled, each trained first label inference model in mode1 is used for tex 2 The inference label set of the erth text to be labeled includes several inference labels; the value range of er is 1 to zn, where zn is tex 2 The number of texts to be labeled in tex 2 Remove tex from tex 1 The text of the tag to be obtained other than ; F400, traverse qa 2 , for qa 2 er Filter and obtain the filtered inference label set nqa 2 er ;nqa 2 er Including QA 2 er Several inference labels remaining after screening; F500, will nqa 2 er Determine as tex 2 The label of the erth text to be judged; F200 includes: F210, tex 1 Perform division to obtain a divided text subset zc1, where zc1 includes ax text subsets, and ax is the number of trained first label inference models included in mode1; F220, initialize the model variable ha to 1; F230, select from zc1 except zc 1,ha The ax-1 text subsets other than zc are used as the hath training samples; 1,ha To tex 1 The hath text subset obtained by division; F240, train the hath first label inference model using the hath training sample and the corresponding original label, and obtain the hath trained first label inference model mode 1,ha ; F250, if ha < ax, then ha = ha + 1, repeat F230 - F240 until ha = ax; The method for obtaining ax includes: F201, get tex 1 The number of texts to be obtained for the tags included 1 ; F202, get the initial number of divisions hua0, hua0=floor(shu 1 / shu0), shu0 is the preset text quantity threshold, floor() is rounded down; F203, obtain the first division quantity hua1, hua1=min(max(hua0,hua min ),hua max ), min() is the minimum value, max() is the maximum value, min is the preset minimum number of divisions, max The maximum number of divisions that is preset; F204, from tex 1 The text of the to-be-acquired label with a ratio of (hua1-1) / hua1 and the corresponding original label are used to train the test label inference model to obtain a trained test label inference model; F205, if the accuracy rate of the trained test label inference model is greater than or equal to the preset accuracy rate threshold, then determine hua1 as ax.
2. The method for obtaining a text label according to claim 1, characterized in that: F400 includes: F410, get qa 2 Each inference label that appears in qa 2 The number of times it appears in F420, if qa 2 A certain inference label appears in qa 2 If the number of occurrences in is greater than or equal to the preset threshold, qa 2 The inference label that appears in is determined as the inference label retained after screening; otherwise, qa 2 The inference label that appears in is determined to be the inference label that is filtered out after filtering.
3. The method for obtaining a text label according to claim 1, characterized in that: F400 includes: F401, get qa 2 er The inference label set wqa appears in 2 er , wqa 2 er Includes cx reasoning labels, cx is qa 2 er The number of inference labels that appear in ; F402, traverse wqa 2 er , use the trained large language model to judge wqa 2 er,cv Is it tex 2 The label of the text to be obtained in the erth label; wqa 2 er,cv For QA 2 er The cvth inference label that appears in , where the value of cv ranges from 1 to cx; F403, if yes, then wqa 2 er,cv Append to the preset erth tag set; otherwise, do not append wqa 2 er,cv Append to the preset erth tag set; the preset erth tag set is initialized to an empty set; F404, determine the preset erth label set as nqa 2 er .
4. The method for obtaining a text label according to claim 1, characterized in that: After F500, the method further includes: F600, traverse tex 2 The original label corresponding to the text of the erth label to be obtained in tex 2 The original label corresponding to the text of the erth label to be obtained in nqa 2 er If it exists in 2 The original label corresponding to the text of the erth label to be obtained is correct; otherwise, judge tex 2 The original label corresponding to the text of the erth label to be obtained is wrong.
