Small-sample named entity recognition method based on hybrid multi-prototypes

By constructing multi-prototype representations of entity-level and label-level prototypes and adopting a strict sampling strategy, it solves the shortcomings of single prototype representation and the failure of N-way K-shot sampling strategy in small-sample named entity recognition, and improves the efficiency of named entities. Accuracy and fairness of identification.

CN114676700BActive Publication Date: 2024-09-06NAT UNIV OF DEFENSE TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210269420.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-18
Publication Date
2024-09-06
Estimated Expiration
2042-03-18

AI Technical Summary

Technical Problem

In existing technology, in small-sample named entity recognition, the expressive ability of a single prototype representation is limited, and the N-way K-shot fragment sampling strategy is difficult to maintain context integrity, resulting in falsely high evaluation results.

Method used

Adopt a small-sample named entity recognition method based on hybrid multi-prototypes to generate multi-prototype representations of classes by constructing entity-level and label-level prototypes, and use strict sampling strategies to ensure that the number of examples of each class is within [K, 2K] , reduce noise and improve recognition accuracy.

Benefits of technology

It achieves more accurate class representation, improves the performance of named entity recognition, ensures the rigor and fairness of small-sample NER tasks, and reduces the risk of falsely high model performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114676700B
    Figure CN114676700B
Patent Text Reader

Abstract

The present invention discloses a small sample named entity recognition method based on hybrid multi-prototype, comprising the following steps: sampling fragments from training and test data sets, the fragments including support sets and query sets; for the support set, using entity labels to expand sequences to enrich the semantics of sentences; using encoders to embed sequences in the support set and query set to generate symbol and label embeddings with context information; based on the symbol and label embeddings with context information, generating hybrid multi-prototype representations of all classes; predicting the labels of words in the query set according to the distance between the symbol and the hybrid multi-prototype class representation. The method of the present invention proposes a new multi-prototype class representation strategy to reduce potential representation bias and improve the expressiveness of the single prototype method; a hybrid strategy is designed to construct multiple prototypes of entity classes and non-entity classes, thereby making the recognition effect of the present invention very high.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of natural language processing, and in particular to a small sample named entity recognition method based on hybrid multi-prototypes. Background Art

[0002] Named entity recognition (NER) is one of the basic tasks of information extraction. It locates text intervals from unstructured text sequences and classifies these text intervals into predefined entity classes (such as Film and Person) or non-entity classes (such as Outside, also referred to as O) (Tjong Kim Sang and De Meulder 2003). In the setting of supervised learning, there are a series of methods, especially those based on deep neural networks, which can handle NER tasks well. However, the premise of training these supervised learning models is a large amount of manually annotated data, which is time-consuming and laborious to obtain. Therefore, how to enhance the ability to recognize entities that have never been seen from a large amount of content with only a small number of labeled samples as reference, also known as few-sample learning, is a key issue that needs to be studied.

[0003] In recent years, more and more studies have contributed to the small-sample NER task. These studies regard NER as a sequence labeling problem, restrict each word (in a sentence) to belong to at most one class, and use metric-based meta-learning to solve it (Huang et al. 2020). Among them, a representative study (Fritzler, Logacheva, and Kretov 2019) (also known as ProtoNER) proposed to use support examples to construct a prototype for each class and use it to represent the corresponding class. Then, given the query, the nearest neighbor search is used to predict their labels (ie, classes) according to their distance from the class prototype.

[0004] However, ProtoNER has two notable issues: (1) ProtoNER only builds a single prototype for each class, which is represented as the average embedding of all words in the class, which has limited expressive power and is even biased. (2) The non-entity class O contains words with irrelevant (or even inconsistent) meanings, so the average of word embeddings may lead to a lot of noise in the prototype representation of class O.

[0005] In addition, in the small sample NER experimental setting of the existing technology, there is a problem that cannot be ignored in the N-way K-shot fragment sampling strategy (Hou et al. 2020; Yang and Katiyar 2020; Ding et al. 2021; Tong et al. 2021). That is, in order to maintain the integrity of the context in the NER task, sentence-level sampling is performed, and this sampling strategy is difficult to accurately meet the constraints of Nway K-shot. Therefore, the restriction on K is relaxed, requiring only the final number of examples (K) of each entity class. * ) is greater than K, but this strategy will provide more examples for each class (K * >K), which virtually reduces the difficulty of the task. This in turn leads to an inflated evaluation result. Summary of the invention

