Named entity extraction method and device and electronic device

By using the named entity recognition model and the label decoder to mark boundary in named entity recognition, the problem of ignoring the difference in non-entity tags in the prior art is solved, and the recognition accuracy of named entities is improved.

CN114358011BActive Publication Date: 2024-12-10NAT UNIV OF DEFENSE TECH
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202210013663.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-06
Publication Date
2024-12-10
Estimated Expiration
2042-01-06

AI Technical Summary

Technical Problem

In the existing named entity recognition technology, the annotation scheme ignores the differences between non-entity tags, resulting in inaccurate identification of named entity boundaries.

Method used

Through named entity recognition model, naming and non-named entities in natural language text are identified, and boundary annotations are performed based on the front and back label relationships. Use pre-trained language model and label decoder to generate target label sequences, which specifically includes changing the second type of label. Mark the boundaries to highlight the boundaries of the named entity.

Benefits of technology

It significantly improves the distinction and recognition accuracy of named entities, making the recognition results of named entities more accurate.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114358011B_ABST
    Figure CN114358011B_ABST
Patent Text Reader

Abstract

The present application provides a method and device for extracting named entities and an electronic device. The method comprises: firstly, using a named entity recognition model, identifying a first type of token belonging to a named entity and a second type of token not belonging to a named entity in a natural language text, so as to convert the natural language text into a token sequence, and annotating the token sequence in a front-to-back order to obtain a target label sequence. According to the target label sequence, each named entity is extracted from the token sequence. Among them, the target label sequence distinguishes the boundary characters before and after the named entity, which significantly improves the discrimination of the named entity and makes the result of the named entity recognition more accurate.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data recognition technology, and in particular to a method and device for extracting named entities and an electronic device. Background Art

[0002] Named entity recognition aims to identify the boundaries and types of entities with specific meanings in natural language texts, mainly including names of people, places, institutions, proper nouns, etc. A token is the basic unit of text, usually a word in English or a character in Chinese. In machine learning, text is regarded as a sequence of tokens, and the task of named entity recognition is transformed into a sequence annotation task, that is, annotating and labeling each token in the sequence. The annotation scheme has a great impact on the performance of named entity recognition. Related named entity recognition schemes regard non-entity tags as the same for the annotation scheme and ignore the differences between these tags. Summary of the invention

[0003] In view of this, the purpose of the present application is to propose a method and device for extracting named entities and an electronic device.

[0004] Based on the above purpose, this application provides

[0005] A method for extracting named entities, comprising:

[0006] By using a named entity recognition model, first-category tokens belonging to named entities and second-category tokens not belonging to named entities in a natural language text are identified to convert the natural language text into a token sequence, and the token sequence is labeled in a front-to-back order to obtain a target label sequence;

[0007] According to the target tag sequence, each named entity is extracted from the token sequence,

[0008] Wherein, labeling the token sequence to obtain the target tag sequence includes:

[0009] Tagging the first category of tokens and the second category of tokens in the token sequence with the first category of tags and the second category of tags respectively in a front-to-back order to obtain an initial tag sequence;

[0010] For each of the second-category labels in the initial label sequence, perform the following operations to obtain the target label sequence:

[0011] In response to determining that a previous label of the second category label does not exist or does not belong to the first category label, and a subsequent label of the second category label belongs to the first category label, changing the second category label to a first category boundary label;

[0012] In response to determining that a previous label of the second category label belongs to the first category label, and a subsequent label of the second category label does not exist or does not belong to the first category label, the second category label is changed to a second category boundary label.

[0013] Furthermore, the operation also includes:

[0014] In response to determining that a previous label and a subsequent label of the second-category label both belong to the first-category label, the second-category label is changed to the second-category boundary label.

[0015] Furthermore, the operation also includes:

[0016] In response to determining that a previous label and a subsequent label of the second-category label both belong to the first-category label, the second-category label is changed to the first-category boundary label.

[0017] Furthermore, the step of changing the second-category label to the first-category boundary label includes:

[0018] Obtaining a first entity type identifier contained in a subsequent tag of the second type of tag;

[0019] changing the second type label to the first type boundary marker including the first entity type identifier,

[0020] Changing the second-class label to a second-class boundary marker comprises:

[0021] Obtain a second entity type identifier contained in a previous tag of the second type tag;

[0022] The second type label is changed to the second type boundary marker including the second entity type identifier.

[0023] Further, in response to determining that the previous label and the next label of the second category label both belong to the first category label, changing the second category label to the second category boundary label includes:

