## 3 Method
### Medical Text Encoder
BERT's contextual understanding ability and BiLSTM's sequence modeling ability complement each other, enabling the model to adapt to the complex structure and multi-level information extraction needs in medical texts. BERT handles the contextual and semantic information of the text, while BiLSTM efficiently captures long-distance dependencies and sequential relationships within the text. This combination enables the model to perform entity recognition and classification more effectively when faced with the complexity and diversity of medicaltexts, significantly improving overall task performance. Taking the text sequence [\" \(\bot\)\", \" \(\blacksquare\)\", \" \(\blacksquare\)\", \" \(\blacksquare\)\", \" \(\blacksquare\)\", \" \(\blacksquare\)\", \" \(\blacksquare\)\", \" \(\blacksquare\)\", \" \(\blacksquare\)\", \" \(\blacksquare\)\"] ([\"upper\", \"abdomen\", \"pain\", \"nausea\", \"heart\", \"is\", \"what\", \"what\", \"origin\", \"cause\"]) as an example, we use the BIO tagging system to annotate these words with entities. In the BIO tagging system, \"B\" represents the beginning of an entity, \"I\" represents the inside of an entity, \"E\" represents the end of an entity, and \"O\" represents non-entity. In the above example, we represented two entities: \" \(\bot\)\"\(\blacksquare\)\" (\"Epigastric pain\") and \" \" \(\blacksquare\)\" (\"nausea\") with the label sequence [B, I, E, B, E, O, O, O, O, O]. In this specific task, the primary role of the BiLSTM layer is to capture bidirectional contextual information in text sequences. Given an input sequence \(X=(x_{1},x_{2},\ldots,x_{n})\), BiLSTM processes the information using the following formula:  
\[ \begin{array}{c}\overset{\rightarrow}{h_{t}}=LSTM(\overset{\rightarrow}{h _{t-1}},\ x_{t}),\overset{\leftarrow}{h_{t}}=LSTM(\overset{\leftarrow}{h_ {t+1}},x_{t}),\\ h_{t}=[\overset{\rightarrow}{h_{t}};\overset{\leftarrow}{h_{t}}]\end{array}  \tag{1}\]  
where \(\overset{\rightarrow}{h_{t}}\) denotes the forward LSTM. For each time step \(t\) in the sequence, the forward LSTM receives the input \(x_{t}\) of the current time step and the hidden state of the previous time step \(\overset{\rightarrow}{h_{t-1}}\) and computes the hidden state of the current time step \(\overset{\rightarrow}{h_{t-1}}\). \(\overset{\leftarrow}{h_{t}}\) denotes the reverse LSTM. It operates in a similar manner but in the opposite direction. For each time step \(t\), the reverse LSTM processes the input \(x_{t}\) of the current time step and the hidden state \(\overset{\leftarrow}{h_{t+1}}\) of the subsequent time step to generate the hidden state \(\overset{\leftarrow}{h_{t}}\) of the current time step. Eventually, the hidden states from the forward and reverse LSTMs are concatenated to form \(h_{t}\), which is the final hidden state for the current time step. This concatenation operation ensures that the hidden state at each time step contains information from both directions of the sequence. In the context of medical named entity recognition, this structure enables the BiLSTM to simultaneously consider contextual information both before and after medical terms, which is crucial for understanding the precise meaning of these terms and recognizing entity boundaries.