Reordering-based named entity recognition method, system, device and storage medium

By ranking the candidate recognition results by F1 score and defining a comparative learning loss function, the named entity recognition model is optimized, solving the exposure bias problem of generative models and improving the accuracy of named entity recognition.

CN117332783BActive Publication Date: 2026-11-20INFORMATION COMM COMPANY STATE GRID SHANDONG ELECTRIC POWER +2
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311219833.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-09-20
Publication Date
2026-11-20
Estimated Expiration
2043-09-20

AI Technical Summary

Technical Problem

Existing generative models suffer from exposure bias in named entity recognition tasks, which means that the most probable answer predicted is not necessarily the expected answer.

Method used

A re-ranking-based approach is adopted to rank the candidate recognition results according to the F1 score calculated based on the preset standard answer. A contrastive learning loss function is defined and combined with the cross-entropy loss function to train the named entity recognition model, so as to optimize the model's generation and ranking capabilities.

Benefits of technology

It improves the accuracy of named entity recognition, solves the exposure bias problem, makes the prediction results more consistent with the expected answer, and enhances the performance of named entity recognition.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117332783B_ABST
    Figure CN117332783B_ABST
Patent Text Reader

Abstract

The application discloses a named entity recognition method and system based on reordering, a device and a storage medium, relates to the technical field of named entity data recognition, and comprises the following steps: obtaining a candidate recognition result by using a pre-constructed named entity recognition model on a text training set; calculating an F1 score value of the candidate recognition result according to a preset standard answer, and sorting the candidate recognition result according to the F1 score value; defining a comparative learning loss function for the sorted candidate recognition result, so as to train the pre-constructed named entity recognition model; and obtaining a classification recognition result of a target entity word by using the trained named entity recognition model on a text to be processed. The named entity recognition effect is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of named entity data recognition technology, and in particular to a method, system, device and storage medium for named entity recognition based on reordering. Background Technology

[0002] The statements in this section are merely background information related to the present invention and do not necessarily constitute prior art.

[0003] Named entity recognition (NER) aims to identify entity words in text and classify them into predefined categories. It is a fundamental task in information extraction and provides technical support for downstream tasks such as relation extraction and text question answering. Existing work models NER as a sequence-to-sequence generative task based on generative pre-trained models.

[0004] However, generative models have an inherent "exposure bias problem," which means that during the training phase, maximum likelihood estimation is used to maximize the conditional probability of the predicted sequence given a standard sequence.

[0005] However, the inference phase predicts the word for the current step based on noisy subsequences generated in previous steps. This mismatch between the training and inference phases affects the model's performance. In other words, among the top K candidate answers predicted by the model using existing methods, the answer with the highest probability is not necessarily the expected answer. Summary of the Invention

[0006] To address the aforementioned issues, this invention proposes a reordering-based named entity recognition method, system, device, and storage medium, which solves the exposure bias problem existing in generative models and improves the named entity recognition performance.

[0007] To achieve the above objectives, the present invention adopts the following technical solution:

[0008] In a first aspect, the present invention provides a named entity recognition method based on reordering, comprising:

[0009] Candidate recognition results are obtained by using a pre-built named entity recognition model on the text training set;

[0010] Calculate the F1 score for each candidate recognition result based on the preset standard answer, and then sort the candidate recognition results according to the F1 score.

[0011] A contrastive learning loss function is defined for the sorted candidate recognition results, and the pre-built named entity recognition model is trained accordingly.

[0012] The trained named entity recognition model is used to identify the target entity words in the text to be processed.

[0013] As an optional implementation, the pre-built named entity recognition model includes an encoder and a decoder, and the process of obtaining candidate recognition results using the pre-built named entity recognition model includes:

[0014] After encoding the text using an encoder, text word vectors are obtained. Then, the text word vectors are mapped using a multilayer perceptron to obtain label space word vectors.

[0015] After mapping the text to Embedding word vectors, the entity word vectors are obtained by weighted summing of the Embedding word vectors and the tag space word vectors.

[0016] The latent vectors of entity words are obtained by decoding the word vectors of the text using a decoder.

[0017] Map entity type tags to embedding tag vectors;

[0018] The probability of the t-th entity word being each index is obtained from the entity word vector and the latent vector. The probability of the entity type label is obtained from the Embedding label vector and the latent vector. The two probabilities are concatenated to obtain the final probability of the t-th entity word and its entity type.