[0024] Obtaining a third entity type identifier contained in a previous tag of the second type tag;

[0025] The second-class label is changed to the second-class boundary marker including the third entity type identifier.

[0026] Further, in response to determining that the previous label and the next label of the second category label both belong to the first category label, changing the second category label to the first category boundary label includes:

[0027] Obtaining a fourth entity type identifier contained in a tag following the second type of tag;

[0028] The second type label is changed to the first type boundary marker including the fourth entity type identifier.

[0029] Furthermore, the named entity recognition model includes a pre-trained language model and a label decoder;

[0030] Identifying the first type of tokens and the second type of tokens in the natural language text to convert the natural language text into the token sequence includes: converting the natural language text into a token representation through the pre-trained language model, and identifying the first type of tokens and the second type of tokens in the token representation to obtain the token sequence;

[0031] Labeling the token sequence in a front-to-back order includes: labeling the token sequence in a front-to-back order through the label decoder.

[0032] Furthermore, the label decoder includes a conditional random field (CRF) model.

[0033] Based on the same concept, the present application also provides a named entity extraction device, comprising:

[0034] A labeling module is used to identify the first type of tokens belonging to the named entity and the second type of tokens not belonging to the named entity in the natural language text through a named entity recognition model, so as to convert the natural language text into a token sequence, and label the token sequence in a front-to-back order to obtain a target label sequence;

[0035] an extraction module, configured to extract each named entity from the token sequence according to the target tag sequence,

[0036] Wherein, the annotation module is configured as follows:

[0037] Tagging the first category of tokens and the second category of tokens in the token sequence with the first category of tags and the second category of tags respectively in a front-to-back order to obtain an initial tag sequence;

[0038] For each of the second-category labels in the initial label sequence, perform the following operations to obtain the target label sequence:

[0039] In response to determining that a previous label of the second category label does not exist or does not belong to the first category label, and a subsequent label of the second category label belongs to the first category label, changing the second category label to a first category boundary label;

[0040] In response to determining that a previous label of the second category label belongs to the first category label, and a subsequent label of the second category label does not exist or does not belong to the first category label, the second category label is changed to a second category boundary label.

[0041] Based on the same concept, the present application 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 implements any of the methods described above when executing the program.

[0042] From the above, it can be seen that the named entity extraction method and device and the electronic device provided by the present application first identify the first type of tokens belonging to the named entity and the second type of tokens that do not belong to the named entity in the natural language text through the named entity recognition model, so as to convert the natural language text into a token sequence, and annotate the token sequence in order from front to back to obtain a target label sequence. According to the target label sequence, each named entity is extracted from the token sequence. Among them, the target label sequence distinguishes the boundary characters before and after the named entity, which significantly improves the discrimination of the named entity and makes the result of named entity recognition more accurate. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] In order to more clearly illustrate the technical solutions in the present application or related technologies, the drawings required for use in the embodiments or related technical descriptions are briefly introduced below. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0044] Figure 1 A flowchart of a method for extracting named entities according to an embodiment of the present application;

[0045] Figure 2 A schematic diagram of a named entity extraction device according to an embodiment of the present application;

[0046] Figure 3 This is a schematic diagram of the structure of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION

[0047] In order to make the objectives, technical solutions and advantages of the present application more clearly understood, the present application is further described in detail below in combination with specific embodiments and with reference to the accompanying drawings.

[0048] It should be noted that, unless otherwise defined, the technical terms or scientific terms used in the embodiments of the present application should be the usual meanings understood by people with ordinary skills in the field to which the present application belongs. The "first", "second" and similar words used in the embodiments of the present application do not represent any order, quantity or importance, but are only used to distinguish different components. "Including" or "comprising" and similar words mean that the elements or objects appearing in front of the word cover the elements or objects listed after the word and their equivalents, without excluding other elements or objects. "Connect" or "connected" and similar words are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect. "Up", "down", "left", "right" and the like are only used to indicate relative positional relationships. When the absolute position of the described object changes, the relative positional relationship may also change accordingly.

[0049] As described in the background technology section, the related named entity recognition annotation schemes only consider the internal tags of the entities and ignore the information of their external tags. All related annotation schemes treat non-entity tags as the same and ignore the differences between these tags. In the process of implementing this application, the applicant found that the tags close to the entity may represent the boundary of the entity and should be treated differently from other tags.

[0050] In view of this, one or more embodiments of this specification provide a named entity extraction solution, referring to Figure 1 A method for named entity recognition according to an embodiment of the present specification comprises the following steps:

