# Named Entity Recognition Based on Multi-Class Label Prompt Selection and Core Entity Replacement
## 3 The MPSCER-NER Model
### BiLSTM-CRF Classification  
After acquiring word vectors with the contextual information of multi-class label prompts, BiLSTM-CRF is used to process semantic information and output label sequences. Multi-class label prompts increase the length of input sentences. The sequence context information can be effectively captured by BiLSTM. The information processed using BiLSTM is passed on to the CRF. An example of how BiLSTM-CRF processes word embeddings in MPSCER-NER is shown in Figure 8.  
Figure 8: An example of how BiLSTM-CRF processes word embeddings in MPSCER-NER. In Figure 8, the acquired word vectors affected by the multi-class label prompts are processed by BiLSTM. Finally, the word vectors with entity context information are output to CRF. Word vectors are generated with the problem of mismatched labels. The classifier can only discern the most likely label for the word vector, but not whether it makes logical sense. Dependencies between labels can be established by CRF. The output is adjusted globally based on the results. It makes the NER model more compatible with the actual labeling constraints and also improves the robustness of the model in terms of the named entity boundaries. The observation sequences and state sequences of the CRF interact with each other by defining the eigenfunctions. The characteristic function is defined on the input sequence. They can capture different features depending on the needs of the modeling task. Therefore, CRF is chosen to solve the label before and after the mismatch problem. The inferred label probability formula based on CRF is shown in the following equation:  
\[P(y|p)=\frac{1}{Z(x)}\exp\left(\sum_{i,k}\lambda_{k}t_{k}(y_{i-1},y_{i},p,i)+ \sum_{i,l}u_{i}s_{l}(y_{i},p,i)\right)Z(x)\lambda_{k}u_{l} \tag{3}\]  
\[Z(x)=\sum\exp\left(\sum_{i,k}\lambda_{k}t_{k}(y_{i-1},y_{i},p,i)+\sum_{i,l}u_{ i}s_{l}(y_{i},p,i)\right) \tag{4}\]  
where \(Z(x)\) is the normalization factor; \(\lambda_{k}\) and \(u_{l}\) are the weight values corresponding to the feature functions; \(p\) and \(y\) are the corresponding labels, respectively; \(k\) represents the \(k\)th transfer feature function; \(y_{i}\) is the label predicting the \(i\)th word; and \(l\) is the \(l\)th state feature function. The function \(t_{k}(\cdot)\) relies on the current position and previous position labels, and \(s_{l}(\cdot)\) relies only on the current position label. The transfer eigenfunctions \(t_{k}(\cdot)\) and \(s_{l}(\cdot)\) are calculated as shown in the following equation:  
\[t_{k}(y_{i-1},y_{i},x,i)=\left\{ \begin{array}{ll}1,&y_{i-1}=\text{B},y_{i}= \text{I}\\ 0,&\text{otherwise}\end{array} \right. \tag{5}\]  
\[s_{l}(y_{i},x,i)=\left\{ \begin{array}{ll}1,&y_{i}=\text{B}\\ 0,&\text{otherwise}\end{array} \right. \tag{6}\]  
where \(y_{i-1}\) is the word label of the previous position, and \(y_{i}\) is the word label of the current position. The letter B denotes the beginning of the label (Begin), and I denotes the position inside the label (Inside). We obtain 1 for B and I, and we obtain 0 in all the other cases. After BiLSTM-CRF processing, the contextual information in the sentence is clearer and the illogical label pairings are reduced. The labels of the identified entities are closer to their real labels. In summary, the MPSCER-NER model training processes are described as follows:  
Multi-class label prompts are selected as prompts using the MPSCER-NER model. The distribution of text in the prompt learning is learned along with the overall input format of the sequence. The weighted random algorithm is used to replace the core entities to help the MPSCER-NER model in identifying entities in different situations. Finally, the word vectors are input into BiLSTM-CRF to deal with the label mismatches that occur before and after the achievement of NER. The training algorithm of the MPSCER-NER model is shown in Algorithm 1. ```
0: Training dataset--D; prompt dataset--P; batch size--Bs; epoch--Ep; learning rate--Lr; dropout--Dr; \(\theta\)--the initial MPSCER-NER model parameters.