[0019] As one alternative implementation, the contrastive learning loss function is:

[0020]

[0021] in, To compare the learning loss function, and For the i-th and j-th candidate identification results, The F1 score is less than F1 score, λ ij It is a linear function of the difference between i and j, and f() is the conditional probability.

[0022] As an alternative implementation method, the linear function λ ij For: λ ij = (ji)*λ; where λ is a constant.

[0023] As an alternative implementation, the named entity recognition model also employs the cross-entropy loss function on the training set. Training is performed on D, where D (i) It is the i-th sentence in the training set, S *(i) This is the standard answer corresponding to the i-th sentence.

[0024] As an alternative implementation, the cross-entropy loss function optimizes the conditional probability given a standard answer, and the optimized conditional probability is:

[0025]

[0026] Where θ represents the parameters included in the named entity recognition model, and P θ Let be the probability.

[0027] As one alternative implementation, the cross-entropy loss function is:

[0028]

[0029] in, Let cross-entropy be the loss function. S* represents a partial sequence of standard answers, P is the probability, l is the length of the standard answer sequence S*, v is the entity word in the sentence, θ is the parameter included in the named entity recognition model, and D is the sentence in the training set.

[0030] Secondly, the present invention provides a named entity recognition system based on reordering, comprising:

[0031] The initial recognition model is configured to use a pre-built named entity recognition model to obtain candidate recognition results on the text training set;

[0032] The ranking model is configured to calculate the F1 score of the candidate recognition results based on the preset standard answer, and rank the candidate recognition results according to the F1 score;

[0033] The training model is configured to define a contrastive learning loss function on the ranked candidate recognition results, thereby training a pre-built named entity recognition model.

[0034] The recognition model is configured to use the trained named entity recognition model on the text to be processed to obtain the classification and recognition results of the target entity words.

[0035] Thirdly, the present invention provides an electronic device including a memory and a processor, and computer instructions stored in the memory and running on the processor, wherein the computer instructions, when executed by the processor, perform the method described in the first aspect.

[0036] Fourthly, the present invention provides a computer-readable storage medium for storing computer instructions, which, when executed by a processor, perform the method described in the first aspect.

[0037] Compared with the prior art, the beneficial effects of the present invention are as follows:

[0038] This invention proposes a named entity recognition method, system, device, and storage medium based on reordering. It calculates F1 scores for candidate recognition results based on preset standard answers and sorts the candidate recognition results according to the F1 scores. A contrastive learning loss function is defined on the candidate recognition results, and the named entity recognition model is trained using both cross-entropy and contrastive learning loss functions. The cross-entropy loss function optimizes the conditional probability given the standard answer, allowing the named entity recognition model to retain its first-stage generative ability while learning to sort candidate recognition results according to F1 scores. This addresses the problem that the answer predicted with the highest probability in existing methods is not necessarily the expected answer, and solves the exposure bias problem in generative models, thus improving the named entity recognition performance.

[0039] Advantages of additional aspects of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. Attached Figure Description

[0040] The accompanying drawings, which form part of this invention, are used to provide a further understanding of the invention. The illustrative embodiments of the invention and their descriptions are used to explain the invention and do not constitute an improper limitation of the invention.

[0041] Figure 1 This is a schematic diagram of the reordering-based named entity recognition method provided in Embodiment 1 of the present invention. Detailed Implementation

[0042] The present invention will be further described below with reference to the accompanying drawings and embodiments.

[0043] It should be noted that the following detailed descriptions are exemplary and intended to provide further illustration of the invention. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains.

[0044] It should be noted that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the exemplary embodiments of the present invention. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. Furthermore, it should be understood that the terms “comprising” and “having”, and any variations thereof, are intended to cover non-exclusive inclusion, for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0045] Where there is no conflict, the embodiments and features in the embodiments of the present invention can be combined with each other.

[0046] Example 1

[0047] To address the exposure bias problem in current generative named entity recognition methods, this embodiment provides a reordering-based named entity recognition method to improve the recognition performance; for example... Figure 1 As shown, it specifically includes:

[0048] Candidate recognition results are obtained by using a pre-built named entity recognition model on the text training set;

[0049] Calculate the F1 score for each candidate recognition result based on the preset standard answer, and then sort the candidate recognition results according to the F1 score.

[0050] A contrastive learning loss function is defined for the sorted candidate recognition results, and the pre-built named entity recognition model is trained accordingly.

