Data processing method for acquiring named entity recognition model
By analyzing the data of training, testing and new text sets, the optimal number of texts is determined to optimize the retraining of the named entity recognition model, which solves the problem of decreased accuracy after retraining in the existing technology, and improves the accuracy of the model against the original and new text sets. The recognition ability of new type entities is added, which enhances the semantic recognition ability.
Patent Information
- Application Number
- CN202410997258.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-24
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2044-07-24
AI Technical Summary
When the existing technology retrains the named entity recognition model, the recognition accuracy of the new specific types of entities increases, but the accuracy of the original types of entities decreases, and the decrease increases with the increase in the number of training samples, making it difficult to balance both aspects. recognition accuracy.
By obtaining the proportion of positive samples of the training text set, test text set and new text set and the weight of the training text set, the optimal number of texts obtained from the new text set is determined to optimize the retraining of the named entity recognition model. Taking into account the recognition accuracy of original and newly added types of entities.
It is realized that in the retrained named entity recognition model, the recognition ability of new types of entities is improved, and the recognition accuracy of original types of entities is maintained or improved, and the semantic recognition ability of the model is enhanced.
Smart Images

Figure CN118690751A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of electronic digital data processing, and in particular to a data processing method for obtaining a named entity recognition model. Background Art
[0002] In the prior art, a trained named entity recognition model can be used to identify specific types of entities in a text. For example, a Chinese patent with a publication number of CN109190110B discloses a training method, system and electronic device for a named entity recognition model. The patent first pre-annotates unannotated corpus data obtained from a corpus based on a category vocabulary, and then modifies the pre-annotated results to obtain a training text; then the named entity recognition model is trained based on the training text so that the trained named entity recognition model has the function of recognizing the above-mentioned category words from the text.
[0003] When training a named entity recognition model, if two categories of words in the training text are annotated, then the named entity recognition model obtained after training will have the function of recognizing two categories of words in the text; when training a named entity recognition model, if three categories of words in the training text are annotated, then the named entity recognition model obtained after training will have the function of recognizing three categories of words in the text. If you want the trained named entity recognition model to recognize more specific types of entities, then you need to train the trained named entity recognition model again. For example, the trained named entity recognition model can recognize entities of the first specific type and the second specific type. If you want the trained named entity recognition model to also recognize entities of the third specific type, the existing method is to use new training samples and the corresponding annotation results of the first specific type, the second specific type and the third specific type of entities to train the trained named entity recognition model again. However, such a problem may be encountered: although the retrained named entity recognition model has the function of being able to recognize the third specific type of entity, the recognition accuracy of the retrained named entity recognition model for the first specific type and the second specific type of entity is not improved, but decreases, and sometimes the degree of decrease increases with the increase in the number of new training samples. How to determine the number of new training samples to take into account the recognition accuracy of the retrained named entity recognition model for the original specific type of entity and the recognition accuracy of the newly added specific type of entity is an urgent problem to be solved. Summary of the invention
[0004] The purpose of the present invention is to provide a data processing method for obtaining a named entity recognition model to determine the number of new training samples so as to take into account the recognition accuracy of the retrained named entity recognition model for the original specific type of entity and the recognition accuracy of the newly added specific type of entity.
[0005] According to the present invention, a data processing method for obtaining a named entity recognition model is provided, the data processing method comprising the following steps: D100, obtain the training text set data of the trained named entity recognition model, data includes st training text sets, each training text set includes a number of training texts; st is the number of training text sets of the trained named entity recognition model; the trained named entity recognition model is a model trained using data, and the trained named entity recognition model is used to identify entities of preset type ty in the input text and mark corresponding labels; ty includes ht preset types, and ht is the number of preset preset types.
[0006] D200, traverse data, if using data se When training the named entity recognition model, se The entity of the mtth preset type is labeled, then the data se The proportion of positive samples of the mt-th preset type of entity in data is determined as data se The mtth weight qz se,mt ; Otherwise, set qz se,mt is 0; data se is the se-th training text set of the trained named entity recognition model. The value range of se is 1 to st; the value range of mt is 1 to ht.
[0007] D300, obtain the positive sample proportion cb of ht preset types of entities in the test text set.
[0008] D400, obtain the positive sample ratio zb of ht preset types of entities in the newly added text set.
[0009] D500, according to qz se,mt、 cb and zb determine the optimal amount of text to be obtained from the newly added text set for training the trained named entity recognition model.
[0010] Compared with the prior art, the present invention has at least the following beneficial effects: The trained named entity recognition model in the present invention is obtained by training based on the training text set data, and it already has the function of identifying ht preset types of entities; the newly added text set is the text obtained by the present invention in order to enable the trained text set to have the function of identifying entities of newly added preset types other than the above-mentioned ht preset types. When the trained named entity recognition model is retrained using the newly added text set, the number of texts selected from the newly added text set will not only affect the recognition ability of the retrained named entity recognition model for the newly added preset types of entities, but also affect the recognition ability of the retrained named entity recognition model for the above-mentioned ht preset types of entities; the present invention retrains the named entity recognition model based on the positive sample ratio of ht preset types of entities in the test text set, the positive sample ratio zb of ht preset types of entities in the newly added text set and the weight of each training text set corresponding to each preset type in data. Determine the optimal number of texts to be obtained from the newly added text set for training the trained named entity recognition model, wherein the proportion of positive samples of ht preset types of entities in the newly added text set determines the degree of influence of using the newly added text set to train the trained named entity recognition model on the recognition accuracy of the original ht preset types of entities, and the proportion of positive samples of ht preset types of entities in the test text set and the weight of each training text set corresponding to each preset type in the data reflect the recognition accuracy of the trained named entity recognition model for the original ht preset types of entities. Therefore, the present invention can achieve the purpose of taking into account the recognition accuracy of the retrained named entity recognition model for the original ht preset types of entities and the recognition accuracy of the newly added preset types of entities, so that the retrained named entity recognition model has stronger semantic recognition ability. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] 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.
[0012] Figure 1 A flowchart of a data processing method for obtaining a named entity recognition model provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0013] 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.
[0014] According to the present invention, a data processing method for obtaining a named entity recognition model is provided, the data processing method comprising the following steps: Figure 1 As shown: D100, obtain the training text set data of the trained named entity recognition model, data includes st training text sets, each training text set includes a number of training texts; st is the number of training text sets of the trained named entity recognition model; the trained named entity recognition model is a model trained using data, and the trained named entity recognition model is used to identify entities of preset type ty in the input text and mark corresponding labels; ty includes ht preset types, and ht is the number of preset preset types.
[0015] In this embodiment, data={data1,data2,…,data se ,…,data st}, data se is the se-th training text set of the trained named entity recognition model, data se Includes several training texts, the value range of se is 1 to st. ty=(ty1, ty2, ..., ty mt ,…,ty ht ),ty mt It is the mtth preset type, and the value range of mt is from 1 to ht.
[0016] In this embodiment, the trained named entity recognition model is obtained by training using the st training text sets included in the data. The purpose of training the named entity recognition model using the st training text sets included in the data is to enable the trained named entity recognition model to have the function of recognizing ht preset types of entities.
[0017] In this embodiment, when the named entity recognition model is trained using the st training text sets included in data, at least one entity of a preset type is annotated when each training text set is annotated, and entities other than ht entities of the preset types are not annotated, and each entity of the ht preset types has been annotated by at least one training text set. Thus, the trained named entity recognition model has and only has the function of recognizing entities of ht preset types.
[0018] D200, traverse data, if using data se When training the named entity recognition model, se The entity of the mtth preset type is labeled, then the data seThe proportion of positive samples of the mt-th preset type of entity in data is determined as data se The mtth weight qz se,mt ; Otherwise, set qz se,mt is 0; data se is the se-th training text set of the trained named entity recognition model. The value range of se is 1 to st; the value range of mt is 1 to ht.
[0019] In this embodiment, when the named entity recognition model is trained using the st training text sets included in data, not all entities of ht preset types are annotated when each training text set is annotated. For example, st=2, ht=4, when the named entity recognition model is trained using the first training text set and the second training text set, only entities of the first preset type and the second preset type are annotated when the first training text set is annotated, and only entities of the second preset type, the third preset type, and the fourth preset type are annotated when the second training text set is annotated.
[0020] In this embodiment, data se The proportion of positive samples of the mt-th preset type of entity in data is se The number of entities marked as entities of the mtth preset type in data se The ratio of the number of entities in se When training the named entity recognition model, se The entity of the mtth preset type is labeled, then the data se The value of the positive sample ratio of the mt-th preset type of entity in is assigned to qz se,mt ; If you use data se When training the named entity recognition model, there is no data se To label the entity of the mtth preset type, then qz se,mt Set to 0.
[0021] D300, obtain the positive sample proportion cb of ht preset types of entities in the test text set.
[0022] In this embodiment, cb=(cb1,cb2,…,cb mt ,…,cb ht ), cb mt is the proportion of positive samples of the mt-th preset type of entity in the test text set.
[0023] In this embodiment, the positive sample ratio of the mt-th preset type of entity in the test text set is the ratio of the number of entities in the test text set that are marked as entities of the mt-th preset type to the number of entities in the test text set.
[0024] In this embodiment, the proportion of positive samples of the mt-th preset type of entity in the test text set can represent the proportion of positive samples of the mt-th preset type of entity in the text set to be recognized subsequently by the trained named entity recognition. Optionally, the test text set is text extracted from the text set to be recognized subsequently by the trained named entity recognition, and the ht preset types of entities in the test text set are annotated by manual annotation method, and the proportion of positive samples of the ht preset types of entities is obtained.
[0025] D400, obtain the positive sample ratio zb of ht preset types of entities in the newly added text set.
[0026] In this embodiment, zb=(zb1,zb2,…,zb mt ,…,zb ht ), zb mt It is the proportion of positive samples of the mt-th preset type of entity in the newly added text set.
[0027] In this embodiment, the newly added text set is a text obtained in order to enable the trained text set to have the function of identifying entities of the newly added preset type, and the positive sample ratio of the mt-th preset type entity in the newly added text set is the ratio of the number of entities marked as entities of the mt-th preset type in the newly added text set to the number of entities in the newly added text set. As an optional specific implementation, D400 includes: D410, obtaining a preset proportion of text from the newly added text set to form a first extracted text set cq.
[0028] Optionally, a random extraction method is used to obtain a preset proportion of texts from the newly added text set to form a first extracted text set cq, where the preset proportion is an empirical value.
[0029] D420, using the trained named entity recognition model to perform ht preset types of entity recognition on each text in cq, and obtain labeling results of ht preset types of entities corresponding to each text in cq.
[0030] In this embodiment, each text in cq is used as the input of the trained named entity recognition model to obtain the corresponding labeling results of ht preset types of entities.
[0031] D430, according to the annotation result of each text in cq corresponding to the entity of the mt-th preset type, it is determined as zb mt .
[0032] In this embodiment, zb mt =∑ fs fe=1 en fe,mt / (∑ fs fe=1 q fe ),zh fe,mt is the number of entities annotated as entities of the mtth preset type in the feth text in cq, qh fe It is the number of entities included in the fe-th text in cq. The value range of fe is 1 to fs, and fs is the number of texts included in cq.
[0033] D500, according to qz se,mt、 cb and zb determine the optimal amount of text to be obtained from the newly added text set for training the trained named entity recognition model.
[0034] The trained named entity recognition model in this embodiment is obtained by training based on the training text set data, and it already has the function of identifying ht preset types of entities; the newly added text set is the text obtained in this embodiment in order to enable the trained text set to have the function of identifying newly added preset types of entities in addition to the above-mentioned ht preset types. When the trained named entity recognition model is retrained using the newly added text set, the number of texts selected from the newly added text set will not only affect the recognition ability of the retrained named entity recognition model for the newly added preset types of entities, but also affect the recognition ability of the retrained named entity recognition model for the above-mentioned ht preset types of entities; this embodiment selects the named entity recognition model based on the positive sample ratio of ht preset types of entities in the test text set, the positive sample ratio of ht preset types of entities in the newly added text set zb and each training text in data. This set corresponds to the weight of each preset type to determine the optimal number of texts to be obtained from the newly added text set for training the trained named entity recognition model, wherein the proportion of positive samples of ht preset types of entities in the newly added text set determines the degree of influence of using the newly added text set to train the trained named entity recognition model on the recognition accuracy of the original ht preset types of entities, and the proportion of positive samples of ht preset types of entities in the test text set and the weight of each training text set corresponding to each preset type in the data reflect the recognition accuracy of the trained named entity recognition model for the original ht preset types of entities. Therefore, this embodiment can achieve the purpose of taking into account the recognition accuracy of the named entity recognition model after re-training for the original ht preset types of entities and the recognition accuracy of the newly added preset types of entities.
[0035] As a preferred embodiment, D500 includes: D510, get the loss dif of the newly added text, dif=(∑ht mt=1 |cb mt -((∑ st se=1 qz se,mt ×mu se )+zb mt ×zq) / (su se + zq)|)+ke×zq,mu se For data se The amount of text included, su se is the corresponding qz in data se,mt The sum of the number of texts included in the training text set that is not 0; ke is a preset adjustment coefficient, ke>0, zq is the number of texts to be obtained from the newly added text set for training the trained named entity recognition model; zb mt cb is the proportion of positive samples of the mt-th preset type of entity in the newly added text set; mt is the proportion of positive samples of the mt-th preset type of entity in the test text set.
[0036] In this embodiment, ke is an empirical value, optional, 0 <ke<1。
[0037] D520, determining the value of zq when dif takes the minimum value as the optimal number of texts obtained from the newly added text set for training the trained named entity recognition model.
[0038] Based on the above preferred specific implementation manner, the loss of newly added texts corresponding to the optimal number of texts obtained is minimal. Obtaining texts from the newly added text set according to the optimal number of texts as training samples for the trained named entity recognition model can make the proportion of positive samples of entities of each preset type used for the named entity recognition model closer to the proportion of positive samples of entities of the corresponding preset type in the test sample, so that the named entity recognition model trained with the texts of the optimal number of texts in the newly added text set has a higher recognition accuracy rate for entities of the original preset type; obtaining texts from the newly added text set according to the optimal number of texts as training samples for the trained named entity recognition model can also make the number of texts obtained from the newly added text set larger, so that the named entity recognition model trained with the texts of the optimal number of texts in the newly added text set has a higher recognition accuracy rate for entities of the newly added preset type; therefore, the optimal number of texts obtained based on this preferred specific implementation manner can achieve the purpose of taking into account the recognition accuracy rate of the named entity recognition model for entities of the original preset type and entities of the newly added preset type, so that the named entity recognition model after re-training has stronger semantic recognition ability.
[0039] As an optional specific implementation, after D500, when the computer readable instructions are executed by the processor, the following steps are further implemented: D600, fk texts are obtained from the newly added text set to form a text set to be annotated, where fk is the optimal number of texts.
[0040] D700, obtaining the annotation result res corresponding to the text set to be annotated, res including the annotation result ty corresponding to the text set to be annotated and the annotation result of the newly added preset type corresponding to the text set to be annotated; the newly added preset type and any ty mt Are different.
[0041] In this embodiment, the annotation result of ty corresponding to the to-be-annotated text set includes each ty corresponding to the to-be-annotated text set. mt The labeling results.
[0042] D800: train the trained named entity recognition model using the to-be-annotated text set and res.
[0043] Based on D600-D800, the obtained trained named entity recognition model not only has the function of identifying entities of newly added preset types, but also enables the trained named entity recognition model to reduce or improve the recognition accuracy of entities of the original preset types, thereby improving the recognition function of the trained named entity recognition model as a whole.
[0044] 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 data processing method for obtaining a named entity recognition model, characterized in that: The data processing method comprises the following steps: D100, obtaining a training text set data of a trained named entity recognition model, where data includes st training text sets, each training text set includes a number of training texts; st is the number of training text sets of the trained named entity recognition model; the trained named entity recognition model is a model trained using data, and the trained named entity recognition model is used to identify entities of a preset type ty in an input text and annotate corresponding labels; ty includes ht preset types, and ht is the number of preset preset types; D200, traverse data, if using data se When training the named entity recognition model, se The entity of the mtth preset type is labeled, then the data se The proportion of positive samples of the mt-th preset type of entity in data is determined as data se The mt-th weight qz se,mt ; Otherwise, set qz se,mt is 0; data se is the se-th training text set of the trained named entity recognition model, the value range of se is 1 to st; the value range of mt is 1 to ht; D300, obtain the positive sample proportion cb of ht preset types of entities in the test text set; D400, obtain the positive sample ratio zb of ht preset types of entities in the newly added text set; D500, according to qz se,mt、 cb and zb determine the optimal amount of text to be obtained from the newly added text set for training the trained named entity recognition model.
2. The data processing method for obtaining a named entity recognition model according to claim 1, characterized in that: The D500 includes: D510, get the loss dif of the newly added text, dif=(∑ ht mt=1 |cb mt -((∑ st se=1 qz se,mt ×mu se )+zb mt ×zq) / (su se + zq)|)+ke×zq,mu se For data se The amount of text included, su se is the corresponding qz in data se,mt The sum of the number of texts included in the training text set that is not 0; ke is a preset adjustment coefficient, ke>0, zq is the number of texts to be obtained from the newly added text set for training the trained named entity recognition model; zb mt cb is the proportion of positive samples of the mt-th preset type of entity in the newly added text set; mt is the proportion of positive samples of the mt-th preset type of entity in the test text set; D520, determining the value of zq when dif takes the minimum value as the optimal number of texts obtained from the newly added text set for training the trained named entity recognition model.
3. The data processing method for obtaining a named entity recognition model according to claim 2, characterized in that: D400 includes: D410, obtaining a preset proportion of texts from the newly added text set to form a first extracted text set cq; D420, using the trained named entity recognition model to perform ht preset types of entity recognition on each text in cq, and obtain labeling results of ht preset types of entities corresponding to each text in cq; D430, according to the annotation result of each text in cq corresponding to the entity of the mt-th preset type, it is determined as zb mt .
4. The data processing method for obtaining a named entity recognition model according to claim 1, characterized in that: After D500, when the computer readable instructions are executed by the processor, the following steps are further implemented: D600, fk texts are obtained from the newly added text set to form a text set to be annotated, where fk is the optimal number of texts; D700, obtaining the annotation result res corresponding to the text set to be annotated, res including the annotation result ty corresponding to the text set to be annotated and the annotation result of the newly added preset type corresponding to the text set to be annotated; the newly added preset type and any ty mt All are different; D800: train the trained named entity recognition model using the to-be-annotated text set and res.
5. The data processing method for obtaining a named entity recognition model according to claim 3, characterized in that: zb mt =∑ fs fe=1 en fe,mt / (∑ fs fe=1 q fe ),zh fe,mt is the number of entities annotated as entities of the mtth preset type in the feth text in cq, qh fe It is the number of entities included in the fe-th text in cq. The value range of fe is 1 to fs, and fs is the number of texts included in cq.
6. The data processing method for obtaining a named entity recognition model according to claim 2, characterized in that: 0 <ke<1。 7. The data processing method for obtaining a named entity recognition model according to claim 4, characterized in that: The annotation results of ty corresponding to the to-be-annotated text set include annotation results of each preset type corresponding to the to-be-annotated text set.
Citation Information
Patent Citations
Data monitoring method and device based on machine learning
CN110852602A
Named entity recognition-oriented training set automatic labeling method and system
CN115146642A
Named entity recognition model training method, electronic equipment and storage medium
CN115345258A
Automatic prompt-based few-sample entity recognition method
CN117094321A
Training method and apparatus for named entity model, device, and medium
WO2022142123A1
