Named entity recognition method, system, electronic device and storage medium

By combining sequence encoding, entity span generation, and span relationship extraction of the named entity recognition model with attention U-Net and multi-head biaffine predictor, the problem of insufficient consideration of semantic relationships in multi-type named entity recognition is solved, and high-accuracy recognition of nested and non-continuous entities is achieved.

CN117592477BActive Publication Date: 2026-11-24TSINGHUA UNIVERSITY +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311515932.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-11-14
Publication Date
2026-11-24
Estimated Expiration
2043-11-14

AI Technical Summary

Technical Problem

Existing technologies fail to fully consider the rich semantic relationships between entities across multiple types of named entity recognition, resulting in insufficient recognition performance.

Method used

A named entity recognition model is adopted, which constructs entity span representation and semantic relationship matrix through sequence encoding layer, entity span generation layer and span relationship extraction layer, combined with attention U-Net segmentation network and multi-head biaffine predictor, and performs fine-grained partitioning and unified decoding.

Benefits of technology

It improves the accuracy of named entity recognition, especially when dealing with nested and non-continuous entities, reduces recognition errors, and enables in-depth exploration and unified decoding of the semantic relationships within nested and overlapping entities.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117592477B_ABST
    Figure CN117592477B_ABST
Patent Text Reader

Abstract

This invention relates to the field of entity recognition technology for natural text, and provides a named entity recognition method, system, electronic device, and storage medium. The recognition method includes: acquiring a sentence to be recognized; inputting the sentence to be recognized into a trained named entity recognition model to obtain a prediction result of the named entity recognition model, the prediction result including entity spans and semantic relationships corresponding to each entity span pair; and decoding entities based on the prediction result to obtain the named entities in the sentence to be recognized. The named entity recognition model obtains the entity spans in the sentence by identifying the tail boundaries of each entity in the sentence as sentence separators. This invention addresses the shortcomings of existing unified recognition methods for multiple types of named entities, which fail to consider the rich semantic relationships between entity spans, resulting in insufficient recognition performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of entity recognition technology for natural text, and more particularly to named entity recognition methods, systems, electronic devices, and storage media. Background Technology

[0002] Named Entity Recognition (NER) aims to identify and classify named entities with specific meanings in text into predefined entity categories, including people, places, and organization names. It is an important subtask of information extraction. Because named entities typically contain rich semantic information and are closely related to key information in the text, NER has been widely applied to various downstream NLP tasks, such as web search, relation extraction, knowledge graphs, and question answering systems. Different domains contain various types of named entities. The simplest and most common is the first type, called flat entities, which satisfy two basic conditions: each entity consists of consecutive words or characters; and no two entities overlap. However, many complex entity structures in practical applications do not meet these conditions. The second type is nested entities, where one entity is completely contained within another. The third type is discontinuous entities, composed of non-continuous words or characters. These complex entity structures are particularly common in the biomedical field and are of great significance for electronic medical record recognition, medical literature mining, and drug safety monitoring.

[0003] As mentioned above, named entity recognition tasks mainly involve three types, including flat, nested, and non-contiguous entity recognition. Currently, there are two methods for unified recognition of multiple types of named entities:

[0004] The first approach transforms the three named entity recognition subtasks into a single entity span sequence generation task, then processes them using a unified sequence-to-sequence (Seq2Seq) framework. This scheme explores three types of entity span representations to linearize entities into a sequence, leveraging a pre-trained sequence-to-sequence model to simultaneously address the three NER subtasks without requiring specially designed annotation patterns or enumerated spans. This framework is not only easy to implement but also achieves state-of-the-art or near-state performance on eight English NER datasets, including two flat entity datasets, three nested entity datasets, and three non-contiguous entity datasets, providing insights for the application of generative models in information extraction.

[0005] The second approach unifies the three named entity recognition subtasks into a word-word relation classification problem. This method effectively learns the adjacency and boundary relationships between entity words by introducing next-nearest neighbor (NNW) and last-word-entity-category (THW-*) relationships, thus solving the boundary localization problem for different types of named entity recognition. Based on the word-word relation definition, this scheme proposes a deep neural model where multi-type named entity recognition is uniformly transformed into two-dimensional grid classification of word pairs. Then, a multi-granularity two-dimensional convolutional module is designed to better refine and extract the grid representation. Finally, biaffine collaborative prediction of word-word relations is combined. This method achieves state-of-the-art recognition results on 14 widely used Chinese and English benchmark named entity recognition datasets.

[0006] However, the sequence-to-sequence (seq2seq) framework is limited by low decoding efficiency and suffers from exposure bias due to inconsistencies between training and testing. Its decoder can accept real sequences as input during training, but during testing, the current input can only be the output of the previous step. Word-word relation classification methods, on the other hand, use fine-grained words or characters as basic units, ignoring semantic relationships across entity spans, and are prone to error accumulation when there are many non-contiguous segments. Summary of the Invention