[0051] The trained named entity recognition model is used to identify the target entity words in the text to be processed.

[0052] The three types of named entity recognition tasks—non-nested named entity recognition, nested named entity recognition, and non-contiguous named entity recognition—can all be formalized as follows: Given a text X = [x1, x2, ..., xn] with n words... n The target entity sequence is represented as Y = [s] 11 ,e 11 ,…,s 1j ,e 1j ,t1,…,s i1 ,…,s ik ,e ik ,t i ], where s and e represent the start and end indices of a fragment. Since an entity may contain one (for non-nested and nested tasks) or more (for non-contiguous tasks) fragments, each entity is represented as [s i1 ,e i1 ,…,s ij ,e ij ,t i ], where t i This indicates the entity type label index.

[0053] Based on the formal definition above, if the named entity recognition task is modeled as a sequence-to-sequence generation task, then the sequence-to-sequence generative objective function is:

[0054]

[0055] Where m is the length of the target entity sequence, and P(Y|X) is the probability of the generated sentence.

[0056] Named entity recognition models consist of an encoder and a decoder. The encoder encodes the input text X to obtain text word vectors H. e This embodiment uses the encoder of the BART pre-trained model:

[0057] H e =Encoder(X)

[0058] in, d is the dimension of the hidden layer.

[0059] The decoder is used to generate the target entity sequence in an autoregressive manner, generating the t-th entity word y in the target entity sequence Y at step t. t probability distribution P t =P(y t |X,Y <t The process of obtaining this probability distribution includes:

[0060] (1) Map text X to Embedding word vector E e :

[0061] E e =Embedding(X)

[0062] Embedding() is a shared parameter between the Encoder and Decoder, used to map text X into a vector.

[0063] (2)H e For text word vectors that have been encoded by an encoder and incorporated with contextual information, the text word vector H is... e Word vectors in the label space are obtained through multilayer perceptron (MLP) mapping.

[0064]

[0065] (3) Through label space word vectors And Embedding word vector E e Weighted summation yields entity word vectors

[0066]

[0067] in, As weight.

[0068] (4) Map the entity type label G to the Embedding label vector.

[0069] G d =Embedding(G)

[0070] (5) Use a decoder to process the text word vector H e The latent vectors of entity words are obtained after decoding.

[0071]

[0072] (6) The final probability of the t-th entity word is:

[0073] in, It is the latent vector of the t-th entity word; and Multiplying them gives the probability that the t-th entity word in the target entity sequence is any of the indices, G. d and Multiplying these probabilities yields the probability of the entity type label. Concatenating these two probabilities gives the final probability of the t-th entity word and its entity type.

[0074] In this embodiment, the cross-entropy loss function is used on the training set. After training, a named entity recognition model is obtained, where D (i) It is the i-th sentence in the training set, S *(i) It is the standard answer corresponding to the i-th sentence;

[0075] Use the named entity recognition model for each training sample Several candidate recognition results are generated. The system calculates an F1 score for each candidate recognition result based on the standard answer, and then sorts the candidate recognition results from highest to lowest based on the F1 score.

[0076] The cross-entropy loss function optimizes the conditional probability given a standard answer S*, as shown in the following formula:

[0077]

[0078] Where θ represents the parameters included in the named entity recognition model, and P θ Let be the probability.

[0079] For a single sample, the above optimization is equivalent to minimizing the negative log-likelihood function, i.e., the cross-entropy loss function:

[0080]

[0081] in, S* represents a partial sequence of standard answers, P is the probability, l is the length of the standard answer sequence S*, v is the entity word in the sentence, θ is the parameter included in the named entity recognition model, and D is the sentence in the training set.

[0082] A contrastive learning loss function is defined on the candidate recognition results. The name entity recognition model is then trained on multiple tasks using the cross-entropy loss function and the contrastive learning loss function. This allows the name entity recognition model to retain the generation capability of the first stage and learn to sort the candidate recognition results according to the F1 score.

[0083] For a sample and its several candidate identification results Define the contrastive learning loss function as follows:

[0084]

[0085] For any two candidate recognition results and The F1 score is less than F1 score, λ ij It is a linear function of the difference between i and j:

[0086] λ ij =(ji)*λ

[0087] Where λ is a constant, and in this embodiment it is taken as 0.001.

[0088] f() is the conditional probability output by the named entity recognition model, which is optimized by the cross-entropy loss function;

[0089] In order to explore the impact of the problems described in the background art on the named entity recognition task, this embodiment conducts exploratory experiments on eight mainstream named entity recognition datasets, namely CoNLL2003, OntoNotes4, Genia, ACE04, ACE05, CADEC, ShARe13, and ShARe14, for flat named entity recognition tasks, nested named entity recognition tasks, and discontinuous named entity recognition tasks. This experiment can also be regarded as measuring the performance limit of the beam search algorithm used in the prediction stage.

[0090] Specifically, a trained named entity recognition model was obtained using existing methods, and several candidate answers were generated. Then, the F1 score of each candidate answer was calculated under the given standard answer, and the candidate answer with the highest F1 score was selected as the final answer. The results are shown in Tables 1-3, including the performance of existing methods, the performance upper limit of the beam search algorithm when generating 5 candidate answers, and the performance upper limit of the beam search algorithm when generating 10 candidate answers. This result shows that the "exposure bias problem" has a certain impact on the performance of generative named entity recognition tasks, and the performance upper limit of beam search is much higher than that obtained using existing methods.

[0091] Table 1 Results of the flat NER task (no nesting)

[0092]

[0093] Table 2 Results of the Nested Named Entity Recognition (NER) Task

[0094]

[0095] Table 3 Results of the Discontinuous Named Entity Recognition (NER) task

[0096]

[0097] The candidate reordering method provided in this embodiment improves the F1 score of the named entity recognition model. The effectiveness was verified on three named entity recognition tasks: non-nested, nested, and non-contiguous. The experimental setup was as follows: a BART-large pre-trained model was used for 30 training rounds, with a learning rate of 2e-5, a batch size of 16, a beam size of 10, 10 candidate sequences, a contrastive learning loss weight of 1, and a contrastive learning loss of 0.01. The results are shown in Table 4. Compared with the baseline model (first row) and the theoretical upper limit (second row), although the method proposed in this embodiment still has some gap with the theoretical upper limit, it achieved a consistent improvement on all datasets, verifying the effectiveness of the method in this embodiment.

[0098] Table 4 shows the F1 scores on eight mainstream named entity recognition datasets.

[0099]

[0100] The reordering-based named entity recognition method proposed in this embodiment calculates F1 scores for candidate recognition results based on preset standard answers, and sorts the candidate recognition results according to the F1 scores. A contrastive learning loss function is defined on the candidate recognition results, and the named entity recognition model is trained on multiple tasks using cross-entropy loss and contrastive learning loss functions. The cross-entropy loss function optimizes the conditional probability given the standard answer, allowing the named entity recognition model to retain its generation capability in the first stage while also learning to sort candidate recognition results according to F1 scores. This solves the problem that the answer predicted with the highest probability in existing methods is not necessarily the expected answer, addresses the exposure bias problem in generative models, and improves the performance of named entity recognition.

[0101] Example 2

[0102] This embodiment provides a reordering-based named entity recognition system, including:

[0103] The initial recognition model is configured to use a pre-built named entity recognition model to obtain candidate recognition results on the text training set;

[0104] The ranking model is configured to calculate the F1 score of the candidate recognition results based on the preset standard answer, and rank the candidate recognition results according to the F1 score;

[0105] The training model is configured to define a contrastive learning loss function on the ranked candidate recognition results, thereby training a pre-built named entity recognition model.

[0106] The recognition model is configured to use the trained named entity recognition model on the text to be processed to obtain the classification and recognition results of the target entity words.

[0107] It should be noted that the above modules correspond to the steps described in Embodiment 1, and the examples and application scenarios implemented by the above modules and the corresponding steps are the same, but are not limited to the content disclosed in Embodiment 1. It should also be noted that the above modules, as part of the system, can be executed in a computer system such as a set of computer-executable instructions.

[0108] In further embodiments, the following is also provided:

[0109] An electronic device includes a memory and a processor, as well as computer instructions stored in the memory and running on the processor, wherein the computer instructions, when executed by the processor, perform the method described in Embodiment 1. For brevity, further details are omitted here.

[0110] It should be understood that in this embodiment, the processor can be a central processing unit (CPU), or it can be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor, etc.

[0111] Memory may include read-only memory and random access memory, and provides instructions and data to the processor. A portion of memory may also include non-volatile random access memory. For example, memory may also store information about the device type.

[0112] A computer-readable storage medium for storing computer instructions, which, when executed by a processor, perform the method described in Embodiment 1.

[0113] The method in Example 1 can be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules within the processor. The software modules can reside in readily available storage media in the field, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, or registers. This storage medium is located in memory, and the processor reads information from the memory and, in conjunction with its hardware, completes the steps of the above method. To avoid repetition, a detailed description is not provided here.

[0114] Those skilled in the art will recognize that the units, i.e., algorithm steps, of the various examples described in connection with this embodiment can be implemented in electronic hardware or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0115] While the specific embodiments of the present invention have been described above in conjunction with the accompanying drawings, this is not intended to limit the scope of protection of the present invention. Those skilled in the art should understand that various modifications or variations that can be made by those skilled in the art without creative effort based on the technical solutions of the present invention are still within the scope of protection of the present invention.

