Entity relationship joint extraction method, network, device and computer-readable storage medium based on Chinese electronic medical records
By applying the deep fusion algorithm of Memory-LSTM, self-attention and Co-Attention mechanisms in Chinese electronic medical records, the problem of low entity relationship extraction performance in the Chinese medical field is solved, and more efficient information interaction and long-distance feature learning are achieved. Improved the accuracy of entity relationship extraction.
Patent Information
- Application Number
- CN202210749641.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-29
- Publication Date
- 2024-10-25
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The performance of entity relationship extraction in the Chinese medical field is low, mainly due to the sparse distribution and large span of entities in medical texts. Traditional models cannot learn long-distance dependent information, and information interaction is insufficient, resulting in poor entity recognition and relationship extraction effects.
A deep fusion algorithm of entity relationship information based on Memory-LSTM coding algorithm, self-attention mechanism and Co-Attention mechanism is used to alleviate long-distance information forgetting through Memory-LSTM network, self-attention network reduces redundant information interference, and Co-Attention network Realize deep information fusion and combine multi-layer convolutional networks for relationship extraction.
It improves the accuracy of entity relationship extraction, effectively captures long-distance contextual semantic information, enhances the information interaction between entity recognition and relationship extraction, and improves model performance.
Smart Images

Figure CN115017910B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of natural language processing and relates to a method for joint extraction of entity relationships from Chinese electronic medical record (EMR) text, specifically referring to a method based on a Memory-LSTM encoding algorithm, a deep fusion algorithm of entity relationship information based on a collaborative attention (Co-Attention) mechanism, entity recognition based on a self-attention mechanism and a CRF algorithm, and relationship extraction based on a multi-layer CNN. Background Art
[0002] Entity Relation Extraction (ERE) is one of the core tasks in Information Extraction (IE), which includes two subtasks: Named Entity Recognition (NER) and Relation Extraction (RE). It aims to automatically extract predefined types of named entities from unstructured text and classify the types of relationships between each entity pair. In the medical field, electronic medical records record a wealth of clinical medical information, such as important medical entities such as diseases, examinations, symptoms, treatments, and parts, as well as semantic relationships between various types of medical entities. Entity Relation Extraction can extract valuable medical information from massive electronic medical records, and can provide important technical support for multiple downstream tasks such as medical question-answering systems, high-quality medical knowledge graph construction, and clinical decision support.
[0003] The entity relationship extraction task was first proposed by the Message Understanding Conference (MUC) in 1996. Subsequently, authoritative evaluation conferences such as ACE, TAC, and SemEval provided high-quality evaluation corpora and recognized evaluation standards for the task, which effectively promoted the research and development of entity relationship extraction in general fields. In 2010, the National Center for Integrated Biology and the Bedside (I2B2) of the United States released a medical entity relationship extraction task based on English electronic medical records, which brought medical entity relationship extraction into the research field. In terms of Chinese medical entity relationship extraction, in 2020, the Sixth China Health Information Processing Conference (CHIP2020) released a medical text information extraction task, and then launched the Chinese medical information processing evaluation benchmark CBLUE (Chinese Biomedical Language Understanding Evaluation), which is currently the first public benchmark in the field of medical information processing in China. It aims to build a unified consensus medical information system performance evaluation platform to promote the rapid development of medical informatics.
[0004] Entity relationship extraction is mainly divided into pipeline methods and joint extraction methods. The traditional entity relationship extraction method is based on the pipeline form, which regards entity recognition and relationship extraction as two independent subtasks. For a piece of text, all entities are first identified, and then the relationship category of each entity pair is determined. However, the pipeline method has the problem of error propagation, that is, the errors accumulated in the previous stage will propagate to the next stage. For example, the erroneous entities obtained in the entity recognition stage will seriously affect the training and effect of the relationship model in the relationship extraction stage. At the same time, the pipeline method also ignores the potential correlation information between the two tasks of entity recognition and relationship extraction, so the traditional pipeline method cannot achieve satisfactory results.
[0005] In order to solve the problems of pipeline methods, researchers proposed to design a joint model to perform entity recognition and relation extraction simultaneously. The joint extraction method can effectively alleviate the problem of error propagation, and can use the correlation between the two tasks to make the information of the two tasks interact, thereby mining deeper semantic information. Miwa and Bansal (End-to-end relation extraction using lstms on sequences and tree structures [C]. Association for Computational Linguistics, 2016) first proposed an end-to-end model for joint extraction of entity relations, and made the relation extraction share the features of the entity recognition task, proving that the feature information of entity recognition helps to improve the performance of relation extraction. Zheng et al. (Joint extraction of entities and relations based on a novel tagging scheme [C]. Association for Computational Linguistics, 2017) unified entity relations into a sequence tagging problem, so that the two tasks share a unified network model for learning, thereby realizing the interaction of implicit information. However, the above early joint extraction models cannot effectively extract more complex nested entities and overlapping relations. To solve this problem, Bekoulis et al. (Joint entity recognition and relation extraction as a multi-head selection problem [J]. Expert Systems with Applications, 2018) proposed a table filling decoding method, which can represent complex entities and overlapping relations using the table filling framework. Wei et al. (A novel cascade binary tagging framework for relational triple extraction [C]. Association for Computational Linguistics, 2020) converted triple extraction into extracting subject words first, then object words and relation types, so that the model can effectively extract overlapping relations. This type of model generally uses a shared parameter approach to model the information interaction between the two tasks, that is, entity recognition and relation extraction share the same word embedding. However, this information interaction method is not sufficient and fails to deeply combine the information of the two tasks of entity recognition and relation extraction.This is specifically manifested in two aspects: first, the two tasks only share the same input features, and then the two models learn the task features independently; second, the information interaction is one-way, and relation extraction requires the use of recognized entity features to classify relations, but entity recognition does not effectively utilize the features of relation extraction. Wang et al. (Two are better than one: Joint entity and relation extraction with table-sequence encoders [C]. Empirical Methods in Natural Language Processing, 2020) adopted a multi-layer Transformer structure, interacting with entity recognition and relation extraction features at each layer, thus strengthening information interaction. Yan et al. (Apartition filter network for joint entity and relation extraction [C]. Empirical Methods in Natural Language Processing, 2021) split and recombined entity features and relation features, so that each task can integrate the information of another task, achieving two-way interaction, and proving that relation extraction promotes entity recognition.
[0006] From the above analysis, we can see that the research on entity relationship extraction has achieved relatively rich results. However, in the field of Chinese medicine, the performance of joint extraction is still relatively low (the highest F-values of entity recognition and relationship extraction on the CBLUE2.0 benchmark are only 70.1% and 62.8% respectively). The main reasons are: first, the entity distribution of medical texts (such as electronic medical records) is sparse and the span is large, and traditional recursive neural networks cannot learn long-distance dependency information. Second, medical entities are relatively complex and there is a lot of redundant information in medical texts, which increases the difficulty of model distinction. Finally, the current joint model still has the problem of insufficient information interaction. How to build a deeper joint method and strengthen information interaction between tasks is still a research topic that many researchers are very concerned about. Summary of the invention
[0007] The present invention provides a method, network, device and computer-readable storage medium for joint extraction of entity relationships based on Chinese electronic medical records, which realizes the extraction of medical entities from a large number of unstructured electronic medical records and the classification of entity relationships, and solves the problems that existing research cannot fully capture long-distance contextual semantic information and the insufficient information interaction between entity recognition and relationship extraction.
[0008] Based on the above purpose, the present invention proposes the following technical solutions:
[0009] A joint extraction method of entity relations based on Chinese electronic medical records includes the following steps:
[0010] By encoding each position of the sentence in the Chinese electronic medical record, the output features of each position of the sentence are obtained And the output features of each position Splicing, obtaining sentence feature representation;
[0011] By concatenating the forward temporal features and reverse temporal features represented by the sentence features, we can obtain the bidirectional temporal features H of the sentence. m ;
[0012] The bidirectional timing characteristic H m Through the self-attention network, the entity task feature H is obtained ner , entity task feature H ner The entity tag sequence is obtained through the conditional random field;
[0013] The entity task feature H of the sentence ner With bidirectional timing characteristics H m Through the Co-Attention network, we can obtain the deep fusion feature H merge , and the deep fusion feature H merge Through multi-layer convolution, we can obtain the relationship extraction feature H re ;
[0014] By using the entity tag sequence, pairing the obtained entities in pairs to obtain a plurality of entity pairs;
[0015] Extract feature H based on the relationship re The features of the corresponding positions of each entity are weighted and averaged to obtain the entity feature h e ;
[0016] The features h of the entities corresponding to the two entities of the entity pair e The sentence representation h of the pre-trained model cls The concatenation representation is obtained by concatenation, and the entity relationship type obtained according to the concatenation representation is output through a classifier.
[0017] In one aspect, the present invention also relates to an entity relationship joint extraction network based on Chinese electronic medical records, comprising:
[0018] LSTM improved network based on Memory mechanism,
[0019] Self-attention based entity extraction network,
[0020] Entity relationship deep information fusion network based on Co-Attention mechanism, and
[0021] Relation extraction network based on multi-layer convolution;
[0022] The improved LSTM network based on the Memory mechanism is composed of two LSTM units, two storage units, and two gating units, which are represented as The forward and reverse arrows indicate the direction of data input; input data X = {x0, x1, ..., x L-1 The dimension of} is L×H, where L is the length of the input data and H is the dimension of the feature; the input size of the LSTM unit is 1×H, for each character feature x of the input data t ∈X, and input it into the forward LSTM unit in turn to get The output size is 1×H / 2; the storage unit is a fully connected layer, whose input size is 1×H / 2, and the features encoded by the forward LSTM unit are Acquiring memory features through forward storage units The output size is 1×H / 2; the gate unit is a linear layer connected to the sigmoid function, its input size is 1×H / 2, and the output size is 1×1, which is used to memorize the feature Obtain gate control weights through gate control units Then the features encoded by the LSTM unit and memory characteristics By weight Linear combination gives Its output size is 1×H / 2; all characters are passed through the forward LSTM unit in sequence and concatenated to obtain The output size is L×H / 2. All characters are reversed and passed through the reverse LSTM unit in turn to obtain Concatenate it with the forward feature to finally get the bidirectional Memory-LSTM feature Its output size is L×H;
[0023] The self-attention-based entity extraction network consists of a self-attention network and a CRF decoding module; the input size of the self-attention network is L×H, and the output size is L×H; the entity task feature H is obtained through the self-attention network ner Entity task characteristics H ner Decoding is performed through a CRF module, the input size of the CRF module is L×H, and the output is the label sequence L of the path with the highest score pred ;
[0024] The entity relationship deep information fusion network based on the Co-Attention mechanism consists of two attention feature learners. The learner is a linear layer with an input size of L×H and an output size of L×1. nerAnd the feature H of Memory-LSTM m Through their respective feature learners, the output is Concatenate two attention features Get the attention weight attn through the softmax activation function m ,attn ner ∈R L×1 Finally, the attention weights are multiplied with the original features to obtain the fused features H re , taking this feature as the input of the relation extraction module based on multi-layer convolution;
[0025] The multi-layer convolution-based relationship extraction model is composed of two one-dimensional convolution units stacked together, namely Conv1 and Conv2; the input size of Conv1 is L×H, the output size is L×H / 2, and the convolution kernel size is 3; the input size of Conv2 is L×H / 2, the output size is L×H, and the convolution kernel size is 3; the H features obtained through the Co-Attention network are merge After the convolution operation, the output H is obtained re , whose output size is L×H; then the features of the corresponding position of the entity are weighted to obtain the entity feature h e , whose feature size is 1×H; the entity features are spliced in pairs and integrated into the global features to obtain the entity pair features Its feature size is 1×3H; the feature is classified through a linear layer and the prediction result y is output ored ∈R 1×C .
[0026] In one aspect, the present invention also relates to an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps in the described method when executing the computer program.
[0027] In one aspect, the present invention also relates to a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps in the method described above are implemented.
[0028] Beneficial effects: The present invention improves the accuracy of entity relationship extraction. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1 :Framework diagram of the entity relationship joint extraction model based on Memory-LSTM. DETAILED DESCRIPTION
[0030] The present invention first constructs a training set to train the model, then tests the prediction effect of the model, and compares it with advanced pipeline models and joint models to verify the effectiveness of the model proposed in the present invention.
[0031] 1. Dataset preprocessing
[0032] First, the electronic medical record data is manually annotated according to the entity and relationship types defined in the present invention. The constructed data set contains a total of 12,219 samples. The data set is randomly divided into a training set and a test set. The total number of samples in the training set is 9,773, and the total number of samples in the test set is 2,446, with a ratio of 80%:20%.
[0033] 2. Network model structure
[0034] like Figure 1 As shown, the network model constructed in the present invention includes an improved LSTM network based on a memory mechanism, an entity extraction network based on self-attention, an entity relationship deep information fusion network based on a Co-Attention mechanism, and a relationship extraction network based on multi-layer convolution.
[0035] In the present invention, the LSTM improved network based on the Memory mechanism is composed of two LSTM units, two storage units, and two gating units, which are respectively represented as The forward and reverse arrows indicate the direction of data input. Input data X = {x0, x1, ..., x L-1 The dimension of} is L×H, where L is the length of the input data and H is the dimension of the feature. The input size of the LSTM unit is 1×H. For each character feature x of the input data t ∈X, and input it into the forward LSTM unit in turn to get The output size is 1×H / 2. The storage unit is a fully connected layer with an input size of 1×H / 2. The features encoded by the forward LSTM unit are Acquiring memory features through forward storage units The output size is 1×H / 2. The gated unit is a linear layer connected to a sigmoid function, with an input size of 1×H / 2 and an output size of 1×1. Obtain gate control weights through gate control units Then the features encoded by the LSTM unit and memory characteristics By weight Linear combination gives The output size is 1×H / 2. So the output of each character is It contains both the LSTM unit output and the memory feature, which alleviates the problem of long-distance information forgetting, and the ratio of the two features can be dynamically adjusted through the gating mechanism. All characters are passed through the forward LSTM unit in turn and concatenated to obtain The output size is L×H / 2. Similarly, all characters are reversed and passed through the reverse LSTM unit in turn to obtain Concatenate it with the forward feature to finally get the bidirectional Memory-LSTM feature Its output size is L×H.
[0036] In the present invention, the self-attention-based entity extraction network consists of a self-attention network and a CRF decoding module. The input size of the self-attention network is L×H, and the output size is L×H. The self-attention network is used to learn the characteristics of the entity, and the attention mechanism is used to strengthen the weight of important features and reduce the interference of redundant information, so as to obtain the entity task feature H ner Entity Task Features H ner Decoding is performed through a CRF module, the input size of the CRF module is L×H, and the output is the label sequence L of the path with the highest score pred And the loss of entity recognition loss ner It uses the Viterbi algorithm to calculate the true path score s real And the total score of all paths s total , the loss of entity recognition is loss ner =s real -s total .
[0037] In the present invention, the entity relationship deep information fusion network based on the Co-Attention mechanism is composed of two attention feature learners, and the learner is a linear layer with an input size of L×H and an output size of L×1. ner And the feature H of Memory-LSTM m Through their respective feature learners, the output is Then concatenate the two attention features Get the attention weight attn through the softmax activation function m ,attn ner ∈R L×1 Finally, the attention weights are multiplied with the original features to obtain the fused features H re , and use this feature as the input of the relation extraction module.
[0038] In the present invention, the multi-layer convolution-based relationship extraction model is composed of two one-dimensional convolution units stacked together, namely Conv1 and Conv2. The input size of Conv1 is L×H, the output size is L×H / 2, and the convolution kernel size is 3. The input size of Conv2 is L×H / 2, the output size is L×H, and the convolution kernel size is 3. The H features obtained through the Co-Attention network are merge After the convolution operation, the output H is obtained re , whose output size is L×H. Then the features of the corresponding position of the entity are weighted to obtain the entity feature h e , whose feature size is 1×H. The entity features are spliced in pairs and integrated into the global features to obtain entity pair features Its feature size is 1×3H. The feature is classified through a linear layer and the prediction result y is output pred ∈R 1×C Finally, the cross entropy is used to calculate the loss to get loss re The total loss of the joint model is loss = loss ner +loss re .
[0039] 3. Model training
[0040] For a training sample, such as Figure 1 As shown in the figure, the electronic medical record text is firstly passed through the BERT pre-training model to obtain the context feature representation of each character, and then encoded through the Memory-LSTM network to obtain the feature H m , the encoded feature H m Obtain entity task features H through self-attention network ner , and then the entity feature H ner After decoding by the CRF module, the loss of the entity recognition task is obtained ner and the predicted entity tag sequence L pred . The entity task feature H encoded by the self-attention network ner And the Memory-LSTM encoded feature H m Through the Co-Attention network, we get the feature H of deep information fusion merge , and then use multi-layer convolution to obtain the relationship extraction feature H re , according to the entity label sequence, we get the feature representation h of the entity pair <e1,e2> , calculate the loss loss through cross entropy re , and finally the total loss loss = loss ner +loss re Perform back-propagation to train the model.
[0041] 4. Methods for designing network models
[0042] The method comprises the following steps:
[0043] Step 1: Steps to build an electronic medical record dataset
[0044] The corpus of the present invention comes from the real electronic medical record data of the internal medicine, surgery and pediatric departments of a hospital. According to the Unified Medical Language System (UMLS) concept standard and combined with the characteristics of the Chinese electronic medical record corpus, the present invention defines 5 entity types: disease, part, symptom, examination and treatment; and 7 relationship categories: "disease-disease", "disease-symptom", "disease-part", "treatment-symptom", "treatment-disease", "examination-symptom" and "examination-disease".
[0045] Step 2: Build an entity relationship joint extraction model
[0046] (I) Building an improved LSTM network based on the Memory mechanism
[0047] The relationship in the electronic medical record has the problem that the head and tail entities are far apart and the entity relationship is relatively sparse. The traditional Long Short Term Memory network (LSTM) cannot effectively extract the relationship features of the head and tail entities with a large span. Therefore, the present invention proposes a Memory-LSTM structure, which uses the Memory mechanism to save the features obtained by each LSTM unit iteration, and the LSTM unit can use the information saved in the Memory in the next iteration, which effectively alleviates the problem of forgetting feature information in the traditional LSTM.
[0048] The LSTM network is mainly composed of input gates, forget gates, and output gates, and the gate mechanism controls the transmission and loss of information. At time t, the LSTM unit has three input features: the current input feature x t , the hidden layer feature h of the previous moment t-1 and the LSTM cell state C at the previous moment t-1 , and finally get the output feature h at time t t , the LSTM model formula is as follows:
[0049] f t =σ(W f ·[h t-1 , x t ]+b f )
[0050] i t =σ(W i ·[ht-1 , x t ]+b i )
[0051] o t =σ(W o ·[h t-1 , x t ]+b o )
[0052]
[0053]
[0054] h t =o t ⊙tanh(C t )
[0055] Among them, W (·) , b (·) represents the trainable weights and biases, tanh and σ are activation functions, and ⊙ represents the element-wise multiplication. In the LSTM structure, the hidden layer feature h t For short-term input features that are sensitive and change quickly, the unit state C t The state used to save long-term changes slowly. That is, the unit state C t Contains the information of long-distance text, so the present invention introduces a memory unit M to store C t Features, at time t, the input of the memory unit is the unit state C t , the formula is as follows:
[0056] m t =W M ·C t +b M
[0057] Among them, W M , b M Represents the trainable parameters of the memory unit. After t-1 iterations, the previous unit state C0~C t-1 The features will be stored in W M , b M In the above example, we obtain the memory feature m containing long-distance text information. t , and then linearly combine the output features h of LSTM through the gating mechanism t and memory feature m t , get the final output at time t The formula is as follows:
[0058] g t =σ(W g ·m t +b g)
[0059]
[0060] Among them, W g , b g represents the trainable parameters of the gated unit, σ represents the sigmoid activation function, and ⊙ represents the element-by-element multiplication. For a text of length k, the output feature of each position is We concatenate them together to get a complete feature representation of a sentence encoded by Memory-LSTM. Finally, we concatenate the forward and reverse features to get the feature H of the bidirectional Memory-LSTM. m :
[0061]
[0062]
[0063] (II) Constructing an entity extraction network based on self-attention
[0064] There is a large amount of redundant information in the electronic medical record text, and the distribution of medical entities is relatively sparse. The traditional time-series-based entity recognition model will learn entity information and redundant information equally. When there is too much redundant information, it will hinder the learning of entity features and affect the effect of entity extraction. Therefore, the present invention adopts a self-attention mechanism to learn entity features, strengthens the weight of important information such as medical entities through the attention model, and reduces the interference of irrelevant redundant information. The calculation formula of self-attention is as follows:
[0065] Q=W Q ·H m +b Q
[0066] K=W K ·H m +b K
[0067] V=W V ·H m +b V
[0068]
[0069] Get entity feature H through attention mechanism ner , and then get the entity tag sequence through the conditional random field (CRF) and calculate the loss function. Assuming the length of the sequence is N, there are M types of entity tag categories, and the calculation formula is as follows:
[0070]
[0071]
[0072] Among them, s i is the score of a certain labeled sequence, s real is the fraction of true labeled sequences; Indicates that i Position y j Marked score, Indicates that the marker at the current position is y i , move to the next position marked y j The loss of entity recognition is calculated by CRF. ner .
[0073] (III) Constructing an entity relationship deep information fusion network based on the Co-Attention mechanism
[0074] In the joint extraction model, how to model the information interaction between entity recognition and relationship extraction has always been the focus of research. Most current studies only use the extracted entity features as interactive information, ignoring the context of the entity and other potentially useful information for relationship extraction. Therefore, the present invention proposes a deep information fusion algorithm based on the collaborative attention mechanism (Co-Attention), which can realize the "character-level" information interaction of the complete features of the entity recognition task, thereby achieving deep information fusion. The implementation method is to first learn the entity features H obtained by the self-attention mechanism through an attention feature learner. ner And the feature H of Memory-LSTM m , get the attention feature (L is the length of the sentence); then concatenate the two attention features The attention score attn is obtained through the softmax activation function m , attn ner ∈R L×1 ; Finally, the attention score is multiplied by the original feature to obtain the fused feature. The calculation formula is as follows:
[0075]
[0076]
[0077]
[0078]
[0079] Among them, the specific expression of the attention score is Each element represents the ratio of the feature at the current position to the fused feature. For example, at position i in the text, the feature after collaborative attention fusion is Attention score and During the training process, the optimal ratio can be dynamically adjusted to achieve "character-level" deep information fusion. At the same time, the attention score satisfies The scale before and after feature fusion is guaranteed to remain unchanged. The collaborative attention mechanism not only considers all features from the entity extraction task, but also gives higher weight to important information in the entity task (such as entities and their contexts) through the attention score, so that the relationship extraction model can pay attention to all important information and perform better.
[0080] (IV) Constructing a relation extraction network based on multi-layer convolution
[0081] Relation extraction uses Convolutional Neural Network (CNN) as the feature extractor. The fusion feature H is obtained by collaborative attention. merge The relation extraction feature H is obtained through two layers of one-dimensional convolution re For all entities extracted, we use a pair-by-pair approach to predict the relationship type of each entity pair.<E1,E2> , assuming that the position of entity E1 in the sentence is i~j, then the feature of entity E1 is the weighted average of the features of positions i~j, expressed as Similarly, the characteristics of entity E2 are Finally, the two entity features are combined with the feature h at the "[CLS]" position of the BERT model. 2ls After concatenation, a classifier is used to determine the relationship type and calculate the loss. The formula is as follows:
[0082]
[0083] loss re =CrossEntropyLoss(y pred ,y label )
[0084] Among them, W pred and b pred represents the trainable parameters of the classifier, y pred ∈R 1×C (C represents the total number of relationship categories) represents the predicted relationship category, y label Represents the true value of the relationship category, and the loss of relationship extraction is obtained through the CrossEntropyLoss cross entropy loss function re .
[0085] 5. Execute entity relationship joint extraction method based on Chinese electronic medical records based on network model
[0086] The extraction method comprises the following steps:
[0087] By encoding each position of the sentence in the Chinese electronic medical record, the output features of each position of the sentence are obtained And the output features of each position Splicing, obtaining sentence feature representation;
[0088] By concatenating the forward and reverse features of the sentence feature representation, we can obtain the bidirectional temporal feature H of the sentence. m ;
[0089] The bidirectional timing characteristic H m Through the self-attention network, the entity task feature H is obtained ner , entity task feature H ner The entity tag sequence is obtained through the conditional random field;
[0090] The entity task feature H of the sentence ner With bidirectional timing characteristics H m Through the Co-Attention network, we can obtain the deep fusion feature H merge , and the fusion feature H merge Through multi-layer convolution, we can obtain the relationship extraction feature H re ;
[0091] By using the entity tag sequence, pairing the obtained entities in pairs to obtain a plurality of entity pairs;
[0092] Extract feature H based on the relationship re The features of the corresponding positions of each entity are weighted and averaged to obtain the entity feature h e ;
[0093] The features h of the entities corresponding to the two entities of the entity pair e The sentence representation h of the pre-trained model cls The concatenation representation is obtained by concatenation, and the entity relationship type obtained according to the concatenation representation is output through a classifier.
[0094] In one approach, the first output feature is obtained The method comprises the following steps:
[0095] Input the feature representation of each character of the sentence into LSTM to obtain the cell state C of LSTM containing long-distance text information t ;
[0096] The cell state C of LSTM is stored through the memory unit M t , in response to the cell state Ct Get the memory feature m t ;
[0097] The output feature h of LSTM at time t t and memory feature m t Linear combination obtains the output features at time t
[0098] In one scenario:
[0099] Get memory feature m t Expressed by the formula: m t =W M ·C t +b M , W M , b M Represents the trainable parameters of the memory unit M. After t-1 iterations, the unit states C0~C t-1 The features are stored in W M , b M Middle memory feature m t Contains long-distance text information;
[0100] Get the output features at time t Expressed by the formula: g t =σ(W g ·m t +b g ), W g , b g represents the trainable parameters of the gated unit, σ represents the sigmoid activation function, and ⊙ represents the corresponding multiplication of elements;
[0101] The sentence feature representation is obtained by the formula: k is the length of the text, t∈(0~k-1);
[0102] Get the bidirectional temporal features H of the sentence m Expressed by the formula: Represents the forward timing characteristics, Indicates reverse timing characteristics.
[0103] In one solution, the fusion feature H is obtained merge The method comprises the following steps:
[0104] The entity task feature H is transformed into ner and bidirectional timing characteristics H m Linear mapping to obtain entity task attention features and bidirectional temporal attention features L is the sentence length;
[0105] Bidirectional temporal attention features and entity task characteristics Splicing, and through the softmax activation function, obtain the bidirectional temporal attention feature The attention score attn m and entity task attention characteristics The attention score attn ner , attn m 、attn ner ∈R L×1 ,
[0106] Attention score attn m Bidirectional temporal attention features The fusion feature H accounts for the feature at any position merge The proportions of features at corresponding positions are obtained by arranging them in order of position.
[0107] Attention score attn ner By entity task attention features The fusion feature H accounts for the feature at any position merge The proportions of features at corresponding positions are obtained by arranging them in order of position.
[0108] Fusion feature H merge The features at any position are based on the bidirectional temporal attention features The features of the corresponding position and the ratio of the position to the entity task attention features The ratio of the feature corresponding to the position to the determined ratio of the position is calculated.
[0109] In one scenario:
[0110] Obtaining bidirectional temporal attention features Expressed by the formula:
[0111] Obtaining entity task attention features Expressed by the formula:
[0112] The attention score is expressed by the formula:
[0113] Get fusion feature H merge Expressed by the formula:
[0114] In one solution, the feature H is extracted according to the relationship re The features of the entities in the corresponding positions of each entity pair in the sentence are weighted and averaged to obtain the entity feature h e Expressed by the formula: he =H re [i~j] / (ji), the entity is located at position i~j in the sentence.
[0115] In one scenario:
[0116] Entity Pair<E1,E2> In the sentence, the position of entity E1 is i~j, then the feature of entity E1 is the weighted average of the features at positions i~j, expressed as
[0117] Entity Pair<E1,E2> In the sentence, the position of entity E2 is i~j, then the feature of entity E2 is the weighted average of the features at positions i~j, expressed as
[0118] Combine the two entity features with the sentence representation h of the pre-trained model cls Splicing, the entity relationship type obtained by the classifier output according to the splicing representation is expressed by the formula: W pred and b pred represents the trainable parameters of the classifier, y pred ∈R 1×C , C represents the total number of relationship categories, y label Represents the true value of the relation category.
[0119] 6. Model Quality Assessment
[0120] In order to evaluate the effect of entity relationship extraction of this model, the micro-average method is used to use precision (P) and recall (F)
[0121] The predicted triples are evaluated by strict matching, that is, the predicted triples are considered correct if and only if the entity boundaries, entity types, and relationship types in the predicted triples are completely correct.
[0122] Table 1: Entity recognition evaluation results
[0123]
[0124] The evaluation results of entity recognition are shown in Table 1. It can be seen that all categories of entity recognition have achieved good results, and the overall F-value has reached 88.05%. From the results, it can be seen that the results of the "symptom" and "location" types are poor. One of the reasons is that the "symptom" type entities are semantically similar to the "disease" type entities. For example, "migraine" belongs to the disease, but it is easy to be confused with the symptom "headache". The "location" type entities account for a small proportion of the total entities, and the model cannot fully learn their features. If complex "location" entities such as "ureter crossing iliac vessels" and "ureteropelvic junction" are encountered, they cannot be correctly extracted. The "disease", "treatment" and "examination" type entities have better extraction effects due to their obvious features and sufficient samples.
[0125] Table 2: Relation extraction evaluation results
[0126]
[0127] The results of relationship extraction are shown in Table 2. It can be seen that the overall relationship extraction has achieved good results, reaching an F-value of 77.17%. The effects of the "disease-disease" and "disease-symptom" categories are relatively low. The reason is that the "symptom" type entity is semantically similar to the "disease" type entity, and the model is not easy to distinguish. If the "disease" (or "symptom") type entity is incorrectly predicted as the "symptom" (or "disease") type, the relationship extraction model will use this wrong information to predict the wrong relationship type. At the same time, in the process of manually annotating the electronic medical record data set, the annotators are prone to incorrectly annotating the entity relationship type due to insufficient medical knowledge, which will introduce noise into the model training.
[0128] 7. Model comparison
[0129] In order to verify the effectiveness of the model proposed in the present invention, the relationship extraction results of the present invention are compared with advanced pipeline models and joint models. The pipeline model adopts Li et al. (Electronic medical record entity relationship extraction based on position denoising and rich semantics [J]. Journal of Chinese Information Science, 2021); the joint model adopts Yan et al. (A partition filter network for joint entity and relation extraction [C]. Empirical Methods in Natural Language Processing, 2021). The above two models use the same training set, test set and evaluation method as the present invention. The F-values of the pipeline model entity recognition and relationship extraction are 86.10% and 65.07% respectively. The results of each category of entity recognition and relationship extraction are shown in Table 3 and Table 4 respectively:
[0130] Table 3: Evaluation results of pipeline method entity recognition
[0131]
[0132] Table 4: Evaluation results of pipeline method relation extraction
[0133]
[0134] It can be seen from the results of the pipeline model that the joint model of the present invention is significantly better than the traditional pipeline model. The F-value of entity recognition has increased by 1.95%, the F-value of relationship extraction has increased by 12.10%, and the improvement is obvious in all categories. Analyzing the reasons, first of all, the pipeline model uses the knowledge base matching method to extract entities in the entity recognition stage. Although this method can ensure the accuracy of the extracted entities, it cannot effectively extract long and difficult entities. For example, the entity "pancreatic head enlargement with surrounding exudation" will be split in the word segmentation stage, resulting in the entity cannot be matched by the knowledge base. At the same time, the quality of the knowledge base will also directly affect the effect of entity matching. From Table 3, it can be seen that the extraction effect of the "part" type entity is very low. A big reason is that the "part" type entity in the knowledge base is not perfect, resulting in poor matching effect. Finally, the pipeline model has the problem of error propagation, and it is also impossible to utilize the potential correlation between the two tasks, so the results of the pipeline model are poor.
[0135] We also compare the model of the present invention with the current advanced joint model (A partition filter network for joint entity and relation extraction [C]. Empirical Methods in Natural Language Processing, 2021). The joint model (PFN) achieved the best results in 2021 on the general field dataset. The F-values of the PFN model for entity recognition and relation extraction on the dataset of the present invention reached 87.18% and 74.49% respectively. The results of each category of entity recognition and relation extraction are shown in Tables 5 and 6 respectively:
[0136] Table 5: Comparison of entity recognition evaluation results of joint methods
[0137]
[0138] Table 6: Comparison of joint method relation extraction evaluation results
[0139]
[0140]
[0141] The results show that the joint model of the present invention is better than the PFN joint model in overall effect, with the F-value of entity recognition increased by 0.87% and the F-value of relationship extraction increased by 2.68%. From the effect of each category, the model of the present invention is significantly better than the PFN model in predicting relationships related to "disease" (such as "disease-disease" and "disease-symptom"), because medical entities are more complex than entities in general fields, and the relationship span between head and tail entities is larger. The joint model of the present invention uses the Memory mechanism to effectively preserve long-distance features, so it is better in extracting medical entity relationships with a larger span.
[0142] In summary, the present invention proposes a joint entity-relationship extraction model based on Chinese electronic medical records, and proposes an improved LSTM encoding algorithm based on the memory mechanism according to the characteristics of the electronic medical record document level; and proposes a deep information fusion mechanism based on Co-Attention to strengthen the information interaction between entity recognition and relationship extraction. Finally, the model of the present invention is compared with the advanced pipeline model and the joint model. The model of the present invention has obvious improvements in the results of entity extraction and relationship extraction, which verifies the effectiveness of this method.
[0143] The embodiment of the present invention further provides an electronic device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps in the method provided in the above embodiment when executing the computer program. The electronic device provided in the embodiment of the present invention can implement each implementation method in the above method embodiment and the corresponding beneficial effects.
[0144] An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the method provided by the embodiment of the present invention is implemented and the same technical effect can be achieved.
[0145] A person skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The above-mentioned storage medium can be a magnetic disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM).
[0146] The above disclosure is only the preferred embodiment of the present invention, which certainly cannot be used to limit the scope of the present invention. Therefore, equivalent changes made according to the claims of the present invention are still within the scope of the present invention.
Claims
1. A joint extraction method of entity relations based on Chinese electronic medical records, It is characterized in that The steps include: By encoding each position of the sentence in the Chinese electronic medical record, the output features of each position of the sentence are obtained And the output features of each position Splicing, obtaining sentence feature representation; By concatenating the forward and reverse features of the sentence feature representation, we can obtain the bidirectional temporal feature H of the sentence. m ; The bidirectional timing characteristic H m Through the self-attention network, the entity task feature H is obtained ner , entity task feature H ner Obtain entity tag sequence through conditional random field; The entity task feature H of the sentence ner With bidirectional timing characteristics H m Through the Co-Attention network, we can obtain the deep fusion feature H merge , and the deep fusion feature H merge Through multi-layer convolution, we can obtain the relationship extraction feature H re ; By using the entity tag sequence, pairing the obtained entities in pairs to obtain a plurality of entity pairs; Extract feature H based on the relationship re The features of the corresponding positions of each entity are weighted and averaged to obtain the entity feature h e ; The features h of the entities corresponding to the two entities of the entity pair e The sentence representation h of the pre-trained model cls The concatenation representation is obtained by concatenation, and the entity relationship type obtained according to the concatenation representation is output through a classifier.
2. The entity relationship joint extraction method based on Chinese electronic medical records as described in claim 1, It is characterized in that Get the first output feature The method comprises the following steps: Input the feature representation of each character of the sentence into LSTM to obtain the cell state C of LSTM containing long-distance text information t ; The cell state C of LSTM is stored through the memory unit M t , in response to the cell state C t Get the memory feature m t ; The output feature h of LSTM at time t t and memory feature m t Linear combination obtains the output features at time t 3. The entity relationship joint extraction method based on Chinese electronic medical records as described in claim 2, It is characterized in that Get memory feature m t Expressed by the formula: m t =W M ·C t +b M , W M , b M Represents the trainable parameters of the memory unit M. After t-1 iterations, the unit state C 0 ~C t-1 The features are stored in W M , b M Middle memory feature m t Contains long-distance text information; Get the output features at time t Expressed by the formula: g t =σ(W g ·m t +b g ), W g , b g represents the trainable parameters of the gated unit, σ represents the sigmoid activation function, and ⊙ represents the corresponding multiplication of elements; The sentence feature representation is obtained by the formula: k is the length of the text, t∈(0~k-1); Get the bidirectional temporal features H of the sentence m Expressed by the formula: Represents the forward timing characteristics, Indicates reverse timing characteristics.
4. The entity relationship joint extraction method based on Chinese electronic medical records as claimed in claim 1, It is characterized in that Get the deep fusion feature H merge The method comprises the following steps: The entity task feature H is transformed into ner and bidirectional timing characteristics H m Linear mapping to obtain bidirectional temporal attention features and entity task attention features L is the sentence length; Bidirectional temporal attention features and entity task attention features Splicing, and through the softmax activation function, obtain the bidirectional temporal attention feature The attention score attn m and entity task attention characteristics The attention score attn ner , attn m 、attn ner ∈R L×1 , Attention score attn m Bidirectional temporal attention features The fusion feature H accounts for the feature at any position merge The proportions of features at corresponding positions are obtained by arranging them in order of position. Attention score attn ner By entity task attention features The feature at any position occupies the deep fusion feature H merge The proportions of features at corresponding positions are obtained by arranging them in order of position. Deep fusion feature H merge The features at any position are based on the bidirectional temporal attention features The features of the corresponding position and the ratio of the position to the entity task attention features The ratio of the feature corresponding to the position to the determined ratio of the position is calculated.
5. The entity relationship joint extraction method based on Chinese electronic medical records as described in claim 4, It is characterized in that Obtaining bidirectional temporal attention features Expressed by the formula: Obtaining entity task attention features Expressed by the formula: The formula for obtaining the attention score is: Get fusion feature H merge Expressed by the formula:
6. The entity relationship joint extraction method based on Chinese electronic medical records as claimed in claim 1, It is characterized in that Extract feature H based on the relationship re The features of the entities in the corresponding positions of each entity pair in the sentence are weighted and averaged to obtain the entity feature h e Expressed by the formula: h e =H re [i~j] / (ji), the entity is located at position i~j in the sentence.
7. The entity relationship joint extraction method based on Chinese electronic medical records as claimed in claim 6, It is characterized in that Entity Pair <E 1 , E 2 >Medium Entity E 1 The position in the sentence is i~j, then entity E 1 The feature is the weighted average of the features at position i to j, expressed as Entity Pair <E 1 , E 2 >Medium Entity E 2 The position in the sentence is i~j, then entity E 2 The feature is the weighted average of the features at position i to j, expressed as Combine the two entity features with the sentence representation h of the pre-trained model cls Splicing, the entity relationship type obtained by the classifier output according to the splicing representation is expressed by the formula: W pred and b pred represents the trainable parameters of the classifier, y pred ∈R 1×C , C represents the total number of relationship categories, y label Represents the true value of the relation category.
8. A network for implementing the entity relationship joint extraction method based on Chinese electronic medical records according to any one of claims 1 to 7, It is characterized in that include LSTM improved network based on Memory mechanism, Self-attention based entity extraction network, Entity relationship deep information fusion network based on Co-Attention mechanism, and Relation extraction network based on multi-layer convolution; The improved LSTM network based on the Memory mechanism is composed of two LSTM units, two storage units, and two gating units, which are represented as The forward and reverse arrows indicate the direction of data input; input data X = {x 0 , x 1 , ..., x L-1 The dimension of} is L×H, where L is the length of the input data and H is the dimension of the feature; the input size of the LSTM unit is 1×H, for each character feature x of the input data t ∈X, and input it into the forward LSTM unit in turn to get The output size is 1×H / 2; the storage unit is a fully connected layer, whose input size is 1×H / 2, and the features encoded by the forward LSTM unit are Acquiring memory features through forward storage units The output size is 1×H / 2; the gate unit is a linear layer connected to the sigmoid function, its input size is 1×H / 2, and the output size is 1×1, which is used to memorize the feature Obtain gate control weights through gate control units Then the features encoded by the LSTM unit and memory characteristics By weight Linear combination gives Its output size is 1×H / 2; all characters are passed through the forward LSTM unit in sequence and concatenated to obtain The output size is L×H / 2. All characters are reversed and passed through the reverse LSTM unit in turn to obtain Concatenate it with the forward feature to finally get the bidirectional Memory-LSTM feature Its output size is L×H; The self-attention-based entity extraction network consists of a self-attention network and a CRF decoding module; the input size of the self-attention network is L×H, and the output size is L×H; the entity task feature H is obtained through the self-attention network ner Entity task characteristics H ner Decoding is performed through a CRF module, the input size of the CRF module is L×H, and the output is the label sequence Lpre of the path with the highest score d ; The entity relationship deep information fusion network based on the Co-Attention mechanism consists of two attention feature learners. The learner is a linear layer with an input size of L×H and an output size of L×1. ner And the feature H of Memory-LSTM m Through their respective feature learners, the output is Concatenate two attention features Get the attention weight attn through the softmax activation function m , attn ner ∈R L×1 Finally, the attention weights are multiplied with the original features to obtain the fused features H re , taking this feature as the input of the relation extraction module based on multi-layer convolution; The multi-layer convolution-based relation extraction model is composed of two one-dimensional convolution units stacked together, namely Conv1 and Conv2. v 2; the input size of Conv1 is L×H, the output size is L×H / 2, and the convolution kernel size is 3; Con v 2 has an input size of L×H / 2, an output size of L×H, and a convolution kernel size of 3; the H features obtained through the Co-Attention network merge After the convolution operation, the output H is obtained re , whose output size is L×H; then the features of the corresponding position of the entity are weighted to obtain the entity feature h e , whose feature size is 1×H; the entity features are spliced in pairs and integrated into the global features to obtain the entity pair feature h <e1,e2> = Its feature size is 1×3H; the feature is classified through a linear layer and the prediction result y is output pred ∈R 1×C .
9. An electronic device, It is characterized in that include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in any one of the methods of claims 1 to 7 are implemented.