[0007] This invention provides a named entity recognition method, system, electronic device, and storage medium to address the shortcomings of existing unified recognition methods for multiple types of named entities, which fail to take into account or only minimally consider the rich semantic relationships that exist between entities, resulting in insufficient recognition performance.

[0008] This invention provides a named entity recognition method, comprising:

[0009] Obtain the statement to be recognized;

[0010] The sentence to be identified is input into the trained named entity recognition model to obtain the prediction result of the named entity recognition model for the sentence to be identified. The prediction result includes the entity span and the semantic relationship corresponding to each entity span pair.

[0011] Based on the prediction results, entity decoding is performed to obtain the named entities in the statement to be identified;

[0012] The named entity recognition model obtains the entity span in the sentence by identifying the tail boundary of each entity in the sentence to be recognized as a sentence separator.

[0013] According to the named entity recognition method of the present invention, the step of inputting the statement to be recognized into a trained named entity recognition model to obtain the prediction result of the named entity recognition model for the statement to be recognized includes:

[0014] The statement to be identified is input into the sequence encoding layer of the named entity recognition model, and the sequence encoding layer performs sequence encoding on the statement to be identified to obtain a sequence output by the sequence encoding layer consisting of word vector representations corresponding to the statement to be identified;

[0015] The sequence is input into the entity span generation layer of the named entity recognition model. The entity span generation layer identifies the entity tail boundaries in the sequence as the sentence separator, and the entity span generation layer outputs all the entity span representations in the sequence.

[0016] The entity span representation is input into the span relationship extraction layer of the named entity recognition model. The span relationship extraction layer constructs a relationship matrix based on the entity span representation to determine the semantic relationship of each entity span pair, thereby obtaining the semantic relationship output by the span relationship extraction layer.

[0017] According to the named entity recognition method of the present invention, the step of constructing a relation matrix based on the entity span representation to determine the semantic relationship of each entity span pair, and obtaining the semantic relationship output by the span relationship extraction layer, includes:

[0018] Based on the entity span representation, an initial relation matrix is ​​constructed;

[0019] The initial relation matrix is ​​updated using the attention-based U-Net segmentation network;

[0020] Based on the updated relation matrix, the semantic relation of each entity span pair is determined.

[0021] According to the named entity recognition method of the present invention, the step of constructing a relation matrix based on the entity span representation to determine the semantic relationship of each entity span pair, and obtaining the semantic relationship output by the span relation extraction layer, further includes:

[0022] The initial relation matrix is ​​updated using a multi-headed biaffine predictor.

[0023] According to the named entity recognition method of the present invention, the named entity recognition model is trained based on a sample dataset, and the actual entity span and sample named entities corresponding to the sample dataset;

[0024] In the training process of the named entity recognition model, based on the intersection-union ratio, the actual entity span with the highest overlap with the entity span obtained by the named entity recognition model is determined as the target actual entity span.

[0025] The actual entity span representation is replaced with the corresponding entity span representation, and the entity span with an overlap greater than a preset threshold is used as a positive sample for further training of the named entity recognition model.

[0026] According to the named entity recognition method of the present invention, during the training process of the named entity recognition model, the class balance of the sample named entities is improved based on the focus loss function.

[0027] According to the named entity recognition method of the present invention, based on the relationship between the spans in the obtained entity span pairs, the relationship between the entity spans is divided into a variety of predefined types, including: adjacency, end-beginning boundary-entity category, and same entity type;

[0028] The step of decoding entities based on the prediction results to obtain named entities in the statement to be identified includes:

[0029] Based on the prediction results, the entity span and the semantic relationship corresponding to each entity span pair are respectively regarded as nodes and directed paths;

[0030] Using any two predefined types of the statement to be identified as the ending and beginning boundaries - the entity span of the entity category as the ending node and the beginning node respectively, search for all directed paths from the beginning node to the ending node.

[0031] The present invention also provides a named entity recognition system, comprising:

[0032] The input module is used to obtain the statement to be recognized;

[0033] The prediction module is used to input the statement to be recognized into the trained named entity recognition model and obtain the prediction result of the named entity recognition model for the statement to be recognized. The prediction result includes entity span and semantic relationship corresponding to each entity span pair.

[0034] The recognition module is used to perform entity decoding based on the prediction result to obtain the named entities in the statement to be recognized;

[0035] The named entity recognition model obtains the entity span in the sentence by identifying the tail boundary of each entity in the sentence to be recognized as a sentence separator.

[0036] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the named entity recognition method as described above.

[0037] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the named entity recognition method as described above.