Claims

1. A named entity recognition method based on reordering, characterized in that, include: Candidate recognition results are obtained by using a pre-built named entity recognition model on the text training set; Calculate the F1 score for each candidate recognition result based on the preset standard answer, and then sort the candidate recognition results according to the F1 score. A contrastive learning loss function is defined for the sorted candidate recognition results, and the pre-built named entity recognition model is trained accordingly. The trained named entity recognition model is used to process the text to obtain the classification and recognition results of the target entity words; The pre-built named entity recognition model includes an encoder and a decoder. The process of obtaining candidate recognition results using the pre-built named entity recognition model includes: After encoding the text using an encoder, text word vectors are obtained. Then, the text word vectors are mapped using a multilayer perceptron to obtain label space word vectors. After mapping the text to Embedding word vectors, the entity word vectors are obtained by weighted summing of the Embedding word vectors and the tag space word vectors. The latent vectors of entity words are obtained by decoding the text word vectors using a decoder. Map entity type tags to embedding tag vectors; Based on the entity word vectors and latent vectors, the first [word] in the target entity sequence is obtained. t The probability of each entity word at its index is obtained by concatenating the embedding tag vector and the latent vector to determine the probability of its corresponding entity type tag. t The final probability of each entity word and its corresponding entity type; The contrastive learning loss function is: in, To compare the learning loss function, and For the first i The and the first j One candidate identification result, The F1 score is less than F1 score, It is about i and j A linear function of the difference It is conditional probability.