[0051] Step S101: using a named entity recognition model, identifying first-class tokens belonging to named entities and second-class tokens not belonging to named entities in a natural language text, so as to convert the natural language text into a token sequence, and annotating the token sequence in a front-to-back order to obtain a target label sequence;

[0052] In this step, labeling the token sequence to obtain the target tag sequence includes:

[0053] Tagging the first category of tokens and the second category of tokens in the token sequence with the first category of tags and the second category of tags respectively in a front-to-back order to obtain an initial tag sequence;

[0054] For each of the second-category labels in the initial label sequence, perform the following operations to obtain the target label sequence:

[0055] In response to determining that a previous label of the second category label does not exist or does not belong to the first category label, and a subsequent label of the second category label belongs to the first category label, changing the second category label to a first category boundary label;

[0056] In response to determining that the previous tag of the second - type tag belongs to the first - type tag, while the subsequent tag of the second - type tag does not exist or does not belong to the first - type tag, change the second - type tag to a second - type boundary marker.

[0057] In this embodiment, the natural - language text includes named entities and non - named entities. Named entities are personal names, organization names, place names, and all other entities identified by names. More extensive named entities also include numbers, dates, currencies, addresses, etc. Non - named entities are the other parts. A token is the basic unit of text, usually referring to a word in English or a character in Chinese. The tokens corresponding to named entities are the first - type tokens, and the tokens corresponding to non - named entities are the second - type tokens. For the first - type tokens, first mark them as the first - type tags to indicate that the characters or words corresponding to the tokens are named entities; for the second - type tokens, first mark them as the second - type tags to indicate that the characters or words corresponding to the tokens are non - named entities. Then, analyze the tag situations before and after the second - type tags, and change the second - type tags corresponding to the non - named entities on both sides of the named entity to boundary markers to prominently indicate the front and back boundaries of the named entity.

[0058] As a specific example, for the sentence "Premature infants' renal function is not yet mature", where "kidney" is a named entity, it is necessary to mark the first boundary marker on "infants" before "kidney" and the second boundary marker on "function" after "kidney".

[0059] Step S102: Extract each named entity from the token sequence according to the target tag sequence.

[0060] In this step, the target tag sequence corresponding to the token sequence has tags with named - entity and named - entity boundary information. When extracting, just extract the named entities according to the corresponding tags.

[0061] It can be seen that the target tag sequence makes a distinguishable annotation for the boundary characters before and after the named entity, significantly improving the distinguishability of the named entity and making the result of named - entity recognition more accurate.

[0062] In some other embodiments, the operations described in the foregoing embodiments may further include:

[0063] In response to determining that both the previous tag and the subsequent tag of the second - type tag belong to the first - type tag, change the second - type tag to the second - type boundary marker.

[0064] In this embodiment, there is a situation where the character or word of a non-named entity only occupies the length of one token, so there is only one second-class label corresponding to the non-named entity. If the non-named entity is preceded and followed by named entities, the second-class label corresponding to the non-named entity needs to be changed to the second-class boundary marker to serve as the marker of the rear boundary of the preceding named entity.

[0065] As a specific example, to annotate the sentence "The renal and liver functions of premature infants are not yet mature", where "kidney" and "liver" are named entities, it is necessary to annotate the "kidney" before the "kidney" with the first-class boundary marker, annotate the "kidney" after the "kidney" with the second-class boundary marker, and annotate the "liver" after the "liver" with the second-class boundary marker.

[0066] In some other embodiments, the operations described in the foregoing embodiments may further include:

[0067] In response to determining that a previous label and a subsequent label of the second-category label both belong to the first-category label, the second-category label is changed to the first-category boundary label.

[0068] In this embodiment, there is a situation where the character or word of a non-named entity only occupies the length of one token, so there is only one second-class label corresponding to the non-named entity. If the non-named entity is preceded and followed by named entities, the second-class label corresponding to the non-named entity needs to be changed to the first-class boundary marker to serve as the marker of the front boundary of the following named entity.

[0069] In some other embodiments, the changing of the second-class label to the first-class boundary label in the aforementioned embodiment includes:

[0070] Obtaining a first entity type identifier contained in a subsequent tag of the second type of tag;

[0071] changing the second type label to the first type boundary marker including the first entity type identifier,

[0072] Changing the second-class label to a second-class boundary marker comprises:

[0073] Obtain a second entity type identifier contained in a previous tag of the second type tag;