[0038] The named entity recognition method, system, electronic device, and storage medium provided by this invention, by inputting the acquired sentence to be recognized into a trained named entity recognition model, can obtain the entity spans in the sentence to be recognized and the semantic relationships corresponding to each entity span pair output by the named entity recognition model. Then, based on the entity span representation and the semantic relationships corresponding to each entity span pair, entity decoding is performed to obtain the named entities in the sentence to be recognized. In particular, the named entity recognition model identifies the tail boundaries of each entity in the sentence to be recognized as sentence separators to obtain the entity span representation in the sentence to be recognized. This makes the left and right boundaries of each entity in the sentence to be recognized regarded as sentence separators, realizing fine-grained division of the entity spans in the sentence to be recognized. This not only allows for in-depth exploration of the internal semantic relationships of nested and overlapping entities, but also enables unified decoding of nested and non-continuous entities through span connections, thereby improving the accuracy of named entity recognition. Attached Figure Description

[0039] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0040] Figure 1 This is a flowchart illustrating a named entity recognition method provided in an embodiment of the present invention;

[0041] Figure 2 This is a schematic diagram of the entity span of the three types of NER provided in the embodiments of the present invention;

[0042] Figure 3 This is a schematic diagram of the architecture of an example of the named entity recognition model provided in an embodiment of the present invention;

[0043] Figure 4 This is a schematic diagram of an example of an entity span-level relationship matrix provided in an embodiment of the present invention;

[0044] Figure 5This is a schematic diagram of the training process and testing flow of the named entity recognition model in the named entity recognition method provided in the embodiments of the present invention;

[0045] Figure 6 This is a schematic diagram of the structure of a named entity recognition system provided by the present invention;

[0046] Figure 7 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation

[0047] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.

[0048] The following is combined with Figures 1 to 5 This invention describes a named entity recognition method, which can be executed by software and / or hardware in electronic devices such as computers, tablets, and mobile phones. Figure 1 As shown, the method includes the following steps:

[0049] 101. Obtain the statement to be recognized;

[0050] 102. Input the sentence to be recognized into the trained named entity recognition model to obtain the prediction result of the named entity recognition model. The prediction result includes the entity span and the semantic relationship corresponding to each entity span pair.

[0051] 103. Based on the prediction results, perform entity decoding to obtain the named entities in the sentence to be identified;

[0052] Among them, the named entity recognition model obtains the entity span in the sentence by identifying the tail boundary of each entity in the sentence to be recognized as the sentence separator.

[0053] In this embodiment, a named entity recognition model is trained by identifying the tail boundaries of each entity in the sentence to be recognized as sentence delimiters and defining the entity span in the sentence to be recognized. That is, by treating the left and right boundaries of each entity in the sentence to be recognized as two delimiters, the segments of the sentence / sequence divided by the delimiters are taken as entity spans. This allows for in-depth exploration of the internal semantic relationships of nested and overlapping entities, and also enables unified decoding of nested and non-continuous entities through span connection.

[0054] Specifically, when generating entity span using the named entity recognition model provided in this embodiment of the invention, the following can be predefined: Figure 2 The three types of relationships shown include Succession (for nested and non-contiguous NERs), Tail-head-* (for all three types of NERs), and Same-entity-type (for flat NERs only), where * represents the entity category, such as people, places, genes, adverse drug reactions, etc.

[0055] In a specific embodiment, such as Figure 2 As shown in (b), the traditional entity span generation mode generates entity spans of "South African" and "South African scientists," while the named entity recognition model provided by this embodiment outputs entity spans of "South African" and "scientists." It is evident that the named entity recognition model provided by this embodiment can explore the internal semantic relationships of nested and overlapping entities more deeply, thereby improving the accuracy of named entity recognition and reducing recognition errors.

[0056] Based on the above embodiments, the statement to be recognized is input into the trained named entity recognition model to obtain the prediction result of the named entity recognition model for the statement to be recognized, including:

[0057] The sentence to be recognized is input into the sequence encoding layer of the named entity recognition model. The sequence encoding layer encodes the sentence to be recognized and outputs a sequence of word vector representations corresponding to the sentence to be recognized.

[0058] The sequence is input into the entity span generation layer of the named entity recognition model. The entity span generation layer identifies the entity tail boundaries in the sequence as sentence delimiters, and the entity span generation layer outputs the entity span representation of all entities in the sequence.

[0059] The entity span representation is input into the span relation extraction layer of the named entity recognition model. The span relation extraction layer constructs a relation matrix based on the entity span representation to determine the semantic relation of each entity span pair, thus obtaining the semantic relation output by the span relation extraction layer.

[0060] In this embodiment, the named entity recognition model is a deep learning model consisting of three essential components: a sequence encoding layer (SEL), an entity span generation layer (ESG), and a span relation extraction layer (SRE). Its architecture is as follows: Figure 3As shown, the process begins with the SEL receiving the input sentence to be recognized and generating contextualized word representations. Then, the ESG applies methods such as sequence labeling to identify entity tail boundaries as sentence delimiters. Finally, the SRE constructs a relation matrix representing entity spans, thereby learning the semantic relationships for each span pair.

