Medical named entity recognition method based on graph attention network and word fusion
By using graph attention network and word fusion method in medical named entity recognition, combining Bert model and SoftLexicon, using BiLSTM and feedforward neural network, the problem of insufficient character vector expression ability in the existing technology is solved, and more accurate is achieved Medical text entity recognition.
Patent Information
- Application Number
- CN202310038699.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-01-12
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2043-01-12
AI Technical Summary
The existing technology fails to make full use of vocabulary information in medical named entity recognition, resulting in insufficient character vector expression capabilities and inability to effectively extract features.
Using a method based on graph attention network and word fusion, through the combination of embedding layer, graph attention layer, context encoding layer and conditional random field layer, the Bert model and SoftLexicon method are used to obtain word features and vocabulary features, and through graph attention The force network is fused, and BiLSTM and feedforward neural network are combined to improve network capabilities with residual connections and layer normalization.
It effectively improves the expressive ability of character vectors, can more accurately extract named entities in medical texts, and improves the accuracy and efficiency of named entity recognition.
Smart Images

Figure CN116738992B
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of natural language processing, and in particular relates to a medical named entity recognition method based on graph attention network and word fusion. Background Art
[0002] Medical texts record the diagnosis and treatment information of patients and contain a large number of medical text records, which are very important medical resources. In this information age, a large amount of electronic medical record text data has been accumulated. However, most of this information is recorded in electronic medical records in an unstructured form. In order to efficiently use this text information, it needs to be structured. Named entity recognition (NER) technology in the field of natural language processing (NLP) can play an important role. Through named entity recognition, effective information in electronic medical records can be quickly extracted, such as identifying entities such as diseases and diagnoses, imaging examinations, laboratory tests, surgeries, drugs, and anatomical parts, saving time for doctors to read electronic medical records of various recording styles and improving doctors' work efficiency. Therefore, medical named entity recognition is extremely important.
[0003] At present, named entity recognition technologies mainly include rule-based and dictionary-based methods, statistical learning-based methods, and deep learning-based methods. Among them, deep learning-based methods are becoming more and more popular in named entity recognition because they do not require too much professional knowledge and have good results. With the development of graph neural networks, the application of graph neural networks to named entity recognition also has very important research value. The existing methods of introducing graph neural networks for named entity recognition are roughly as follows:
[0004] A graph neural network method based on a dictionary and with global semantics. This method converts a sentence into a directed graph, with each character in the sentence as a node and each word as an edge. The state of the node represents the characteristics of the character, the state of the edge represents the characteristics of the word, and a global relay node is maintained to collect information from the nodes and edges. Then, the information of the edges adjacent to the node is aggregated to the node, the information of the nodes adjacent to the edge is aggregated to the edge, and the information of each node and edge is aggregated to the global relay node. Then, update modules are designed for the nodes, edges, and global relay nodes respectively to update the information. The aggregation and update process is repeated, and finally the node is sent to the conditional random field layer for decoding.
[0005] A collaborative graph network method based on graph attention network. This method takes both characters and words as nodes and constructs three character-word interaction networks. The first is the inclusion graph, which simulates the inclusion relationship between characters and words. If a character is included in a self-matching word, the character and the self-matching word are connected. The second graph is the transition graph, which is used to represent the adjacency relationship between characters, between characters and words, and between words, connecting adjacent nodes. The third graph is a grid graph, which uses a grid structure to integrate vocabulary knowledge. The different knowledge captured by the three graphs is then fused through a fusion layer.
[0006] However, these methods do not fully utilize vocabulary information and cannot solve the problem of insufficient expressive power of character vectors. Summary of the invention
[0007] In view of the problems existing in the prior art, the present invention provides a medical named entity recognition method based on a graph attention network and word fusion, and constructs an entity recognition network, which includes an embedding layer, a graph attention layer, a context encoding layer, and a conditional random field layer. The process of performing entity recognition includes the following steps:
[0008] In the embedding layer, the text sequence to be recognized is input into the Bert model to obtain the feature vector of each character in the text sequence, that is, the character feature; the lexical representation layer feature vector matching the characters in the text sequence is obtained through the SoftLexicon method, that is, the lexical feature;
[0009] In the graph attention layer, the word features are pointed to the corresponding lexical features to construct a directed graph, and the adjacency matrix is used to save the information of the directed graph. The word features, lexical features and their corresponding adjacency matrices are fused using the graph attention network to obtain the word feature vector;
[0010] In the context encoding layer, the BiLSTM network is used to extract the context semantics of the word feature vector to obtain the context semantic vector;
[0011] The context semantic vector is input into the conditional random field layer to predict the label corresponding to the text sequence.
[0012] The present invention integrates character information and matching word information of characters in an interactive manner through a graph attention network, which can make full use of vocabulary information to improve the expressive power of character vectors. In addition, a single graph attention network is not enough to extract ideal features. The present invention adds a feedforward neural network on the basis of the graph attention network. In order to make the information transfer deeper, a residual connection is added between the graph attention network and the feedforward neural network, and a layer normalization operation is performed, which can further improve the network's capabilities. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] Figure 1 It is a flow chart of entity recognition network training in the medical named entity recognition method based on graph attention network and word fusion of the present invention;
[0014] Figure 2 A schematic diagram of an entity recognition network structure in a medical named entity recognition method based on a graph attention network and word fusion according to the present invention;
[0015] Figure 3 It is a directed graph constructed by the present invention for graph attention network training. DETAILED DESCRIPTION
[0016] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0017] The present invention provides a medical named entity recognition method based on a graph attention network and word fusion, constructs an entity recognition network, and the network includes an embedding layer, a graph attention layer, a context encoding layer, and a conditional random field layer. The process of performing entity recognition includes the following steps:
[0018] In the embedding layer, the text sequence to be recognized is input into the Bert model to obtain the feature vector of each character in the text sequence, that is, the character feature; the lexical representation layer feature vector matching the characters in the text sequence is obtained through the SoftLexicon method, that is, the lexical feature;
[0019] In the graph attention layer, the word features are pointed to the corresponding lexical features to construct a directed graph, and the adjacency matrix is used to save the information of the directed graph. The word features, lexical features and their corresponding adjacency matrices are fused using the graph attention network to obtain the word feature vector;
[0020] In the context encoding layer, the BiLSTM network is used to extract the context semantics of the word feature vector to obtain the context semantic vector;
[0021] The context semantic vector is input into the conditional random field layer to predict the label corresponding to the text sequence.
[0022] In this embodiment, the training process of the medical named entity recognition model is as follows: Figure 1 As shown, the training process of this embodiment specifically includes the following steps:
[0023] Unlabeled Chinese electronic medical record data were obtained for manual labeling and divided into training data and validation data in a 4:1 ratio.
[0024] Specifically, for the sentence "Three years ago, the patient had repeated acid reflux and discomfort in the middle and lower abdomen without obvious causes, accompanied by nausea and belching, without vomiting, dysphagia, heartburn, abdominal pain, or diarrhea. A gastroscopy examination showed "chronic antral gastritis" (unspecified)." The corresponding entity annotation is:
[0025] "OOOOOOOOOOOOOO B-POS I-POS I-POS OOOOOOOOOOOOOOOOOOOOO B-POSOO B-POS OOOOOOOOOOO B-DIS I-DIS I-DIS I-DIS I-DIS OOOOOOOO";
[0026] In this embodiment, entity categories include six categories: disease and diagnosis, imaging examination, laboratory test, surgery, medicine, and anatomical part. OPE represents surgery entity, LAB represents laboratory test entity, DIS represents disease and diagnosis entity, POS represents anatomical part entity, SCR represents imaging examination entity, and MED represents medicine entity. The label adopts a BIO format label. In the BIO format label, B represents the beginning of the entity, I represents the other parts except the beginning of the entity, and O represents a non-entity label. For example, the entities in the above sentence include "middle and lower abdomen", "abdomen", and "chronic antral gastritis". There are two types of entities in the above sentence, namely anatomical part entity and disease and diagnosis entity. Taking the anatomical part entity "middle and lower abdomen" as an example, the vocabulary is expressed as "B-POS I-POS I-POS", B-POS represents the beginning of the anatomical part entity "middle and lower abdomen", I-POS represents the other parts of the anatomical part entity "middle and lower abdomen", and other vocabulary is similar, which will not be repeated in this embodiment.
[0027] The entity recognition network structure is as follows Figure 2 As shown in the figure, it includes an embedding layer, a graph attention layer (also called a graph attention network layer), a context encoding layer, and a conditional random field layer (also called a decoding layer). The process of entity recognition includes:
[0028] Map the characters in the text sequence into character vectors. Assume that the original text of the medical record is X = {x1,...,x n}, where x i represents the i-th character in the sequence, and n represents the number of characters in the sequence. The characters are mapped into vectors through the Bert model, which is expressed as:
[0029] bc i = Bert(x i ),bc i ∈R d
[0030] Bc=[bc1,...,bc n ]∈R n*d
[0031] Because the Bert model can only accept a maximum of 512 characters, the text is truncated to a length of 256 characters. If it is less than 256 characters, it is padded with padding.
[0032] Among them, bc i represents the word feature vector of the i-th character, Bc represents the word feature vector of the text, and d represents the dimension of the word feature vector of the character.
[0033] This embodiment uses the Softlexicon algorithm to classify the words matched by the characters into four sets: word set B, word set M, word set E, and word set S. If the character is at the beginning of the matching word, the matching word is placed in word set B; if the character is in the middle of the matching word, the matching word is placed in word set M; if the character is at the end of the matching word, the matching word is placed in word set E; if the character itself is a word, the matching word is placed in word set S. After obtaining the word set B, word set M, word set E, and word set S of each character, each word set needs to be compressed into a vector of fixed dimension. The following method is adopted to compress the word set into a vector, and the compression process is expressed as:
[0034]
[0035] Among them, e w Get the word vector of the vocabulary, z(w) represents the frequency of word w in the dictionary in the statistical data. Z represents the sum of z(w) of all words in the four word sets.
[0036] The lexical feature vector of a character is represented as:
[0037] l i =[v(B(x i ));v(M(x i ));v(E(x i )); v(S(x i ))],l i ∈R 4d
[0038] L=Linear[l1,...,l n ]∈R n*d
[0039] Wherein Linear[] represents a linear mapping. In this embodiment, the lexical feature vector l of the character is i ∈R 4d After linear mapping, it becomes l i ∈Rd , that is, using linear mapping to perform dimensionality reduction operations.
[0040] Concatenate Bc and L obtained in the above way as the node input for constructing a directed graph, and the node of the directed graph is represented as:
[0041] Node=[bc1,...,bc n ,l1,...,l n ]
[0042] When constructing a directed graph, the word feature bc of the i-th word i and the lexical feature l of the jth word j As nodes, the directed graph constructed is as follows Figure 3 As shown, for the constructed directed graph, if the i-th word feature bc i There is a lexical feature l pointing to the jth word j The directed edge of , or the lexical feature l of the jth word j There is a feature bc pointing to the i-th word i If there is a directed edge between the nodes, the value of the corresponding position in the adjacency matrix is set to 1. If there is no edge connecting the nodes, write 0 in the corresponding row and column positions in the adjacency matrix. The adjacency matrix is denoted by A. The adjacency matrix is an N×N matrix, N=2n. The 1st to nth nodes correspond to the character features of each word, and the n+1st to 2nth nodes correspond to the lexical features of each word.
[0043] Use the graph attention network to process each node. For N nodes, if we use h = {h1,h2,...,h N} represents input data, h i represents an input vector of dimension d, h′={h1′,h2′,...,h′ N} represents the output data with dimension d′. For a node i, it is necessary to consider the influence of its neighbor nodes on it, that is, the influence of the nodes with edge relationships on it. For this reason, the attention coefficient α is proposed in this embodiment. ij Represents the influence of node j on node i. The process of obtaining the attention coefficient includes the following steps:
[0044] Calculate the similarity coefficient between a node and its adjacent nodes, expressed as:
[0045] e ij =a T [Wh i ||Wh j ],j∈N i
[0046] Among them, a and W are trainable parameters, || represents the concatenation operation; N irepresents all nodes adjacent to node i, that is, all nodes that have an edge relationship with node i;
[0047] After obtaining the similarity coefficient, the attention coefficient is calculated through the softmax operation, which is expressed as:
[0048]
[0049] E ij Substituting the calculation formula into the above formula, we can get:
[0050]
[0051] According to the calculated attention coefficient, the feature vector is weighted summed to obtain the output vector of the graph attention network:
[0052]
[0053] In order to obtain better generalization ability, multi-head attention is used in the training process, that is, K groups of attention layers are used, and finally their outputs are concatenated. The formula is as follows:
[0054]
[0055] In the graph attention network layer, the output h of the graph attention network i 'The network capacity will be improved through feedforward neural network, and further processed by residual connection and layer normalization, including:
[0056] FFN(h i ′)=max(0;h i ′W1+b1)W2+b2
[0057] G = LayerNorm(FFN(h i ′)+h i ′)
[0058] Among them, G∈R d′*(2n) , split into two d′×n matrices, and then fuse them, that is, split the first n vectors and the last n vectors in the matrix G and fuse them. The fusion process is expressed as:
[0059] G'=M1G[:,1:n]+M2G[:,n+1:]
[0060] Among them, G' is the word feature vector obtained by fusion; G[:,1:n] represents the feature matrix obtained by cutting the first column to the nth column from the matrix G, and this matrix feature matrix is used as the feature matrix to be fused for word features; G[:,n+1:] represents the feature matrix obtained by cutting the n+1th column to the 2nth column from the matrix G, and this matrix feature matrix is used as the feature matrix to be fused for vocabulary features; M1∈Rd′*d′ and M2∈R d′*d′ is a trainable parameter.
[0061] After obtaining the word feature vector G', it is input into a BiLSTM network for classification and recognition. BiLSTM is an improved network of LSTM. The classification and recognition process is expressed as:
[0062] Obtain the contextual features of word feature vectors through the BiLSTM network;
[0063] The output vector of BiLSTM is then input into the conditional random field layer. The vector output by the BiLSTM layer can be considered as the score of the characters in the sentence belonging to each type of entity. This score will be used as the emission score of the CRF layer and input into the CRF layer.
[0064] The CRF layer combines the results of deep learning with the statistical learning model, calculates the predicted label scores of all characters in the text based on the input feature vector, and then calculates the loss with the actual label, back-propagates, and updates the network parameters.
[0065] The scale of BiLSTM's output score matrix P is n×m, where n is the number of characters and m is the number of labels. Specifically, for the predicted sequence, its score function is expressed as:
[0066]
[0067] Where X={x1,...,x n} is a text sequence consisting of n words, Y = {y1,...,y n} is the predicted label corresponding to each word, Represents the label y i Transfer to label y i+1 The score, for example, y i represents the B-POS tag, y i+1 Indicates I-POS tag, It indicates the probability that the next label in B-POS is I-POS. This value is initialized to a random score during training and automatically updated during the training process. i,y It represents the score of the jth label of the ith word. This score is the output parameter of the BiLSTM network and the emission score of the CRF layer of the BiLSTM network. Specifically, it is equivalent to representing each word in a text of n words with an m-dimensional vector, that is, the probability that a word belongs to each label.
[0068] Given a text sequence X = {x1,...,x n} generates a label sequence Y = {y1,...,y nThe probability of} is expressed as:
[0069]
[0070] in, represents the predicted label sequence, Y represents the manually annotated label sequence, and Y X Represents all possible labeled sequences; taking the logarithm of both ends of the above formula to obtain the likelihood function of the predicted sequence, expressed as:
[0071]
[0072] The loss function of this embodiment during the training process is expressed as:
[0073]
[0074] During the training process, the present invention trains the model based on a gradient method. When the number of iterations reaches a preset number, the training is stopped and the network parameters with the highest F1 value are saved.
[0075] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.
Claims
1. A medical named entity recognition method based on graph attention network and word fusion, characterized in that: Construct an entity recognition network, which includes an embedding layer, a graph attention layer, a context encoding layer, and a conditional random field layer. The process of entity recognition includes the following steps: In the embedding layer, the text sequence to be recognized is input into the Bert model to obtain the feature vector of each character in the text sequence, that is, the character feature; the lexical representation layer feature vector matching the characters in the text sequence is obtained through the SoftLexicon method, that is, the lexical feature; In the graph attention layer, the word features are pointed to the corresponding vocabulary features to construct a directed graph, and the adjacency matrix is used to save the information of the directed graph. The word features, vocabulary features and their corresponding adjacency matrices are fused using the graph attention network to obtain the word feature vector, which specifically includes the following steps: According to the connection relationship of the nodes in the adjacency matrix, the attention coefficient of the adjacent nodes of a node is calculated, and the node vector representation is weighted according to the attention coefficient; in the process of weighted summation of the feature vector using the attention coefficient, multi-head attention is adopted, that is, K groups of attention layers are used to obtain the attention coefficients respectively, and the K groups of attention coefficients are weighted for the input features respectively and then spliced together as the output of the graph attention network, which is expressed as: in, represents the attention coefficient obtained by the kth attention layer, W k represents the trainable parameters of the kth attention layer; The weighted vector representation is input into a feedforward neural network, and residual connection and layer normalization are used to obtain the graph attention vector representation of a node, namely: FFN(h i ′)=max(0;h i ′W1+b1)W2+b2 G=LayerNorm(FFN(h i ′)+h i ′) Split the 1st to nth columns of matrix G as the character features to be fused, and the other columns as the vocabulary features to be fused. The two matrices are fused again, expressed as: G′=M1*G[:,0:n]+M2*G[:,n:] Where FFN(·) represents a feedforward neural network, W1, W2, b1, b2, M1∈R d′*d′ and M2∈R d′*d′ are all trainable parameters, LayerNorm() represents the layer normalization operation; G′∈R d′*n It is the final output of the graph attention network layer; The graph attention vector representations of the nodes corresponding to the character features and the nodes corresponding to the vocabulary features are fused to obtain the word feature vector; In the context encoding layer, the BiLSTM network is used to extract the context semantics of the word feature vector to obtain the context semantic vector; The context semantic vector is input into the conditional random field layer to predict the label corresponding to the text sequence.
2. According to claim 1, the medical named entity recognition method based on graph attention network and word fusion is characterized in that: During the training of the entity recognition network, the unlabeled Chinese electronic medical record data was manually labeled to obtain the original text of the Chinese electronic medical record and its entity labels, and the labeled data was divided into training data and verification data. The training data was used to train the entity recognition network in each round of training. After the training was completed, the verification data was used to calculate the F1 score of the entity recognition network, and the network parameters in the round of training with the highest F1 score were used as the final network parameters of the entity recognition network to complete the training.
3. The medical named entity recognition method based on graph attention network and word fusion according to claim 2 is characterized in that: The original text of the Chinese electronic medical record is represented as X = {x1,...,x n }, x i represents the i-th Chinese character in the original text of the Chinese electronic medical record, i∈{1,2,…,n}, n is the length of the Chinese characters in the original text of the Chinese electronic medical record; the label is represented by Y={y1,…,y n },y i Indicates the label corresponding to the i-th Chinese character in the original text of the Chinese electronic medical record. The label adopts the BIO format label. In the BIO format label, B represents the beginning of the entity, I represents the other parts except the beginning of the entity, and O represents a non-entity label.
4. The medical named entity recognition method based on graph attention network and word fusion according to claim 2, characterized in that: During the training process, the loss function is calculated using the labels predicted by the entity recognition network and the manually annotated labels. The loss function is used to update the parameters of the entity recognition network using a gradient-based training method. The loss function is expressed as: Among them, ln(p(Y|X)) is the likelihood function of the predicted sequence; Represents the label y i Transfer to label y i+1 The score of i,y represents the score of the jth tag of the i-th word; represents the predicted label sequence, Y represents the manually annotated label sequence, and Y X represents all possible tag sequences; n represents the number of characters in the text sequence to be recognized.
5. The medical named entity recognition method based on graph attention network and word fusion according to claim 1, characterized in that: The original text of the Chinese electronic medical records is classified, that is: if the character in the text is at the beginning of the matching word, the matching word is placed in the word set B; if the character in the text is in the middle of the matching word, the matching word is placed in the word set M; if the character in the text is at the end of the matching word, the matching word is placed in the word set E; if the character in the text itself is a matching word, the matching word is placed in the word set S; obtain the word set B, word set M, word set E and word set S of each character, compress each word set into a vector of fixed dimension, and then concatenate the four word sets to obtain the lexical feature vector corresponding to the character, expressed as: l i =[v(B(x i ));v(M(x i ));v(E(x i ));v(S(x i ))],l i ∈R 4d Among them, l i represents the vocabulary feature vector corresponding to the ith Chinese character in the original text of the Chinese electronic medical record; v(B(x i ))、v(M(x i ))、v(E(x i ))、v(S(x i )) are respectively a vector of fixed dimension compressed from word set B, word set M, word set E, and word set S; d represents the dimension of a vector after word set compression; e w (w) is the word vector representation of the matching word w, z(w) represents the frequency of occurrence of the matching word w in the dictionary in the statistical data, Z represents the sum of z(w) of all words in the four word sets B, M, E and S; s represents a set in the four word sets B, M, E and S, that is, s∈{word set B, word set M, word set E, word set S}, and w represents a word belonging to a certain word set.
6. The medical named entity recognition method based on graph attention network and word fusion according to claim 1, characterized in that: When constructing a directed graph, each word feature and vocabulary feature is used as a node in the directed graph. The i-th word feature points to the i-th vocabulary feature corresponding to it, and the i-th vocabulary feature points to the i-th word feature corresponding to it. There is an edge relationship between two nodes with a pointing relationship. If there is no pointing relationship between the two nodes, there is no edge relationship.
7. The medical named entity recognition method based on graph attention network and word fusion according to claim 1, characterized in that: The process of weighting the node vector representation according to the attention coefficient includes: Take a character feature as a node and a word feature as a node. If there are N nodes in total, unify the dimension of each node to d, then the i-th node is represented as h i , the vectors of all nodes are represented as: h = {h1,h2,...,h N }; The similarity coefficient between a node and its adjacent nodes is calculated. The obtained similarity coefficient is then used to calculate the attention coefficient through the softmax operation. The similarity coefficient between a node and its adjacent nodes is expressed as: e ij =a T [Wh i ||Wh j ],j∈N i ; Among them, a and W are trainable parameters, || represents the concatenation operation; N i represents all nodes adjacent to node i, that is, all nodes that have an edge relationship with node i; According to the attention coefficient, the feature vector is weighted and summed, and the feature of the weighted node i is expressed as: Among them, h i ' is the vector representation of the i-th node after being processed by the graph attention network; α ij represents the attention coefficient of the j-th node to the i-th node; σ(·) represents the Sigmoid function.
Citation Information
Patent Citations
Named entity identification method for word fusion based on label guidance
CN112699685A
Visual rich document information extraction method for actual OCR scene
CN112801010A
Named entity recognition method and device based on hybrid lattice self-attention network
CN114429132A
Myocardial infarction entity recognition method based on word fusion representation and graph attention network
CN115130468A
Entity identification method and apparatus, device and storage medium
WO2022078102A1