[0006] The present invention aims to solve at least one of the technical problems existing in the prior art. To this end, the present invention discloses a small sample named entity recognition method based on hybrid multi-prototype. For an entity class, the method does not use a single prototype to represent all entity intervals in the class, but constructs entity-level and label-level prototypes for each text interval, thereby generating a multi-prototype representation of the class. Specifically, by inserting labels into sentences in a support set to better utilize label information, word and label embeddings can be learned through more context information. Then for each entity, the average of word embeddings with context information is taken to represent its entity-level prototype, while the label embedding with context information is regarded as the label-level prototype of the entity. The prototype set of all entities in a class constitutes the multi-prototype of this entity class. For a non-entity class, a word embedding set is directly used to represent it, where multi-prototypes refer to multiple word embeddings. By treating a hybrid multi-prototype strategy that treats entity classes and non-entity classes differently, a more accurate class representation can be extracted from support examples, thereby facilitating inference in query sets.

[0007] The technical solution of the present invention is as follows: a small sample named entity recognition method based on hybrid multi-prototypes comprises the following steps:

[0008] Step 1: Sample segments from the training and test datasets. The segments include support sets and query sets.

[0009] Step 2: For the support set, use entity tags to expand the sequence to enrich the semantics of the sentence;

[0010] Step 3: Use the encoder to embed the sequences in the support set and query set, producing symbol and label embeddings with contextual information.

[0011] Step 4: Generate hybrid multi-prototype representations of all classes based on symbol and label embeddings with contextual information;

[0012] Step 5 predicts the labels of the words in the query set based on the distance between the symbol and the hybrid multi-prototype class representation.

[0013] In step 2, given the support set (x, y), the expanded sequence is represented as x' = {x1, x2, y1, ..., x n ,y k}, including n symbols and k inserted tags, the symbols and tags with context information encoded by the encoder in step 3 are embedded as follows: f θ (·) represents the encoder, Indicates embedding.

[0014] All classes described in step 4 include entity classes and non-entity classes. The multiple prototypes of entity classes are represented by c: Among them, e represents the entity, ε c represents the entity labeled c in the support set, e e Represents the entity-level prototype, which is the symbol of entity e {x1,x2,…,x |e|} with context information, l e Represents the label-level prototype, which is the label y of entity e e The embedding with context information; the multi-prototype representation of non-entity classes uses symbolic embedding to represent classes, let O = {x1, x2, …, x o} is a symbol marked as o in the support set, then the multiple prototypes of class o are represented as:

[0015] In step 5, given the query sequence and the symbolic embedding of the query sequence First calculate the symbol The probability of belonging to each category, and then assign the category with the highest probability to symbol The probability of belonging to class c is calculated as follows:

[0016]

[0017] Among them, mindis represents the minimum distance between the symbol embedding and the multi-prototype representation of this class, and c j Represents the multiple prototypes of the j-th class.

[0018] During the training phase, negative log-likelihood loss is used to update the parameters in the encoder:

[0019]

[0020] in, Indicates that The predicted label, cg represents the true label, p represents the probability calculation, and N represents the total number of symbols in the query set of the training data.

[0021] The sampling process described in step 1 can be expressed as: given a set with M classes C + are all entity classes, data sets D, M and K, and sampling support set S; the specific sampling steps are: random iterative sampling of (x, y) ∈ D until the following conditions are met: The number of entities labeled c is in [K, 2K]. Next, delete the (x, y) pairs in the support set S according to the following conditions: the number of entities of any class will not be less than K due to deleting (x, y) from S; finally, when (x, y) in S cannot be deleted, the sampling ends.

[0022] For each class, the label is inserted only after α entity intervals, where α is a preset value.

