A method for named entity recognition in medical text
By combining the neural network with the pre-trained language model and the conditional random field module, using L1 regression and reverse modification of the transfer matrix, the problem of insufficient accuracy and inference speed of the medical text named entity recognition model is solved, and higher accuracy is achieved. sex and real-time.
Patent Information
- Application Number
- CN202111559318.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-20
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2041-12-20
AI Technical Summary
Existing medical text named entity recognition models have shortcomings in accuracy and inference speed. The traditional conditional random field method leads to sparse label space, the loss function does not conform to the natural probability distribution, and the pre-trained language model suffers from pattern forgetting in the named entity recognition task. There is a mismatch problem with the learning rate, and the Viterbi decoding efficiency is low.
A neural network is used to build a medical text named entity recognition model. By combining the pre-trained language model and the conditional random field module, L1 regression is used to balance parameter learning, and the conditional random field transfer matrix is reversely modified to avoid illegal labels and only rely on argmax decoding to reduce the cost. Spatial sparsity of conditional random field sequences.
It improves the accuracy and reasoning speed of medical text named entity recognition, avoids illegal labels, improves real-time performance under large data volumes, balances the parameter learning of pre-training and additional parts, and is close to the natural probability distribution.
Smart Images

Figure FDA0004847420080000011 
Figure FDA0004847420080000012 
Figure FDA0004847420080000014
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of text intelligent recognition, and in particular to a method for recognizing named entities in medical texts. Background Art
[0002] Named entity recognition of medical text refers to identifying the text parts that refer to specific concepts in medical texts such as medical clinical diagnosis and treatment guidelines, medical textbooks, clinical electronic medical records, medical research literature, etc., such as disease diagnosis, symptoms and signs, abnormal structures, pharmaceutical consumables, etc., and can be applied in downstream application fields such as medical knowledge graph construction, clinical medical record quality control, medical insurance medical record verification, clinical auxiliary diagnosis, etc. with subsequent technologies. Therefore, the accuracy of the model of named entity recognition of medical text directly determines the accuracy of downstream applications in these medical fields.
[0003] At present, most of the medical text named entity recognition models with relatively high accuracy are achieved through the combination of pre-trained language models and conditional random field methods. However, a large number of literature studies have shown that the traditional conditional random field method cannot significantly improve the accuracy of named entity recognition. The reason is that the conditional random field method of normalizing the sequence level of the label sequence greatly improves the sparsity of the label space. In addition, in the process of continuous training and learning of samples whose reasoning is correct, the use of one-hot labels to continuously reduce the result of the loss function does not conform to the natural probability distribution of the label, which is not conducive to the training process of the model, resulting in a decrease in the final training accuracy of the named entity recognition model using conditional random fields. On the other hand, when the pre-trained language model is fine-tuned on the training dataset for named entity recognition, the pre-trained part of the model contains a large amount of learned pattern knowledge, while the additional part for the named entity recognition task does not have any knowledge. Since the learning rate of the model training process is uniform, a higher learning rate will cause pattern forgetting in the pre-trained part of the model, while a lower learning rate will cause the additional part to fall into a local minimum. Moreover, since the additional part has not been pre-trained, its most suitable learning rate is naturally different from that of the pre-trained part, which will inevitably lead to a decrease in accuracy.
[0004] In addition, in terms of reasoning efficiency, traditional named entity recognition methods require the use of Viterbi decoding at the end to avoid illegal labeling results. However, the operating efficiency of the Viterbi algorithm is not high, which will slow down the processing speed in scenarios where large amounts of text are processed. Summary of the invention
[0005] In order to overcome the deficiencies of the above technologies, the present invention provides a method for improving the accuracy and reasoning speed of named entity recognition in medical texts.
[0006] The technical solution adopted by the present invention to overcome the technical problems is:
[0007] A method for named entity recognition in medical texts comprises the following steps:
[0008] a) Establish a medical text named entity recognition model consisting of a neural network;
[0009] b) Pre-training the language model, representing the parameters of the pre-trained language model as a set P1′;
[0010] c) The trainable parameters of the medical text named entity recognition model are represented as a set {P1, P2}, where the P1 subset is the trainable parameters in the medical text named entity recognition model corresponding to the pre-trained language model, and the P2 subset is all the trainable parameters in the medical text named entity recognition model except P1; d) A conditional random field module is defined, the transfer matrix in the conditional random field is represented as K, and the number of the transfer from the Y label of the j-th entity to the Z label of the n-th entity in the transfer matrix K in the conditional random field is represented as The tag structure is a BIO tag. The value of Y is the B tag or I tag in the BIO tag. The value of Z is the B tag or I tag in the BIO tag.
[0011] e) Randomly initialize the P1 subset and the P2 subset, and convert the transfer matrix K in the conditional random field to the I label in the BIO label that satisfies j≠n and Z The number of is assigned to ζ, and the other numbers are assigned to 0;
[0012] f) Input the medical text into the medical text named entity recognition model, obtain the model output represented by W′, represent the label sequence corresponding to the medical text as L, input W′ and L into the conditional random field module and output the loss value;
[0013] g) Perform argmax calculation on the matrix W′ along the columns, convert the argmax calculation result into a BIO label sequence, and express the obtained BIO label sequence as
[0014] h) Through the formula The final loss function is calculated and used to adjust the trainable parameters in the medical text named entity recognition model until early-stop, and the adjusted medical text named entity recognition model is obtained, where λ is a variable and γ is a fixed parameter. is the average of the absolute values of the differences between the parameter set P1′ and all parameters in P1;
[0015] i) Input the medical text of the entity to be identified into the adjusted medical text named entity recognition model to obtain the output matrix W′ of the model, perform argmax calculation on the matrix W′ along the columns, convert the argmax calculation result into a BIO label sequence, and the obtained BIO label sequence is the final result of named entity recognition.
[0016] Furthermore, in step a), the neural network is an LSTM network, a GRU network, or a Transformer network.
[0017] Furthermore, in step b), the language model is pre-trained using BERT, ELMO, ALBERT or ROBERTA methods. Furthermore, in step d), j and n are positive integers.
[0018] Furthermore, in step e), the value of ζ is 5.
[0019] Furthermore, in step f), W′ is a matrix of m rows and x columns, m is the number of words in the medical text, and x is the number of BIO tags.
[0020] Further, in step h), when When it is not equal to L, λ is equal to a, a is a fixed parameter, and a takes the value of 1. When it is equal to L, λ is equal to b, b is a fixed parameter, b takes the value of 0.001, and γ takes the value of 0.1.
[0021] Furthermore, in step i), W′ is a matrix of m rows and x columns, m is the number of words in the medical text, and x is the number of BIO tags.
[0022] The beneficial effects of the present invention are: using the L1 regression method of the pre-trained language model in the loss function to learn, balancing the parameter learning of the pre-training part and the part added in cooperation with the named entity recognition, improving the model training effect while also improving the effect of named entity recognition. In the training process, the method of reversely modifying the transfer matrix in the conditional random field is innovatively adopted to form a penalty for illegal labels, so that the medical text named entity recognition model can passively master the method of avoiding illegal labels, so only argmax operation can be used for decoding during the decoding process, getting rid of the dependence on the Viterbi algorithm, improving the reasoning speed of medical named entity recognition, and improving the real-time performance of medical text named entity recognition scenarios under large data volumes. DETAILED DESCRIPTION
[0023] The present invention is further described below.
[0024] A method for named entity recognition in medical texts comprises the following steps:
[0025] a) Establish a medical text named entity recognition model composed of a neural network. The medical text named entity recognition model can input medical text data and obtain corresponding output.
[0026] b) Pre-training the language model, representing the parameters of the pre-trained language model as a set P1′.
[0027] c) The trainable parameters of the medical text named entity recognition model are represented as a set {P1, P2}, where the P1 subset is the trainable parameters in the medical text named entity recognition model corresponding to the pre-trained language model, and the P2 subset is all the trainable parameters in the medical text named entity recognition model except P1. d) Define the conditional random field module, represent the transfer matrix in the conditional random field as K, and represent the number of the transfer from the Y label of the j-th entity to the Z label of the n-th entity in the transfer matrix K of the conditional random field as The tag structure is a BIO tag. The value of Y is the B tag or I tag in the BIO tag, and the value of Z is the B tag or I tag in the BIO tag.
[0028] e) Randomly initialize the P1 subset and the P2 subset, and convert the transfer matrix K in the conditional random field to the I label in the BIO label that satisfies j≠n and Z The number of is assigned to ζ, and the other numbers are assigned to 0. During the training process, the value in the transfer matrix K in the conditional random field does not change.
[0029] f) Input the medical text into the medical text named entity recognition model, and obtain the model output represented as W′. The label sequence corresponding to the medical text is represented as L. W′ and L are input into the conditional random field module and then the loss value is obtained.
[0030] g) Perform argmax calculation on the matrix W′ along the columns, convert the argmax calculation result into a BIO label sequence, and express the obtained BIO label sequence as
[0031] h) Through the formula The final loss function is calculated and used to adjust the trainable parameters in the medical text named entity recognition model until early-stop, and the adjusted medical text named entity recognition model is obtained, where λ is a variable and γ is a fixed parameter. is the average of the absolute values of the differences between the parameter set P1′ and all the parameters in P1.
[0032] i) Input the medical text of the entity to be identified into the adjusted medical text named entity recognition model to obtain the output matrix W′ of the model, perform argmax calculation on the matrix W′ along the columns, convert the argmax calculation result into a BIO label sequence, and the obtained BIO label sequence is the final result of named entity recognition.
[0033] This method uses a larger loss weight only for samples with poor inference results, and performs high-intensity one-hot label learning. For models with accurate inference, a very low loss weight is used for retention learning. While balancing the learning process of difficult and easy samples, it indirectly reduces the sparsity constraints of the conditional random field sequence space, especially reduces the degree of constraints on learned samples, making the constraint state closer to the natural probability distribution state compared to traditional methods, and ultimately improves the effect of named entity recognition in medical texts. At the same time, when integrating the pre-trained language model, the parameters of the pre-trained language model are not directly loaded for initialization. Instead, the pre-trained language model is learned by L1 regression in the loss function, which balances the parameter learning of the pre-training part and the part added for named entity recognition, improving the model training effect while also improving the named entity recognition effect. During the training process, an innovative method of reversely modifying the transfer matrix in the conditional random field was adopted to form a penalty for illegal labels, so that the medical text named entity recognition model can passively master the method of avoiding illegal labels. Therefore, only argmax operation is used for decoding during the decoding process, which gets rid of the dependence on the Viterbi algorithm, improves the inference speed of medical named entity recognition, and improves the real-time performance of medical text named entity recognition scenarios under large data volumes.
[0034] Preferably, the neural network in step a) is an LSTM network or a GRU network or a Transformer network, and is mapped in series at the output end to a named entity recognition tag MLP component.
[0035] Preferably, in step b), the language model is pre-trained using BERT, ELMO, ALBERT or ROBERTA methods. Preferably, in step d), j and n are positive integers.
[0036] Preferably, in step e), the value of ζ is 5.
[0037] Furthermore, in step f), W′ is a matrix of m rows and x columns, m is the number of words in the medical text, and x is the number of BIO tags.
[0038] Preferably, in step h) When it is not equal to L, λ is equal to a, a is a fixed parameter, and a takes the value of 1. When it is equal to L, λ is equal to b, b is a fixed parameter, b takes the value of 0.001, and γ takes the value of 0.1.
[0039] Furthermore, in step i), W′ is a matrix of m rows and x columns, m is the number of words in the medical text, and x is the number of BIO tags.
[0040] Finally, it should be noted that the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art can still modify the technical solutions described in the aforementioned embodiments or replace some of the technical features therein by equivalents. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for named entity recognition in medical texts, It is characterized in that The steps include: a) Establish a medical text named entity recognition model consisting of a neural network; b) Pre-trained language model, the parameters of the pre-trained language model are represented as a set P 1 ′; c) The trainable parameters of the medical text named entity recognition model are represented as a set {P 1 ,P 2 }, in the set P 1 The subset is the part of the pre-trained language model that corresponds to the trainable parameters in the medical text named entity recognition model, P 2 The subset is the medical text named entity recognition model except P 1 All other trainable parameters except ; d) Define a conditional random field module, denote the transfer matrix in the conditional random field as K, and denote the number of the transfer from the Y label of the j-th entity to the Z label of the n-th entity in the transfer matrix K in the conditional random field as The tag structure is a BIO tag. The value of Y is the B tag or I tag in the BIO tag. The value of Z is the B tag or I tag in the BIO tag. e) Randomly initialize P 1 Subsets and P 2 Subset, the transfer matrix K in the conditional random field satisfies j≠n and the value of Z is the I label in the BIO label The number of is assigned to ζ, and the other numbers are assigned to 0; f) Input the medical text into the medical text named entity recognition model, obtain the model output represented by W′, represent the label sequence corresponding to the medical text as L, input W′ and L into the conditional random field module and output the loss value; g) Perform argmax calculation on the matrix W′ along the columns, convert the argmax calculation result into a BIO label sequence, and express the obtained BIO label sequence as h) Through the formula The final loss function is calculated and used to adjust the trainable parameters in the medical text named entity recognition model until early-stop, and the adjusted medical text named entity recognition model is obtained, where λ is a variable and γ is a fixed parameter. is the parameter set P 1 ′ and P 1 The average of the absolute values of the differences of all parameters in ; i) Input the medical text of the entity to be identified into the adjusted medical text named entity recognition model to obtain the output matrix W′ of the model, perform argmax calculation on the matrix W′ along the columns, convert the argmax calculation result into a BIO label sequence, and the obtained BIO label sequence is the final result of named entity recognition.
2. The method for named entity recognition in medical text according to claim 1, Features: In step a), the neural network is an LSTM network, a GRU network, or a Transformer network.
3. The method for named entity recognition in medical text according to claim 1, Features: In step b), the language model is pre-trained using the BERT, ELMO, ALBERT or ROBERTA method.
4. The method for named entity recognition in medical text according to claim 1, Features: In step d), j and n are positive integers.
5. The method for named entity recognition in medical text according to claim 1, Features: In step e), the value of ζ is 5.
6. The method for named entity recognition in medical text according to claim 1, Features: In step f), W′ is a matrix of m rows and x columns, m is the number of words in the medical text, and x is the number of BIO tags.
7. The method for named entity recognition in medical text according to claim 1, Features: In step h) when When it is not equal to L, λ is equal to a, a is a fixed parameter, and a takes the value of 1. When it is equal to L, λ is equal to b, b is a fixed parameter, b takes the value of 0.001, and γ takes the value of 0.
1.
8. The method for named entity recognition in medical text according to claim 1, Features: In step i), W′ is a matrix of m rows and x columns, m is the number of words in the medical text, and x is the number of BIO tags.