[0061] Specifically, the SEL of the named entity recognition model can use BERT (Bidirectional Encoder Representation from Transformers, a pre-trained language model) and bidirectional LSTM (Long Short-Term Memory) to sequence encode the input sentence, generating word vector representations with contextual information. For example, Figure 3 As shown, given an input statement X = {x1, x2, ..., x...} N The sequence encoding layer connects BERT context word vectors. Glove word embedding vector Part-of-speech vectors and character-level vectors The process yields a vector representation for each word or character. After BERT computation, each word may be divided into several word pieces. Max pooling is then used to generate the word's representation vector based on the word embedding vectors of all pieces. To obtain character-level word embedding vectors, the sequence encoding layer follows previous work, applying a bidirectional LSTM to encode the characters in each word. The representation vector of each word is then input into another bidirectional LSTM module to produce the final sequence representation. The formula is shown below:

[0062]

[0063]

[0064]

[0065]

[0066] Where N is the length of the input sequence, and d is twice the dimension of the LSTM hidden vectors. θ represents the vector concatenation operation. f and θ b These represent the parameters of the forward and reverse LSTM networks, respectively. and These represent the hidden states of the forward and reverse LSTM at position i, respectively.

[0067] Next, the named entity recognition model's ESG identifies the entity tail boundaries in the sequence as sentence separators, thus obtaining the span of all entities in the sequence. For example... Figure 2 As shown, ESG treats the left and right boundaries of each entity (or each fragment in a non-contiguous scene) as two sentence separators, and defines all sentence fragments separated by the separators as new entity spans. The generated entity spans include the following types:

[0068] Entity span: refers to the innermost flat entity that does not overlap with any other entity.

[0069] Fragment span: Represents a portion of one or more external entities, but not the entirety of any external entity.

[0070] Context span: refers to a continuous context that does not belong to any entity.

[0071] Since both entity fragments and context are treated as special entity spans, each statement contains a series of consecutive spans. Therefore, entity span detection is transformed into a statement delimiter localization task, which can be solved using a sequence labeling framework.

[0072] In one specific embodiment, such as Figure 3 As shown, the BIO (B-begin, I-inside, O-outside) three-dimensional annotation method is used to identify entity tail boundaries. Two labels, "B" and "I", are defined: "B" indicates that the current word is the tail boundary of a span (i.e., a sentence separator), and "I" indicates other words within the new span. Specifically, the final sequence representation H is input into a fully connected layer to determine whether each word or character is a sentence separator.

[0073] p i =σ(W ESG h i +b ESG )

[0074] Among them, h i W refers to the vector representation of the i-th word. ESG Let b represent the trainable weight matrix. ESG σ represents the bias parameter, and σ represents the sigmoid activation function. The calculated result p i This indicates the probability score for identifying the i-th word as a sentence separator. Specifically, the binary cross-entropy (BCE) loss function can be used to optimize the entity span generation layer.

[0075]

[0076] Where n represents the sequence length, p i y represents the predicted score.i Represents a binary target, indicating whether a word is a span tail boundary (sentence separator).

[0077] Finally, SRE constructs a relation matrix from the entity span representations identified by ESG to determine the semantic relationship of each entity span pair. Specifically, given the original input statement X = {x1, x2, ..., x...} N}, using b i and e i Let represent the entity span s respectively. i The start and end positions (1≤b) i ≤e i ≤n). The span of each entity is jointly represented by span boundary word embedding and span length embedding vector:

[0078]

[0079] in, Let w represent the vector concatenation operation, where w represents the span-length embedding obtained through a learnable lookup table, with dimension k, and therefore each span represents a vector of dimension d. s It is 2d+k.

[0080] like Figure 4 As shown, the goal of SER is to learn the structural and semantic relationships between entity spans, therefore it is necessary to learn the structural and semantic relationships between each span pair (s). i s j Generate the initial representation of the relation. Considering the directionality of the relation, s can be... i to s j The relationship is modeled as a conditional probability: P r (end=s j |start=s i ), where r represents a predefined span relationship (such as adjacency, end-start boundary, etc.). Then, a high-quality two-dimensional relation matrix is ​​generated using the Conditional Layer Normalization (CLN) mechanism. To represent the relationship between each span pair:

[0081]

[0082] in,

[0083] Among them, s i It generates the normalized layer gain parameter. and bias parameters The condition vector, s i Let μ and σ represent the input vector, respectively. j The mean and standard deviation of the elements, where l refers to the maximum number of entity spans in the input sequence of the dataset.

[0084] Furthermore, after generating the span-level relation matrix M, the relation matrix M is viewed as having d s For images with multiple channels, the span relationship can be extracted and transformed into a pixel classification problem in computer vision.