[0074] The second type label is changed to the second type boundary marker including the second entity type identifier.

[0075] In this embodiment, the label can represent two aspects of information of a character or word, including two parts: a first-class label and a second-class label indicating whether the corresponding character or word is a named entity; and an entity type identifier indicating what type of entity the corresponding character or word is, which is used to indicate type information such as a person's name, an organization's name, a place name, etc. In this embodiment, the first-class boundary marker and the second-class boundary marker used to indicate the boundary information of the named entity are also assigned the entity type identifier corresponding to the boundary marker, so that the distinguishability of the named entity is further improved, and the result of the named entity recognition is more accurate.

[0076] In some other embodiments, in response to determining that both the previous label and the next label of the second category label belong to the first category label, changing the second category label to the second category boundary label includes:

[0077] Obtaining a third entity type identifier contained in a previous tag of the second type tag;

[0078] The second-class label is changed to the second-class boundary marker including the third entity type identifier.

[0079] As a specific example, referring to Table 1, a named entity can be a body organ or a disease. The annotation scheme in this embodiment is called BIO+ES, the first-class boundary marker is set to O-, the second-class boundary marker is set to O+, the first-class label of a single-character named entity is set to S, the first-class label of a multi-character named entity is set to B, the middle symbol is set to I, the end symbol is set to E, the second-class label is set to O, the entity type identifier of the body organ is set to bod, the entity type identifier of the disease is set to dis, and "Premature infants have immature renal function, low glucose renal threshold, and are prone to diabetes." is annotated.

[0080] Table 1

[0081] token morning Produce Son kidney achievement able still No become Cooked , Portuguese Grape sugar kidney threshold Comparison Low , easy out now sugar Urine 。 Annotation O O O-bod S-bod O+bod O O O O O O-bod B-bod I-bod E-bod S-bod O+bod O O O O O O-dis B-dis E-dis O+dis

[0082] In some other embodiments, in response to determining that both the previous label and the next label of the second category label belong to the first category label, changing the second category label to the first category boundary label includes:

[0083] Obtaining a fourth entity type identifier contained in a tag following the second type of tag;

[0084] The second type label is changed to the first type boundary marker including the fourth entity type identifier.

[0085] In some other embodiments, the named entity recognition model in the method described in the aforementioned embodiments includes a pre-trained language model and a label decoder;

[0086] Identifying the first type of tokens and the second type of tokens in the natural language text to convert the natural language text into the token sequence includes: converting the natural language text into a token representation through the pre-trained language model, and identifying the first type of tokens and the second type of tokens in the token representation to obtain the token sequence;

[0087] Labeling the token sequence in a front-to-back order includes: labeling the token sequence in a front-to-back order through the label decoder.

[0088] In this embodiment, the character representation includes the embedding and other valid representations of Chinese characters, which is the basic unit of Chinese. In natural language processing, Chinese characters are usually regarded as English words, and each Chinese character is regarded as a token. The function of character representation is to map the token into a continuous space to facilitate subsequent calculations. In general, before performing various machine learning algorithms, we need to vectorize the input. Unique hot encoding represents each token with a very long vector, and the length of the vector is the size of the dictionary. In the unique hot vector space, two different characters have orthogonal representations and cannot reflect the semantic relationship between tokens. Distributed representation can overcome the shortcomings of unique hot representation. The basic idea of ​​distributed representation is to map each token into a short vector of fixed length through training. All these vectors constitute a vector space, and each dimension of the space represents a potential feature, so each token can be regarded as a point in the space. Distributed representation is automatically learned from text, which can automatically capture the semantic and syntactic properties of the token, so that the input characters are often converted into distributed representations in named entity recognition. Therefore, in named entity recognition, the input characters are converted into distributed representations for learning and training in named entity recognition.

[0089] The pre-trained language model is also called a dynamic context-dependent embedding. In this embodiment, the pre-trained language model can be ELMo, GPT, BERT, ERNIE, ALBERT, NEZHA, etc. The character representations generated by these models are context-dependent and will change with the context. For a given character, BERT uses its character position vector, sentence position vector, and character vector sum as input, and uses a masked language model to pre-train the input for deep bidirectional representation, thereby obtaining a robust context-dependent character representation.

[0090] In some embodiments, the pre-trained language model cannot recognize the contextual relevance of natural language text that introduces additional information very well. At this time, the position of characters in the sentence and the dependencies between different characters can be further analyzed through a context encoder, the input representation is encoded, and the representation of each character in the current sentence is obtained.