[0023] Compared with the existing methods, the advantages of the method of the present invention are: a class representation method called hybrid multi-prototype is proposed. Specifically, for entity classes, entity-level and label-level prototypes are constructed for entity spans, thereby generating multi-prototype representations of the class, while for non-entity classes, word embedding sets are directly used to represent it, in which case multi-prototypes refer to multiple word embeddings. In addition, by providing a strict sampling strategy, a more rigorous and reasonable small sample NER experimental setting is established, so that the naming recognition of the method of the present invention achieves very good performance. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] Figure 1 A schematic diagram of a flow chart of an embodiment of the present invention is shown. DETAILED DESCRIPTION

[0025] In order to make the purpose, technical solution and advantages of the present invention clearer, the present invention will be further described in detail below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0026] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.

[0027] In this example, following the setting of previous studies, NER is formulated as a sequence labeling problem. Therefore, the sentences in the original NER problem can be regarded as symbol sequences. Formally, given a symbol sequence x = {x1, x2, ..., x n}, x i∈χ, i∈[1,n], where χ is the set of all symbols. The sequence labeling classification model converts the label y i ∈C is assigned to x i , generate y={y1,y2,…,y n}, where C is a set of predefined classes. Accordingly, (x, y) represents a sentence and its label sequence. It is worth noting that C can be split into entity classes C + (e.g., Film, Person) and a collection of non-entity classes Outside (abbreviated as O). An entity is a symbol interval in a sequence that belongs to the same entity class, and the label of an entity is its corresponding entity class.

[0028] This example uses the common iterative N-way K-shot fragmentary small sample NER training paradigm. Given a class set c i ∈C + , dataset D (all (x, y)), sampling a segment (S train and Q train ) to train the model. Specifically, is a query set, where S train ∩Q train It should be noted that in S train For any class c i , marked as c i The entity book of must be equal to K. Model S train For reference, use Q train Perform training and obtain S during the training process train and Q train All information in the test phase, S test and Q test It is constructed in the same way as the training phase, but it is necessary to ensure that the class set in the training phase is disjoint with that in the test phase. The ultimate goal of small sample NER is to test In the case of using the trained model and S test Predict y.

[0029] In order to make the evaluation condition closer to the original N-way K-shot setting, this embodiment proposes a strict sampling algorithm so that the final number of examples K * The average value of is closer to the setting K. Given a set with M classes C + are all entity classes, data sets D, M and K, and sampling support set S; the specific sampling steps are: random iterative sampling of (x, y) ∈ D until the following conditions are met: The number of entities labeled c is within [K, 2K]. Next, the (x, y) pairs in the support set S are deleted according to the following conditions: the entities of any class will not be less than K due to deleting (x, y) from S; finally, when (x, y) in S cannot be deleted, the sampling ends. Such a sampling strategy can prevent sampling fluctuations caused by unbalanced class distribution and provide an evaluation condition that is closer to the original N-way K-shot setting. This is because an upper limit of 2K is adopted to avoid sampling too many entities in some common classes. More importantly, the sampling results are further optimized by deleting redundant examples, so that the average number of entities in each class is as close to the set K as possible. This sampling method is more reasonable and realistic than existing sampling strategies, can reduce the false performance of previous models, and provide fairer evaluation conditions.

[0030] The technical solution in this embodiment is as follows Figure 1 As shown, the small sample named entity recognition method based on hybrid multi-prototype includes the following steps:

[0031] Step 1: Sample segments from the training and test datasets. The segments include support sets and query sets.

[0032] Step 2: For the support set, use entity tags to expand the sequence to enrich the semantics of the sentence;

[0033] Step 3: Use the encoder to embed the sequences in the support set and query set, producing symbol and label embeddings with contextual information.

[0034] Step 4: Generate hybrid multi-prototype representations of all classes based on symbol and label embeddings with contextual information;

[0035] Step 5 predicts the labels of the words in the query set based on the distance between the symbol and the hybrid multi-prototype class representation.

[0036] Sequence augmentation and embedding

[0037] First, we propose to insert entity labels into the original sequence in the support set to obtain the augmented sequence. This is because labels can enrich sentence semantics and help learn more precise semantic embeddings of words. For example, before sequence augmentation, the symbol Titanic can refer to both a ship and a movie, while enriching the sentence with the label Film makes the semantics clearer. Specifically, for each class, we only insert labels after α entity intervals. This is because inserting too many class labels may damage the original meaning of the sentence.

