# Conditional Knowledge Extraction Using Contextual Information Enhancement
## 4 Approach
### Sentence-Level Conditional Context Enhancement  
Longer distance dependencies can be better captured using LSTM models, as LSTMs can learn which information should be remembered and which information should be forgotten through the training process. However, a further problem with modeling sentences using LSTM is the inability to encode information from back to front. At the finer granularity of classification, the semantic dependencies in both directions can be better captured using BiLSTM. Therefore, in this paper, this paper uses the BiLSTM network to extract semantic features [24] from the text and obtain the semantic features of each part of the text H = (\(h_{1}\), \(h_{2}\),..., \(h_{n}\)), i.e.,  
\[\overset{\rightarrow}{h_{t}}=LSTM\bigg{(}\overset{\rightarrow}{h_{t-1}},c_{ t}\bigg{)}, \tag{1}\]  
\[\overset{\leftarrow}{h_{t}}=LSTM(\overset{\leftarrow}{h_{t-1}},c_{t}), \tag{2}\]  
\[h_{t}=\overrightarrow{h_{t}}\oplus\overset{\leftarrow}{h_{t}}, \tag{3}\]  
where \(\overset{\rightarrow}{h_{t}}\) indicates that the forward LSTM encodes the text information before moment t, and \(\overset{\rightarrow}{h_{t}}\) indicates that the reverse LSTM encodes the text information before moment t. Concatenate the features \(\overset{\rightarrow}{h_{t}}\) with \(\overset{\leftarrow}{h_{t}}\) to obtain the feature vector \(h_{t}\) obtained at moment t, and the text features H at each moment are obtained by calculation.  
After obtaining the semantic features H of each part of the text, to highlight the role of the features of the semantic structure, this paper uses the \"ltp\" tool [25] to obtain the dependent syntactic structure of the sentences. The \"ltp\" tool supports basic Chinese natural language processing tasks, including Chinese word separation, lexical annotation, named entity recognition, and dependent syntactic analysis. The vector H is spliced with the dependency vectors r, obtained from the dependent grammatical relations, i.e.,  
\[C=h_{i}\oplus r_{i}, \tag{4}\]  
considering that different dependencies should have different weights, the attention mechanism is used to find the weight of the current dependency by using the dependencies present in the sentence [10] and the semantic information of the sentence as the basis for assigning weights by the attention mechanism, i.e.,  
\[score_{t}=u^{T}tanh(W_{1}[h_{t}\oplus r_{t}]+b_{1}), \tag{5}\]  
\[\alpha_{t}=exp(score_{t})\left(\sum_{i}exp(score_{i})\right)^{-1}, \tag{6}\]  
where \(h_{t}\) denotes the semantic features extracted at moment t. \(h_{t}\) is fused with \(r_{t}\) in the form of vector splicing; \(\alpha_{t}\) denotes the attention weights at moment t. Where u, \(W_{1}\), and \(b_{1}\) are all on-the-fly initialization parameters, parameter learning is performed based on error feedback from the output layer.  
The attention weights for each component of A=(\(\alpha_{1}\), \(\alpha_{2}\),..., \(\alpha_{n}\)) are obtained through calculation. Then the model adjusts the weight of semantic features in the feature vector  
Figure 7: Sample sentence processing results: “when mixed with equal numbers of B cells”.  
according to the attention weights, i.e., by weighting and summing the final feature vector to obtain the feature representation \(Z\) of the final sentence.  
\[Z=\sum_{i}\alpha_{i}h_{i}, \tag{7}\]