[0091] In this embodiment, the context encoder can be a neural network model based on a cycle, or it can be a Transformer encoder. A recurrent neural network (RNN) is a type of recursive neural network that takes sequence data as input, recurses in the direction of sequence evolution, and all nodes (recurrent units) are connected in a chain. The recurrent neural network designs a parameter-sharing loop structure that does not change with the length and position of the sequence data. The state of each recurrent unit at the current time step is determined by the input of the time step and the state of the previous time step. Its weight coefficient is shared, that is, in one iteration, the recurrent node uses the same weight coefficient to process all time steps. Compared with a feedforward neural network, weight sharing reduces the total number of parameters of the RNN. Weight sharing also means that the RNN can extract time-varying features in the sequence, so it can show generalization ability when the learning and test sequences have different lengths. Due to the gradient vanishing problem, the original RNN assigns more weight to the nearest node and cannot learn long-distance dependencies. Therefore, the gated recurrent network was created. The idea is to give RNN the ability to control its internal information accumulation through the gated unit, so that it can grasp long-distance dependencies and selectively forget information to prevent overload during learning. The mainstream gated recurrent networks are the gated recurrent unit (GRU) and the long short-term memory network (LSTM).

[0092] Recurrent neural network models usually compute input and output sequences sequentially, producing a sequence of hidden states at each position based on the hidden state and input at the previous step. This inherent sequential nature hinders the parallelization of sample training, which becomes critical at longer sequence lengths because limited memory limits the batch size of samples.

[0093] In this embodiment, the context encoder can actually be nested. In fact, BERT and other algorithms have context encoding information, but most of them still add a context encoder with LTSM structure. However, in this case, the effect of adding the context encoder is not obvious. However, the introduced additional information does not have context-related information itself, so the encoder is required to capture its context information.

[0094] In some other embodiments, the label decoder may be a conditional random field (CRF) model.

[0095] In this embodiment, the label decoder is the final stage of the named entity recognition model. It takes the context-dependent representation as input and generates a label sequence corresponding to the input natural language text, namely the target label sequence. There are currently two main implementation forms. (1) MLP+Softmax. The sequence labeling task is converted into a multi-class classification problem. After obtaining the representation of each word, a linear layer is directly used to obtain the scores of each label corresponding to the word. In this structure, the label of each token is independently predicted based on its context-dependent representation obtained by the decoder, without considering the surrounding tokens. (2) Conditional Random Field (CRF), which can model the internal dependencies of the label sequence. For example, in the BIOES labeling scheme, B can only be followed by I or E, but not S. The conditional random field can gradually learn this dependency between labels during training, thereby avoiding some errors. In this application, CRF is used as a decoder.

[0096] A conditional random field is a Markov random field of a random variable Y given a random variable X. The linear chain conditional random field is mainly used in sequence labeling problems. In this case, in the conditional random field model P(Y|X), Y is the output variable, representing the labeled sequence, and X is the input variable, representing the observation sequence that needs to be labeled. When learning, the conditional probability model P'(Y|X) is obtained through maximum likelihood estimation or regularized maximum likelihood estimation using training data; when predicting, for a given input sequence x, find the output y with the maximum conditional probability P'(y|x). The probability calculation problem of the conditional random field is to calculate the conditional probability P(Y|X), given the conditional random field P(Y|X), the input sequence x and the output sequence y. i =y i |x), P(Y i -1 = y i -1,y i |x i ) and the corresponding mathematical expectation problem. The prediction problem of conditional random fields is to find the output sequence (label sequence) y* with the maximum conditional probability given the conditional random field P(Y|X) and the input sequence (observation sequence) x, that is, to label the observation sequence. The prediction algorithm of conditional random fields is the famous Viterbi algorithm, which uses dynamic programming to efficiently solve the optimal path, that is, the target label sequence with the highest probability.

[0097] It can be seen that in this embodiment, a distributed representation of a token sequence is obtained by pre-training a language model. Then, a context encoder uses a recurrent neural network, a Transformer model, or other networks to capture the contextual correlation between characters. Further, a label decoder uses the encoded context information to predict the label of the token, that is, to obtain a target label sequence.

[0098] A specific application scenario of the embodiment of the present application is given below, and Table 2 shows the difference between the BIO+ES labeling scheme in the present application and other related labeling schemes. Similarly, take "premature infants have immature renal function, low renal glucose threshold, and are prone to diabetes" as an example.

[0099] Table 2