[0038] Formally, given a support set (x, y), we denote the expanded sequence as x' = {x1, x2, y1, ..., x n ,y k}, including n symbols and k inserted tags. By using the tag information to guide the embedding learning of the symbol, the tag information can be better utilized.

[0039] Next, we input the expanded sequence set into an encoder, namely BERT (Devlin et al. 2019), to obtain contextual embeddings of symbols and labels. Specifically, the contextual embeddings of the expanded sequence set are: where f θ (·) is the encoder, Indicates embedding.

[0040] Hybrid Multi-Prototype Representation

[0041] Given the context embedding, the goal is to generate a hybrid multi-prototype representation for a class using the support set. We use hybrid to emphasize that we design different treatments for entity classes and non-entity classes according to their specific characteristics. Multi-prototypes of entity classes. Given an entity class c∈C + , we use ε c to represent the entity labeled c in the support set. For each entity e∈ε c , we will entity-level prototype e e Represented by its symbol {x1,x2,…,x |e|}, the average of the embeddings with context information, and the label-level prototype l e Represents its label y e Therefore, the entity-level and label-level prototypes of all entities in an entity class constitute a multi-prototype representation of this entity class.

[0042] Multi-prototypes can reduce potential representation bias and improve the expressiveness of single-prototype methods. By calculating entity-level prototypes, the problem that a single symbol in an entity is difficult to represent the corresponding class is solved, and a specific class representation is obtained. At the same time, the use of label-level prototypes improves the generalization and expressiveness of the model because the label contains general information about the class. It is difficult to fully represent a class with only a few examples, so a single prototype may be biased towards most similar entities. Fortunately, the multi-prototype representation method can retain the representation of a few entities.

[0043] Multiple prototypes of non-entity classes: For non-entity classes o, symbol embeddings are used to represent the class, where multiple prototypes refer to multiple symbol embeddings. Let O = {x1, x2, …, x o} is the symbol marked as o in the support set. Then the multiple prototypes of class o are represented as Multiple symbol embeddings alleviate the problem that a single prototype cannot represent symbols in class o that do not have a unified meaning.

[0044] predict

[0045] Given a query sequence and their symbolic embeddings To predict the symbol We first calculate the probability that it belongs to each category, and then assign the category with the highest probability to Specifically, the symbol The probability of belonging to class c is calculated as follows: Where mindis represents the minimum distance between the symbol embedding and the multi-prototype representation of this class. In this embodiment, the square of the Euclidean distance is used to measure the distance. The lower the mindis, the higher the probability. In addition, label prediction is a continuous process, and label relevance will affect the prediction results. For example, the probability that the label Education appears after the label Airport is low. Therefore, this embodiment follows (Yang and Katiyar 2020) and uses an additional untrained Viterbi decoder to handle the dependencies between labels to make more accurate predictions.

[0046] During the training phase, the negative log-likelihood loss is used to update the parameters in the encoder: Among them, c g represents the true label, p represents the probability calculation, and N represents the total number of symbols in the query set of the training data.

[0047] This embodiment uses three datasets Few-NERD (including Few-NERD (INTER) and Few-NERD (INTRA)) (Ding et al. 2021), WNUT (Derczynski et al. 2017) and re3d (Science and Laborator 2017) to verify the method of the present invention. We tested the model using fragment evaluation. Fragment evaluation is a widely used evaluation method in small sample learning. We adopt a strict sampling strategy to generate support sets and query sets in fragments. We sample 15,000 fragments for training and 5,000 fragments for testing. Note that the class sets of training and test data are disjoint. In addition, since the classes of Few-NERD have two hierarchical structures, we use coarse-grained and fine-grained labels in INTER and only fine-grained labels in INTRA to calculate label-level prototypes. That is, we calculate two label-level prototypes for each entity on INTER. For WNUT and re3d, we only use the test sets of these datasets to evaluate our models. We adopt uncased BERT-Base as our backbone to obtain contextual representations of sequences, and adopt the best hyperparameter values ​​recorded in (Ding et al. 2021). We use PyTorch to implement the models, and all models can be adapted to a V100 GPU with 32G memory. Training lasts for several hours in each setting. We set the hyperparameter α to 2, and all experiments are repeated 5 times with different random seeds, calculating the mean and standard deviation of precision (P), recall (R), and micro F1. We record F1 for all experiments, and optionally record P and R according to previous research settings.