[0085] Therefore, in one embodiment of the present invention, a relation matrix is ​​constructed based on the entity span representation to determine the semantic relationship of each entity span pair, and the semantic relationship output by the span relationship extraction layer is obtained, including:

[0086] Based on entity span representation, construct an initial relation matrix;

[0087] The initial relation matrix is ​​updated by segmenting the network using the attention U-Net.

[0088] Based on the updated relation matrix, the semantic relationship of each entity span pair is determined.

[0089] Understandably, the U-Net segmentation network is one of the most well-known convolutional models in biomedical image semantic segmentation, accurately capturing the relationships between entity spans. The U-Net architecture primarily consists of four downsampling blocks, four upsampling blocks, and several skip connections, forming a symmetrical U-shaped structure. The left side can be viewed as a feature extraction network (encoder), where the input image is downsampled four times through convolution and max pooling to obtain four levels of feature maps. The right side can be called a feature fusion network (decoder), where the encoder's feature maps are fused with the corresponding feature maps obtained through cropping and concatenating deconvolution. In this framework, the convolution and downsampling blocks expand the receptive field of the relation representation of the current span pair in the matrix, providing rich global information for relation classification. Furthermore, the upsampling module transmits feature maps of different levels from the encoder to the decoder through concatenated operations, which distributes the aggregated features across each matrix grid.

[0090] In this embodiment, a linear layer is first used to reduce the dimension of each relation vector, and then an attention U-Net segmentation network is used to capture the relationships between span pairs.