[0100] token IO IOB BIO IOE1 IOE2 BIOE1 BIOE2 BIOS BIOES BIO+ES morning O O O O O O O O O O Produce O O O O O O O O O O Son O O O O O O O O O O-bod kidney I-bod I-bod B-bod I-bod E-bod B-bod E-bod S-bod S-bod S-bod achievement O O O O O O O O O O+bod able O O O O O O O O O O still O O O O O O O O O O No O O O O O O O O O O become O O O O O O O O O O Cooked O O O O O O O O O O , O O O O O O O O O O-bod Portuguese I-bod I-bod B-bod I-bod I-bod B-bod B-bod B-bod B-bod B-bod Portuguese I-bod I-bod I-bod I-bod I-bod I-bod I-bod I-bod I-bod I-bod sugar I-bod I-bod I-bod E-bod E-bod E-bod E-bod I-bod E-bod E-bod kidney I-bod B-bod B-bod I-bod E-bod B-bod E-bod S-bod S-bod S-bod threshold O O O O O O O O O O+bod Comparison O O O O O O O O O O Low O O O O O O O O O O , O O O O O O O O O O easy O O O O O O O O O O out O O O O O O O O O O now O O O O O O O O O O-dis sugar I-dis I-dis B-dis I-dis I-dis B-dis B-dis B-dis B-dis B-dis Urine I-dis I-dis I-dis I-dis E-dis E-dis E-dis I-dis E-dis E-dis 。 O O O O O O O O O O+dis

[0101] In this embodiment, three benchmark Chinese named entity recognition datasets are analyzed, including: MSRA, WEIBO and RESUME. Table 3 shows the recognition effect of the named entity recognition method using BIO+ES and the named entity recognition method using BIOES of the present application on the target text in the dataset when using two pre-trained language models BERT / ERNIE and CRF as an encoder. The recognition effect is displayed by converting the F1 score into a percentage system. As a multi-classification task, the sequence labeling task converted by named entity recognition usually uses the macro-average F1 score and micro-average F1 score in the exact matching F score as evaluation indicators. The F score is an indicator used in statistics to measure the accuracy of the classification model. For unbalanced sample distributions, it is not enough to measure the quality of the model only by accuracy. The F score comprehensively considers the accuracy and recall of the classification model to obtain their weighted harmonic average. The F score is between 0 and 1, and the higher the score, the better the performance.

[0102] Table 3

[0103] MSRA WEIBO RESUME BERT+CRF(BIOES) 95.72 72.28 95.78 BERT+CRF(BIO+ES) 95.93 72.46 95.99 ERNIE+CRF(BIOES) 95.93 71.83 96.77 ERNIE+CRF(BIO+ES) 96.O1 72.97 96.92

[0104] As can be seen from the table, the named entity extraction method of the embodiment of the present application has a higher F score than the related methods, so the BIO+ES annotation scheme proposed in the embodiment of the present application performs better than other schemes in most cases. This shows that the named entity extraction method using the BIO+ES annotation scheme of the present application is a more expressive scheme.

[0105] It should be noted that the method of the embodiment of the present application can be performed by a single device, such as a computer or server. The method of this embodiment can also be applied to a distributed scenario and completed by multiple devices cooperating with each other. In the case of such a distributed scenario, one of the multiple devices can only perform one or more steps in the method of the embodiment of the present application, and the multiple devices will interact with each other to complete the described method.

[0106] It should be noted that the above describes some embodiments of the present application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the above embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0107] Based on the same inventive concept, corresponding to any of the above-mentioned embodiment methods, the present application also provides a named entity extraction device.

[0108] refer to Figure 2 , the named entity extraction device comprises:

[0109] The tagging module 201 is used to identify the first type of tokens belonging to the named entity and the second type of tokens not belonging to the named entity in the natural language text through the named entity recognition model, so as to convert the natural language text into a token sequence, and tag the token sequence in a front-to-back order to obtain a target label sequence;

[0110] An extraction module 202 is used to extract each named entity from the token sequence according to the target tag sequence,

[0111] Wherein, the annotation module is configured as follows:

[0112] Tagging the first category of tokens and the second category of tokens in the token sequence with the first category of tags and the second category of tags respectively in a front-to-back order to obtain an initial tag sequence;

[0113] For each of the second-category labels in the initial label sequence, perform the following operations to obtain the target label sequence:

[0114] In response to determining that a previous label of the second category label does not exist or does not belong to the first category label, and a subsequent label of the second category label belongs to the first category label, changing the second category label to a first category boundary label;