[0048] Baselines Five competitive models are used in our experiments. ProtoNER (Fritzler, Logacheva, and Kretov 2019) uses Prototype Network to compute prototypes for each class and classifies symbols based on their similarity to the prototype. LTC (Hou et al. 2020) uses label representation to improve prototype quality and considers label dependencies. NNShot (Yang and Katiyar 2020) directly uses the similarity between symbols to classify queries. Struct (Yang and Katiyar 2020) improves NNShot with a Viterbi decoder to obtain the most likely label sequence. MUCO (Tong et al. 2021) uses a group classifier to mine undefined classes from class O and improve the recognition ability of the classifier. It can be observed that the proposed method consistently outperforms the state-of-the-art models under all evaluation settings.

[0049] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.

Claims

1. Small sample named entity recognition method based on hybrid multi-prototype, It is characterized in that The following steps are involved: Step 1: Sample segments from the training and test datasets. The segments include support sets and query sets. Step 2: For the support set, use entity tags to expand the sequence to enrich the semantics of the sentence; Step 3: Use the encoder to embed the sequences in the support set and query set, producing symbol and label embeddings with contextual information. Step 4: Generate hybrid multi-prototype representations of all classes based on symbol and label embeddings with contextual information; Step 5: predict the label of the word in the query set based on the distance between the symbol and the hybrid multi-prototype class representation; In step 5, given the query sequence and the symbolic embedding of the query sequence First calculate the symbol The probability of belonging to each category, and then assign the category with the highest probability to symbol The probability of belonging to class c is calculated as follows: Among them, mindis represents the minimum distance between the symbol embedding and the multi-prototype representation of this class, and c j Represents multiple prototypes of the jth class; During the training phase, negative log-likelihood loss is used to update the parameters in the encoder: in, Indicates that The predicted label, c g represents the true label, p represents the probability calculation, and N represents the total number of symbols in the query set of the training data.

2. According to the small sample named entity recognition method based on hybrid multi-prototypes according to claim 1, It is characterized in that In step 2, given the support set (x, y), the expanded sequence is represented as: x' = {x 1 ,x 2 ,y 1 ,…,x n ,y k }, including n symbols {x 1 ,x 2 ,…,x n } and k inserted labels {y 1 ,…,y k }, the symbols and labels with context information encoded by the encoder in step 3 are embedded as: f θ (·) represents the encoder, Indicates embedding.

3. According to the small sample named entity recognition method based on hybrid multi-prototype according to claim 2, It is characterized in that All classes described in step 4 include entity classes and non-entity classes. The multiple prototypes of entity classes are represented by c: Among them, e represents the entity, ε c represents the entity labeled c in the support set, e e Represents the entity-level prototype, which is the symbol {x 1 ,x 2 ,…,x |e| } with context information, l e Represents the label-level prototype, which is the label y of entity e e The embedding with context information; the multi-prototype representation of non-entity classes uses symbolic embedding to represent classes, let Ο = {x 1 ,x 2 ,…,x o } is a symbol marked as o in the support set, then the multiple prototypes of class o are represented as:

4. The method for named entity recognition based on small samples and hybrid multi-prototypes according to claim 1, It is characterized in that The sampling process described in step 1 can be expressed as: given a set with M classes C + is the total entity class, data set D, M and quantity K, sampling support set S; the specific sampling steps are: random iterative sampling of (x, y) ∈ D until the following conditions are met: The number of entities labeled c is in [K, 2K]. Next, delete the (x, y) pairs in the support set S according to the following conditions: the number of entities of any class will not be less than K due to deleting (x, y) from S; finally, when (x, y) in S cannot be deleted, the sampling ends.

5. The small sample named entity recognition method based on hybrid multi-prototype according to claim 1, It is characterized in that For each class, the label is inserted only after α entity intervals, where α is a preset value.

6. The method for named entity recognition based on small samples and hybrid multi-prototypes according to claim 2, It is characterized in that The encoder is a BERT encoder.