# Named Entity Recognition in Online Medical Consultation Using Deep Learning
## 3 The Proposed Approach  
This section provides a detailed explanation of our medical named entity recognition approach designed for online medical consultations. The overall model framework is shown in Figure 1. The framework comprises five core components, including the pre-trained model, the stacked CNN with a local context mechanism, BiLSTM with a global context mechanism, the deep factorization machine with a fusion context mechanism, and MCRF. The framework operation process is divided into five main stages:  
1. A data sample sentence is randomly selected from the experimental dataset. In the pretrained model component, ChineseBERT maps this sentence into a real-valued matrix. The matrix's row count matches the sentence's character count, while its column count corresponds to the final hidden layer dimension of ChineseBERT. Then, the real-valued matrix is input into the stacked CNN with the local context mechanism component and BiLSTM with the global context mechanism component to model the sentence's contextual semantic representation from both local and global perspectives simultaneously. 2. In the stacked CNN with the local context mechanism component, the real-valued matrix first learns local semantic features from simple to complex layer by layer through a three-layer stacked CNN to improve the local understanding ability of the input sentence. Then, the learned local semantic features are input to the multihead self-attention mechanism in the local context mechanism module. Each head within the multihead self-attention module independently acquires representations from distinct segments of the input sentence. These distinct segments are represented by concatenation and linear transformation. The representation comprehensively considers the information from different perspectives to capture the local contextual semantic representation of the input sentence. Subsequently, the local contextual semantic representation is input to the deep factorization machine with the fusion context mechanism component. 3. In BiLSTM with the global context mechanism component, the real-valued matrix first learns global semantic features through BiLSTM's capture of long-distance dependency to improve the global understanding ability of the input sentence. Then, the learned global semantic features are input into the global context mechanism module to further learn the global contextual semantic representation of the input sentence. Subsequently, the global contextual semantic representation is input to the deep factorization machine with the fusion context mechanism component. 4. In the deep factorization machine with the fusion context mechanism component, the factorization machine module of DeepFM is used to capture the first-order and second-order low-order feature interaction relationships, and DeepFM's deep module is used to capture high-order feature interaction relationships to fully fuse the local and global contextual semantic representations to obtain the fusion contextual semantic representation. Subsequently, the fusion contextual semantic representation is input to the MCRF component. 5. In the MCRF component, with the help of the Viterbi algorithm and the masked transition matrix, the MCRF decodes the fusion contextual semantic representation into the tag sequence path with the highest probability score, and the occasional generation of illegal tag sequences is effectively prevented. For better intuitive understanding, we also present the workflow of the proposed medical named entity recognition framework in pseudocode format in Algorithm 1.