[0091] V = UNet(W u M+b u (8)

[0092] in, W represents the output relation matrix of U-Net. u and b u Let d represent the learnable weight parameters and biases, respectively, and let d be the output dimension. u Much smaller than d s .

[0093] Following the attention-based U-Net segmentation network, an updated relation matrix representation V is obtained, which is then fed into a fully connected layer to predict the relation score for each span pair.

[0094] y1=MLP1(V ij (9)

[0095] in, It is the score distribution of the predefined span relationship in set C.

[0096] Furthermore, in one embodiment of the present invention, constructing a relation matrix based on entity span representation to determine the semantic relationship of each entity span pair, and obtaining the semantic relationship output by the span relationship extraction layer, further includes:

[0097] The initial relation matrix is ​​updated using a multi-headed biaffine predictor.

[0098] In this embodiment, the accuracy of relation prediction can be further improved by adding a multi-head biaffine predictor to compute another relation score distribution based on the span representation, and then combining the two distributions into the final relation prediction.

[0099] Specifically, by giving a span pair (s) i s i The calculation process is expressed by the following formula:

[0100] Q i =MLP start (s i (10)

[0101] Q j =MLP end (s j (11)

[0102] y2=MLP2(MHBiaffine(Q i Q j (12)

[0103]

[0104] Where MHBiaffine(.,.) represents a multi-head dual affine decoder. This represents the final probability distribution of the relationship.

[0105] It is understood that the named entity recognition method provided in this embodiment of the invention converts the three types of named entity recognition subtasks into a two-stage process of entity span detection and span relationship extraction, and then decodes the final entity accordingly. Therefore, during the training process of the named entity recognition model, it is necessary to consider how to mitigate the error accumulation problem of the two-stage model.

[0106] Based on this, in one embodiment of the present invention, the named entity recognition model is trained based on a sample dataset and the actual entity span and sample named entities corresponding to the sample dataset.

[0107] In the training process of the named entity recognition model, based on the intersection-union ratio, the actual entity span with the highest overlap with the entity span obtained by the named entity recognition model is determined as the target actual entity span.

[0108] The actual target entity span is used to replace the corresponding entity span, and entity spans with an overlap greater than a preset threshold are used as positive samples to continue training the named entity recognition model.

[0109] In this embodiment, during the training of the named entity recognition model, the entity span set generated in the first stage is represented as S = {s1, s2, ..., s}. i}, where s i =(b i e i Let represent the i-th span. Then, soft-training examples are constructed based on the Intersection over Union (IoU) to utilize entity spans that partially match the ground truth labels. That is, the IoU is used to evaluate the overlap between two entity spans, and its calculation formula is: IoU(s) i s j ) = s i ∩s j / s i ∪s j That is, for each predicted span s in S. i Select the true span t from the set of true spans that matches it and has the highest intersection-union score. i to replace s i Then, predicted spans with scores greater than the threshold μ are considered positive samples and continue to participate in the second stage of training. The IoU weights for the i-th entity span are calculated as follows:

[0110] α i =IoU(s i , t i ) η (14)

[0111] In this embodiment, by introducing the intersection-over-union ratio (IoU) to weight the model loss, the span of partial matching with real entities in the first stage is better utilized, thereby effectively alleviating the error accumulation problem in the two-stage model and improving the accuracy of named entity recognition.

[0112] Understandably, due to the lack of relationships between many entity pairs, there is a significant class imbalance in relation extraction tasks. Furthermore, the large differences in the number of entities of different classes in some datasets also contribute to the imbalance of span relationships.

[0113] Therefore, in one embodiment of the present invention, during the training process of the named entity recognition model, the class balance of sample named entities is improved based on the focus loss function.

[0114] In this embodiment, the focal loss function can reduce the weight of simple positive examples, and the cross-entropy loss function can be adjusted to focus training on more difficult negative examples, thereby alleviating the imbalance of label classes.

[0115]

[0116] in, l is the number of entity spans predicted in the first stage, γ represents the focusing parameter of the focus loss function, and λ i and λ j Let y represent the intersection-union ratio weights of the spans of the i-th and j-th entities, respectively. ij Indicates span pair (s) i s j (True relationship label)

[0117] The named entity recognition method provided in this invention introduces cross-union comparison model loss weighting during the training process of the named entity recognition model to better utilize the entity spans that partially match the real labels in the first stage, thereby alleviating the error accumulation in the two-stage model. Then, the trained named entity recognition model first generates the entity span representation of the sentence to be recognized from the new fine-grained entity span definition, which facilitates in-depth exploration of the internal rules of the entity nesting (overlapping) structure and decodes nested and non-continuous entities in a unified way. Then, the structural and semantic relationships between entity spans are learned through the span relation matrix, attention U-Net semantic segmentation network and multi-head dual affine predictor, which fully explores the structural and semantic relationships between different types of entity spans, thereby further improving the performance of unified recognition of multi-type named entities.

[0118] Based on the above embodiments, and based on the relationship between spans in the obtained entity span pairs, the relationship between entity spans is divided into several predefined types, including: adjacency, end-beginning boundary-entity category, and same entity type;

[0119] Based on the prediction results, entity decoding is performed to obtain the named entities in the statement to be identified, including:

[0120] Based on the prediction results, the entity span and the semantic relationship corresponding to each entity span pair are regarded as nodes and directed paths, respectively.

[0121] Using any two predefined types of the statement to be identified as the ending and the entity span of the entity category as the ending and starting nodes respectively, search for all directed paths from the starting node to the ending node.

[0122] In this embodiment, the entity span is regarded as a node and the adjacency relationship is regarded as a directed edge, so that the entity decoding process can be transformed into a path search task, where each path corresponds to an actual entity.

[0123] In one specific embodiment, the two spans of the end-start boundary-* relationship are used as the end node and the start node, and then the breadth-first search (BFS) algorithm is used to search for all directed paths from the start to the end.

[0124] Figure 5 This diagram illustrates the training and testing processes of the named entity recognition model in the named entity recognition method provided in the above embodiments of the present invention. Dotted lines represent training steps, dashed lines represent testing steps, and solid lines represent common steps. The named entity recognition method provided in this embodiment of the present invention fully explores and accurately defines the semantic relationships between spans of different types of entities by proposing a new fine-grained entity span representation definition. By transforming the three types of named entity recognition subtasks into a two-stage process of entity span detection and span relationship extraction, the intersection-union ratio (IUGR) is introduced to alleviate the error accumulation in the two-stage model, effectively improving the accuracy of named entity recognition. The attention-based U-Net segmentation network is used to learn the span-level relationship matrix, supplemented by a multi-head biaffine mechanism, to better capture various relationships between span pairs, thereby further improving the accuracy of named entity recognition.

[0125] Based on the same general inventive concept, this invention also protects a named entity recognition system. The named entity recognition system provided by this invention will be described below. The named entity recognition system described below can be referred to in correspondence with the named entity recognition method described above.

[0126] Figure 6 This is a schematic diagram of the named entity recognition system provided by the present invention. For example... Figure 6As shown, it includes: an input module 610, a prediction module 620, and a recognition module 630; wherein,

[0127] Input module 610 is used to acquire the statement to be recognized;

[0128] The prediction module 620 is used to input the sentence to be recognized into the trained named entity recognition model and obtain the prediction result of the named entity recognition model outputting the sentence to be recognized. The prediction result includes the entity span and the semantic relationship corresponding to each entity span pair.

[0129] The recognition module 630 is used to perform entity decoding based on the prediction results to obtain the named entities in the statement to be recognized;

[0130] Among them, the named entity recognition model obtains the entity span in the sentence by identifying the tail boundary of each entity in the sentence to be recognized as the sentence separator.

[0131] The named entity recognition system provided in this invention, by inputting the acquired sentence to be recognized into a trained named entity recognition model, can obtain the entity spans and semantic relationships corresponding to each entity span pair in the sentence output by the named entity recognition model. Then, based on the entity spans and the semantic relationships corresponding to each entity span pair, entity decoding is performed to obtain the named entities in the sentence to be recognized. In particular, the named entity recognition model identifies the tail boundaries of each entity in the sentence to be recognized as sentence separators to obtain the entity spans in the sentence to be recognized. This makes the left and right boundaries of each entity in the sentence to be recognized regarded as sentence separators, realizing fine-grained division of the entity span representation of the sentence to be recognized. This not only allows for in-depth exploration of the internal semantic relationships of nested and overlapping entities, but also enables unified decoding of nested and non-continuous entities through span connections, thereby improving the accuracy of named entity recognition.

[0132] Optionally, the prediction module 620 is specifically used for:

[0133] The sentence to be recognized is input into the sequence encoding layer of the named entity recognition model. The sequence encoding layer encodes the sentence to be recognized, and the output of the sequence encoding layer consists of word vector representations corresponding to the sentence to be recognized. The sequence is then input into the entity span generation layer of the named entity recognition model. The entity span generation layer identifies the entity tail boundaries in the sequence as sentence separators, and the output of the entity span generation layer contains all entity spans in the sequence. The entity spans are then input into the span relation extraction layer of the named entity recognition model. The span relation extraction layer constructs a relation matrix based on the entity spans to determine the semantic relations of each entity span pair, and the output of the span relation extraction layer contains the semantic relations.

[0134] Optionally, the prediction module 620 is more specifically used for:

[0135] An initial relation matrix is ​​constructed based on the entity span representation; the initial relation matrix is ​​updated using an attention U-Net segmentation network; and the semantic relationship of each entity span pair is determined based on the updated relation matrix.

[0136] Optionally, the prediction module 620 is also specifically used for:

[0137] The initial relation matrix is ​​updated using a multi-headed biaffine predictor.

[0138] Optionally, the named entity recognition model is trained based on a sample dataset, as well as the actual entity span and sample named entities corresponding to the sample dataset;

[0139] In the training process of the named entity recognition model, based on the intersection-union ratio, the actual entity span with the highest overlap with the entity span obtained by the named entity recognition model is determined as the target actual entity span.

[0140] The actual target entity span is used to replace the corresponding entity span, and entity spans with an overlap greater than a preset threshold are used as positive samples to continue training the named entity recognition model.

[0141] Optionally, during the training of the named entity recognition model, the class balance of sample named entities can be improved based on the focus loss function.

[0142] Optionally, based on the relationship between entities in the obtained entity span pair, the entity span is divided into several predefined types, including: adjacency, end-beginning boundary-entity category, and same entity type;

[0143] The recognition module 630 is specifically used for:

[0144] Based on the prediction results, the entity span and the semantic relationship corresponding to each entity span pair are regarded as nodes and directed paths, respectively. Taking any two predefined types of the statement to be identified as the end and start boundaries - entity span of the entity category as the end node and start node, respectively, all directed paths from the start node to the end node are searched.

[0145] Figure 7 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 7As shown, the electronic device may include a processor 710, a communications interface 720, a memory 730, and a communication bus 740, wherein the processor 710, communications interface 720, and memory 730 communicate with each other via the communication bus 740. The processor 710 can call logical instructions in the memory 730 to execute a named entity recognition method. This method includes: acquiring a statement to be recognized; inputting the statement to be recognized into a trained named entity recognition model to obtain a prediction result of the named entity recognition model for the statement to be recognized, the prediction result including entity span and semantic relationship corresponding to each entity span pair; and performing entity decoding based on the prediction result to obtain the named entities in the statement to be recognized. The named entity recognition model obtains the entity span in the statement to be recognized by identifying the tail boundaries of each entity in the statement to be recognized as sentence separators.

[0146] Furthermore, the logical instructions in the aforementioned memory 730 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0147] On the other hand, the present invention also provides a computer program product, the computer program product including a computer program, which can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the named entity recognition method provided by the above methods. The method includes: acquiring a statement to be recognized; inputting the statement to be recognized into a trained named entity recognition model to obtain a prediction result of the named entity recognition model for the statement to be recognized, the prediction result including entity span and semantic relationship corresponding to each entity span pair; performing entity decoding based on the prediction result to obtain the named entities in the statement to be recognized; wherein the named entity recognition model obtains the entity span in the statement to be recognized by identifying the tail boundary of each entity in the statement to be recognized as a sentence separator.

[0148] In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon. When executed by a processor, the computer program implements the named entity recognition method provided by the above methods. The method includes: acquiring a statement to be recognized; inputting the statement to be recognized into a trained named entity recognition model to obtain a prediction result of the named entity recognition model for the statement to be recognized, the prediction result including entity span and semantic relationship corresponding to each entity span pair; performing entity decoding based on the prediction result to obtain the named entities in the statement to be recognized; wherein the named entity recognition model obtains the entity span in the statement to be recognized by identifying the tail boundary of each entity in the statement to be recognized as a sentence separator.

[0149] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0150] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0151] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A named entity recognition method, characterized in that, include: Obtain the statement to be recognized; The sentence to be identified is input into the trained named entity recognition model to obtain the prediction result of the named entity recognition model for the sentence to be identified. The prediction result includes the entity span and the semantic relationship corresponding to each entity span pair. Based on the prediction results, entity decoding is performed to obtain the named entities in the statement to be identified; The named entity recognition model obtains the entity span in the sentence by identifying the tail boundary of each entity in the sentence to be recognized as a sentence separator. The step of inputting the statement to be recognized into the trained named entity recognition model to obtain the prediction result of the named entity recognition model for the statement to be recognized includes: The statement to be identified is input into the sequence encoding layer of the named entity recognition model, and the sequence encoding layer performs sequence encoding on the statement to be identified to obtain a sequence output by the sequence encoding layer consisting of word vector representations corresponding to the statement to be identified; The sequence is input into the entity span generation layer of the named entity recognition model. The entity span generation layer identifies the entity tail boundaries in the sequence as the sentence separator, and the entity span generation layer outputs all the entity span representations in the sequence. The entity span representation is input into the span relationship extraction layer of the named entity recognition model. The span relationship extraction layer constructs a relationship matrix based on the entity span representation to determine the semantic relationship of each entity span pair, thereby obtaining the semantic relationship output by the span relationship extraction layer.

2. The named entity recognition method according to claim 1, characterized in that, The step of constructing a relation matrix based on the entity span representation to determine the semantic relationship for each entity span pair, and obtaining the semantic relationship output by the span relationship extraction layer, includes: Based on the entity span representation, an initial relation matrix is ​​constructed; The initial relation matrix is ​​updated using the attention-based U-Net segmentation network; Based on the updated relation matrix, the semantic relation of each entity span pair is determined.

3. The named entity recognition method according to claim 2, characterized in that, The step of constructing a relation matrix based on the entity span representation to determine the semantic relationship of each entity span pair, and obtaining the semantic relationship output by the span relationship extraction layer, further includes: The initial relation matrix is ​​updated using a multi-headed biaffine predictor.

4. The named entity recognition method according to claim 1, characterized in that, The named entity recognition model is trained based on a sample dataset, as well as the actual entity span and sample named entities corresponding to the sample dataset. In the training process of the named entity recognition model, based on the intersection-union ratio, the actual entity span with the highest overlap with the entity span obtained by the named entity recognition model is determined as the target actual entity span. The actual target entity span is used to replace the corresponding entity span, and the entity span with an overlap greater than a preset threshold is used as a positive sample for further training of the named entity recognition model.

5. The named entity recognition method according to claim 4, characterized in that, During the training process of the named entity recognition model, the class balance of the sample named entities is improved based on the focus loss function.

6. The named entity recognition method according to claim 1, characterized in that, Based on the relationship between spans in the obtained entity span pairs, the entity span relationship is divided into several predefined types, including: adjacency, end-beginning boundary-entity category, and same entity type; The step of decoding entities based on the prediction results to obtain named entities in the statement to be identified includes: Based on the prediction results, the entity span and the semantic relationship corresponding to each entity span pair are respectively regarded as nodes and directed paths; Using any two predefined types of the statement to be identified as the ending and beginning boundaries - the entity span of the entity category as the ending node and the beginning node respectively, search for all directed paths from the beginning node to the ending node.

7. A named entity recognition system, characterized in that, include: The input module is used to obtain the statement to be recognized; The prediction module is used to input the statement to be recognized into the trained named entity recognition model and obtain the prediction result of the named entity recognition model for the statement to be recognized. The prediction result includes entity span and semantic relationship corresponding to each entity span pair. The recognition module is used to perform entity decoding based on the prediction result to obtain the named entities in the statement to be recognized; The named entity recognition model obtains the entity span in the sentence by identifying the tail boundary of each entity in the sentence to be recognized as a sentence separator. The step of inputting the statement to be identified into a trained named entity recognition model to obtain the prediction result of the statement to be identified output by the named entity recognition model includes: inputting the statement to be identified into the sequence encoding layer of the named entity recognition model, whereby the sequence encoding layer performs sequence encoding on the statement to be identified to obtain a sequence output by the sequence encoding layer consisting of word vector representations corresponding to the statement to be identified; inputting the sequence into the entity span generation layer of the named entity recognition model, whereby the entity span generation layer identifies the entity tail boundaries in the sequence as sentence separators to obtain all entity span representations in the sequence output by the entity span generation layer; and inputting the entity span representations into the span relation extraction layer of the named entity recognition model, whereby the span relation extraction layer constructs a relation matrix based on the entity span representations to determine the semantic relation of each entity span pair, to obtain the semantic relation output by the span relation extraction layer.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the named entity recognition method as described in any one of claims 1 to 6.

9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the named entity recognition method as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Chinese legal text entity recognition method based on boundary detection and prompt learning

    CN114372470A

  • Named entity recognition method, device and equipment and computer readable storage medium

    CN114722822A