## 2 Materials and Methods
### MGFGF-BiLSTM-EGP  
For the MGFGF-BiLSTM-EGP model developed in this study, the algorithmic pseudo-code for the model is presented in Algorithm 1. As illustrated in Figure 2, the model integrates three key modules within its embedding layer: character encoding, word encoding, and sentence encoding. ```
```
1:Pre-trained model RoBERTa, word vectors GloVe, sentence embeddings SBERT, network BiLSTM, efficient global pointer EGP, The number of iterations \(E\). 2:Prodicted entity spans \(E\), optimal model weights \(\hat{\theta}\). 3:\(e=1,\ \ldots,\ E\)do
4:\(h_{i}\leftarrow\text{RoBERTa}(c_{i}),\forall c_{i}\in X\)
5:\(w_{i}^{\prime}\leftarrow\log\left(1+f_{j}\right)\times\text{ GloVe}\left(w_{j}\right),\) according to Equations (4) and (5). 6:\(h_{i}^{\prime}\leftarrow\text{MultiHead}\left(h_{i},w_{i}^{\prime}\right), \forall w_{i}\) containing \(c_{i}\), according to Equations (6)-(11). 7:\(u\leftarrow\text{SBERT}(X)\), according to Equations (12)-(14). 8:\(H_{i}\leftarrow\text{Concat}\left(h_{i},h_{i}^{\prime},u\right),\forall i\)
9:\(\text{ContextualOutput}\leftarrow\text{BiLSTM}(\left\{H_{1},H_{2},\ldots,H_{n}\right\})\)
10:\(s_{i,j}^{\epsilon}\leftarrow\left(W_{q}H_{i}+b_{q}\right)\times\left(W_{k} H_{j}+b_{k}\right),\forall\left(c_{i},c_{j}\right),\) according to Equations (17)-(20). 11:\(\hat{\theta}\leftarrow\text{argmin}_{\theta}\mathcal{L}\)
12:If \(F1>F1_{\text{max}}\gets F1\)
13:\(\text{save }\hat{\theta}\)
14:End for
15:Output: Final predicted spans \(\hat{Y}\), best weights \(\hat{\theta}\). ```

**Algorithm 1** Pseudo-code for the MGFGF-BiLSTM-EGP nested named entity recognition mode

For character encoding, we fine-tuned the RoBERTa pre-trained model using its last hidden state output to generate character vectors. The word encoding module utilized word vectors trained with GloVe, which were aligned with the output from RoBERTa. When a word vector contained the current input character, a multi-head attention mechanism merged the corresponding word vector to form the final word vector. For sentence encoding, each sentence was processed through the SBERT (Sentence-BERT) model, generating a corresponding sentence vector. These three vectors: character, word, and sentence, were concatenated to construct the model's embedding layer. A BiLSTM network was then employed to capture the contextual information within the text. Finally, the EGP component predicted the positions of named entities within the text. Figure 1: An example of nested entity annotation, with different colored lines representing different entities. #### 2.3.1 Character Encoder

As shown in Figure 3, in the character encoding module, we fine-tuned RoBERTa and used RoBERTa's last hidden state as the character vector. The pre-trained RoBERTa model served as our character encoder, building upon the BERT architecture. BERT is a language model based on the transformer framework, which leverages an attention mechanism to dynamically focus on different parts of the input data, enabling effective sequence processing [48]. RoBERTa enhances BERT's capabilities, particularly for tasks like NER, by introducing several key modifications [49]. As an embedding layer, RoBERTa transforms input character sequences into high-dimensional feature vectors that not only capture individual word characteristics, but also rich contextual information. This context-awareness is crucial for accurately identifying and classifying named entities as it allows for a nuanced understanding of the text surrounding each word. RoBERTa's capacity to capture these contextual nuances makes it especially effective for NER tasks. Figure 2: MFGFF-BiLSTM-EGP model framework. #### 2.3.2 Word Encoder

We developed a 200-dimensional word vector for chicken diseases using the GloVe model. This process began with the construction of a co-occurrence matrix \(X\), where \(X_{ij}\) represents the frequency with which word \(i\) co-occurs with word \(j\) within a predefined context window.