A named entity recognition and error correction method based on self-distillation
By using a three-layer named entity recognition model and self-distillation technology, the problems of syntax errors and punctuation errors in named entity recognition are solved, achieving accurate named entity extraction and error correction, and improving recognition speed and accuracy.
Patent Information
- Application Number
- CN202010897066.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-08-31
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2040-08-31
AI Technical Summary
Existing named entity recognition methods cannot accurately extract named entities when faced with grammatical or punctuation errors in text, and lack external knowledge support, leading to incorrect extraction.
A three-layer named entity recognition model is adopted, including the bert-large model, the Transformer Encoder model, and the CBOW model. The model is trained and filled with knowledge through self-distillation technology, and combined with the grammatical and logical rationality detection and error correction mechanism to achieve accurate named entity extraction and error correction.
It improves the accuracy and speed of named entity recognition, can identify and correct grammatical errors in text, and enhances the accuracy and efficiency of named entity extraction.
Smart Images

Figure CN112101032B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of text processing, and in particular to a method, device, storage medium and computing equipment for named entity recognition and error correction based on self-distillation. Background Art
[0002] Named entity recognition based on text data is a natural language processing technology widely used in human-computer dialogue systems. After cleaning, vector mapping, and semantic understanding and matching of text data, it can automatically extract words in the text that meet preset attributes, thereby achieving the purpose of specifically identifying a certain type of special words. This method is mostly used to identify names of people, places, and time.
[0003] Disadvantages of the existing technology:
[0004] 1) In general named entity recognition methods, if there are grammatical errors or punctuation errors in the text named entities, the method will extract incorrect words due to the strong context features, and cannot solve such abnormal errors.
[0005] 2) In general, this type of technology does not have a lot of external knowledge and grammatical logic support, making it difficult to accurately extract special words. Summary of the invention
[0006] In order to solve at least one of the above technical problems, the present invention provides a method, device, storage medium and computing device for named entity recognition and error correction based on self-distillation, which can achieve the purpose of accurately extracting text named entities by training a three-layer named entity recognition model. The purpose of the present invention is achieved by the following scheme:
[0007] A named entity recognition and error correction method based on self-distillation, comprising:
[0008] Training is performed on a named entity recognition model; the named entity recognition model includes a first layer model, a second layer model and a third layer model; the first layer model is used for training according to unlabeled data, and compressing the probability distribution in the first layer model into the second layer model; the second layer model is used for named entity extraction; the third layer model is used for error detection of the extracted named entities, and, after errors are detected, error correction;
[0009] Obtaining text of named entities to be extracted and inputting it into the named entity recognition model;
[0010] The named entities are extracted using the named entity recognition model.
[0011] Furthermore, the first layer model is a bert-large model;
[0012] Training the bert-large model includes:
[0013] The BERT-Large model is trained on unlabeled data, and the BERT-Large model is fine-tuned on vertical domain data.
[0014] Furthermore, the second layer model is a Transformer Encoder model;
[0015] Training the Transformer Encoder model includes:
[0016] The Transformer Encoder model is trained using contextual features of each word in the text; wherein the probability distribution of the first layer model is compressed into the Transformer Encoder model in advance by branched self-distillation, and the fully connected layer output of the first layer model is used as a pre-trained word vector.
[0017] Furthermore, the third layer model is a CBOW model;
[0018] Training the CBOW model includes:
[0019] The CBOW model in vertical fields is trained through regular text data.
[0020] Further, error detection is performed on the extracted named entities, including:
[0021] Calculate the grammatical and logical rationality of the named entity and give a score;
[0022] If the grammatical logic rationality score of the named entity is higher than a preset first threshold, the extracted named entity is output as a result;
[0023] If the grammatical and logical rationality score of the named entity is lower than the preset first threshold, it is confirmed that the extracted named entity is wrong.
[0024] Further, the error correction after the error is detected includes:
[0025] Generating a revised candidate set according to the extracted named entities;
[0026] evaluating the named entities of the revised candidate set;
[0027] According to the evaluation result, a named entity is selected from the correction candidate set as a correction result of the extracted named entity.
[0028] Furthermore, the named entities of the modified candidate set are evaluated, including:
[0029] Obtaining modification rate statistics of named entities in the modification candidate set;
[0030] Calculating the first semantic similarity between the named entities in the revised candidate set and the named entities in the proprietary vocabulary;
[0031] Calculating a second semantic similarity between the named entities in the revised candidate set and the named entities in the public vocabulary;
[0032] The named entities in the revised candidate set are evaluated according to the modification rate statistics, the first semantic similarity, and the second semantic similarity.
[0033] A method and device for named entity recognition and error correction based on self-distillation, comprising:
[0034] A model training module, used for training a named entity recognition model; the named entity recognition model includes a first layer model, a second layer model and a third layer model; the first layer model is used for training according to unlabeled data, and compressing the probability distribution in the first layer model into the second layer model; the second layer model is used for named entity extraction; the third layer model is used for error detection of the extracted named entities, and, after detecting an error, error correction;
[0035] A text acquisition module, used to acquire the text of the named entity to be extracted and input it into the named entity recognition model;
[0036] A named entity extraction module is used to extract the text named entities through the named entity recognition model.
[0037] A readable storage medium has executable instructions thereon, and when the executable instructions are executed, a computer is caused to execute the method as described above.
[0038] A computing device comprising:
[0039] one or more processors;
[0040] A memory; and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors as described above.
[0041] Compared with the prior art, the advantages of the present invention are as follows: the present invention introduces an externally trained knowledge model into the three-layer named entity recognition model to fill the named entity recognition model with knowledge. Even if common grammatical errors or punctuation errors appear in the text, the named entity recognition model can abandon certain words according to the preset threshold, or choose to automatically correct the words, thereby achieving a more accurate named entity extraction effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this specification, illustrate exemplary embodiments of the invention and together with the description serve to explain the principles of the invention.
[0043] Figure 1 It is a flow chart of a method for named entity recognition and error correction based on self-distillation according to an embodiment of the present invention;
[0044] Figure 2 is a schematic diagram of attention scores at different levels according to an embodiment of the present invention;
[0045] Figure 3 The present invention is a structural block diagram of a method and device for extracting named entities from text according to an embodiment of the present invention. Specific implementation plan
[0046] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the relevant content, rather than to limit the present invention. It should also be noted that, for ease of description, only the parts related to the present invention are shown in the accompanying drawings.
[0047] It should be noted that, in the absence of conflict, the embodiments and features of the embodiments of the present invention can be combined with each other. The present invention will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0048] Figure 1 A method for named entity recognition and error correction based on self-distillation according to the present invention is exemplified. The method starts with step S100: training a named entity recognition model. The named entity recognition model here includes three-layer models, namely a first-layer model, a second-layer model, and a third-layer model. In order to achieve a more accurate effect of extracting named entities, it is necessary to perform training on different contents for the three-layer models respectively.
[0049] The first layer model is the Bert-Large model, which is trained with unlabeled data and fine-tuned with vertical domain data. The first layer model is used to train with unlabeled data and compress the probability distribution in the first layer model into the second layer model.
[0050] The second layer model is the Transformer Encoder model. When training the Transformer Encoder model, the Transformer Encoder model is trained through the context features of each word in the text. The probability distribution of the first layer model is compressed into the Transformer Encoder model in advance through branch self-distillation, and the fully connected layer output of the first layer model is used as the pre-trained word vector. The high-dimensional vector features of the corresponding vocabulary in the pre-trained word vector are used to train the named entity recognition model, so as to achieve the purpose of more accurate named entity extraction through the named entity recognition model in subsequent use. The second layer model is used to extract named entities.
[0051] By training the first-layer model and the second-layer model, the named entity recognition model is provided with more accurate external knowledge, while also having a faster speed and smaller size.
[0052] The third layer model is the CBOW model; training is performed on the CBOW model, including: training the CBOW model in a vertical field through regular text data.
[0053] The third layer model is used to detect errors in the extracted named entities and to correct them after errors are detected.
[0054] After the model training is completed, the process proceeds to step S101 to obtain the text of the named entity to be extracted and input it into the named entity recognition model, and then proceeds to step S102 to extract the named entity through the named entity recognition model.
[0055] After the extraction of named entities is completed, the trained third-layer model is used to detect errors in the extracted named entities and to correct them after errors are detected. The trained third-layer model can provide accurate error detection and correction solutions for the extraction of named entities, which can increase the semantic understanding ability of the model.
[0056] At the same time, compared with general named entity recognition methods that can only extract existing words or sentences but cannot identify and correct errors based on existing data, the present invention expands the capability boundary of the named entity model through the trained third-layer model.
[0057] When performing error detection on the extracted named entities, this includes:
[0058] Calculate the grammatical logic rationality of the named entity and score it; if the grammatical logic rationality score of the named entity is higher than a preset first threshold, preferably, the preset first threshold is 0.5, then confirm that the named entity extracted by the named entity recognition model is correct, and output the extracted named entity as the extraction result of the named entity;
[0059] If the grammatical logic rationality score of the named entity is lower than a preset first threshold, it is confirmed that the named entity extracted by the named entity recognition model is wrong.
[0060] The grammatical logic is a logical model presented in the form of a language model based on the training and learning of a large number of unlabeled data in vertical fields. The language model will score the rationality of the grammatical logic based on the context. If the score is too low, it means that the logic does not exist or rarely exists in large-scale corpus, which means that there may be a problem with the grammatical logic here - that is, this may be an abnormal description text. Then it is confirmed that the named entity extracted by the named entity recognition model is wrong.
[0061] After error detection is performed on the named entity, if the grammatical logic rationality score of the named entity is lower than a preset first threshold, it is confirmed that the extracted named entity is wrong, and error correction needs to be performed on the wrong named entity.
[0062] In the process of error correction, we will:
[0063] Generate a correction candidate set based on the extracted named entities;
[0064] Evaluate the named entities of the revised candidate set, including:
[0065] Obtain modification rate statistics of named entities in the modification candidate set;
[0066] The first semantic similarity between the named entities in the modified candidate set and the named entities in the proprietary vocabulary is calculated; the proprietary vocabulary here is related to the enterprise itself that performs the named entity extraction.
[0067] The second semantic similarity between the named entities in the revised candidate set and the named entities in the public vocabulary is calculated; the public vocabulary here may be an existing vocabulary that is publicly searchable, such as WiKi, Babel, or Zhishime.
[0068] The named entities in the revision candidate set are evaluated based on the modification rate statistics, the first semantic similarity, and the second semantic similarity.
[0069] During the evaluation process, the modification rate is defined as: "1-the similarity of the word vectors of the two words", that is, the more similar the two words are, the lower the modification rate will be.
[0070] During the specific evaluation process, if the modification rate is higher than 0.5, or the first semantic similarity is higher than a preset third threshold, preferably, the preset third threshold is 0.7, or the second semantic similarity is higher than a preset fourth threshold, preferably, the preset fourth threshold is 0.5, then it is determined that the named entity in the revised candidate set is correct, and the revised named entity is selected from the revised candidate set as the revised result of extracting the named entity, and is output as the extracted result of the named entity.
[0071] See the instruction manual Figure 2 ,Attention scores at different levels of the embodiment of the present invention,In the pre-training stage, we fine-tuned the vertical field dataset by freezing the weights layer by layer, and found that the attention score was the highest at 3 layers.,The results prove that the 3-layer model already contains most of the information for named entity recognition.
[0072] Based on this, the present invention uses a three-layer Transformer Encoder structure as a knowledge receptor, and uses the Bert-Large model fine-tuned based on a large amount of unlabeled vertical field data as an instructor. Through branch self-distillation, the probability distribution in the Bert-Large model is compressed into a three-layer Transformer carrier model, and the fully connected layer output of the model is used as a pre-trained word vector, thereby providing the named entity recognition model with more accurate external knowledge while also using faster speed and smaller size.
[0073] See the following table for a comparison of the model effects and performances of the named entity recognition model of the present invention and other models, where recall represents the recall rate; precision, F1-score represents the precision rate; and predict_speed represents the prediction speed (i.e., performance) of the model on the CPU:
[0074]
[0075] It can be seen from the above table that: when comparing the effects of this technology with the latest mainstream technology based on the data set in this vertical field, the model of the present invention (distilled-transformer+BiLSTM+CRF) has obvious advantages over other models in terms of recall and precision; in terms of effect, it is almost on par with the current sota technology path (Bert+BiLSTM+CRF), but in terms of performance, it is 8 times faster than the sota technology path (Bert+BiLSTM+CRF), and is more practical.
[0076] The present invention also discloses an accurate self-distillation-based named entity recognition and error correction technology, the specific steps of which are as follows:
[0077] Step 1: Accurate and fast named entity extraction technology, that is, accurately extracting named entities that meet the preset categories in the text through the named entity model:
[0078] This method trains a named entity recognition model through the context features of each word in the text and the corresponding named entity high-dimensional vector features in the miniaturized pre-trained word vector obtained based on knowledge distillation. In subsequent use, more accurate named entities can be obtained through the named entity recognition model.
[0079] Step 2: Automatic error correction technology for named entities based on the named entity recognition model and the vocabulary of the existing vocabulary;
[0080] The grammatical and logical rationality of each suspected named entity is calculated and scored based on the language model trained based on a large amount of text data. Suspected named entities with higher scores can enter the named entity library, while named entities with lower scores need to be modified according to the candidate modification schemes generated by the grammatical model. After automatic correction, the semantic similarity is calculated based on the modification rate of the word, other named entities of the enterprise, and all named entities in the existing vocabulary. If it is higher than the preset threshold, it is judged that the error correction is correct.
[0081] See the instruction manual Figure 3 , an embodiment of the present invention provides a named entity recognition and error correction device based on self-distillation, comprising:
[0082] The model training module 200 is used to train a named entity recognition model; the named entity recognition model includes a first layer model, a second layer model and a third layer model; the first layer model is used to train according to unlabeled data, and compress the probability distribution in the first layer model into the second layer model; the second layer model is used to extract named entities; the third layer model is used to detect errors in the extracted named entities, and correct errors after errors are detected;
[0083] A text acquisition module 201 is used to acquire the text of the named entity to be extracted and input it into a named entity recognition model;
[0084] The named entity extraction module 202 is used to extract text named entities through a named entity recognition model.
[0085] Optionally, it also includes:
[0086] Error detection module, used to calculate and score the grammatical and logical rationality of named entities;
[0087] If the grammatical logic rationality score of the named entity is higher than the preset first threshold, the extracted named entity is output as a result;
[0088] If the grammatical logic rationality score of the named entity is lower than a preset first threshold, it is determined that the extracted named entity is wrong.
[0089] Optionally, it also includes an error correction module, which is used to generate a correction candidate set based on the extracted named entities; evaluate the named entities in the correction candidate set; and select named entities from the correction candidate set as correction results of the extracted named entities based on the evaluation results.
[0090] Optionally, the named entity recognition model also includes a named entity evaluation module, which is used to obtain modification rate statistics of named entities in the revised candidate set; calculate the first semantic similarity between the named entities in the revised candidate set and the named entities in the proprietary vocabulary; calculate the second semantic similarity between the named entities in the revised candidate set and the named entities in the public vocabulary; and evaluate the named entities in the revised candidate set based on the modification rate statistics, the first semantic similarity and the second semantic similarity.
[0091] The present invention also discloses a computer-readable storage medium, on which a computer program is stored, and when the program is executed by a processor, the following steps are implemented: training a named entity recognition model; obtaining text of a named entity to be extracted and inputting it into the named entity recognition model; and extracting the named entity through the named entity recognition model.
[0092] The present invention also discloses a terminal, comprising a memory, a processor and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the following steps are achieved: training a named entity recognition model; obtaining text of a named entity to be extracted and inputting it into the named entity recognition model; and extracting the named entity through the named entity recognition model.
[0093] It should be understood that the various techniques described herein can be implemented in combination with hardware or software, or a combination thereof. Thus, the method and apparatus of the present invention, or some aspects or portions of the method and apparatus of the present invention, can take the form of program codes (i.e., instructions) embedded in a tangible medium, such as a floppy disk, a CD-ROM, a hard disk drive, or any other machine-readable storage medium, wherein when the program is loaded into a machine such as a computer and executed by the machine, the machine becomes a device for practicing the present invention.
[0094] In the case where the program code is executed on a programmable computer, the computing device generally includes a processor, a storage medium readable by the processor (including volatile and non-volatile memory and / or storage elements), at least one input device, and at least one output device. The memory is configured to store the program code; the processor is configured to execute various methods of the present invention according to the instructions in the program code stored in the memory.
[0095] By way of example and not limitation, computer readable media include computer storage media and communication media. Computer readable media include computer storage media and communication media. Computer storage media stores information such as computer readable instructions, data structures, program modules or other data. Communication media generally embodies computer readable instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transmission mechanism, and includes any information delivery medium. Any combination of the above is also included within the scope of computer readable media.
[0096] It should be understood that in order to streamline the present invention and aid in understanding one or more of the various disclosed aspects, in the above description of exemplary embodiments of the present invention, the various features of the present invention are sometimes grouped together into a single embodiment, figure, or description thereof. However, this disclosed method should not be interpreted as reflecting the following intention: that the claimed invention requires more features than the features explicitly recited in each claim. More specifically, as reflected in the claims below, the disclosed aspects lie in less than all the features of the single embodiment disclosed above. Therefore, the claims that follow the specific embodiment are hereby expressly incorporated into the specific embodiment, wherein each claim itself serves as a separate embodiment of the present invention.
[0097] Those skilled in the art will appreciate that the modules or units or components of the devices in the examples disclosed herein may be arranged in the devices described in the embodiment, or alternatively may be located in one or more devices different from the devices in the examples. The modules in the foregoing examples may be combined into one module or may be divided into multiple submodules.
[0098] Those skilled in the art will appreciate that the modules in the devices in the embodiments may be adaptively changed and arranged in one or more devices different from the embodiments. The modules or units or components in the embodiments may be combined into one module or unit or component, and in addition they may be divided into a plurality of submodules or subunits or subcomponents. Except that at least some of such features and / or processes or units are mutually exclusive, all features disclosed in this specification (including the accompanying claims, abstracts and drawings) and all processes or units of any method or device disclosed in this manner may be combined in any combination. Unless otherwise expressly stated, each feature disclosed in this specification (including the accompanying claims, abstracts and drawings) may be replaced by an alternative feature providing the same, equivalent or similar purpose.
[0099] Furthermore, those skilled in the art will appreciate that although some embodiments described herein include certain features included in other embodiments but not other features, the combination of features from different embodiments is meant to be within the scope of the present invention and to form different embodiments.
[0100] In addition, some of the embodiments are described herein as methods or combinations of method elements that can be implemented by a processor of a computer system or by other devices that perform the functions. Therefore, a processor with necessary instructions for implementing the method or method elements forms a device for implementing the method or method elements. In addition, the elements described herein of the device embodiments are examples of devices that are used to implement the functions performed by the elements for the purpose of implementing the disclosure.
[0101] As used herein, unless otherwise specified, the use of ordinal numbers "first," "second," "third," etc. to describe common objects merely indicates that different instances of similar objects are involved and are not intended to imply that the objects so described must have a given order in terms of temporal order, spatial order, or in any other manner.
[0102] Although the present invention has been described according to a limited number of embodiments, it will be apparent to those skilled in the art, with the benefit of the above description, that other embodiments may be envisioned within the scope of the invention thus described. In addition, it should be noted that the language used in this specification is selected primarily for readability and teaching purposes, rather than for explaining or defining the subject matter of the present invention. Therefore, many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the appended claims. The disclosure of the present invention is illustrative, not restrictive, with respect to the scope of the present invention, which is defined by the appended claims.
Claims
1. A method for named entity recognition and error correction based on self-distillation, characterized in that: include: Training is performed on a named entity recognition model; the named entity recognition model includes a first layer model, a second layer model and a third layer model; the first layer model is used for training according to unlabeled data, and compressing the probability distribution in the first layer model into the second layer model; the second layer model is used for named entity extraction; the third layer model is used for error detection of the extracted named entities, and, after errors are detected, error correction; The error detection of the extracted named entity includes: calculating and scoring the grammatical logic rationality of the named entity; if the grammatical logic rationality score of the named entity is higher than a preset first threshold, outputting the extracted named entity as a result; if the grammatical logic rationality score of the named entity is lower than the preset first threshold, confirming that the extracted named entity is wrong; wherein the grammatical logic rationality is obtained by scoring according to the context words through a preset language model; The error correction after the error is detected includes: generating a correction candidate set according to the extracted named entities; evaluating the named entities in the correction candidate set; selecting named entities from the correction candidate set according to the evaluation results as the correction results of the extracted named entities; wherein the evaluation of the named entities in the correction candidate set includes: obtaining modification rate statistics of the named entities in the correction candidate set; calculating the first semantic similarity between the named entities in the correction candidate set and the named entities in the proprietary vocabulary; calculating the second semantic similarity between the named entities in the correction candidate set and the named entities in the public vocabulary; evaluating the named entities in the correction candidate set according to the modification rate statistics, the first semantic similarity and the second semantic similarity; Obtaining text of named entities to be extracted and inputting it into the named entity recognition model; The named entities are extracted using the named entity recognition model.
2. The method according to claim 1, characterized in that The first layer model is the bert-large model; Training the bert-large model includes: The BERT-Large model is trained on unlabeled data, and the BERT-Large model is fine-tuned on vertical domain data.
3. The method according to claim 1, characterized in that The second layer model is a Transformer Encoder model; Training the Transformer Encoder model includes: The Transformer Encoder model is trained using contextual features of each word in the text; wherein the probability distribution of the first layer model is compressed into the Transformer Encoder model in advance by branched self-distillation, and the fully connected layer output of the first layer model is used as a pre-trained word vector.
4. The method according to claim 1, characterized in that The third layer model is a CBOW model; The CBOW model is trained, including: The CBOW model in vertical fields is trained through regular text data.
5. A named entity recognition and error correction device based on self-distillation, characterized in that: include: A model training module, used for training a named entity recognition model; the named entity recognition model includes a first layer model, a second layer model and a third layer model; the first layer model is used for training according to unlabeled data, and compressing the probability distribution in the first layer model into the second layer model; the second layer model is used for named entity extraction; the third layer model is used for error detection of the extracted named entities, and, after detecting an error, error correction; The error detection of the extracted named entity includes: calculating and scoring the grammatical logic rationality of the named entity; if the grammatical logic rationality score of the named entity is higher than a preset first threshold, outputting the extracted named entity as a result; if the grammatical logic rationality score of the named entity is lower than the preset first threshold, confirming that the extracted named entity is wrong; wherein the grammatical logic rationality is obtained by scoring according to the context words through a preset language model; The error correction after the error is detected includes: generating a correction candidate set according to the extracted named entities; evaluating the named entities in the correction candidate set; selecting named entities from the correction candidate set according to the evaluation results as the correction results of the extracted named entities; wherein the evaluation of the named entities in the correction candidate set includes: obtaining modification rate statistics of the named entities in the correction candidate set; calculating the first semantic similarity between the named entities in the correction candidate set and the named entities in the proprietary vocabulary; calculating the second semantic similarity between the named entities in the correction candidate set and the named entities in the public vocabulary; evaluating the named entities in the correction candidate set according to the modification rate statistics, the first semantic similarity and the second semantic similarity; A text acquisition module, used to acquire the text of the named entity to be extracted and input it into the named entity recognition model; A named entity extraction module is used to extract the text named entities through the named entity recognition model.
6. A readable storage medium, characterized in that: There are executable instructions thereon, and when the executable instructions are executed, the computer is caused to execute the method according to any one of claims 1 to 4.
7. A computing device, characterized in that include: one or more processors; Memory; as well as One or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors as the method of any one of claims 1-4.
