Biomedical word sense disambiguation based on two-channel circulation capsule neural network
Through the dual-channel recurrent capsule neural network, combined with the Bert model and multi-head attention mechanism, the problem of limitations of biomedical word meaning disambiguation characteristics and poor classifier effect in traditional methods is solved, and high-accurate word meaning classification and disambiguation are achieved Effect.
Patent Information
- Application Number
- CN202411016458.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-27
- Publication Date
- 2024-11-22
AI Technical Summary
The traditional biomedical word meaning disambiguation method has characteristic limitations and poor classifier training effect, making it difficult to effectively deal with ambiguity in biomedical texts.
A dual-channel recurrent capsule neural network is adopted, and the model is optimized to improve the accuracy of word meaning disambiguation through part-of-speech annotation, semantic annotation, Bert model vectorization processing and multi-head attention mechanism, combined with dynamic routing algorithms and capsule networks.
High-quality disambiguation feature extraction and word meaning classification are achieved, which improves the accuracy of biomedical word meaning disambiguation and the interpretability of the network, reduces errors and updates parameters through backpropagation, and improves the overall disambiguation effect.
Smart Images

Figure QLYQS_1 
Figure QLYQS_3 
Figure QLYQS_4
Abstract
Description
Technical field:
[0001] The invention relates to a biomedical word sense disambiguation method of a dual-channel recurrent capsule neural network, which has good application in the biomedical field. Background technology:
[0002] In biomedical texts, words generally have polysemy. The purpose of word sense disambiguation is to determine the semantic category of ambiguous words in a specific context. Word sense disambiguation has important applications in information retrieval, machine translation, and automatic summarization. At present, some methods commonly used in word sense disambiguation include: SVM, maximum entropy, and naive Bayes classifier. However, traditional methods have some shortcomings and deficiencies. The extracted disambiguation features are limited to local areas, and the training effect of the classifier is not very good. In recent years, deep learning algorithms have been widely used in the field of natural language processing. The advantages of capsule recurrent neural networks are that they can process sequence data and capture sequence correlations in text data, and they use capsule units to encode patterns and features, which improves the interpretability of the network, and can better disambiguate the input text, effectively model text data, and improve the accuracy of word sense disambiguation. For biomedical ambiguous words, capsule recurrent neural networks can be well applied for disambiguation to achieve correct semantic classification. Summary of the invention:
[0003] In order to solve the lexical ambiguity problem in the biomedical field, the present invention discloses a biomedical word sense disambiguation method of a dual-channel recurrent capsule neural network.
[0004] To this end, the present invention provides the following technical solutions.
[0005] 1. Biomedical word sense disambiguation using a dual-channel recurrent capsule neural network, the method comprising the following steps:
[0006] Step 1: Tag all sentences in the biomedical corpus with part-of-speech and semantic category tags;
[0007] Step 2: Set the word window size and ambiguous words, move the word window from left to right, calculate the total frequency of other words in the word window where the ambiguous words will appear during the word window movement, select the words with the highest total frequency and use their parts of speech and semantic classes as disambiguation features;
[0008] Step 3: Divide the processed biomedical corpus into training data and test data in a ratio of 7:3, and use the Bert model to vectorize the training data and test data;
[0009] Step 4: The training includes two processes, forward propagation and back propagation, and the training data is used to optimize the dual-channel recurrent capsule neural network;
[0010] Step 5: The test process is a forward propagation process, that is, a semantic classification process. The test data is input into the optimized dual-channel recurrent capsule neural network, and the probability distribution sequence of ambiguous words in each semantic category is calculated. The semantic category with the maximum probability is taken as the semantic category of the ambiguous word.
[0011] 2. The biomedical word sense disambiguation of the dual-channel recurrent capsule neural network according to claim 1 is characterized in that in step 1, all sentences in the biomedical corpus are tagged with part of speech and semantic class, specifically:
[0012] Step 1-1: Use part-of-speech tagging tools to tag all biomedical sentences;
[0013] Step 1-2 uses semantic class annotation tools to semantically annotate the words in all biomedical sentences;
[0014] 3. The biomedical word sense disambiguation of the dual-channel recurrent capsule neural network according to claim 1 is characterized in that in the step 2, the word window size and the ambiguous word are set, the word window is moved from left to right, the total word frequency of other words in the word window where the ambiguous word will appear during the word window movement is calculated, the words with the highest total word frequency are selected, and their parts of speech and semantic classes are used as disambiguation features, specifically:
[0015] Step 2-1: Set the word window size and ambiguous words;
[0016] Step 2-2: Move the word window from left to right, and calculate the frequency of words other than ambiguous words in the word window where ambiguous words will appear during the word window movement:
[0017]
[0018] Among them, num w represents the number of times word w appears in the word window, l w Represents the distance between word w and the ambiguous word;
[0019] 4. The biomedical word sense disambiguation of the dual-channel recurrent capsule neural network according to claim 1, characterized in that in the step 3, the processed biomedical corpus is divided into training data and test data according to a ratio of 7:3, and the training data and the test data are vectorized using the Bert model, specifically:
[0020] Step 3-1 randomly divides the processed biomedical corpus into training data and test data in a ratio of 7:3;
[0021] Step 3-2 uses the Bert model to vectorize the word form, part of speech, and word meaning in the training data and test data, respectively. Specifically:
[0022] Step 3-2-1 Use tokenizer.encode to convert the input text sequence into the corresponding id sequence in the BERT vocabulary, and add the [CLS] and [SEP] symbols;
[0023] Step 3-2-2 The calculation of Bert’s input is as follows:
[0024] Input(i)=Embedding(t i )+PE(i)+Segment(t i )
[0025] Among them, Embedding(W i ) indicates that W i The operation of mapping to word vectors, PE(i) represents position encoding, which is used to add the information of each position to the word vector of the corresponding position, Segment(W i ) represents sentence coding, which is used to distinguish words in different sentences;
[0026] Step 3-2-3 Input (i) passes through the multi-layer Encoder encoder in Bert, and the contextual information and semantic information of the input corpus are modeled by stacking to generate the feature matrix X;
[0027] Step 3-2-4 divides the feature matrix of the corpus into several groups of 5;
[0028] 5. The biomedical word sense disambiguation of the dual-channel recurrent capsule neural network according to claim 1, characterized in that in step 4, the dual-channel recurrent capsule neural network is optimized using training data, specifically:
[0029] Step 4-1 inputs the feature matrix X of the current batch of training data into the GRU layer and calculates the output of the GRU layer, specifically:
[0030] Step 4-1-1 Calculate the update gate z in the GRU layer t and reset gate b r ,as follows:
[0031] z t =σ(W z [h t-1 ,X t +b z ])
[0032] r t =σ(W r [ht-1 ,X t +b t ])
[0033] Among them, σ represents the sigmoid function, W r represents the weight matrix, b r is the reset gate, r t is the bias term, X t represents the input at time t, W z Represents input X t With update gate Z t The relevant weight matrix of
[0034] Step 4-1-2 Calculate the candidate hidden state at time t as follows:
[0035]
[0036] Among them, h t Represents the candidate hidden state at time t, tanh() is the hyperbolic tangent function;
[0037] Step 4-1-3 Use the hidden state h at time t-1 t-1 and the candidate hidden state h at time t t Calculate the hidden state h at time t t ,as follows:
[0038]
[0039] Step 4-1-4 Repeat steps 4-1-1 to 4-1-3 max_length times, and combine the output at each moment as the output h of the GRU layer t ;
[0040] Step 4-2 inputs the feature matrix X of the current batch of training data into the convolution layer, and uses a convolution kernel of size n×n to perform a convolution operation to obtain the output C′ of the TextCNN layer, as follows:
[0041]
[0042] C′=maxpool(C)
[0043] in, represents the convolution operation, f represents the activation function, W represents the weight matrix of the TextCNN layer, b represents the bias, C represents the convolution result, and maxpool represents the pooling operation;
[0044] Step 4-3 uses torch.cat() to compute the semantic features h output by C′ and GRU layer. tThe feature matrix M is obtained by fusion in the second dimension as follows:
[0045] M = torch.cat(C′,h t )
[0046] Step 4-4 inputs the feature matrix M into the Multi-Head Attention layer to calculate the attention, specifically:
[0047] Step 4-4-1 Split the feature matrix M into M1, M2, …, M n , corresponding to n heads respectively;
[0048] Step 4-4-2Q i =M i , K i =M i 、V i =M i ;
[0049] Step 4-4-3 Calculate the attention head of the i-th head i ,as follows:
[0050]
[0051] Among them, Q represents query, K represents key, V represents value, and d k Represents the dimension of the attention mechanism;
[0052] Step 4-4-4 concatenates the attention results obtained by each head into a matrix to obtain the output Att_output of the multi-head attention layer, as follows:
[0053] Att_output=Concat(head1,....,head n )
[0054] Step 4-5 inputs Att_output into the capsule layer and calculates the output of the capsule layer, specifically:
[0055] Step 4-5-1 Divide Att_output into V1, V2, …, V n As the input of the capsule network;
[0056] Step 4-5-2 Use torch.matmul to initialize the prediction vector U of the capsule network i and routing weight W i ;
[0057] Step 4-5-3 iterates the dynamic routing algorithm three times, specifically:
[0058] Step 4-5-3-1Ui The calculation process is as follows:
[0059] U i =V i *W i
[0060] Step 4-5-3-2 uses the softmax function to calculate the weight c of the output of the i-th capsule to the input of the j-th capsule i,j ,as follows:
[0061]
[0062] Among them, num_capsule represents the number of capsules, b i,j Represents the similarity between the i-th capsule and the j-th capsule;
[0063] Step 4-5-3-3 Calculate S j ,as follows:
[0064]
[0065] Step 4-5-3-4 Use the squash function to j Normalize as follows:
[0066]
[0067] Among them, a j represents the output of the j-th routing algorithm;
[0068] Step 4-5-3-5 Using a j To update b i,j ,as follows:
[0069] b i,j =b i,j +a j *U i
[0070] Step 4-5-4: The output of the capsule network is a3;
[0071] Step 4-6 inputs a3 into the classification layer and obtains the probability distribution vector d through linear transformation;
[0072] Step 4-7 uses the softmax layer to calculate the ambiguous word m in the semantic category s i The predicted probability P(s) under (i=1,2,...,n) i |m)(i=1,2,…,n), as follows:
[0073]
[0074] Among them, di is the i-th component of the probability distribution vector d;
[0075] Step 4-8 From P(s1|m), P(s2|m), ..., P(s n |m) selects the maximum probability as the predicted semantic category probability of ambiguous word m:
[0076]
[0077] Among them, y_predicted j Represents the predicted semantic category probability of the ambiguous word m;
[0078] Step 4-9 uses the cross entropy loss function to calculate the error loss as follows:
[0079]
[0080] Among them, y j Indicates that the ambiguous word m belongs to the semantic category s i The true probability of
[0081] Steps 4-10 are back-propagated according to the error loss, and the parameters are updated layer by layer as follows:
[0082]
[0083] Among them, θ represents the parameter set, θ′ represents the updated parameter set, and α is the learning rate;
[0084] Step 4-11: Continuously execute steps 4-1 to 4-10 until all batches of training data are used up, and an optimized dual-channel recurrent capsule neural network is obtained;
[0085] 6. The biomedical word sense disambiguation of the dual-channel recurrent capsule neural network according to claim 1, characterized in that in step 5, the ambiguous words m in the test data are semantically classified using the optimized dual-channel recurrent capsule neural network, specifically:
[0086] Step 5-1 inputs the feature matrix X of the current batch of test data into the GRU layer and calculates the output of the GRU layer, specifically:
[0087] Step 5-1-1 Calculate the update gate z in the GRU layer t and reset gate b r ,as follows:
[0088] z t =σ(W z [h t-1 ,X t +b z ])
[0089] r t =σ(W r [h t-1 ,X t +b t ])
[0090] Among them, σ represents the sigmoid function, W r represents the weight matrix, b r is the reset gate, r t is the bias term, X t represents the input at time t, W z Represents input X t With update gate Z t The relevant weight matrix of
[0091] Step 5-1-2 Calculate the candidate hidden state at time t as follows:
[0092]
[0093] Among them, h t Represents the candidate hidden state at time t, tanh() is the hyperbolic tangent function;
[0094] Step 5-1-3 Use the hidden state h at time t-1 t-1 and the candidate hidden state h at time t t Calculate the hidden state h at time t t ,as follows:
[0095]
[0096] Step 5-1-4 Repeat steps 5-1-1 to 5-1-3 max_length times, and combine the output at each moment as the output h of the GRU layer t ;
[0097] Step 5-2 inputs the feature matrix X of the current batch of training data into the convolution layer, and uses a convolution kernel of size n×n to perform a convolution operation to obtain the output C′ of the TextCNN layer, as follows:
[0098]
[0099] C′=maxpool(C)
[0100] in, represents the convolution operation, f represents the activation function, W represents the weight matrix of the TextCNN layer, b represents the bias, C represents the convolution result, and maxpool represents the pooling operation;
[0101] Step 5-3 uses torch.cat() to compute the semantic features h output by C′ and GRU layer t The feature matrix M is obtained by fusion in the second dimension as follows:
[0102] M = torch.cat(C′,h t )
[0103] Step 5-4 inputs the feature matrix M into the Multi-Head Attention layer to calculate the attention, specifically:
[0104] Step 5-4-1 Split the feature matrix M into M1, M2, …, M n , corresponding to n heads respectively;
[0105] Step 5-4-2Q i =M i , K i =M i 、V i =M i ;
[0106] Step 5-4-3 Calculate the attention head of the i-th head i ,as follows:
[0107]
[0108] Among them, Q represents query, K represents key, V represents value, and d k Represents the dimension of the attention mechanism;
[0109] Step 5-4-4 concatenates the attention results obtained by each head into a matrix to obtain the output Att_output of the multi-head attention layer, as follows:
[0110] Att_output=Concat(head1,....,head n )
[0111] Step 5-5 inputs Att_output into the capsule layer and calculates the output of the capsule layer, specifically:
[0112] Step 5-5-1 Divide Att_output into V1, V2, …, V n As the input of the capsule network;
[0113] Step 5-5-2 Use torch.matmul to initialize the prediction vector U of the capsule network i and routing weight W i ;
[0114] Step 5-5-3 iterates the dynamic routing algorithm three times, specifically:
[0115] Step 5-5-3-1U i The calculation process is as follows:
[0116] U i =V i *W i
[0117] Step 5-5-3-2 uses the softmax function to calculate the weight c of the output of the i-th capsule to the input of the j-th capsule i,j ,as follows:
[0118]
[0119] Among them, num_capsule represents the number of capsules, b i,j Represents the similarity between the i-th capsule and the j-th capsule;
[0120] Step 5-5-3-3 Calculate S j ,as follows:
[0121]
[0122] Step 5-5-3-4 Use the squash function to j Normalize as follows:
[0123]
[0124] Among them, a j represents the output of the j-th routing algorithm;
[0125] Step 5-5-3-5 Using a j To update b i,j ,as follows:
[0126] b i,j =b i,j +a j *U i
[0127] Step 5-5-4: The output of the capsule network is a3;
[0128] Step 5-6: Input a3 into the classification layer and obtain the probability distribution vector d through linear transformation;
[0129] Step 5-7 uses the softmax layer to calculate the ambiguous word m in the semantic category s i The predicted probability P(s) under (i=1,2,...,n) i |m)(i=1,2,…,n), as follows:
[0130]
[0131] Among them, d i is the i-th component of the probability distribution vector d;
[0132] Step 5-8 selects the semantic category with the maximum probability as the predicted semantic category s of the ambiguous word m, as follows:
[0133]
[0134] Step 5-9 continuously executes step 5-1 to step 5-8 until all batches of test data are used up.
[0135] Beneficial effects:
[0136] The present invention is a biomedical word sense disambiguation of a dual-channel recurrent capsule neural network.
[0137] 1. Perform part-of-speech tagging and semantic class tagging on sentences containing ambiguous words. Use Bert to vectorize word form, part-of-speech, and semantic class respectively. The extracted disambiguation features are of high quality.
[0138] 2. The network used in the present invention is a dual-channel recurrent capsule neural network, the biggest feature of which is that the recurrent structure of the capsule network can achieve long-term memory and correct classification. No need to manually select data features, as long as the dual-channel recurrent capsule neural network is trained, a good word sense disambiguation effect can be obtained.
[0139] 3. When training the network, the stochastic gradient descent method is used to update the parameters. By calculating the error, the error is used to return along the original route through back propagation, that is, from the output layer through each intermediate hidden layer, and the parameters of each layer are updated layer by layer, and finally return to the input layer. Forward propagation and back propagation are continuously performed to reduce the error and update the model parameters until the dual-channel recurrent capsule neural network is trained. As the error back propagation continuously updates the parameters, the accuracy of the entire dual-channel recurrent capsule neural network in disambiguating the input data will also be improved.
[0140] 4. The present invention is based on the public biomedical word sense disambiguation corpus MSH to verify the method proposed in the present invention. The results show that the present invention has high accuracy. Description of the drawings:
[0141] Figure 1 Flow chart of biomedical word sense disambiguation of a dual-channel recurrent capsule neural network in an embodiment of the present invention
[0142] Figure 2Schematic diagram of the training process of biomedical word sense disambiguation of a dual-channel recurrent capsule neural network in an embodiment of the present invention
[0143] Figure 3 Schematic diagram of the test process of biomedical word sense disambiguation of a dual-channel recurrent capsule neural network in an embodiment of the present invention Specific implementation method:
[0144] In order to make the technical solutions in the embodiments of the present invention clearly and completely described, the test sentence "Kinetic mechanism of DNA unwinding by the BLM helicase core and molecular basis for its low processivity" containing the biomedical ambiguous word "BLM" is taken as an example, and the present invention is further described in detail in combination with the drawings in the embodiments. The biomedical ambiguous word "BLM" has two semantic categories, s1 = Bloom's syndrome protein, s2 = bleomycin. The training data of "BLM" has a total of 139 sentences, and the test data of "BLM" has a total of 59 sentences.
[0145] The flowchart of the biomedical word sense disambiguation of the dual-channel recurrent capsule neural network according to the embodiment of the present invention is as follows: Figure 1 As shown, the following steps are included:
[0146] Step 1: Process the sentence “Kinetic mechanism of DNA unwinding by the BLM helicase core and molecular basis for its lowprocessivity” containing the biomedical ambiguous word “BLM”. The steps are as follows:
[0147] Step 1-1 Use the part-of-speech tagging tool to tag all biomedical sentences. The results are as follows:
[0148] Part-of-speech tagging: Kinetic / JJ mechanism / NN of / IN DNA / NNP unwinding / NN by / INthe / DT BLM / NNP helicase / NN core / NN and / CC;
[0149] Step 1-2 uses the semantic class annotation tool to semantically annotate the biomedical words in all biomedical sentences. The results are as follows:
[0150] Semantic class annotation: Kinetic / JJ / kinetic.a.01mechanism / NN / mechanism.n.01of / IN / -1DNA / NNP / deoxyribonucleic_acid.n.01unwinding / NN / unwind.v.01by / IN / by.r.01the / DT / -1BLM / NNP / -1helicase / NN / -1core / NN / core.n.01and / CC / -1;
[0151] Step 2 calculates the total frequency of other words in the word window where the ambiguous word will appear during the word window movement, selects the words with the highest total frequency, and uses their parts of speech and semantic classes as disambiguation features, specifically:
[0152] Step 2-1 sets the word window size to 3 and the biomedical ambiguous vocabulary to BLM;
[0153] Step 2-2 moves the word window from left to right, and calculates the frequency of words other than ambiguous words in the word window where ambiguous words will appear during the word window movement. The results are as follows:
[0154]
[0155] (the,3), (helicase,10), (core,10), (by,3);
[0156] Step 3 uses the Bert model to vectorize the training data and test data, specifically:
[0157] Step 3-1 randomly divides the processed biomedical corpus into training data and test data in a ratio of 7:3;
[0158] Step 3-2 uses the Bert model to vectorize the word form, part of speech, and word meaning in the training data and test data, respectively. Specifically:
[0159] Step 3-2-1 Use tokenizer.encode to convert the input text sequence into the corresponding id sequence in the BERT vocabulary, and add the [CLS] and [SEP] symbols;
[0160] Step 3-2-2 The calculation of Bert’s input is as follows:
[0161] Input(i)=Embedding(t i )+PE(i)+Segment(t i )
[0162] Among them, Embedding(W i ) indicates that W i The operation of mapping to word vectors, PE(i) represents position encoding, which is used to add the information of each position to the word vector of the corresponding position, Segment(W i ) represents sentence coding, which is used to distinguish words in different sentences;
[0163] Step 3-2-3 Input(i) passes through the multi-layer Encoder encoder in Bert, and the contextual information and semantic information of the input corpus are modeled by stacking to generate the feature matrix X as follows:
[0164] X=tensor([[[[0.6571,-0.1294,0.5947,...,-0.3042,0.6505,0.6167],[-0.5688,-0.5995,-0.0630, ...,-0.3121,0.0935,0.2767],...,[-1.4341,-0.8592,-0.4891,...,-0.1431,0.2498,0.3636]]]);
[0165] Step 3-2-4 divides the feature matrix of the corpus into several groups of 5;
[0166] Step 4: Use the training data to optimize the two-channel recurrent capsule neural network, specifically:
[0167] Step 4-1 inputs the feature matrix X of the current batch of training data into the GRU layer and calculates the output of the GRU layer, specifically:
[0168] Step 4-1-1 Calculate the update gate z in the GRU layer t and reset gate b r ,as follows:
[0169] z t =σ(W z [h t-1 ,X t +b z ])
[0170] r t =σ(W r [h t-1 ,X t +b t ])
[0171] Among them, σ represents the sigmoid function, W r represents the weight matrix, b r is the reset gate, r t is the bias term, Xt represents the input at time t, W z Represents input X t With update gate Z t The relevant weight matrix of
[0172] Step 4-1-2 Calculate the candidate hidden state at time t as follows:
[0173]
[0174] Among them, h t Represents the candidate hidden state at time t, tanh() is the hyperbolic tangent function;
[0175] Step 4-1-3 Use the hidden state h at time t-1 t-1 and the candidate hidden state h at time t t Calculate the hidden state h at time t t ,as follows:
[0176]
[0177] Step 4-1-4 Repeat steps 4-1-1 to 4-1-3 max_length times, and combine the output at each moment as the output h of the GRU layer t ,as follows:
[0178] h t =tensor([[[0.6571,-0.1294,0.5947,...,-0.3042,0.6505,0.6167],[-0.5688,
[0179] -0.5995,-0.0630,...,-0.3121,0.0935,0.2767],...,[-1.4341,-0.8592,-0.4891,...,-0.1431,0.2498,0.3636]]]);
[0180] Step 4-2 inputs the feature matrix X of the current batch of training data into the convolution layer, and uses a convolution kernel of size n×n to perform a convolution operation to obtain the output C′ of the TextCNN layer, as follows:
[0181]
[0182] C′=maxpool(C)
[0183] in, represents the convolution operation, f represents the activation function, W represents the weight matrix of the TextCNN layer, b represents the bias, C represents the convolution result, maxpool represents the pooling operation, and the calculation result of C′ is as follows:
[0184] C′=tensor([[[1.6608e-01,-1.9116e-01,-1.8075e-01,...,4.8323e-01,4.3544e-01,1.6120e-01],[-1.0040e-01,4.6077e-01,-9.7891e-0 2,...,3.5548e-01,3.3140e-01,6.7565e-02],[-2.0531e-01,-1.4097e-01,4.6273e-02,...,-2.3069e-01,4.1694e-01,2.9945e-02],...);
[0185] Step 4-3 uses torch.cat() to compute the semantic features h output by C′ and GRU layer. t The feature matrix M is obtained by fusion in the second dimension as follows:
[0186] M = torch.cat(C′,h t ),
[0187] The calculation result of M is as follows:
[0188] M=tensor([[[1.6608e-01,-1.9116e-01,-1.8075e-01,...,-1.6954e-01,1.2304e-01,-1.3469e-01],[-1.0040e-01,4.6077e-01,-9.7891e -02,...,3.4539e-03,3.4095e-02,-8.5425e-02],[-2.0531e-01,-1.4097e-01,4.6273e-02,...,-1.4437e-01,4.1055e-04,-6.5629e-02]);
[0189] Step 4-4 inputs the feature matrix M into the Multi-Head Attention layer to calculate the attention, specifically:
[0190] Step 4-4-1 Split the feature matrix M into M1, M2, …, M n , corresponding to n heads respectively;
[0191] Step 4-4-2Q i =M i , Ki =M i 、V i =M i ;
[0192] Step 4-4-3 Calculate the attention head of the i-th head i ,as follows:
[0193]
[0194] Among them, Q represents query, K represents key, V represents value, and d k Represents the dimension of the attention mechanism;
[0195] Step 4-4-4 concatenates the attention results obtained by each head into a matrix to obtain the output Att_output of the multi-head attention layer, as follows:
[0196] Att_output=Concat(head1,....,head n ),
[0197] The calculation result of Att_output is as follows:
[0198] Att_output=tensor([[[-0.0170,0.0616,0.0347,...,-0.0600,-0.0482,0.0434],[-0.0169,0.0614,0. 0347,…,-0.0597,-0.0480,0.0437],…,[-0.0154,0.0617,0.0342,…,-0.0597,-0.0486,0.0439]]]);
[0199] Step 4-5 inputs Att_output into the capsule layer and calculates the output of the capsule layer, specifically:
[0200] Step 4-5-1 Divide Att_output into V1, V2, …, V n As the input of the capsule network;
[0201] Step 4-5-2 Use torch.matmul to initialize the prediction vector U of the capsule network i and routing weight W i ;
[0202] Step 4-5-3 iterates the dynamic routing algorithm three times, specifically:
[0203] Step 4-5-3-1U i The calculation process is as follows:
[0204] U i =V i *W i
[0205] Step 4-5-3-2 uses the softmax function to calculate the weight c of the output of the i-th capsule to the input of the j-th capsule i,j ,as follows:
[0206]
[0207] Among them, num_capsule represents the number of capsules, b i,j Represents the similarity between the i-th capsule and the j-th capsule;
[0208] Step 4-5-3-3 Calculate S j ,as follows:
[0209]
[0210] Step 4-5-3-4 Use the squash function to j Normalize as follows:
[0211]
[0212] Among them, a j represents the output of the j-th routing algorithm;
[0213] Step 4-5-3-5 Using a j To update b i,j ,as follows:
[0214] b i,j =b i,j +a j *U i
[0215] Step 4-5-4 The capsule network output is a3, as follows:
[0216] a3=tensor([[[0.0377,-0.0593,-0.2287,0.0519,-0.0273,0.4065,0.1237,-0.1059,
[0217] 0.0692,-0.0669,-0.0338,0.2063,0.1140,0.1295,0.0589,0.3401,0.1104,-0.0800,-0.0834,0.4019,-0.2337,0.0715,-0.1768,0.1080,-0.0444]]]);
[0218] Step 4-6 inputs a3 into the classification layer and obtains the probability distribution vector d through linear transformation;
[0219] Step 4-7 uses the softmax layer to calculate the ambiguous word m in the semantic category s i The predicted probability P(s) under (i=1,2,...,n) i |BLM)(i=1,2,…,n), as follows:
[0220]
[0221] Among them, d i is the i-th component of the probability distribution vector d;
[0222] Step 4-8 From P(s1|m), P(s2|m), ..., P(s n |BLM) selects the maximum probability as the predicted semantic category probability of the ambiguous word BLM:
[0223]
[0224] Among them, y_predicted j Represents the predicted semantic category probability of the ambiguous word BLM;
[0225] Step 4-9 uses the cross entropy loss function to calculate the error loss as follows:
[0226]
[0227] Among them, y j Indicates that the ambiguous word BLM belongs to the semantic category s i The true probability of
[0228] Steps 4-10 are back-propagated according to the error loss, and the parameters are updated layer by layer as follows:
[0229]
[0230] Among them, θ represents the parameter set, θ′ represents the updated parameter set, and α is the learning rate;
[0231] Step 4-11: Continuously execute steps 4-1 to 4-10 until all batches of training data are used up, and an optimized dual-channel recurrent capsule neural network is obtained;
[0232] Step 5: Use the optimized dual-channel recurrent capsule neural network to semantically classify the ambiguous vocabulary BLM in the test data. The specific process is as follows:
[0233] Step 5-1 inputs the feature matrix X of the current batch of test data into the GRU layer and calculates the output of the GRU layer, specifically:
[0234] Step 5-1-1 Calculate the update gate z in the GRU layer t and reset gate b r ,as follows:
[0235] z t =σ(W z [h t-1 ,X t +b z ])
[0236] r t =σ(W r [h t-1 ,X t +b t ])
[0237] Among them, σ represents the sigmoid function, W r represents the weight matrix, b r is the reset gate, r t is the bias term, X t represents the input at time t, W z Represents input X t With update gate Z t The relevant weight matrix of
[0238] Step 5-1-2 Calculate the candidate hidden state at time t as follows:
[0239]
[0240] Among them, h t Represents the candidate hidden state at time t, tanh() is the hyperbolic tangent function;
[0241] Step 5-1-3 Use the hidden state h at time t-1 t-1 and the candidate hidden state h at time t t Calculate the hidden state h at time t t ,as follows:
[0242]
[0243] Step 5-1-4 Repeat steps 5-1-1 to 5-1-3 max_length times, and combine the output at each moment as the output h of the GRU layer t ,as follows:
[0244] h t=tensor([[[-0.3126,0.0919,-0.0333,...,-0.4758,0.6554,0.0783],[-0.0433,
[0245] 0.0752,-0.1998,...,-0.1238,-0.0963,0.3949],[-0.0359,-0.1071,0.0689,...,-0.1740,0.3918,0.3039],...,[0.2642,-0.0298,0.3326,...,0.3246,-0.0445,0.1004]]);
[0246] Step 5-2 inputs the feature matrix X of the current batch of training data into the convolution layer, and uses a convolution kernel of size n×n to perform a convolution operation to obtain the output C′ of the TextCNN layer, as follows:
[0247]
[0248] C′=maxpool(C)
[0249] in, represents the convolution operation, f represents the activation function, W represents the weight matrix of the TextCNN layer, b represents the bias, C represents the convolution result, maxpool represents the pooling operation, and the calculation result of C′ is as follows:
[0250] C′=tensor([[[1.6608e-01,-1.9116e-01,-1.8075e-01,...,-1.6954e-01,1.2304e-01,-1.3469e-01],[-1.0040e-01,4.6077e-01,-9.7891e-0 2,...,3.4539e-03,3.4095e-02,-8.5425e-02],[-2.0531e-01,-1.4097 e-01,4.6273e-02,...,-1.4437e-01,4.1055e-04,-6.5629e-02],...);
[0251] Step 5-3 uses torch.cat() to compute the semantic features h output by C′ and GRU layer t The feature matrix M is obtained by fusion in the second dimension as follows:
[0252] M = torch.cat(C′,h t ),
[0253] The calculation result of M is as follows:
[0254] M=tensor([[[1.6608e-01,-1.9116e-01,-1.8075e-01,...,-1.6954e-01,1.2304e-01,-1.3469e-01],[-1.0040e-01,4.6077e-01,-9.7891e -02,...,3.4539e-03,3.4095e-02,-8.5425e-02],[-2.0531e-01,-1.4097e-01,4.6273e-02,...,-1.4437e-01,4.1055e-04,-6.5629e-02]);
[0255] Step 5-4 inputs the feature matrix M into the Multi-Head Attention layer to calculate the attention, specifically:
[0256] Step 5-4-1 Split the feature matrix M into M1, M2, …, M n , corresponding to n heads respectively;
[0257] Step 5-4-2Q i =M i , K i =M i 、V i =M i ;
[0258] Step 5-4-3 Calculate the attention head of the i-th head i ,as follows:
[0259]
[0260] Among them, Q represents query, K represents key, V represents value, and d k Represents the dimension of the attention mechanism;
[0261] Step 5-4-4 concatenates the attention results obtained by each head into a matrix to obtain the output Att_output of the multi-head attention layer, as follows:
[0262] Att_output=Concat(head1,....,head n ),
[0263] The calculation result of Att_output is as follows:
[0264] Att_output=tensor([[[-0.0503,-0.0334,0.0743,...,-0.0696,-0.0264,-0.0754],[-0.0502,-0.0330,0.0736,...,-0.0693,-0.0267,-0 .0749],[-0.0501,-0.0334,0.0744,...,-0.0699,-0.0266,-0.0755],...,[-0.0503,-0.0337,0.0747,...,-0.0700,-0.0266,-0.0751]]);
[0265] Step 5-5 inputs Att_output into the capsule layer and calculates the output of the capsule layer, specifically:
[0266] Step 5-5-1 Divide Att_output into V1, V2, …, V n As the input of the capsule network;
[0267] Step 5-5-2 Use torch.matmul to initialize the prediction vector U of the capsule network i and routing weight W i ;
[0268] Step 5-5-3 iterates the dynamic routing algorithm three times, specifically:
[0269] Step 5-5-3-1U i The calculation process is as follows:
[0270] U i =V i *W i
[0271] Step 5-5-3-2 uses the softmax function to calculate the weight c of the output of the i-th capsule to the input of the j-th capsule i,j ,as follows:
[0272]
[0273] Among them, num_capsule represents the number of capsules, b i,j Represents the similarity between the i-th capsule and the j-th capsule;
[0274] Step 5-5-3-3 Calculate S j ,as follows:
[0275]
[0276] Step 5-5-3-4 Use the squash function toj Normalize as follows:
[0277]
[0278] Among them, a j represents the output of the j-th routing algorithm;
[0279] Step 5-5-3-5 Using a j To update b i,j ,as follows:
[0280] b i,j =b i,j +a j *U i
[0281] Step 5-5-4: The output of the capsule network is a3;
[0282] a3=tensor([[[-0.0503,-0.0334,0.0743,...,-0.0696,-0.0264,-0.0754],[-0.0502,
[0283] -0.0330,0.0736,...,-0.0693,-0.0267,-0.0749],...,[-0.0503,-0.0337,0.0747,...,-0.0700,-0.0266,-0.0751]]]);
[0284] Step 5-6: Input a3 into the classification layer and obtain the probability distribution vector d through linear transformation;
[0285] Step 5-7 uses the softmax layer to calculate the ambiguous word m in the semantic category s i The predicted probability P(s) under (i=1,2,...,n) i |BLM)(i=1,2,…,n), as follows:
[0286]
[0287] Among them, d i is the i-th component of the probability distribution vector d;
[0288] Step 5-8 selects the semantic category with the maximum probability as the predicted semantic category s of the ambiguous word BLM, as follows:
[0289]
[0290] Step 5-9 continuously executes step 5-1 to step 5-8 until all batches of test data are used up.
[0291] The word sense disambiguation model of the optimized dual-channel recurrent capsule neural network was used to perform word sense disambiguation on the test sentence "Kinetic mechanism of DNA unwinding by the BLM helicase coreand molecular basis for its low processivity" containing the biomedical ambiguous word "BLM". The semantic category corresponding to the biomedical ambiguous word "BLM" is s1 = Lum syndrome protein.
[0292] The optimized dual-channel recurrent capsule neural network word sense disambiguation model was used to disambiguate "BLM" in all test data, with an accuracy rate of 96.61%.
[0293] The above is a detailed description of the embodiments of the present invention in conjunction with the accompanying drawings, and the specific implementation methods herein are only used to help understand the method of the present invention. For those of ordinary skill in the art, according to the idea of the present invention, changes and modifications can be made in the specific implementation methods and application scopes, so the present invention should not be understood as limiting the present invention.
Claims
1. Biomedical word sense disambiguation using a dual-channel recurrent capsule neural network, the method comprising the following steps: Step 1: Tag all sentences in the biomedical corpus with part-of-speech and semantic category tags; Step 2: Set the word window size and ambiguous words, move the word window from left to right, calculate the total frequency of other words in the word window where the ambiguous words will appear during the word window movement, select the words with the highest total frequency and use their parts of speech and semantic classes as disambiguation features; Step 3: Divide the processed biomedical corpus into training data and test data in a ratio of 7:3, and use the Bert model to vectorize the training data and test data; Step 4: The training includes two processes, forward propagation and back propagation, and the training data is used to optimize the dual-channel recurrent capsule neural network; Step 5: The test process is a forward propagation process, that is, a semantic classification process. The test data is input into the optimized dual-channel recurrent capsule neural network, and the probability distribution sequence of ambiguous words in each semantic category is calculated. The semantic category with the maximum probability is taken as the semantic category of the ambiguous word.
2. The biomedical word sense disambiguation of the dual-channel recurrent capsule neural network according to claim 1, characterized in that: In step 1, all sentences in the biomedical corpus are tagged with part of speech and semantic category, specifically: Step 1-1: Use part-of-speech tagging tools to tag all biomedical sentences; Step 1-2 uses semantic class annotation tools to semantically annotate the words in all biomedical sentences.
3. The biomedical word sense disambiguation of the dual-channel recurrent capsule neural network according to claim 1, characterized in that: In step 2, the word window size and ambiguous words are set, the word window is moved from left to right, the total word frequency of other words in the word window where the ambiguous words will appear during the word window movement is calculated, the words with the highest total word frequency are selected, and their parts of speech and semantic classes are used as disambiguation features, specifically: Step 2-1: Set the word window size and ambiguous words; Step 2-2: Move the word window from left to right, and calculate the frequency of words other than ambiguous words in the word window where ambiguous words will appear during the word window movement: Among them, num w represents the number of times word w appears in the word window, l w Represents the distance between word w and the ambiguous word.
4. The biomedical word sense disambiguation of the dual-channel recurrent capsule neural network according to claim 1, characterized in that: In step 3, the processed biomedical corpus is divided into training data and test data according to a ratio of 7:3, and the training data and test data are vectorized using the Bert model, specifically: Step 3-1 randomly divides the processed biomedical corpus into training data and test data in a ratio of 7:3; Step 3-2 uses the Bert model to vectorize the word form, part of speech, and word meaning in the training data and test data, respectively. Specifically: Step 3-2-1 Use tokenizer.encode to convert the input text sequence into the corresponding id sequence in the BERT vocabulary, and add the [CLS] and [SEP] symbols; Step 3-2-2 The calculation of Bert’s input is as follows: Input(i)=Embedding(t i )+PE(i)+Segment(t i ) Among them, Embedding(W i ) indicates that W i The operation of mapping to word vectors, PE(i) represents position encoding, which is used to add the information of each position to the word vector of the corresponding position, Segment(W i ) represents sentence coding, which is used to distinguish words in different sentences; Step 3-2-3 Input (i) passes through the multi-layer Encoder encoder in Bert, and the contextual information and semantic information of the input corpus are modeled by stacking to generate the feature matrix X; Step 3-2-4 divides the feature matrix of the corpus into several groups of 5.
5. The biomedical word sense disambiguation of the dual-channel recurrent capsule neural network according to claim 1, characterized in that: In step 4, the dual-channel recurrent capsule neural network is optimized using training data, specifically: Step 4-1 inputs the feature matrix X of the current batch of training data into the GRU layer and calculates the output of the GRU layer, specifically: Step 4-1-1 Calculate the update gate z in the GRU layer t and reset gate b r ,as follows: z t =σ(W z [h t-1 ,X t +b z ]) r t =σ(W r [h t-1 ,X t +b t ]) Among them, σ represents the sigmoid function, W r represents the weight matrix, b r is the reset gate, r t is the bias term, X t represents the input at time t, W z Represents input X t With update gate Z t The relevant weight matrix of Step 4-1-2 Calculate the candidate hidden state at time t as follows: Among them, h t Represents the candidate hidden state at time t, tanh() is the hyperbolic tangent function; Step 4-1-3 Use the hidden state h at time t-1 t-1 and the candidate hidden state h at time t t Calculate the hidden state h at time t t ,as follows: Step 4-1-4 Repeat steps 4-1-1 to 4-1-3 max_length times, and combine the output at each moment as the output h of the GRU layer t ; Step 4-2 inputs the feature matrix X of the current batch of training data into the convolution layer, and uses a convolution kernel of size n×n to perform a convolution operation to obtain the output C′ of the TextCNN layer, as follows: C′=maxpool(C) in, represents the convolution operation, f represents the activation function, W represents the weight matrix of the TextCNN layer, b represents the bias, C represents the convolution result, and maxpool represents the pooling operation; Step 4-3 uses torch.cat() to process the semantic features h output by C′ and GRU layer t The feature matrix M is obtained by fusion in the second dimension as follows: M=torch.cat(C′,h t ) Step 4-4 inputs the feature matrix M into the Multi-Head Attention layer to calculate the attention, specifically: Step 4-4-1 Split the feature matrix M into M1, M2, …, M n , corresponding to n heads respectively; Step 4-4-2Q i =M i , K i =M i 、V i =M i ; Step 4-4-3 Calculate the attention head of the i-th head i ,as follows: Among them, Q represents query, K represents key, V represents value, and d k Represents the dimension of the attention mechanism; Step 4-4-4 concatenates the attention results obtained by each head into a matrix to obtain the output Att_output of the multi-head attention layer, as follows: Att_output=Concat(head1,....,head n ) Step 4-5 inputs Att_output into the capsule layer and calculates the output of the capsule layer, specifically: Step 4-5-1 Divide Att_output into V1, V2, …, V n As the input of the capsule network; Step 4-5-2 Use torch.matmul to initialize the prediction vector U of the capsule network i and routing weight W i ; Step 4-5-3 iterates the dynamic routing algorithm three times, specifically: Step 4-5-3-1U i The calculation process is as follows: U i =V i *W i Step 4-5-3-2 uses the softmax function to calculate the weight c of the output of the i-th capsule to the input of the j-th capsule i,j ,as follows: Among them, num_capsule represents the number of capsules, b i,j Represents the similarity between the i-th capsule and the j-th capsule; Step 4-5-3-3 Calculate S j ,as follows: Step 4-5-3-4 Use the squash function to j Normalize as follows: Among them, a j represents the output of the j-th routing algorithm; Step 4-5-3-5 Using a j To update b i,j ,as follows: b i,j =b i,j +a j *U i Step 4-5-4: The output of the capsule network is a3; Step 4-6 inputs a3 into the classification layer and obtains the probability distribution vector d through linear transformation; Step 4-7 uses the softmax layer to calculate the ambiguous word m in the semantic category s i The predicted probability P(s) under (i=1,2,...,n) i |m)(i=1,2,…,n), as follows: Among them, d i is the i-th component of the probability distribution vector d; Step 4-8 From P(s1|m), P(s2|m), ..., P(s n |m) selects the maximum probability as the predicted semantic category probability of ambiguous word m: Among them, y_predicted j Represents the predicted semantic category probability of the ambiguous word m; Step 4-9 uses the cross entropy loss function to calculate the error loss as follows: Among them, y j Indicates that the ambiguous word m belongs to the semantic category s i The true probability of Steps 4-10 are back-propagated according to the error loss, and the parameters are updated layer by layer as follows: Among them, θ represents the parameter set, θ′ represents the updated parameter set, and α is the learning rate; Step 4-11 continuously executes step 4-1 to step 4-10 until all batches of training data are used up, and an optimized dual-channel recurrent capsule neural network is obtained.
6. The biomedical word sense disambiguation of the dual-channel recurrent capsule neural network according to claim 1, characterized in that: In step 5, the optimized dual-channel recurrent capsule neural network is used to perform semantic classification on the ambiguous words m in the test data. The specific process is as follows: Step 5-1 inputs the feature matrix X of the current batch of test data into the GRU layer and calculates the output of the GRU layer, specifically: Step 5-1-1 Calculate the update gate z in the GRU layer t and reset gate b r ,as follows: z t =σ(W z [h t-1 ,X t +b z ]) r t =σ(W r [h t-1 ,X t +b t ]) Among them, σ represents the sigmoid function, W r represents the weight matrix, b r is the reset gate, r t is the bias term, X t represents the input at time t, W z Represents input X t With update gate Z t The relevant weight matrix of Step 5-1-2 Calculate the candidate hidden state at time t as follows: Among them, h t Represents the candidate hidden state at time t, tanh() is the hyperbolic tangent function; Step 5-1-3 Use the hidden state h at time t-1 t-1 and the candidate hidden state h at time t t Calculate the hidden state h at time t t ,as follows: Step 5-1-4 Repeat steps 5-1-1 to 5-1-3 max_length times, and combine the output at each moment as the output h of the GRU layer t ; Step 5-2 inputs the feature matrix X of the current batch of training data into the convolution layer, and uses a convolution kernel of size n×n to perform a convolution operation to obtain the output C′ of the TextCNN layer, as follows: C′=maxpool(C) in, represents the convolution operation, f represents the activation function, W represents the weight matrix of the TextCNN layer, b represents the bias, C represents the convolution result, and maxpool represents the pooling operation; Step 5-3 uses torch.cat() to compute the semantic features h output by C′ and GRU layer t The feature matrix M is obtained by fusion in the second dimension as follows: M=torch.cat(C′,h t ) Step 5-4 inputs the feature matrix M into the Multi-Head Attention layer to calculate the attention, specifically: Step 5-4-1 Split the feature matrix M into M1, M2, …, M n , corresponding to n heads respectively; Step 5-4-2Q i =M i , K i =M i 、V i =M i ; Step 5-4-3 Calculate the attention head of the i-th head i ,as follows: Among them, Q represents query, K represents key, V represents value, and d k Represents the dimension of the attention mechanism; Step 5-4-4 concatenates the attention results obtained by each head into a matrix to obtain the output Att_output of the multi-head attention layer, as follows: Att_output=Concat(head1,....,head n ) Step 5-5 inputs Att_output into the capsule layer and calculates the output of the capsule layer, specifically: Step 5-5-1 Divide Att_output into V1, V2, …, V n As the input of the capsule network; Step 5-5-2 Use torch.matmul to initialize the prediction vector U of the capsule network i and routing weight W i ; Step 5-5-3 iterates the dynamic routing algorithm three times, specifically: Step 5-5-3-1U i The calculation process is as follows: U i =V i *W i Step 5-5-3-2 uses the softmax function to calculate the weight c of the output of the i-th capsule to the input of the j-th capsule i,j ,as follows: Among them, num_capsule represents the number of capsules, b i,j Represents the similarity between the i-th capsule and the j-th capsule; Step 5-5-3-3 Calculate S j ,as follows: Step 5-5-3-4 Use the squash function to j Normalize as follows: Among them, a j represents the output of the j-th routing algorithm; Step 5-5-3-5 Using a j To update b i,j ,as follows: b i,j =b i,j +a j *U i Step 5-5-4: The output of the capsule network is a3; Step 5-6: Input a3 into the classification layer and obtain the probability distribution vector d through linear transformation; Step 5-7 uses the softmax layer to calculate the ambiguous word m in the semantic category s i The predicted probability P(s) under (i=1,2,...,n) i |m)(i=1,2,…,n), as follows: Among them, d i is the i-th component of the probability distribution vector d; Step 5-8 selects the semantic category with the maximum probability as the predicted semantic category s of the ambiguous word m, as follows: Step 5-9 continuously executes step 5-1 to step 5-8 until all batches of test data are used up.