[0115] In response to determining that a previous label of the second category label belongs to the first category label, and a subsequent label of the second category label does not exist or does not belong to the first category label, the second category label is changed to a second category boundary label.

[0116] For the convenience of description, the above device is described in terms of functions divided into various modules. Of course, when implementing the present application, the functions of each module can be implemented in the same or multiple software and / or hardware.

[0117] The device of the above embodiment is used to implement the corresponding named entity recognition method in any of the above embodiments, and has the beneficial effects of the corresponding method embodiment, which will not be repeated here.

[0118] Based on the same inventive concept, corresponding to any of the above-mentioned embodiment methods, the present application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the named entity extraction method described in any of the above embodiments is implemented.

[0119] Figure 3 A more specific schematic diagram of the hardware structure of an electronic device provided in this embodiment is shown, and the device may include: a processor 1010, a memory 1020, an input / output interface 1030, a communication interface 1040, and a bus 1050. The processor 1010, the memory 1020, the input / output interface 1030, and the communication interface 1040 are connected to each other through the bus 1050 in the device.

[0120] The processor 1010 can be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this specification.

[0121] The memory 1020 may be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage device, dynamic storage device, etc. The memory 1020 may store an operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented by software or firmware, the relevant program codes are stored in the memory 1020 and are called and executed by the processor 1010.

[0122] The input / output interface 1030 is used to connect the input / output module to realize information input and output. The input / output module can be configured in the device as a component (not shown in the figure), or it can be externally connected to the device to provide corresponding functions. The input device may include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output device may include a display, a speaker, a vibrator, an indicator light, etc.

[0123] The communication interface 1040 is used to connect a communication module (not shown) to realize communication interaction between the device and other devices. The communication module can realize communication through a wired mode (such as USB, network cable, etc.) or a wireless mode (such as mobile network, WIFI, Bluetooth, etc.).

[0124] The bus 1050 includes a path that transmits information between the various components of the device (eg, the processor 1010, the memory 1020, the input / output interface 1030, and the communication interface 1040).

[0125] It should be noted that, although the above device only shows the processor 1010, the memory 1020, the input / output interface 1030, the communication interface 1040 and the bus 1050, in the specific implementation process, the device may also include other components necessary for normal operation. In addition, it can be understood by those skilled in the art that the above device may also only include the components necessary for implementing the embodiments of the present specification, and does not necessarily include all the components shown in the figure.

[0126] The electronic device of the above embodiment is used to implement the corresponding named entity extraction method in any of the above embodiments, and has the beneficial effects of the corresponding method embodiment, which will not be described in detail here.

[0127] Based on the same inventive concept, corresponding to any of the above-mentioned embodiment methods, the present application also provides a non-transitory computer-readable storage medium, wherein the non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the computer to execute the named entity extraction method described in any of the above embodiments.

[0128] The computer-readable medium of this embodiment includes permanent and non-permanent, removable and non-removable media, and information storage can be implemented by any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, read-only compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device.

[0129] The computer instructions stored in the storage medium of the above embodiment are used to enable the computer to execute the named entity extraction method described in any of the above embodiments, and have the beneficial effects of the corresponding method embodiments, which will not be repeated here.

[0130] Those skilled in the art should understand that the discussion of any of the above embodiments is merely illustrative and is not intended to imply that the scope of the present application (including the claims) is limited to these examples. In line with the concept of the present application, the technical features in the above embodiments or different embodiments may be combined, the steps may be implemented in any order, and there are many other variations of the different aspects of the embodiments of the present application as described above, which are not provided in detail for the sake of simplicity.

[0131] In addition, to simplify the description and discussion, and in order not to make the embodiments of the present application difficult to understand, the known power supply / ground connection with the integrated circuit (IC) chip and other components may or may not be shown in the provided drawings. In addition, the device can be shown in the form of a block diagram to avoid making the embodiments of the present application difficult to understand, and this also takes into account the fact that the details of the implementation of these block diagram devices are highly dependent on the platform to be implemented in the embodiments of the present application (that is, these details should be fully within the scope of understanding of those skilled in the art). In the case of elaborating specific details (e.g., circuits) to describe exemplary embodiments of the present application, it is obvious to those skilled in the art that the embodiments of the present application can be implemented without these specific details or when these specific details are changed. Therefore, these descriptions should be considered to be illustrative rather than restrictive.

[0132] Although the present application has been described in conjunction with specific embodiments of the present application, many replacements, modifications and variations of these embodiments will be apparent to those skilled in the art from the foregoing description. For example, other memory architectures (e.g., dynamic RAM (DRAM)) may use the embodiments discussed.

