## 3 Method
### Medical Text Encoder  
In the study of named entity recognition in the medical field, selecting an appropriate pre-trained model as an encoder is crucial for improving recognition accuracy. Given the specialized and complex nature of medical terms and expressions, this study adopts a BERT pre-trained model based on the Transformer architecture to better capture complex semantics and terminological features in medical texts. Transformer encoders are the core of BERT. The Transformer model consists of multiple stacked encoder layers, each containing a self-attention mechanism and a feed-forward neural network. The self-attention mechanism allows the model to process each word while considering all other words in the sequence, capturing contextual relationships, and the feed-forward neural network further processes and transforms the output of the self-attention mechanism. BERT uses a bidirectional encoding approach, allowing it to understand context from both the left and right directions simultaneously, unlike traditional language models that model from only one direction (left-to-right or right-to-left). This bidirectional capability enables BERT to understand the contextual information of words more comprehensively. In medical named entity recognition (NER) tasks, BERT's bidirectional encoding capability enhances its understanding of the meanings of medical terms in different contexts, which is crucial for accurately recognizing complex medical entities such as disease names, drug names, and symptoms. By considering both left and right contextual information, BERT captures more nuanced semantic relationships in medical texts. BERT excels in fine-grained feature extraction, capturing rich contextual features from input text, which enhances the recognition accuracy of medical entities, particularly with terminology and complex expressions. BERT's contextual understanding significantly enhances its ability to handle long texts and effectively capture long-distance dependencies. In the medical literature, texts are often long and complex in structure, and BERT's processing capability makes it particularly effective in handling long sentences and complex structures. To overcome the limitation of BERT input length, we used a segmentation processing method in our experiment to split long texts into multiple segments while maintaining context consistency between segments. We introduced a sliding window mechanism in the processing process to ensure that there is a certain overlap between the segments, thereby reducing the risk of important information being truncated. To further improve BERT's performance regarding medical texts, we adopt a systematic strategy. First, additional pre-training on a large-scale medical corpus enables BERT to learn terminology and linguistic patterns specific to the medical domain, enhancing its comprehension of medical texts. Second, expanding the model's vocabulary is essential. Adding more medical terminology to the vocabulary significantly reduces the model's unknown word (OOV, out of vocabulary) problem when processing medical terminology, thus improving recognition accuracy. Additionally, fine-tuning BERT's attention mechanism is necessary. Optimizing the attention mechanism ensures the model focuses more on medical entities and their contextual information, enhancing its ability to accurately identify and categorize medical named entities such as diseases, drugs, and medical procedures. To enhance the performance of the model in the medical named entity recognition task, BERT and BiLSTM are used as the core processing units in this study. BERT offers significant advantages in medical named entity recognition tasks. BiLSTM also exhibits unique advantages in medical named entity recognition tasks. The combination of BERT and BiLSTM leverages their complementary strengths to further enhance performance in medical named entity recognition tasks. When addressing the complexity of medical texts, the combination of BERT and BiLSTM demonstrates excellent capabilities.