2. The named entity recognition method based on reordering as described in claim 1, characterized in that, linear functions for: ;in It is a constant.

3. The named entity recognition method based on reordering as described in claim 1, characterized in that, The named entity recognition model also employs the cross-entropy loss function on the training set. Training is conducted on the above, among which, It is the first in the training set i One sentence. It is the first i The standard answer to each sentence.

4. The named entity recognition method based on reordering as described in claim 3, characterized in that, The cross-entropy loss function optimizes the conditional probability given a standard answer. The optimized conditional probability is: in, This represents the parameters included in the named entity recognition model. Let be the probability.

5. The named entity recognition method based on reordering as described in claim 4, characterized in that, The cross-entropy loss function is: in, Let cross-entropy be the loss function. Let P be a sequence of partial standard answers. l For the standard answer sequence S Length, v For entity words in the sentence, The parameters included in the named entity recognition model. D These are sentences from the training set.

6. A named entity recognition system based on reordering, characterized in that, The method for implementing the reordering-based named entity recognition method according to any one of claims 1-5 includes: The initial recognition model is configured to use a pre-built named entity recognition model to obtain candidate recognition results on the text training set; The ranking model is configured to calculate the F1 score of the candidate recognition results based on the preset standard answer, and rank the candidate recognition results according to the F1 score; The training model is configured to define a contrastive learning loss function on the ranked candidate recognition results, thereby training a pre-built named entity recognition model. The recognition model is configured to use the trained named entity recognition model on the text to be processed to obtain the classification and recognition results of the target entity words.

7. An electronic device, characterized in that, It includes a memory and a processor, as well as computer instructions stored in the memory and running on the processor, which, when executed by the processor, perform the method according to any one of claims 1-5.

8. A computer-readable storage medium, characterized in that, Used to store computer instructions, which, when executed by a processor, perform the method described in any one of claims 1-5.

Citation Information

Patent Citations

  • Word vector training method, system and device based on multi-task learning and medium

    CN109992773A

  • Multi-label text classification method and system based on dynamic weight contrast learning

    CN114580433A