## 2 Materials and Methods
### MGFGF-BiLSTM-EGP
These improvements make EGP a robust and scalable solution for NER tasks, capable of delivering superior performance across various datasets and entity types. Figure 6 illustrates the entity prediction process using EGP for the sentence \"Swelling of the spleen in chickens infected with Newcastle disease\". EGP accurately labels the entity by employing positional coding, where the end position of the entity is marked as 1. This approach allows the model to effectively identify nested named entities. After obtaining the integrated token representation \(H\), the next step is to predict spans for entity recognition, which involves identifying the start and end positions of potential entity spans within a sentence. For each token \(x_{i}\), the span prediction process utilizes feed-forward layers to compute the start and end representations as follows:\[f_{j}^{\prime}=\log\bigl{(}1+f_{j}\bigr{)} \tag{4}\]4 \[f_{j}^{\prime}=\log\bigl{(}1+f_{j}\bigr{)} \tag{4}\]5

Here, \(q_{i,\alpha}\) and \(k_{i,\alpha}\) represent the vector representations for the start and end tokens of the span for entity type \(\alpha\). The span score \(s_{\alpha}(i,j)\) for entity type \(\alpha\) is then calculated by:

\[f_{j}^{\prime}=\log\bigl{(}1+f_{j}\bigr{)} \tag{4}\]6

To incorporate positional information, relative position encoding (RoPE) is applied, modifying the span score calculation as follows:

\[f_{j}^{\prime}=\log\bigl{(}1+f_{j}\bigr{)} \tag{4}\]7

In this equation, \(R_{i}\) and \(R_{j}\) are the position encodings for the start and end tokens, respectively. The EGP approach splits the NER task into extraction and classification, sharing parameters across entity types to reduce the total parameter count. Extraction finds the entity spans, and classification assigns the correct type. The scoring function that integrates both tasks is formulated as follows:

\[f_{j}^{\prime}=\log\bigl{(}1+f_{j}\bigr{)} \tag{4}\]8

\[f_{j}^{\prime}=\log\bigl{(}1+f_{j}\bigr{)} \tag{4}\]9 An example of EGP prediction for nested entities, where the end position of the entity part of the label is coded 1, and the non-entity part is coded 0. Here, \(W_{q}\) and \(W_{k}\) are the projection matrices used for span extraction, and \(w_{n}^{T}\) is the parameter vector associated with entity classification. To further optimize the use of parameters, we employed concatenated span representations \((q_{i};k_{i})\) instead of the full token representation \(H_{i}\). The scoring function is then reformulated as:

\[w_{j}^{\prime}=f_{j}^{\prime}w_{j} \tag{5}\]0

In this equation, \(w_{n}^{T}\) is a parameter vector specific to the entity type \(\alpha\). To improve the NER performance with imbalanced datasets, EGP introduces a specialized loss function inspired by circle loss. This ensures that the target class scores are higher than non-target ones. The loss function is defined as follows:

\[w_{j}^{\prime}=f_{j}^{\prime}w_{j} \tag{5}\]1

Here, \(\Omega_{pos}\) and \(\Omega_{neg}\) represent the sets of positive and negative samples, respectively. This formulation is extended to handle the imbalance in entity types using the following loss function for a specific entity type \(\alpha\):

\[w_{j}^{\prime}=f_{j}^{\prime}w_{j} \tag{5}\]2

In this equation, \(E_{\alpha}\) denotes the set of entity spans for entity type \(\alpha\), while \(P_{\alpha}\) and \(Q_{\alpha}\) represent the sets of non-entity spans and negative spans for entity type \(\alpha\), respectively. The term \(s_{q,k}^{\alpha}\) is the span score for entity type \(\alpha\) between tokens \(q\) and \(k\). The loss function \(\mathcal{L}_{\alpha}\) effectively balances the classification of both the entity and non-entity spans, ensuring that the model accurately distinguishes between them, thereby addressing class imbalance and improving the overall NER performance. ### Experimental Environment and Hyperparameter

The experiments were conducted using a Tesla P100 GPU and PyTorch 2 as the deep learning framework. Table 2 outlines the specific experimental parameters.