[0133] The embodiments of the present application are intended to cover all such substitutions, modifications and variations that fall within the broad scope of the appended claims. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the embodiments of the present application should be included in the scope of protection of the present application.

Claims

1. A method for extracting named entities, characterized in that: include: By using a named entity recognition model, first-category tokens belonging to named entities and second-category tokens not belonging to named entities in a natural language text are identified to convert the natural language text into a token sequence, and the token sequence is labeled in a front-to-back order to obtain a target label sequence; Extracting each named entity from the token sequence according to the target tag sequence, Wherein, labeling the token sequence to obtain the target tag sequence includes: Tagging the first category of tokens and the second category of tokens in the token sequence with the first category of tags and the second category of tags respectively in a front-to-back order to obtain an initial tag sequence; For each of the second-category labels in the initial label sequence, perform the following operations to obtain the target label sequence: In response to determining that a previous label of the second category label does not exist or does not belong to the first category label, and a subsequent label of the second category label belongs to the first category label, changing the second category label to a first category boundary label; In response to determining that a previous label of the second category label belongs to the first category label, and a subsequent label of the second category label does not exist or does not belong to the first category label, the second category label is changed to a second category boundary label.

2. The method according to claim 1, characterized in that: The operations also include: In response to determining that a previous label and a subsequent label of the second-category label both belong to the first-category label, the second-category label is changed to the second-category boundary label.

3. The method according to claim 1, characterized in that The operations also include: In response to determining that a previous label and a subsequent label of the second-category label both belong to the first-category label, the second-category label is changed to the first-category boundary label.

4. The method according to claim 1, characterized in that: Changing the second-class label to the first-class boundary label comprises: Obtaining a first entity type identifier contained in a subsequent tag of the second type of tag; changing the second type label to the first type boundary marker including the first entity type identifier, Changing the second-class label to a second-class boundary marker comprises: Obtain a second entity type identifier contained in a previous tag of the second type tag; The second type label is changed to the second type boundary marker including the second entity type identifier.

5. The method according to claim 2, characterized in that: In response to determining that a previous label and a subsequent label of the second-category label both belong to the first-category label, changing the second-category label to the second-category boundary label comprises: Obtaining a third entity type identifier contained in a previous tag of the second type tag; The second-class label is changed to the second-class boundary marker including the third entity type identifier.

6. The method according to claim 3, characterized in that In response to determining that a previous label and a subsequent label of the second-category label both belong to the first-category label, changing the second-category label to the first-category boundary label includes: Obtaining a fourth entity type identifier contained in a tag following the second type tag; The second type label is changed to the first type boundary marker including the fourth entity type identifier.

7. The method according to any one of claims 1 to 6, characterized in that The named entity recognition model includes a pre-trained language model and a label decoder; Identifying the first type of tokens and the second type of tokens in the natural language text to convert the natural language text into the token sequence includes: converting the natural language text into a token representation through the pre-trained language model, and identifying the first type of tokens and the second type of tokens in the token representation to obtain the token sequence; Labeling the token sequence in a front-to-back order includes: labeling the token sequence in a front-to-back order through the label decoder.

8. The method according to claim 7, characterized in that The label decoder includes a conditional random field (CRF) model.

9. A named entity extraction device, characterized in that: include: A labeling module is used to identify the first type of tokens belonging to the named entity and the second type of tokens not belonging to the named entity in the natural language text through a named entity recognition model, so as to convert the natural language text into a token sequence, and label the token sequence in a front-to-back order to obtain a target label sequence; an extraction module, configured to extract each named entity from the token sequence according to the target tag sequence, Wherein, the annotation module is configured as follows: Tagging the first category of tokens and the second category of tokens in the token sequence with the first category of tags and the second category of tags respectively in a front-to-back order to obtain an initial tag sequence; For each of the second-category labels in the initial label sequence, perform the following operations to obtain the target label sequence: In response to determining that a previous label of the second category label does not exist or does not belong to the first category label, and a subsequent label of the second category label belongs to the first category label, changing the second category label to a first category boundary label; In response to determining that a previous label of the second category label belongs to the first category label, and a subsequent label of the second category label does not exist or does not belong to the first category label, the second category label is changed to a second category boundary label.

10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable by the processor, characterized in that: The processor implements the method according to any one of claims 1 to 8 when executing the computer program.

Citation Information

Cited By

  • Data driven optimization of information extraction

    US12783518B1