# TCM Prescription Generation via Knowledge Source Guidance Network Combined with Herbal Candidate Mechanism

Authors: Jiaxin Hou; Ping Song; Zijuan Zhao; Yan Qiang; Juanjuan Zhao; Qianqian Yang
Journal: Computational and Mathematical Methods in Medicine
 (2023)

---

## Abstract

Traditional Chinese medicine (TCM) prescriptions have made great contributions to the treatment of diseases and health preservation. To alleviate the shortage of TCM resources and improve the professionalism of automatically generated prescriptions, this paper deeply explores the connection between symptoms and herbs through deep learning technology, and realizes the automatic generation of TCM prescriptions. Particularly, this paper considers the significance of referring to similar underlying prescriptions as herbal candidates in the TCM prescribing process. Moreover, this paper incorporates the idea of referring to the potential guidance information of corresponding prescriptions when model extracts symptoms representations. To provide a reference for inexperienced young TCM doctors when they prescribe, this paper proposes a dual-branch guidance strategy combined with candidate attention model (DGSCAM) to automatically generate TCM prescriptions based on symptoms text. The format of the data used this paper is the “symptoms-prescription” data pair. The specific method is as follows. First, DGSCAM realizes the extraction of key information of prescription-guided symptoms through a dual-branch network. Then, herbal candidates in the form of prescriptions that can treat symptoms are proposed in view of the compatibility knowledge of TCM prescriptions. To our knowledge, this is the first attempt to use prescriptions as herbal candidates in the prescription generation process. We conduct extensive experiments on a mixed public and clinical dataset, achieving 37.39% precision, 25.04% recall, and 29.99% F1 score, with an average doctor score of 7.7 out of 10. The experimental results show that our proposed model is valid and can generate more specialized TCM prescriptions than the baseline models. The DGSCAM developed by us has broad application scenarios and greatly promotes the research on intelligent TCM prescribing.


---

## Body

## 1. Introduction

As a documented summary of the valuable experience of the ancient Chinese people in their struggle against disease [1, 2], traditional Chinese medicine (TCM) is receiving increasing attention and recognition from researchers and scholars around the world [3]. As a key component of TCM, TCM prescriptions realize the conversion between doctors’ professional medical skills and patients’ treatment needs [4, 5]. In the research field of various diseases, TCM has an inestimable prospect. All kinds of traditional Chinese medicine not only have excellent performance in relieving symptoms but also play a huge role in curing diseases [6–8]. In the fight against the novel coronavirus disease 2019 (COVID-19), traditional Chinese medicines have a remarkable effect on preventing infection and curing mild infections [9–11]. However, the generation and daily application of TCM prescriptions have always been constrained by TCM resources. The small number of TCM health institutions and training colleges, and the strict standards for TCM doctors to become talents, all of which limit the output speed of TCM talents. And these result in a huge discrepancy between the number of TCM doctors and the number of patients [12, 13]. In addition, some newly recruited young doctors are inexperienced and lack standard prescriptions as a reference when prescribing. This makes it difficult for them to determine whether the prescribed prescription is effective. As a result of these problems, it is difficult for both patients and doctors to have a sense of belonging and identity in the field of TCM, which in turn leads to the slow development of TCM.Faced with these problems, there is an urgent need for an easy way to provide convenience for patients and inexperienced young doctors. With the rise of artificial intelligence [14], some people gradually link the generation of TCM prescriptions with computer technology. Many researchers have conducted standardized and objective researches on the automatic generation of TCM prescriptions [15, 16]. In terms of generating TCM prescriptions from texts, many researchers have tried to explore the correspondence between symptoms and prescriptions using multigraph convolutional networks. Jin et al. [17] proposed an approach to recommend herbal medicines using the MGCN framework to consider the process of the implicit syndrome induction prescription generation. In this study, not only the correlation between symptoms and prescribed herbs was considered but also the intrinsic connection of “symptoms and symptoms” and “herbs and herbs” was studied separately. Yang et al. [18] built a multilayer information fusion graph convolution model by introducing additional information representing herbal attributes. And they used symptom feature representation and herbal feature representation to facilitate prescription generation. In addition, Zhao et al. [19] similarly proposed an MGCN-based prescription recommendation model. This model assisted computer deduction to reproduce the connotation of TCM diagnosis and treatment by focusing on the patient’s state elements and syndrome types of symptoms. In addition to the MGCN approach, there are also researchers who use topic models as research ideas. Wang et al. [20] proposed a subject model of TCM theory combined with herbal compatibility, which can better characterize diagnostic and therapeutic processes. Yao et al. [21] proposed a subject model that introduced the background of herbal medicine as domain knowledge to facilitate prescription generation, which used TCM theory to generate prescriptions. Although the above studies have demonstrated the effectiveness of a number of existing computer techniques in TCM prescription generation, the MGCN approaches in these studies did not take into account the correlation between herbs well, and the topic models were difficult to capture the higher-order correlation of herbs or symptoms.In order to obtain prescriptions which are more in line with TCM prescribing concepts and achieve prescription “generation” rather than herbal “mapping”, more researches on prescription generation have focused on the use of seq2seq structures [22–24]. Wang et al. [25] viewed TCM prescription generation as a machine translation problem. They proposed a seq2seq model to explore potential associations among symptoms and decoded such associations into prescriptions. The model designed by Liu et al. [26] learned the interaction between symptoms and herbs by simulating the correspondence between clinical consultation and prescription. And then this model used an attention mechanism that identified the primary and secondary symptoms to assist prescription generation. Undeniably, these models based on seq2seq have achieved good results. However, the current extraction of key information about symptoms is limited by the infrastructure of the seq2seq model. And the identification of some key information is not sufficient. At the same time, the existence of information that can be used in prescriptions closely related to symptoms is also ignored, which leads to generate inaccurate prescriptions. In addition, there is another problem that needs to be solved urgently. The concept of herbal preselection proposed by Li et al. [24] is a new idea to guide prescription generation. However, its herbal preselection method simply selected herbs that can treat symptoms. In the known prescription generation studies, there has never been a method to correlate herbal preselection to compatibility theory.To address the above issues, this paper establishes new Chinese herbs guided and prescription candidates’ attention depth model based on symptoms text. This model incorporates TCM background knowledge into the seq2seq structure to assist in prescription generation. The originality of our proposed method has two main components. On the one hand, this paper retains the original encoder structure for extracting critical symptoms information, and additionally uses prescription knowledge to build a branch network to guide the extraction of the symptoms information. This cross-conceptual knowledge source guidance method will be a worthwhile attempt. On the other hand, our method also incorporates the knowledge of TCM prescription compatibility. The concept of herbal preselection proposed by Li et al. [24] is expanded to a larger scope by selecting a set of prescriptions as candidate herbs. These prescriptions can treat symptoms similar to those being treated. This paper hopes that the selected candidate herbs will not only treat the symptoms but also balance the overall efficacy of the prescriptions. In conclusion, we propose a dual-branch guidance strategy combined with candidate attention model (DGSCAM) to automatically generate TCM prescriptions based on symptoms text. Firstly, in order to play the guiding role of prescription efficacy on symptoms information extraction, a dual-branch information extraction module (DIEM) is designed. This module extracts the intermediate vector of prescription efficacy, and guides the bidirectional hybrid encoder (EnGRU) to improve its own performance (Section 3.2). Secondly, we propose a task-qualified knowledge base matching module (TKMM). It guides the generation of the prescription-based herbal candidates pool based on the knowledge of TCM prescription compatibility (Section 3.3). In addition, this paper proposes a multi-dimensional complementary attention module (MCAM) to fuse the attention of the prescription-based herbal candidates pool with that of the conventional herbal library (Section 3.4). Then, to obtain prescriptions without duplicate herbs, the candidates coverage decoder (DeGPT2) is mainly built by integrating TKMM and MCAM (Section 3.5).The main contributions of this paper are as follows:(1)
We propose a novel seq2seq-based Chinese herbs guided and prescription candidates attention depth model to generate TCM prescriptions. A dual-branch guidance strategy combined with candidate attention model (DGSCAM) is designed to analyze symptoms text information and generates prescriptions that are consistent with the concept of TCM(2)
For all we know, our work is the first to investigate the effect of prescriptions as herbal candidates on prescription generation. We propose a dual-branch information extraction module (DIEM), so that prescriptions can be used to guide the extraction of symptoms information. At the same time, in order to give full play to the positive effect of TCM prescription compatibility rules on the automatic generation of TCM prescriptions, we also propose a task-qualified knowledge base matching module (TKMM)(3)
The feasibility of this method has been verified by experiments. Feeding symptoms text into our model generates symptomatic prescriptions with overall efficacy. The results show that our model has certain advantages over the currently popular prescription generation models. Meanwhile, the method has been recognized by professional TCM doctors


## 2. Related Work

### 2.1. Dual-Branch Network

Since many problems do not exist in isolation, they can all be solved through domain knowledge and multidimensional thinking [27, 28]. Guided by the above thinking concepts, the dual-branch network is becoming more and more momentous. Extensive works [29–32] have shown that dual-branch network can not only reduce computational cost but also have the potential to improve task performance. Chen et al. [33] proposed a dual-branch adversarial learning framework in the task of named entity recognition, where one branch learned entity domain knowledge, and the other branch captured better features, the two aspects worked together to improve the results. Chen et al. [34] combined a Bayesian network based on medical knowledge graph augmentation with a multibranch entity-aware convolutional neural network. They used the multibranch network to extract each basic information in electronic medical records (EMR) separately for comprehensive analysis. Finally, they constructed a network model for automatic diagnosis based on EMR. Deng et al. [35] used a dual-branch adversarial learning model based on keyword information to complete the Chinese text summarization task. The application of the dual-branch network not only reduced the probability of incomplete information extracted by the encoder but also served as a guide for the generation of target summaries. All the studies mentioned above have demonstrated from different perspectives that the dual-branch network can improve the learning ability of the subject task through knowledge extraction from multiple perspectives.


### 2.2. Attention Mechanism

The attention mechanism can automatically learn and calculate the contributing degree of the input data to the output data. And it can explore the regions that need to be focused in a focused manner and suppresses the interference of weakly relevant information. Bahdanau et al. [36] used an attention-like mechanism to simultaneously perform translation and alignment on machine translation task. It was the first proposal to apply the concept of attention mechanism to the field of natural language processing (NLP). Wang et al. [25] conducted a study on the generation of TCM prescriptions based on machine translation. The study used scaled dot-product attention and multihead transformation parallel computation to extract symptoms information. This approach can better explore potential correlations between symptoms. Li et al. [24] tried to use the knowledge of herbal effects to enhance the effect of TCM prescription generation. At the same time, these scholars also used multiple attention mechanisms to assist the acquisition of symptoms information. Liu et al. [26] used two kinds of attention in a study on TCM prescription generation. They were, respectively, main-subordinate symptom attention and dynamical herb attention. The first type of attention emphasizes which symptoms have a more significant impact on the disease. The second type of attention achieves the effect that the herbs treating the main symptoms were first predicted. Ruan et al. [23] also studied the attention mechanism in the generation of TCM prescriptions. They used attention mechanisms to explore the relationships between different symptoms and different herbs. These relationships included, but were not limited to, the same herbs for different symptoms, and different herbs for the same symptoms. Liu et al. [37] proposed the transfer learning model of the few-shot learning to generate TCM prescriptions. This study used multiple levels of attention during the prescription-generation phase to dig into the associations between symptoms information, medical history information, and herbs information.


## 2.1. Dual-Branch Network

Since many problems do not exist in isolation, they can all be solved through domain knowledge and multidimensional thinking [27, 28]. Guided by the above thinking concepts, the dual-branch network is becoming more and more momentous. Extensive works [29–32] have shown that dual-branch network can not only reduce computational cost but also have the potential to improve task performance. Chen et al. [33] proposed a dual-branch adversarial learning framework in the task of named entity recognition, where one branch learned entity domain knowledge, and the other branch captured better features, the two aspects worked together to improve the results. Chen et al. [34] combined a Bayesian network based on medical knowledge graph augmentation with a multibranch entity-aware convolutional neural network. They used the multibranch network to extract each basic information in electronic medical records (EMR) separately for comprehensive analysis. Finally, they constructed a network model for automatic diagnosis based on EMR. Deng et al. [35] used a dual-branch adversarial learning model based on keyword information to complete the Chinese text summarization task. The application of the dual-branch network not only reduced the probability of incomplete information extracted by the encoder but also served as a guide for the generation of target summaries. All the studies mentioned above have demonstrated from different perspectives that the dual-branch network can improve the learning ability of the subject task through knowledge extraction from multiple perspectives.


## 2.2. Attention Mechanism

The attention mechanism can automatically learn and calculate the contributing degree of the input data to the output data. And it can explore the regions that need to be focused in a focused manner and suppresses the interference of weakly relevant information. Bahdanau et al. [36] used an attention-like mechanism to simultaneously perform translation and alignment on machine translation task. It was the first proposal to apply the concept of attention mechanism to the field of natural language processing (NLP). Wang et al. [25] conducted a study on the generation of TCM prescriptions based on machine translation. The study used scaled dot-product attention and multihead transformation parallel computation to extract symptoms information. This approach can better explore potential correlations between symptoms. Li et al. [24] tried to use the knowledge of herbal effects to enhance the effect of TCM prescription generation. At the same time, these scholars also used multiple attention mechanisms to assist the acquisition of symptoms information. Liu et al. [26] used two kinds of attention in a study on TCM prescription generation. They were, respectively, main-subordinate symptom attention and dynamical herb attention. The first type of attention emphasizes which symptoms have a more significant impact on the disease. The second type of attention achieves the effect that the herbs treating the main symptoms were first predicted. Ruan et al. [23] also studied the attention mechanism in the generation of TCM prescriptions. They used attention mechanisms to explore the relationships between different symptoms and different herbs. These relationships included, but were not limited to, the same herbs for different symptoms, and different herbs for the same symptoms. Liu et al. [37] proposed the transfer learning model of the few-shot learning to generate TCM prescriptions. This study used multiple levels of attention during the prescription-generation phase to dig into the associations between symptoms information, medical history information, and herbs information.


## 3. Material and Method

An overview of the dual-branch guidance strategy combined with candidate attention model (DGSCAM) proposed in this paper is shown in Figure1. The model is based on the seq2seq structure and can well integrate TCM prescription knowledge for automatic generation of intelligent TCM prescriptions. First, in the encoding part, in order to allow the bidirectional hybrid encoder (EnGRU) to extract more accurate content representation Cs from the symptoms Ss1,s2,⋯,sn1, this paper designs a dual-branch information extraction module (DIEM). The branch of the cross-concept knowledge source guidance module (CKGM) in DIEM can assist the EnGRU branch to extract Cs using the potential association of prescriptions with symptoms. Second, in the decoding part, in order to consider the compatibility knowledge of TCM prescriptions, this paper proposes a task-qualified knowledge base matching module (TKMM). TKMM calculates the matching of symptoms S with the symptoms in the knowledge base (KB) built in this paper, and obtains the base prescriptions to form the prescription-based herbal candidates pool (HCP). Meanwhile, we propose the multidimensional complementary attention module (MCAM). MCAM combines the attention of HCP with the attention of the conventional herbal library (CHL) to improve the quality of generated prescriptions. Moreover, we improve a new coverage mechanism (Cover) to solve the problem of duplicate herbs in prescriptions Hh1,h1,⋯,hn4 generated by the candidates’ coverage decoder (DeGPT2). We will further explain the four important components of the model in this paper: DIEM, TKMM, MCAM, and DeGPT2 in the following sections.Figure 1
The framework of the proposed GSCCAM. (In CKGM, CKGM-encoder and CKGM-decoder are, respectively, the encoder and decoder of CKGM;Pp1,p2,⋯,pn2 is the prescription-guided; Vv1,v2,⋯,vn3 is the efficacy; Ch is the content representation of the prescription-guided efficacy. In EnGRU (encoder), HM is the hybrid module; hienc is the final hidden state of the symptoms at the ith step. In DeGPT2 (decoder), Hh1,h2,⋯,hn4 is generated prescription; Cover is the new coverage mechanism.).


### 3.1. Datasets

In this work, we use two datasets: the “symptoms-prescription” data pairs set (SP) and the “prescription-efficacy” data pairs set (PE). (1) There are three sources of the “symptoms-prescription” data pair set (SP), namely the public data set (CKCEST) [23], the traditional diagnostic records extracted from the ancient Chinese medical books (ACMB), and the clinical diagnosis records provided by cooperative Chinese medicine company (CCMC). Among them, the CKCEST and ACMB, respectively, contain 33,765 and 80,420 “symptoms-prescription” data pairs. CCMC contains 1,265 real clinical records in the form of “symptoms-prescription” data pairs. We clean the acquired data using TCM symptom differential diagnosis [38] and the TCM MeSH [25]. After normalized processing, we perform statistics on the resulting 115,450 “symptoms-prescription” data pairs (dataset 1), and obtain the distribution of symptoms sequence length and the distribution of herbs quantity in prescriptions. As shown in Figure 2, about 91.96% of the prescriptions contain no more than 21 symptoms and no more than 23 herbs. In order to avoid the dependence of model on too long data and lead to overfitting situations, we remove the data that do not satisfy these conditions. Ultimately, this paper obtains a dataset (SP) with 106,168 “symptoms-prescription” data pairs. To make the experimental results more robust, we randomly divide the dataset SP into two parts, 95,551 data for training (90%) and 10,617 data for testing (10%). (2) The “prescription-efficacy” data pairs set (PE) are derived from CKCEST and ACMB. The original data is standardized and normalized as above, and finally the PE containing 25,563 “prescription-efficacy” data pairs is obtained. Likewise, we divide the training set and test set in a ratio of 9 : 1.Figure 2
Distribution of symptoms sequence lengths and herbal quantities and their corresponding prescription quantities.


### 3.2. Dual-Branch Multiview Information Extraction Module

#### 3.2.1. Bidirectional Hybrid Encoder

EnGRU compresses the symptomsS into Cs through the knowledge of TCM syndrome differentiation. Since there are multiple complex logical relationships among a group of symptoms, the expression of each symptom does not independently represent a certain function of the body. Therefore, when extracting Cs from symptoms S, it is necessary to comprehensively consider the relationship among the symptoms. To this end, this paper encodes the symptoms Ss1,s2,⋯,sn1 using the bidirectional GRU [39] defined by
(1)hienc′=BiGRUsi,hienc′.This can get the forward hidden statesHfenc′=h1,fenc′,⋯⋯,hi,fenc′,⋯⋯,hn1,fenc′ and the backward hidden states Hbenc′=h1,benc′,⋯⋯,hi,benc′,⋯⋯,hn1,benc′. Meanwhile, the hybrid module (HM) is designed to adaptively weight the hidden states in both directions. The final hidden states of the symptoms Henc=h1enc,⋯⋯,hienc,⋯⋯,hn1enc are calculated by
(2)hienc=wis×hi,fenc′+1−wis×hi,benc′.Here, the parameterwis is the weight of the influencing degree of the forward-propagating hidden states on si. Its calculation method is shown in
(3)wis=sigmoidwzhi,fenc′,hi−1enc,si−1,∑1≤j≤isi×wjs+bz.wz and bz are the learning parameters. The final hidden states Henc are computed by the attention mechanism of Equation (4). Then, we obtain the content representation Cst of input symptoms S at the tth step.
(4)Cst=∑i=1n1ati∙hienc,where ati=softmaxVT∙tanhws∙st−1dec+whenc∙htenc; ws and whenc are learning parameters in ati. st−1dec is the hidden state of the DeGPT2, which will be introduced in the subsequent Section 3.5.


#### 3.2.2. Cross-Concept Knowledge Source Guidance Module

In the research on TCM prescriptions, it is generally accepted that the internal representation of symptoms can be manifested in another perspective by the efficacy of the corresponding prescription [40]. However, few studies on TCM prescription generation have used prescriptions as a knowledge source to guide the extraction of symptoms information. Guided by traditional Chinese medical knowledge [41], this paper attempts to use the efficacy Ch of symptoms-related prescription-guided to directly influence the extraction of symptoms content representation Cs. Although Ch does not directly act on the generation of the final target prescriptions. However, since Ch assists in the generation of Cs, it belongs to indirectly influencing the generation of the final target prescriptions. This paper hopes to obtain the more complete and accurate content representation Cs of symptoms S by exploiting the potential correlation between prescription and symptoms. To achieve this goal, we construct a cross-concept knowledge source guidance module (CKGM), as shown in Figure 3.Figure 3
Structure chart of the cross-concept knowledge source guidance module (CKGM).CKGM is guided by the theoretical knowledge of TCM on the efficacy of prescription extraction. And it constrains the network by the loss value of the generation efficacyVv1,v2,⋯,vn3 and the label efficacy Vv1′,v2′,⋯,vn5′ of the prescription Pp1,p2,⋯,pn2. Eventually, the trained CKGM can extract the content representation Ch that can represent the efficacy of prescription P. The prescription encoder CKGM-encoder and the efficacy decoder CKGM-decoder of CKGM are described below, respectively.(1) Prescription Encoder CKGM-Encoder. According to the theory of TCM prescription, the herbs within a prescription do not function individually, but synergistically and interactively. It is the same idea as the logical relationships among symptoms. So the encoder of CKGM uses the structure of the EnGRU as shown in Figure 1. After inputting the prescription P into the CKGM-encoder, we obtain the content representation Cht of input prescription P at the tthstep.(2) Efficacy Decoder CKGM-Decoder. GPT2 [42] is a character-level language model with deeper self-attention and autoregressive properties. It can take into account the generated content and predict one letter or character at a time, which is very much in line with the research idea of this paper. Therefore, this paper chooses a pretrained GPT2 model with 117 M parameters as the CKGM-decoder. The most likely prescription efficacy output vt can be expressed by
(5)vt=argmaxvPvtgt−1,Ch,v1,v2,⋯⋯,vt−1,where gt−1=GPT2Ch,gt−2,v1,⋯⋯,vt−2 is the hidden state of the CKGM-decoder at the t−1th step. After the above calculation process, the prescription efficacy V calculated from the prescription P is obtained.


#### 3.2.3. Similarity Calculation Module

For jointing the guidance informationCh of prescription, we propose the similarity calculation module (SCM). As shown in Equation (6), the semantic distance SC between Cs and Ch is calculated by the cosine similarity function as follows:
(6)SC=Cs∙ChCs∙Ch.IfSCis greater than or equal to the threshold δ set in this paper (δ is set to 0.6 in this paper), then it can indicate that the Cscomputed by the EnGRU can already represent the information of symptoms S completely and accurately. At this time, the supervision of the EnGRU by CKGM is reduced. If SCis smaller than the threshold δ set in this paper, it indicates that the EnGRU is not yet able to extract Cs well. And it needs to be supervised more by CKGM to achieve the expected effect.


### 3.3. Task-Qualified Knowledge Base Matching Module

TCM doctors prescribe prescriptions under the guidance of the theory of prescription compatibility [43]. At the same time, TCM doctors generally prescribe prescriptions based on their own past experiences and ancient medical books in history as references. In order to improve the rationality of the prescription generated by the model, and also to make the prescription generation based on a traceable basis, this paper proposes a task-qualified knowledge base matching module (TKMM). We expect that TKMM can construct a prescription-based herbal candidates pool (HCP) based on the pre-created knowledge base (KB) and Cs. The HCP is used to store symptom-related herbs and provide herbal candidates for subsequent prescription generation. It should be noted that some of the herbs selected in the HCP can treat diseases, and some only play an auxiliary role.The knowledge base (KB) uses dataset 1 as the essential data. This paper calculates the content representationKBCsi of each symptom KBSi in dataset 1, and stores the result in the data group KBi of “symptoms-prescription-content representation”. Taking the data group as the basic unit, a D×3-dimensional matrix is formed, that is the knowledge base (KB).To populate HCP for symptomsS, this paper calculates the correlation of Cs with KBCsi. The improved similarity calculation method based on the syndrome knowledge of TCM is shown in
(7)Sim=λ11−SP+λ2NorED,SPCs,KBCsi=∑Cs∙KBCsi∑Cs2·∑KBCsi2,EDCs,KBCsi=∑Cs−KBCsi2,Here,SP denotes the comparison method of spatial vector similarity; ED denotes the calculation method of Euclidean distance similarity; and NorED denotes the normalization of Euclidean distance. In particular, λ1 and λ2 are adjustable parameters for balancing the contributions of the two similarity methods, and in this paper, λ1 is set to 0.4 and λ2 is set to 0.6.The similarity calculation results are sorted from smallest to largest. The prescriptions corresponding to the firstk similar KBCsi are selected, and the herbs contained in these prescriptions are used to form the HCP.


### 3.4. Multidimensional Complementary Attention Module

In order to better generate TCM prescriptions, it is not enough to have only the symptoms-related HCP but also need to be supplemented with conventional herbal library (CHL) that contains more herbs. In dataset 1, many herbs are used less frequently and are not in the current list of commonly used TCM herbs. Therefore, we select herbs that occur more than 480 times to form the CHL. For the two candidate herbal forms to complement each other, we propose a multidimensional complementary attention module (MCAM) as shown in Figure4. The attention distribution at1 of the herbs in the CHL is calculated by the attention of the conventional herbal library (LA). And the attention distribution at2 of the herbs in the HCP is calculated by the attention of the prescription-based herbal candidates pool (PA). The specific implementation process is shown
(8)at1=softmaxV1T·tanhwq∙qi+wqs∙stdec+bq,at2=softmaxV2T·tanhwr∙rj+wrs∙stdec+br,Figure 4
Structure chart of the multidimensional complementary attention module (MCAM). (r1,r2,⋯,rm1 are herbs in the HCP, and q1,q2,⋯,qm2 are herbs in the CHL.).Here,qi is the ith herb in the CHL; rj is the jth herb in the HCP; stdec is the hidden state at tth step of the DeGPT2; and V1T, V2T, wq, wr, wqs, wrs, bq, and br are the learning parameters.In order to combine the two types of attention, we need an adaptive parameterghyb as shown in
(9)ghyb=sigmoidwhyb∙st−1dec,∑iqi∙ati2,ht−1,where whyb is a learning parameter. ht−1 and ∑iqi∙ati2, respectively, emphasize the LA and the PA, so ghyb can represent two kinds of attention. Meanwhile, since ∑iqi∙ati2 emphasizes the PA, so ghyb pays more attention to the PA. After the adaptive parameter ghyb is obtained, the complementary attention distribution atihyb and the complementary attention context vector.Ot are calculated by
(10)atihyb=ghyb∙ati2+1−ghyb∙ati1,(11)Ot=∑iatihyb∙hienc.Here,hienc is the final hidden state of the EnGRU at the ith step.


### 3.5. Candidates Coverage Decoder

The candidates coverage decoder (DeGPT2) is based on GPT2. To bring the generated prescriptions closer to the prescribing level of TCM doctors, DeGPT2 fuses the new coverage mechanism (Cover) with the multidimensional complementary attention module (MCAM) to generate targeted prescriptionsHh1,h1,⋯,hn4 with the content representation Cs of symptoms. The task of generating TCM prescriptions requires that there are no duplicate herbs in the final generated prescriptions. Inspired by Li et al. [44], this paper encourages the model to generate new herbs and suppress existing ones through the Cover. It can reduce the probability of duplicating herbs in the generated prescriptions and improve the recall rate. The process of implementing the Cover is shown as
(12)at3=softmaxV3T∙tanhwhenc∙hkenc+wm∙stdec+wcov∙h1,⋯⋯,ht+br,(13)ct3=∑katk3∙hkenc,where hkenc is the final hidden state of the EnGRU at the kth step; h1,⋯⋯,ht are the t herbs that have been generated; at3 is the coverage vector; and stdec is the hidden state of the DeGPT2 at the tth step, which calculated by
(14)stdec=GPT2st−1dec,h1,⋯⋯,ht,Ot,Cs,ct3.When the DeGPT2 generates a prescription, there are two sources of herbs that make up the prescription. One is copied from two candidate herbs, and the attention distribution can be regarded as the replication probability of each candidate herb attth step. The other is generated by the decoder. The herb ht predicted by our DeGPT2 at tth step is obtained by combining the vocabulary generation probability Pvocab with the candidate herbs replication probability Pcandidate. The calculation method of the two probabilities is shown as
(15)Pvocab=softmaxVvocab∙st−1dec,Cs+bvocab,Pcandidate=∑jatjhyb,where Vvocab and bvocab are the learning parameters. The two probabilities have different sources and require the weight value pgen∈0,1 shown in Equation (16) to control the final result:
(16)pgen=sigmoidws∙stdec+wp∙ht−1+wCs∙Cs+bgen.Here,ws, wp, wCs, and bgen are all learning parameters.The final probability ofht is obtained by combining Pvocab and Pcandidate by Equation (17) as follows:
(17)PVt=pgen∙Pvocab+1−pgen∙Pcandidate.


### 3.6. Loss Function

In the task of extractingCh (Section 3.2.2), we propose a multilevel loss function for training CKGM as shown as
(18)LOSSCKGM=−φ1∑t12qv′M1+vt′logvt+φ2−∑n2∑vtvti′logvti.Among them,vt′ is the label efficacy of the prescription P; vt is the generation efficacy of the prescription P; vti′ is the component of the label efficacy; vti is the component of the generation efficacy; qv′ is a vector with dimension equal to the number of all existing efficacies, set to 1 at the “label efficacy” position and 0 at the rest; M1 is the number of efficacies in the label efficacy; φ1 and φ2 are the parameters automatically learned by the model.LOSSCKGM is composed of the soft loss function [44] and the traditional loss function. This paper uses the soft loss function because there is no strict semantic order among multiple efficacies of TCM prescriptions. This paper uses the traditional loss function because each efficacy is a phrase or sentence with independent semantics, and there needs to be a strict semantic order within the efficacies.Inspired by Verboven et al. [45], this paper designs the loss function LOOSfinal as shown in Equation (19) to train DGSCAM.
(19)LOOSfinal=−ψ1∑t12qh′M2+ht′loght+ψ2LOSSCKGM,where ht is the herb generated at tth step of the DeGPT2; ht′ is the labeled herbs at tth step; qh′ is the one-hot code of the labeled prescription; M2 is the number of herbs in the labeled prescription. ψ1 and ψ2 are the weights for the two tasks, which are computed dynamically by our model.The loss functionLOOSfinal is composed of the soft loss function [44] and the multilevel loss function LOSSCKGM. It can well regulate the training process of DGSCAM. This paper uses the soft loss function because our task does not require strict word order for the herbs in generated prescriptions.


## 3.1. Datasets

In this work, we use two datasets: the “symptoms-prescription” data pairs set (SP) and the “prescription-efficacy” data pairs set (PE). (1) There are three sources of the “symptoms-prescription” data pair set (SP), namely the public data set (CKCEST) [23], the traditional diagnostic records extracted from the ancient Chinese medical books (ACMB), and the clinical diagnosis records provided by cooperative Chinese medicine company (CCMC). Among them, the CKCEST and ACMB, respectively, contain 33,765 and 80,420 “symptoms-prescription” data pairs. CCMC contains 1,265 real clinical records in the form of “symptoms-prescription” data pairs. We clean the acquired data using TCM symptom differential diagnosis [38] and the TCM MeSH [25]. After normalized processing, we perform statistics on the resulting 115,450 “symptoms-prescription” data pairs (dataset 1), and obtain the distribution of symptoms sequence length and the distribution of herbs quantity in prescriptions. As shown in Figure 2, about 91.96% of the prescriptions contain no more than 21 symptoms and no more than 23 herbs. In order to avoid the dependence of model on too long data and lead to overfitting situations, we remove the data that do not satisfy these conditions. Ultimately, this paper obtains a dataset (SP) with 106,168 “symptoms-prescription” data pairs. To make the experimental results more robust, we randomly divide the dataset SP into two parts, 95,551 data for training (90%) and 10,617 data for testing (10%). (2) The “prescription-efficacy” data pairs set (PE) are derived from CKCEST and ACMB. The original data is standardized and normalized as above, and finally the PE containing 25,563 “prescription-efficacy” data pairs is obtained. Likewise, we divide the training set and test set in a ratio of 9 : 1.Figure 2
Distribution of symptoms sequence lengths and herbal quantities and their corresponding prescription quantities.


## 3.2. Dual-Branch Multiview Information Extraction Module

### 3.2.1. Bidirectional Hybrid Encoder

EnGRU compresses the symptomsS into Cs through the knowledge of TCM syndrome differentiation. Since there are multiple complex logical relationships among a group of symptoms, the expression of each symptom does not independently represent a certain function of the body. Therefore, when extracting Cs from symptoms S, it is necessary to comprehensively consider the relationship among the symptoms. To this end, this paper encodes the symptoms Ss1,s2,⋯,sn1 using the bidirectional GRU [39] defined by
(1)hienc′=BiGRUsi,hienc′.This can get the forward hidden statesHfenc′=h1,fenc′,⋯⋯,hi,fenc′,⋯⋯,hn1,fenc′ and the backward hidden states Hbenc′=h1,benc′,⋯⋯,hi,benc′,⋯⋯,hn1,benc′. Meanwhile, the hybrid module (HM) is designed to adaptively weight the hidden states in both directions. The final hidden states of the symptoms Henc=h1enc,⋯⋯,hienc,⋯⋯,hn1enc are calculated by
(2)hienc=wis×hi,fenc′+1−wis×hi,benc′.Here, the parameterwis is the weight of the influencing degree of the forward-propagating hidden states on si. Its calculation method is shown in
(3)wis=sigmoidwzhi,fenc′,hi−1enc,si−1,∑1≤j≤isi×wjs+bz.wz and bz are the learning parameters. The final hidden states Henc are computed by the attention mechanism of Equation (4). Then, we obtain the content representation Cst of input symptoms S at the tth step.
(4)Cst=∑i=1n1ati∙hienc,where ati=softmaxVT∙tanhws∙st−1dec+whenc∙htenc; ws and whenc are learning parameters in ati. st−1dec is the hidden state of the DeGPT2, which will be introduced in the subsequent Section 3.5.


### 3.2.2. Cross-Concept Knowledge Source Guidance Module

In the research on TCM prescriptions, it is generally accepted that the internal representation of symptoms can be manifested in another perspective by the efficacy of the corresponding prescription [40]. However, few studies on TCM prescription generation have used prescriptions as a knowledge source to guide the extraction of symptoms information. Guided by traditional Chinese medical knowledge [41], this paper attempts to use the efficacy Ch of symptoms-related prescription-guided to directly influence the extraction of symptoms content representation Cs. Although Ch does not directly act on the generation of the final target prescriptions. However, since Ch assists in the generation of Cs, it belongs to indirectly influencing the generation of the final target prescriptions. This paper hopes to obtain the more complete and accurate content representation Cs of symptoms S by exploiting the potential correlation between prescription and symptoms. To achieve this goal, we construct a cross-concept knowledge source guidance module (CKGM), as shown in Figure 3.Figure 3
Structure chart of the cross-concept knowledge source guidance module (CKGM).CKGM is guided by the theoretical knowledge of TCM on the efficacy of prescription extraction. And it constrains the network by the loss value of the generation efficacyVv1,v2,⋯,vn3 and the label efficacy Vv1′,v2′,⋯,vn5′ of the prescription Pp1,p2,⋯,pn2. Eventually, the trained CKGM can extract the content representation Ch that can represent the efficacy of prescription P. The prescription encoder CKGM-encoder and the efficacy decoder CKGM-decoder of CKGM are described below, respectively.(1) Prescription Encoder CKGM-Encoder. According to the theory of TCM prescription, the herbs within a prescription do not function individually, but synergistically and interactively. It is the same idea as the logical relationships among symptoms. So the encoder of CKGM uses the structure of the EnGRU as shown in Figure 1. After inputting the prescription P into the CKGM-encoder, we obtain the content representation Cht of input prescription P at the tthstep.(2) Efficacy Decoder CKGM-Decoder. GPT2 [42] is a character-level language model with deeper self-attention and autoregressive properties. It can take into account the generated content and predict one letter or character at a time, which is very much in line with the research idea of this paper. Therefore, this paper chooses a pretrained GPT2 model with 117 M parameters as the CKGM-decoder. The most likely prescription efficacy output vt can be expressed by
(5)vt=argmaxvPvtgt−1,Ch,v1,v2,⋯⋯,vt−1,where gt−1=GPT2Ch,gt−2,v1,⋯⋯,vt−2 is the hidden state of the CKGM-decoder at the t−1th step. After the above calculation process, the prescription efficacy V calculated from the prescription P is obtained.


### 3.2.3. Similarity Calculation Module

For jointing the guidance informationCh of prescription, we propose the similarity calculation module (SCM). As shown in Equation (6), the semantic distance SC between Cs and Ch is calculated by the cosine similarity function as follows:
(6)SC=Cs∙ChCs∙Ch.IfSCis greater than or equal to the threshold δ set in this paper (δ is set to 0.6 in this paper), then it can indicate that the Cscomputed by the EnGRU can already represent the information of symptoms S completely and accurately. At this time, the supervision of the EnGRU by CKGM is reduced. If SCis smaller than the threshold δ set in this paper, it indicates that the EnGRU is not yet able to extract Cs well. And it needs to be supervised more by CKGM to achieve the expected effect.


## 3.2.1. Bidirectional Hybrid Encoder

EnGRU compresses the symptomsS into Cs through the knowledge of TCM syndrome differentiation. Since there are multiple complex logical relationships among a group of symptoms, the expression of each symptom does not independently represent a certain function of the body. Therefore, when extracting Cs from symptoms S, it is necessary to comprehensively consider the relationship among the symptoms. To this end, this paper encodes the symptoms Ss1,s2,⋯,sn1 using the bidirectional GRU [39] defined by
(1)hienc′=BiGRUsi,hienc′.This can get the forward hidden statesHfenc′=h1,fenc′,⋯⋯,hi,fenc′,⋯⋯,hn1,fenc′ and the backward hidden states Hbenc′=h1,benc′,⋯⋯,hi,benc′,⋯⋯,hn1,benc′. Meanwhile, the hybrid module (HM) is designed to adaptively weight the hidden states in both directions. The final hidden states of the symptoms Henc=h1enc,⋯⋯,hienc,⋯⋯,hn1enc are calculated by
(2)hienc=wis×hi,fenc′+1−wis×hi,benc′.Here, the parameterwis is the weight of the influencing degree of the forward-propagating hidden states on si. Its calculation method is shown in
(3)wis=sigmoidwzhi,fenc′,hi−1enc,si−1,∑1≤j≤isi×wjs+bz.wz and bz are the learning parameters. The final hidden states Henc are computed by the attention mechanism of Equation (4). Then, we obtain the content representation Cst of input symptoms S at the tth step.
(4)Cst=∑i=1n1ati∙hienc,where ati=softmaxVT∙tanhws∙st−1dec+whenc∙htenc; ws and whenc are learning parameters in ati. st−1dec is the hidden state of the DeGPT2, which will be introduced in the subsequent Section 3.5.


## 3.2.2. Cross-Concept Knowledge Source Guidance Module

In the research on TCM prescriptions, it is generally accepted that the internal representation of symptoms can be manifested in another perspective by the efficacy of the corresponding prescription [40]. However, few studies on TCM prescription generation have used prescriptions as a knowledge source to guide the extraction of symptoms information. Guided by traditional Chinese medical knowledge [41], this paper attempts to use the efficacy Ch of symptoms-related prescription-guided to directly influence the extraction of symptoms content representation Cs. Although Ch does not directly act on the generation of the final target prescriptions. However, since Ch assists in the generation of Cs, it belongs to indirectly influencing the generation of the final target prescriptions. This paper hopes to obtain the more complete and accurate content representation Cs of symptoms S by exploiting the potential correlation between prescription and symptoms. To achieve this goal, we construct a cross-concept knowledge source guidance module (CKGM), as shown in Figure 3.Figure 3
Structure chart of the cross-concept knowledge source guidance module (CKGM).CKGM is guided by the theoretical knowledge of TCM on the efficacy of prescription extraction. And it constrains the network by the loss value of the generation efficacyVv1,v2,⋯,vn3 and the label efficacy Vv1′,v2′,⋯,vn5′ of the prescription Pp1,p2,⋯,pn2. Eventually, the trained CKGM can extract the content representation Ch that can represent the efficacy of prescription P. The prescription encoder CKGM-encoder and the efficacy decoder CKGM-decoder of CKGM are described below, respectively.(1) Prescription Encoder CKGM-Encoder. According to the theory of TCM prescription, the herbs within a prescription do not function individually, but synergistically and interactively. It is the same idea as the logical relationships among symptoms. So the encoder of CKGM uses the structure of the EnGRU as shown in Figure 1. After inputting the prescription P into the CKGM-encoder, we obtain the content representation Cht of input prescription P at the tthstep.(2) Efficacy Decoder CKGM-Decoder. GPT2 [42] is a character-level language model with deeper self-attention and autoregressive properties. It can take into account the generated content and predict one letter or character at a time, which is very much in line with the research idea of this paper. Therefore, this paper chooses a pretrained GPT2 model with 117 M parameters as the CKGM-decoder. The most likely prescription efficacy output vt can be expressed by
(5)vt=argmaxvPvtgt−1,Ch,v1,v2,⋯⋯,vt−1,where gt−1=GPT2Ch,gt−2,v1,⋯⋯,vt−2 is the hidden state of the CKGM-decoder at the t−1th step. After the above calculation process, the prescription efficacy V calculated from the prescription P is obtained.


## 3.2.3. Similarity Calculation Module

For jointing the guidance informationCh of prescription, we propose the similarity calculation module (SCM). As shown in Equation (6), the semantic distance SC between Cs and Ch is calculated by the cosine similarity function as follows:
(6)SC=Cs∙ChCs∙Ch.IfSCis greater than or equal to the threshold δ set in this paper (δ is set to 0.6 in this paper), then it can indicate that the Cscomputed by the EnGRU can already represent the information of symptoms S completely and accurately. At this time, the supervision of the EnGRU by CKGM is reduced. If SCis smaller than the threshold δ set in this paper, it indicates that the EnGRU is not yet able to extract Cs well. And it needs to be supervised more by CKGM to achieve the expected effect.


## 3.3. Task-Qualified Knowledge Base Matching Module

TCM doctors prescribe prescriptions under the guidance of the theory of prescription compatibility [43]. At the same time, TCM doctors generally prescribe prescriptions based on their own past experiences and ancient medical books in history as references. In order to improve the rationality of the prescription generated by the model, and also to make the prescription generation based on a traceable basis, this paper proposes a task-qualified knowledge base matching module (TKMM). We expect that TKMM can construct a prescription-based herbal candidates pool (HCP) based on the pre-created knowledge base (KB) and Cs. The HCP is used to store symptom-related herbs and provide herbal candidates for subsequent prescription generation. It should be noted that some of the herbs selected in the HCP can treat diseases, and some only play an auxiliary role.The knowledge base (KB) uses dataset 1 as the essential data. This paper calculates the content representationKBCsi of each symptom KBSi in dataset 1, and stores the result in the data group KBi of “symptoms-prescription-content representation”. Taking the data group as the basic unit, a D×3-dimensional matrix is formed, that is the knowledge base (KB).To populate HCP for symptomsS, this paper calculates the correlation of Cs with KBCsi. The improved similarity calculation method based on the syndrome knowledge of TCM is shown in
(7)Sim=λ11−SP+λ2NorED,SPCs,KBCsi=∑Cs∙KBCsi∑Cs2·∑KBCsi2,EDCs,KBCsi=∑Cs−KBCsi2,Here,SP denotes the comparison method of spatial vector similarity; ED denotes the calculation method of Euclidean distance similarity; and NorED denotes the normalization of Euclidean distance. In particular, λ1 and λ2 are adjustable parameters for balancing the contributions of the two similarity methods, and in this paper, λ1 is set to 0.4 and λ2 is set to 0.6.The similarity calculation results are sorted from smallest to largest. The prescriptions corresponding to the firstk similar KBCsi are selected, and the herbs contained in these prescriptions are used to form the HCP.


## 3.4. Multidimensional Complementary Attention Module

In order to better generate TCM prescriptions, it is not enough to have only the symptoms-related HCP but also need to be supplemented with conventional herbal library (CHL) that contains more herbs. In dataset 1, many herbs are used less frequently and are not in the current list of commonly used TCM herbs. Therefore, we select herbs that occur more than 480 times to form the CHL. For the two candidate herbal forms to complement each other, we propose a multidimensional complementary attention module (MCAM) as shown in Figure4. The attention distribution at1 of the herbs in the CHL is calculated by the attention of the conventional herbal library (LA). And the attention distribution at2 of the herbs in the HCP is calculated by the attention of the prescription-based herbal candidates pool (PA). The specific implementation process is shown
(8)at1=softmaxV1T·tanhwq∙qi+wqs∙stdec+bq,at2=softmaxV2T·tanhwr∙rj+wrs∙stdec+br,Figure 4
Structure chart of the multidimensional complementary attention module (MCAM). (r1,r2,⋯,rm1 are herbs in the HCP, and q1,q2,⋯,qm2 are herbs in the CHL.).Here,qi is the ith herb in the CHL; rj is the jth herb in the HCP; stdec is the hidden state at tth step of the DeGPT2; and V1T, V2T, wq, wr, wqs, wrs, bq, and br are the learning parameters.In order to combine the two types of attention, we need an adaptive parameterghyb as shown in
(9)ghyb=sigmoidwhyb∙st−1dec,∑iqi∙ati2,ht−1,where whyb is a learning parameter. ht−1 and ∑iqi∙ati2, respectively, emphasize the LA and the PA, so ghyb can represent two kinds of attention. Meanwhile, since ∑iqi∙ati2 emphasizes the PA, so ghyb pays more attention to the PA. After the adaptive parameter ghyb is obtained, the complementary attention distribution atihyb and the complementary attention context vector.Ot are calculated by
(10)atihyb=ghyb∙ati2+1−ghyb∙ati1,(11)Ot=∑iatihyb∙hienc.Here,hienc is the final hidden state of the EnGRU at the ith step.


## 3.5. Candidates Coverage Decoder

The candidates coverage decoder (DeGPT2) is based on GPT2. To bring the generated prescriptions closer to the prescribing level of TCM doctors, DeGPT2 fuses the new coverage mechanism (Cover) with the multidimensional complementary attention module (MCAM) to generate targeted prescriptionsHh1,h1,⋯,hn4 with the content representation Cs of symptoms. The task of generating TCM prescriptions requires that there are no duplicate herbs in the final generated prescriptions. Inspired by Li et al. [44], this paper encourages the model to generate new herbs and suppress existing ones through the Cover. It can reduce the probability of duplicating herbs in the generated prescriptions and improve the recall rate. The process of implementing the Cover is shown as
(12)at3=softmaxV3T∙tanhwhenc∙hkenc+wm∙stdec+wcov∙h1,⋯⋯,ht+br,(13)ct3=∑katk3∙hkenc,where hkenc is the final hidden state of the EnGRU at the kth step; h1,⋯⋯,ht are the t herbs that have been generated; at3 is the coverage vector; and stdec is the hidden state of the DeGPT2 at the tth step, which calculated by
(14)stdec=GPT2st−1dec,h1,⋯⋯,ht,Ot,Cs,ct3.When the DeGPT2 generates a prescription, there are two sources of herbs that make up the prescription. One is copied from two candidate herbs, and the attention distribution can be regarded as the replication probability of each candidate herb attth step. The other is generated by the decoder. The herb ht predicted by our DeGPT2 at tth step is obtained by combining the vocabulary generation probability Pvocab with the candidate herbs replication probability Pcandidate. The calculation method of the two probabilities is shown as
(15)Pvocab=softmaxVvocab∙st−1dec,Cs+bvocab,Pcandidate=∑jatjhyb,where Vvocab and bvocab are the learning parameters. The two probabilities have different sources and require the weight value pgen∈0,1 shown in Equation (16) to control the final result:
(16)pgen=sigmoidws∙stdec+wp∙ht−1+wCs∙Cs+bgen.Here,ws, wp, wCs, and bgen are all learning parameters.The final probability ofht is obtained by combining Pvocab and Pcandidate by Equation (17) as follows:
(17)PVt=pgen∙Pvocab+1−pgen∙Pcandidate.


## 3.6. Loss Function

In the task of extractingCh (Section 3.2.2), we propose a multilevel loss function for training CKGM as shown as
(18)LOSSCKGM=−φ1∑t12qv′M1+vt′logvt+φ2−∑n2∑vtvti′logvti.Among them,vt′ is the label efficacy of the prescription P; vt is the generation efficacy of the prescription P; vti′ is the component of the label efficacy; vti is the component of the generation efficacy; qv′ is a vector with dimension equal to the number of all existing efficacies, set to 1 at the “label efficacy” position and 0 at the rest; M1 is the number of efficacies in the label efficacy; φ1 and φ2 are the parameters automatically learned by the model.LOSSCKGM is composed of the soft loss function [44] and the traditional loss function. This paper uses the soft loss function because there is no strict semantic order among multiple efficacies of TCM prescriptions. This paper uses the traditional loss function because each efficacy is a phrase or sentence with independent semantics, and there needs to be a strict semantic order within the efficacies.Inspired by Verboven et al. [45], this paper designs the loss function LOOSfinal as shown in Equation (19) to train DGSCAM.
(19)LOOSfinal=−ψ1∑t12qh′M2+ht′loght+ψ2LOSSCKGM,where ht is the herb generated at tth step of the DeGPT2; ht′ is the labeled herbs at tth step; qh′ is the one-hot code of the labeled prescription; M2 is the number of herbs in the labeled prescription. ψ1 and ψ2 are the weights for the two tasks, which are computed dynamically by our model.The loss functionLOOSfinal is composed of the soft loss function [44] and the multilevel loss function LOSSCKGM. It can well regulate the training process of DGSCAM. This paper uses the soft loss function because our task does not require strict word order for the herbs in generated prescriptions.


## 4. Results and Discussion

### 4.1. Implementation Details

All experiments are conducted on a workstation with Ubuntu 18.04 LTS, Intel(R) Xeon(R) W-2102 CPU and NVIDIA TITAN XP GPU. This paper implemented GSCCAM based on PyTorch. Our model sets the embedding size of Chinese characters in symptoms and prescription markers to 512, and the hidden states size of bidirectional GRU and GPT2 to 512 as well. We use the Adam optimizer (base learning rate is 0.001,beta1 is 0.9, beta2 is 0.999, epsilon is 1e-6, decay is 0, correct_bias is True), set the epoch number to 500 and the batch size to 64. During the training process, the model with the lowest total loss is saved for validation on the test set.


### 4.2. Evaluation Metrics

#### 4.2.1. Automatic Quantitative Evaluation Metrics

In order to automatically evaluate the performance of our model, this paper selects precision, recall, and F1 score as automatic quantitative evaluation metrics, which are commonly used in studies on TCM prescription generation. For all “symptoms-prescription” data pairsS,Plabel in the test dataset, they are defined as
(20)Precision=H∩PlabelH,Recall=H∩PlabelPlabel,F1−score=2H∩PlabelH+Plabel,where H represents the prescription sequence generated by the model GSCCAM. Plabel represents the “prescription” in the “symptoms-prescription” data pair, that is, the label prescription sequence.


#### 4.2.2. Human Qualitative Evaluation Metrics

Since our model takes into account the compatibility idea of TCM prescriptions in the final generation of prescriptions, the labeled prescriptions within the dataset are not necessarily the only choice for treating symptoms. However, the above automatic quantitative evaluation metrics can only calculate the quality of the model based on labeled prescriptions, and do not take into account the diversity of herbs and the concept of compatibility of prescriptions. So these metrics can only represent part of the performance of our model. Therefore, to evaluate our model more comprehensively, we invited four TCM doctors from Shanxi University of Traditional Chinese Medicine to independently perform the manual qualitative evaluation of the prescriptions generated by our model. Each doctor evaluates in terms of herbal effectiveness (HE) and herbal compatibility (HC) [26], both of which range from (0, 5), and higher scores indicate better effectiveness or compatibility.


### 4.3. Baseline Models

This paper chooses the following baseline models for comparison.(1)
KDHR [18]: a graph convolution model for multilayer information fusion with herbal attributes as auxiliary knowledge(2)
PTM [21]: the topic model that can describe the prescription generation process according to the theory of TCM, and it used the connection between herbs and symptoms and the respective internal connections between the two as the implementation of the TCM domain knowledge guidance model(3)
Coverage-Soft-Model [44]: it is a seq2seq model with a decoder having a coverage mechanism and a soft loss function(4)
Herb-Know [24]: a seq2seq model that incorporated external knowledge of herbs(5)
TPGen [23]: a seq2seq model using lite Transformer and bidirectional gated recurrent unit combined with TCM clinical knowledge


### 4.4. Contrast Experiments

#### 4.4.1. Comparative Results Using Automatic Quantitative Evaluation Metrics

To verify the performance of our model, we compare the performance differences between the baseline models in Section4.3 and our model using the test set data. Table 1 shows the performance comparison of our proposed GSCCAM with several other baseline models in terms of precision, recall, and F1 score. In the comparison, it is found that our GSCCAM significantly outperforms all other methods in the task of TCM prescription generation. As shown in Table 1, GSCCAM achieves 37.39% precision and 25.04% recall, and also achieves an excellent F1 score which is higher than the best baseline model TPGen by 4.81%. KDHR, PTM, and Coverage-Soft-Model all achieve relatively small precision and recall. In a sense, the multilabel classification idea of KDHR is difficult to grasp the compatibility among herbs. The topic model of PTM cannot incorporate the whole knowledge into the model when considering the prior knowledge of TCM. And Coverage-Soft-Model is limited to the coverage mechanism and soft loss function to solve the problem of duplication and weak order of herbs, which is less helpful to the target task. GSCCAM has improved these aspects and achieved the overall effect of “1+1+1>3” when compared with the above three models. Clearly, both Herb-Know and TPGen achieve good results on our test set. Through analysis, we believe that this is because these two models are better at capturing the relationship between symptoms and herbs than general deep learning methods.Table 1
Performance comparison of the baseline models with our model (GSCCAM) for automatic quantitative evaluation.
ModelsPrecisionRecallF1-scoreKDHR [18]0.20410.14730.1711PTM [21]0.19820.15360.1731Coverage-Soft-Model [44]0.18440.10730.1357Herb-Know [24]0.30820.21010.2499TPGen [23]0.27940.22910.2518GSCCAM0.37390.25040.2999


#### 4.4.2. Comparative Results Using Human Qualitative Evaluation Metrics

Since it takes a lot of time and energy for doctors to perform human qualitative evaluation, this paper chooses to randomly sample 500 data from the test set for this work. As shown in Table2, our GSCCAM outperforms other baseline models on both metrics, obtaining an average HE value of 4.15 and an average HC value of 3.55. This situation indicates that our model can generate effective herbs and the herbs basically conform to the principles of TCM compatibility. Both HE and HC scores of KDHR and Coverage-Soft-Model do not exceed 2.5, and the distribution of their total values is centered between [3.2, 4]. It indicates that the multilabel classification idea of KDHR does not fit well with the compatibility principles of TCM prescriptions. Meanwhile, Coverage-Soft-Model is difficult to obtain prescriptions that conform to TCM ideas because it does not focus specifically on TCM prior knowledge. It is difficult for PTM as a topic model to capture higher-order correlations of herbs or symptoms, so it can only achieve an average HE value of 2.85 and an average HC value of 1.775. Although TPGen and Herb-Know have good effects, they only consider the influence of external knowledge of TCM on the model and ignore the positive effect of general text on the model. In comparison, our model is highly approved by 4 doctors. And it is approximately 40.0% higher than the baseline model TPGen, which is the second-approved baseline model by doctors. This fully demonstrates the superiority of our GSCCAM in the prescription generation task. At the same time, our GSCCAM obtained almost unanimously optimistic results, with only the 15.81% fluctuation compared with the evaluation results of other baseline models. This indicates that our model has better stability and robustness in the field of specialized TCM.Table 2
Performance comparison of the baseline models and our model (GSCCAM) by four doctors for human qualitative evaluation.
ModelsDoctor1Doctor2Doctor3Doctor4HEHCTotalHEHCTotalHEHCTotalHEHCTotalKDHR [18]2.21.53.72.31.13.42.01.23.22.41.64.0PTM [21]2.91.74.62.81.94.72.61.54.13.12.05.1Coverage-Soft-Model [44]1.91.53.42.21.43.62.01.33.32.51.54.0Herb-Know [24]3.51.85.33.12.35.42.91.94.83.82.26.0TPGen [23]3.71.85.53.22.25.42.92.15.03.62.56.1GSCCAM4.33.57.84.23.47.63.93.67.54.23.77.9Considering that there may be inconsistencies in doctors’ recognition of multiple prescriptions generated by the same model. To avoid the influence of the volatility of doctors’ subjective judgments on the performance evaluation of the baseline models, we take out the symptomsSi corresponding to the prescription result Hi with the highest overall evaluation of each baseline model. Putting Si into our GSCCAM to generate prescription Hi−GSCCAM. By plotting a thermodynamic chart of the symptoms-herbs relationship of Hi, Hi−GSCCAM, and Si-labeled prescription Pilabel, the performance of our model versus the baseline models is more intuitively shown. As shown in Figure 5, the area in the ith row and jth column represents the relationship between the ith herb and the jth symptom. Green represents correlation, yellow represents irrelevance, and the darker color represents the heavier degree. It is easy to see from the visualization that our model can produce prescription results that are closer to the ground truth when compared to all baseline models. This shows that our model can still take into account the relationship between symptoms and herbs while considering the external knowledge of TCM herbs. And our model can balance the external knowledge of TCM herbs and the compatibility principles of TCM, and satisfactorily complete the task of prescription generation.Figure 5
Thermodynamic comparison chart of the symptoms-herbs relationship between the baseline models and our model (GSCCAM).
(a)
PKDHRlabel(b)
HKDHR−GSCCAM(c)
HKDHR(d)
PPTMlabel(e)
HPTM−GSCCAM(f)
HPTM(g)
PCoverage−Soft−Modellabel(h)
HCoverage−Soft−Model−GSCCAM(i)
HCoverage−Soft−Model(j)
PHerb−Knowlabel(k)
HHerb−Know−GSCCAM(l)
HHerb−Know(m)
PTPGenlabel(n)
HTPGen−GSCCAM(o)
HTPGen


### 4.5. Ablation Experiments

In this section, to further evaluate the effectiveness of the proposed cross-concept knowledge source guidance module (CKGM), task-qualified knowledge base matching module (TKMM), multidimensional complementary attention module (MCAM), we conduct several ablation experiments. Under the same training settings and the same dataset, we separately verify the performance of the modules mentioned in GSCCAM and evaluate them according to the above automatic quantitative evaluation metrics.


#### 4.5.1. Double-Branch Task Analysis

To verify the effectiveness of the CKGM branch network for the dual-branch task in the proposed method, this paper chooses the base model (BM) without the addition of CKGM to compare with our model. Meanwhile, to illustrate the applicability of the decoder structure in CKGM, this paper adjusts it to the decoder structure of GSCCAM for ablation experiments. As shown in Table3, the BM (EnGRU, DeGPT2) without the addition of CKGM produces the worst results (precision is 23.38%, recall is 17.65%, and F1 score is 20.11%). Compared to the BM (EnGRU and DeGPT2), the BMEnGRUandDeGPT2+CKGMCKGM−encoderandDeGPT2 still yields unsatisfactory results, although the values of precision, recall, and F1 score are improved. We analyze that the reason for this phenomenon is that the new coverage mechanism in the DeGPT2 does not have a positive effect on the task of prescription extraction efficacy, but rather has a negative impact. In contrast, we find that adding CKGM which has CKGM-decoder as a decoder in the base model is the most effective. It achieves the precision, recall, and F1 scores of 37.39%, 25.04%, and 29.99% in the prescription generation task, respectively. By using the CKGM included the CKGM-decoder decoder to fully exploit the efficacy of prescriptions, the base model is conceptually aided in extracting the intermediate vectors of symptoms with TCM prescriptions knowledge. Therefore, we believe that using CKGM to guide the base model to extract the intermediate information of symptoms is effective.Table 3
Performance comparison of the model of no branch network or the model of decoder of replacing branching network and our model (GSCCAM).
ModelsPrecisionRecallF1-scoreBM (EnGRU,DeGPT2)0.23380.17650.2011BMEnGRU,DeGPT2+CKGMCKGM−encoder,DeGPT20.32440.22810.2679BMEnGRU,DeGPT2+CKGM (CKGM-encoder, CKGM-decoder) (ours)0.37390.25040.2999


#### 4.5.2. Task-Qualified Knowledge Base Matching Module Analysis

To demonstrate the advantages of the TKMM, this paper compares the performance of our proposed GSCCAM with the model without TKMM. For simplicity, this paper only validates the effectiveness of TKMM on the basis of the model with the addition of the most effective dual-branch structure. The experimental results are shown in Figure6, which shows that the automatic quantitative evaluation metrics of the model are significantly reduced after removing TKMM. In noTKMM-GSCCAM, the precision, recall, and F1 score are 33.06%, 23.15%, and 27.23%, respectively, which are 4.33%, 1.89%, and 2.76% lower than those of GSCCAM, respectively. This means that TKMM can establish the HCP that is closer to the target task by screening the prescriptions with similar symptoms to be treated. The HCP can provide guidance on the direction of herbs selection for the generation of the final prescription, and help the model to come up with prescriptions that are more characteristic of TCM diagnostic thinking.Figure 6
Performance comparison of the models with and without TKMM.For the setting of the hyperparametersλ1 and λ2, this paper sets the different hyperparameter values by the traditional manual search method, so as to determine the best solution of the two similarity comparison methods. Since the hyperparameters λ1 and λ2 are synergistic, the basic condition of “λ1+λ2=1.0” needs to be satisfied. Therefore, this paper sets the values of λ1 to (0.0, 1.0), respectively, with 0.1 as the unit of change each time; λ2 corresponds to changing its value. As shown in Table 4, we find that the model performs the best overall when λ1 and λ2 are 0.4 and 0.6, respectively. We believe that this is due to the better sensitivity of the Euclidean distance similarity calculation method and the advantage of the spatial vector similarity calculation method that does not need to be normalized. And the optimal results are obtained by combining the advantages of each. Therefore, this paper uses 0.4 and 0.6 as the optimal values of λ1 and λ2.Table 4
Performance comparison of different combinations of hyperparameters in TKMM.
(λ1,λ2)PrecisionRecallF1-score(0.0,1.0)0.33960.20650.2568(0.1,0.9)0.34870.22980.2770(0.2,0.8)0.35210.23300.2804(0.3,0.7)0.36530.25090.2975(0.4,0.6)0.37390.25040.2999(0.5,0.5)0.37110.24850.2977(0.6,0.4)0.36620.24090.2906(0.7,0.3)0.36190.23370.2840(0.8,0.2)0.35500.22910.2785(0.9,0.1)0.34980.21340.2651(1.0,0.0)0.34020.19680.2493In addition, in order to evaluate the value of the number of candidate prescriptionsk selected from the KB to achieve the best performance of our model, this paper uses the best values of λ1 and λ2. While this paper uses the traditional manual search method to set the value of k to [5, 35] with 5 as the unit of variation each time. The experimental results are shown in Table 5. When k is taken as 20, our model has the best performance. After analysis, we conclude that when k is taken as less than 20, the number of herbs in the HCP is too small, which limits the range of model selection. When k is taken as greater than 20, the number of herbs in the HCP is too large, which lose the significance of building a targeted set of candidates herbs. Therefore, our model selects 20 as the optimal value of k.Table 5
Performance comparison of different number of candidate prescriptions in TKMM.
kPrecisionRecallF1-score50.35270.23960.2854100.35710.24020.2872150.36850.24680.2956200.37390.25040.2999250.35860.24510.2912300.34000.24130.2823350.33950.23780.2797


#### 4.5.3. Multidimensional Complementary Attention Module Analysis

In order to demonstrate that the two candidate herb sets of the HCP and the CHL can promote each other during the model training process, this paper conducts ablation experiments on the multidimensional complementary attention module (MCAM). This paper removes the HCP and the CHL, respectively, and observes the performance changes of the no-candidate herbal set, the single-candidate herbal set and the double-candidate herbal set. The results are shown in Table6. Without any candidate herb set, the precision, recall, and F1 score can only reach 31.55%, 20.05%, and 24.52%, respectively. This means that without any candidates, the model can only autonomously generate the herbs that make up the prescription based on the experience obtained during training. Without the guidance of any external thinking of TCM, the effect is bound to be unsatisfactory. In the case of retaining only the CHL as candidates, the precision, recall, and F1 scores are 32.92%, 22.01%, and 26.38%, respectively. In the case of retaining only the HCP as candidates, the precision, recall, and F1 scores are 35.36%, 44.39%, and 28.87%, respectively. Judging from the situation of these two single-candidate herbal sets, it is possible to obtain better experimental results by properly guiding the model with the correct knowledge of TCM. Moreover, since the HCP contains targeted candidate herbs, it is closer to the main treatment thinking of the target task than the general high-frequency herbs in the CHL. Therefore, adding the HCP is more helpful for the model to generate prescriptions according to the TCM ideology. We can also see from the data in Table 6 that only-HCP-GSCCAM has 2.44% higher precision, 2.38% higher recall, and 2.49% higher F1 score than only-CHL-GSCCAM. When both herbal candidate sets are used in the model, the experimental results show significant improvements in precision, recall, and F1 score. This further illustrates that the double-candidate herbal set can complement strengths each other, and our proposed MCAM module can achieve this complementary operation.Table 6
Performance comparison of the no-candidate herbal set, the single-candidate herbal set, and the double-candidate herbal set.
ModelsPrecisionRecallF1-scorenoCHL-noHCP-GSCCAM0.31550.20050.2452Only-CHL-GSCCAM0.32920.22010.2638Only-HCP-GSCCAM0.35360.24390.2887GSCCAM0.37390.25040.2999


### 4.6. Case Analysis

In order to better demonstrate the feasibility and reliability of our model in practical applications, this paper selects two groups of symptoms and compares the similarity between prescriptions generated by our model, prescriptions generated by the baseline models, and label prescriptions, respectively. And at the same time, the human qualitative evaluation is performed by professional doctors. The details are shown in Table7. After comprehensively considering the performance of each model, the following conclusions are drawn.Table 7
Comparison of predicted cases among labeled prescriptions, baseline models and our model (GSCCAM), and their human qualitative evaluation scores. Herbs whose predicted prescriptions are consistent with the labeled prescriptions are marked in bold font, and herbs that appear in the candidates are underlined.
Case 1Case 2SymptomsSixty-four kinds of wind enter skin, crawling like insects, stiff waist and spine, disharmony of internal organs, inability to stretch hands and feet, urticaria turns into sores after being scratched, itches on the body when the wind blows, finally, the face swells, the hands cannot be raised over the head, the mouth cannot talk.TotalThe Yang Qi in the liver is weak, the yin and cold are condensed, the ribs under the armpit are painful and full of Qi, and the eyes are blurred.TotalLabel prescriptionPhotinia serratifolia, Dried Zingiber, Scutellaria baicalensis georgi, Asarum, dried Rehmannia glutinosa, Ligusticum chuanxiong Hort, Panax ginseng, ephedra, peeled cinnamomum cassia, Angelica sinensis, Glycyrrhiza, Zanthoxylum ailanthoides.8.5Areca catechu, old zingiber, Aconitum carmichaeli, Poria cocos, Evodia rutaecarpa, Pericarpium Citri reticulata, peeled cinnamomum cassia, Platycodon grandiflorus, Atractylodes macrocephala.8.8KDHR [18]Photinia serratifolia, Saposhnikovia divaricata, Anemarrhena asphodeloides Bunge, Akebia quinata, Cynanchum otophyllum, Poria cocos, Cimicifuga foetida, dendrobium, Bupleurum, Gardenia jasminoides, Rehmannia glutinosa, Ziziphus jujuba, Atractylodes macrocephala, Houpoea officinalis, Mentha, Pueraria lobata, Citrus reticulata, Tribulus terrestris, Panax notoginseng, Arctium lappa, Fallopia multiflora.3.9Areca catechu, Aconitum carmichaeli, Cinnamomum cassia, Dimocarpus longan, roasted Zingiber, curcuma, Bupleurum, dried Zingiber, Dendrobium, Panax ginseng, Citrus medica, Perilla frutescens, chrysanthemum, Mentha, Houpoea officinalis.4.3PTM [21]Photinia serratifolia,Zingiber, Saposhnikovia divaricata, Perilla frutescens, Phellodendron, corydalis yanhusuo, Corydalis decumbens, Coptis chinensis, curcuma, roasted Zingiber.5.1Areca catechu, Zingiber, Cinnamomi Ramulus, dried Zingiber, Eucommia ulmoides, Cinnamomum cassia, Lycium barbarum.5.5Coverage-Soft-Model [44]Photinia serratifolia, Phellodendron, folium pini, aconitum kusnezoffii, Arctium lappa, Codonopsis pilosula, Mylabris, Aconitum carmichaeli, Bambusa basihirsuta McClure.3.5Areca catechu, Zingiber, Syzygium aromaticum, Cinnamomum cassia, Curcuma, Ephedra, Asarum.4.0Herb-Know [24]Photinia serratifolia, Scutellaria baicalensis georgi, Anemarrhena asphodeloides Bunge, Asarum, Atractylodes macrocephala, roasted Zingiber, Achyranthes bidentata, Corydalis decumbens, Saposhnikovia divaricata, Coptis chinensis, Tribulus terrestris, Alumen, Pinellia ternate, Nepeta cataria, Pericarpium Citrus reticulata.5.7Areca catechu, Zingiber, Aconitum carmichaeli, Poria cocos, Cynanchum otophyllum, Astragalus membranaceus, Eucommia ulmoides, Citrus medica, Lycium barbarum, Cassia tora, Dendrobium.5.6TPGen [23]Photinia serratifolia, Zingiber, Scutellaria baicalensis georgi, Pinellia ternate, Ziziphus jujuba, Pericarpium Citrus reticulata, Angelica sinensis, Corydalis yanhusuo, Dendrobium, Panax notoginseng.5.4Areca catechu, Lycium barbarum, dried zingiber, Aconitum carmichaeli, Pericarpium Citri reticulata, Ziziphus jujuba, Dioscoreae, aconitum.5.8GSCCAMPhotinia serratifolia, Cinnamomi Ramulus, Angelica sinensis, Glycyrrhiza, Zingiber, Nepeta cataria, Scutellaria baicalensis georgi, Asarum, Panax ginseng, dried Rehmannia glutinosa, Zanthoxylum ailanthoides, Saposhnikovia divaricata, Angelica dahurica.7.6Areca catechu, Platycodon grandiflorus, Zingiber, Aconitum carmichaeli, Poria cocos, Cinnamomi Ramulus, Pericarpium Citri reticulata, Astragalus membranaceus, Evodia rutaecarpa.7.8For case 1, the similarity between the prescription predicted by KDHR and the label is very low, and onlyPhotinia serratifolia is overlapped with the label content. Moreover, KDHR tends to predict high-frequency common herbs, such as Houpoea officinalis, Panax notoginseng, and Ziziphus jujuba. The number of generated herbs is far more than the actual required number. And the compatibility among herbs is very poor, almost irrelevant to the compatibility concept followed by TCM. PTM, as a topic model, likes to predict herbs with similar efficacy, such as Zingiber and Roasted zingiber and Coptis chinensis and Phellodendron. Meanwhile, although PTM considers the external knowledge of TCM, it is far from integrating the theoretical knowledge of TCM prescribing, and the predicted prescription also has few herbs that matched the label. In the prescription generated by Coverage-Soft-Model, only Photinia serratifolia is used to treat symptoms. Some of the herbs (e.g., Mylabris) not only do not play a curative role but even contradict the pathological nature of the symptoms. It may aggravate the condition of patient or even affect his life and health. Although Herb-Know can generate more reasonable prescriptions, the herbs Photinia serratifolia, Nepeta cataria, Roasted zingiber, and Corydalis decumbens, those are useful for the main symptoms account for less than 26.67% of the total herbs. And the rest of the herbs are mainly used to alleviate the subordinate symptoms. This shows that although Herb-Know can combine the knowledge of symptoms and herbs, its learning ability is limited. And it cannot better reflect the theoretical thinking of TCM prescribing. Three herbs (Photinia serratifolia, Scutellaria baicalensis georgi, and Angelica sinensis) are prescribed by TPGen that overlapped with the label. Most of the remaining herbs are mild tonics that could not be used to treat symptoms, but would not harm the patient’s health. Our GSCCAM yields prescription that is roughly close to the labeled prescription. At the same time, our model predicts that Photinia serratifolia, Nepeta cataria, Saposhnikovia divaricata and Zingiber all target the “deficient wind and wind evil”, and the main function of these herbs is to dispel wind. Although they are not exactly the same as the Photinia serratifolia, Dried zingiber and Ephedra used in the labeled prescription, they are the more reasonable combination than the labeled prescription. Angelica sinensis, dried Rehmannia glutinosa, and Angelica dahurica are not treating the main symptoms, but they can be used to nourish the blood, invigorate the blood and calm the wind, and relieve the condition. As for other herbs predicted by GSCCAM, such as Cinnamomi Ramulus, Scutellaria baicalensis georgi, and Glycyrrhiza can be used to lower ascending and floating Qi and clear heat; Asarum and Zanthoxylum ailanthoides can be used to tonify the Yang energy of the spleen and stomach; and Panax ginseng can nourish Qi and support correctness.For case 2, KDHR generates far more herbs than the number of herbs in the label, but it generates prescription that is not appropriate for treating this group of symptoms. This shows that KDHR pays great attention to the influence of herbal properties on the generated prescriptions, but ignores the connections among herbs. Therefore, in the prescriptions generated by KDHR, there areMentha, Chrysanthemum, and other herbs those are used only for better eyesight. Prescriptions generated by PTM can be marginally effective in treating the symptoms. For example, Cinnamomum cassia can treat pain of the ribs under the armpit caused by the invasion of cold evil. However, because PTM has difficulty capturing higher-order correlations between herbs and symptoms, herbs with very similar efficacy (Dried zingiber and Zingiber) appear in the prescriptions it generated. Areca catechu, Zingiber, and Cinnamomum cassia generated by Coverage-Soft-Model all have a certain effect on the treatment of symptoms. However, Curcuma and Syzygium aromaticum are herbs that cannot be used together in the compatibility of TCM prescriptions, so this prescription has great side effects on the treatment of symptoms. Herb-Know generates herbs those can have a positive effect on treating symptoms. For example, the combination of Astragalus membranaceus and Eucommia ulmoides can nourish the liver and benefit Qi. However, there are still some herbs (Lycium barbarum, Dendrobium, etc.) in the prescription those can only achieve the most basic auxiliary functions for the treatment of symptoms. The similarity between the prescription generated by TPGen and the label prescription is relatively high. But the main feature of TPGen is the improvement of the model structure, which ignores the influence of TCM knowledge on prescription generation. So it generates herbs those are mild but useless for treating symptoms. The coincidence rate between the herbs predicted by our GSCCAM and the herbs in the label prescription is as high as 66.67%, and the remaining herbs not in the label are from herbal candidates. This group of symptoms in case 2 is mainly liver deficiency and cold invasion. In terms of the efficacy in treating symptoms, the herbs generated by our model have clear effects and reasonable collocation. For example, Aconitum carmichaeli can increase Yang Qi, dispel cold and relieve pain; Zingiber and Astragalus membranaceus can treat weakness and cold invasion; and Pericarpium Citri reticulata and Evodia rutaecarpa can nourish Yang Qi. From the overall performance of prescription, the prescription generated by our model is more reasonable than those generated by other baseline models.Overall, our model does not just treat symptoms based on their correspondence with herbs. But it is influenced by the idea of potential compatibility in the prescription-based herbal candidates, analyzes and differentiates symptoms as professional TCM doctors do. And then it predicts appropriate herbs based on traditional prescription compatibility knowledge, ultimately forming a prescription with holistic, comprehensive, and correlative properties. It can also be seen through the human qualitative evaluation of doctors that our GSCCAM outperforms other baseline models. In some cases, the prescriptions predicted by our model are more reasonable than the labeled prescriptions.


## 4.1. Implementation Details

All experiments are conducted on a workstation with Ubuntu 18.04 LTS, Intel(R) Xeon(R) W-2102 CPU and NVIDIA TITAN XP GPU. This paper implemented GSCCAM based on PyTorch. Our model sets the embedding size of Chinese characters in symptoms and prescription markers to 512, and the hidden states size of bidirectional GRU and GPT2 to 512 as well. We use the Adam optimizer (base learning rate is 0.001,beta1 is 0.9, beta2 is 0.999, epsilon is 1e-6, decay is 0, correct_bias is True), set the epoch number to 500 and the batch size to 64. During the training process, the model with the lowest total loss is saved for validation on the test set.


## 4.2. Evaluation Metrics

### 4.2.1. Automatic Quantitative Evaluation Metrics

In order to automatically evaluate the performance of our model, this paper selects precision, recall, and F1 score as automatic quantitative evaluation metrics, which are commonly used in studies on TCM prescription generation. For all “symptoms-prescription” data pairsS,Plabel in the test dataset, they are defined as
(20)Precision=H∩PlabelH,Recall=H∩PlabelPlabel,F1−score=2H∩PlabelH+Plabel,where H represents the prescription sequence generated by the model GSCCAM. Plabel represents the “prescription” in the “symptoms-prescription” data pair, that is, the label prescription sequence.


### 4.2.2. Human Qualitative Evaluation Metrics

Since our model takes into account the compatibility idea of TCM prescriptions in the final generation of prescriptions, the labeled prescriptions within the dataset are not necessarily the only choice for treating symptoms. However, the above automatic quantitative evaluation metrics can only calculate the quality of the model based on labeled prescriptions, and do not take into account the diversity of herbs and the concept of compatibility of prescriptions. So these metrics can only represent part of the performance of our model. Therefore, to evaluate our model more comprehensively, we invited four TCM doctors from Shanxi University of Traditional Chinese Medicine to independently perform the manual qualitative evaluation of the prescriptions generated by our model. Each doctor evaluates in terms of herbal effectiveness (HE) and herbal compatibility (HC) [26], both of which range from (0, 5), and higher scores indicate better effectiveness or compatibility.


## 4.2.1. Automatic Quantitative Evaluation Metrics

In order to automatically evaluate the performance of our model, this paper selects precision, recall, and F1 score as automatic quantitative evaluation metrics, which are commonly used in studies on TCM prescription generation. For all “symptoms-prescription” data pairsS,Plabel in the test dataset, they are defined as
(20)Precision=H∩PlabelH,Recall=H∩PlabelPlabel,F1−score=2H∩PlabelH+Plabel,where H represents the prescription sequence generated by the model GSCCAM. Plabel represents the “prescription” in the “symptoms-prescription” data pair, that is, the label prescription sequence.


## 4.2.2. Human Qualitative Evaluation Metrics

Since our model takes into account the compatibility idea of TCM prescriptions in the final generation of prescriptions, the labeled prescriptions within the dataset are not necessarily the only choice for treating symptoms. However, the above automatic quantitative evaluation metrics can only calculate the quality of the model based on labeled prescriptions, and do not take into account the diversity of herbs and the concept of compatibility of prescriptions. So these metrics can only represent part of the performance of our model. Therefore, to evaluate our model more comprehensively, we invited four TCM doctors from Shanxi University of Traditional Chinese Medicine to independently perform the manual qualitative evaluation of the prescriptions generated by our model. Each doctor evaluates in terms of herbal effectiveness (HE) and herbal compatibility (HC) [26], both of which range from (0, 5), and higher scores indicate better effectiveness or compatibility.


## 4.3. Baseline Models

This paper chooses the following baseline models for comparison.(1)
KDHR [18]: a graph convolution model for multilayer information fusion with herbal attributes as auxiliary knowledge(2)
PTM [21]: the topic model that can describe the prescription generation process according to the theory of TCM, and it used the connection between herbs and symptoms and the respective internal connections between the two as the implementation of the TCM domain knowledge guidance model(3)
Coverage-Soft-Model [44]: it is a seq2seq model with a decoder having a coverage mechanism and a soft loss function(4)
Herb-Know [24]: a seq2seq model that incorporated external knowledge of herbs(5)
TPGen [23]: a seq2seq model using lite Transformer and bidirectional gated recurrent unit combined with TCM clinical knowledge


## 4.4. Contrast Experiments

### 4.4.1. Comparative Results Using Automatic Quantitative Evaluation Metrics

To verify the performance of our model, we compare the performance differences between the baseline models in Section4.3 and our model using the test set data. Table 1 shows the performance comparison of our proposed GSCCAM with several other baseline models in terms of precision, recall, and F1 score. In the comparison, it is found that our GSCCAM significantly outperforms all other methods in the task of TCM prescription generation. As shown in Table 1, GSCCAM achieves 37.39% precision and 25.04% recall, and also achieves an excellent F1 score which is higher than the best baseline model TPGen by 4.81%. KDHR, PTM, and Coverage-Soft-Model all achieve relatively small precision and recall. In a sense, the multilabel classification idea of KDHR is difficult to grasp the compatibility among herbs. The topic model of PTM cannot incorporate the whole knowledge into the model when considering the prior knowledge of TCM. And Coverage-Soft-Model is limited to the coverage mechanism and soft loss function to solve the problem of duplication and weak order of herbs, which is less helpful to the target task. GSCCAM has improved these aspects and achieved the overall effect of “1+1+1>3” when compared with the above three models. Clearly, both Herb-Know and TPGen achieve good results on our test set. Through analysis, we believe that this is because these two models are better at capturing the relationship between symptoms and herbs than general deep learning methods.Table 1
Performance comparison of the baseline models with our model (GSCCAM) for automatic quantitative evaluation.
ModelsPrecisionRecallF1-scoreKDHR [18]0.20410.14730.1711PTM [21]0.19820.15360.1731Coverage-Soft-Model [44]0.18440.10730.1357Herb-Know [24]0.30820.21010.2499TPGen [23]0.27940.22910.2518GSCCAM0.37390.25040.2999


### 4.4.2. Comparative Results Using Human Qualitative Evaluation Metrics

Since it takes a lot of time and energy for doctors to perform human qualitative evaluation, this paper chooses to randomly sample 500 data from the test set for this work. As shown in Table2, our GSCCAM outperforms other baseline models on both metrics, obtaining an average HE value of 4.15 and an average HC value of 3.55. This situation indicates that our model can generate effective herbs and the herbs basically conform to the principles of TCM compatibility. Both HE and HC scores of KDHR and Coverage-Soft-Model do not exceed 2.5, and the distribution of their total values is centered between [3.2, 4]. It indicates that the multilabel classification idea of KDHR does not fit well with the compatibility principles of TCM prescriptions. Meanwhile, Coverage-Soft-Model is difficult to obtain prescriptions that conform to TCM ideas because it does not focus specifically on TCM prior knowledge. It is difficult for PTM as a topic model to capture higher-order correlations of herbs or symptoms, so it can only achieve an average HE value of 2.85 and an average HC value of 1.775. Although TPGen and Herb-Know have good effects, they only consider the influence of external knowledge of TCM on the model and ignore the positive effect of general text on the model. In comparison, our model is highly approved by 4 doctors. And it is approximately 40.0% higher than the baseline model TPGen, which is the second-approved baseline model by doctors. This fully demonstrates the superiority of our GSCCAM in the prescription generation task. At the same time, our GSCCAM obtained almost unanimously optimistic results, with only the 15.81% fluctuation compared with the evaluation results of other baseline models. This indicates that our model has better stability and robustness in the field of specialized TCM.Table 2
Performance comparison of the baseline models and our model (GSCCAM) by four doctors for human qualitative evaluation.
ModelsDoctor1Doctor2Doctor3Doctor4HEHCTotalHEHCTotalHEHCTotalHEHCTotalKDHR [18]2.21.53.72.31.13.42.01.23.22.41.64.0PTM [21]2.91.74.62.81.94.72.61.54.13.12.05.1Coverage-Soft-Model [44]1.91.53.42.21.43.62.01.33.32.51.54.0Herb-Know [24]3.51.85.33.12.35.42.91.94.83.82.26.0TPGen [23]3.71.85.53.22.25.42.92.15.03.62.56.1GSCCAM4.33.57.84.23.47.63.93.67.54.23.77.9Considering that there may be inconsistencies in doctors’ recognition of multiple prescriptions generated by the same model. To avoid the influence of the volatility of doctors’ subjective judgments on the performance evaluation of the baseline models, we take out the symptomsSi corresponding to the prescription result Hi with the highest overall evaluation of each baseline model. Putting Si into our GSCCAM to generate prescription Hi−GSCCAM. By plotting a thermodynamic chart of the symptoms-herbs relationship of Hi, Hi−GSCCAM, and Si-labeled prescription Pilabel, the performance of our model versus the baseline models is more intuitively shown. As shown in Figure 5, the area in the ith row and jth column represents the relationship between the ith herb and the jth symptom. Green represents correlation, yellow represents irrelevance, and the darker color represents the heavier degree. It is easy to see from the visualization that our model can produce prescription results that are closer to the ground truth when compared to all baseline models. This shows that our model can still take into account the relationship between symptoms and herbs while considering the external knowledge of TCM herbs. And our model can balance the external knowledge of TCM herbs and the compatibility principles of TCM, and satisfactorily complete the task of prescription generation.Figure 5
Thermodynamic comparison chart of the symptoms-herbs relationship between the baseline models and our model (GSCCAM).
(a)
PKDHRlabel(b)
HKDHR−GSCCAM(c)
HKDHR(d)
PPTMlabel(e)
HPTM−GSCCAM(f)
HPTM(g)
PCoverage−Soft−Modellabel(h)
HCoverage−Soft−Model−GSCCAM(i)
HCoverage−Soft−Model(j)
PHerb−Knowlabel(k)
HHerb−Know−GSCCAM(l)
HHerb−Know(m)
PTPGenlabel(n)
HTPGen−GSCCAM(o)
HTPGen


## 4.4.1. Comparative Results Using Automatic Quantitative Evaluation Metrics

To verify the performance of our model, we compare the performance differences between the baseline models in Section4.3 and our model using the test set data. Table 1 shows the performance comparison of our proposed GSCCAM with several other baseline models in terms of precision, recall, and F1 score. In the comparison, it is found that our GSCCAM significantly outperforms all other methods in the task of TCM prescription generation. As shown in Table 1, GSCCAM achieves 37.39% precision and 25.04% recall, and also achieves an excellent F1 score which is higher than the best baseline model TPGen by 4.81%. KDHR, PTM, and Coverage-Soft-Model all achieve relatively small precision and recall. In a sense, the multilabel classification idea of KDHR is difficult to grasp the compatibility among herbs. The topic model of PTM cannot incorporate the whole knowledge into the model when considering the prior knowledge of TCM. And Coverage-Soft-Model is limited to the coverage mechanism and soft loss function to solve the problem of duplication and weak order of herbs, which is less helpful to the target task. GSCCAM has improved these aspects and achieved the overall effect of “1+1+1>3” when compared with the above three models. Clearly, both Herb-Know and TPGen achieve good results on our test set. Through analysis, we believe that this is because these two models are better at capturing the relationship between symptoms and herbs than general deep learning methods.Table 1
Performance comparison of the baseline models with our model (GSCCAM) for automatic quantitative evaluation.
ModelsPrecisionRecallF1-scoreKDHR [18]0.20410.14730.1711PTM [21]0.19820.15360.1731Coverage-Soft-Model [44]0.18440.10730.1357Herb-Know [24]0.30820.21010.2499TPGen [23]0.27940.22910.2518GSCCAM0.37390.25040.2999


## 4.4.2. Comparative Results Using Human Qualitative Evaluation Metrics

Since it takes a lot of time and energy for doctors to perform human qualitative evaluation, this paper chooses to randomly sample 500 data from the test set for this work. As shown in Table2, our GSCCAM outperforms other baseline models on both metrics, obtaining an average HE value of 4.15 and an average HC value of 3.55. This situation indicates that our model can generate effective herbs and the herbs basically conform to the principles of TCM compatibility. Both HE and HC scores of KDHR and Coverage-Soft-Model do not exceed 2.5, and the distribution of their total values is centered between [3.2, 4]. It indicates that the multilabel classification idea of KDHR does not fit well with the compatibility principles of TCM prescriptions. Meanwhile, Coverage-Soft-Model is difficult to obtain prescriptions that conform to TCM ideas because it does not focus specifically on TCM prior knowledge. It is difficult for PTM as a topic model to capture higher-order correlations of herbs or symptoms, so it can only achieve an average HE value of 2.85 and an average HC value of 1.775. Although TPGen and Herb-Know have good effects, they only consider the influence of external knowledge of TCM on the model and ignore the positive effect of general text on the model. In comparison, our model is highly approved by 4 doctors. And it is approximately 40.0% higher than the baseline model TPGen, which is the second-approved baseline model by doctors. This fully demonstrates the superiority of our GSCCAM in the prescription generation task. At the same time, our GSCCAM obtained almost unanimously optimistic results, with only the 15.81% fluctuation compared with the evaluation results of other baseline models. This indicates that our model has better stability and robustness in the field of specialized TCM.Table 2
Performance comparison of the baseline models and our model (GSCCAM) by four doctors for human qualitative evaluation.
ModelsDoctor1Doctor2Doctor3Doctor4HEHCTotalHEHCTotalHEHCTotalHEHCTotalKDHR [18]2.21.53.72.31.13.42.01.23.22.41.64.0PTM [21]2.91.74.62.81.94.72.61.54.13.12.05.1Coverage-Soft-Model [44]1.91.53.42.21.43.62.01.33.32.51.54.0Herb-Know [24]3.51.85.33.12.35.42.91.94.83.82.26.0TPGen [23]3.71.85.53.22.25.42.92.15.03.62.56.1GSCCAM4.33.57.84.23.47.63.93.67.54.23.77.9Considering that there may be inconsistencies in doctors’ recognition of multiple prescriptions generated by the same model. To avoid the influence of the volatility of doctors’ subjective judgments on the performance evaluation of the baseline models, we take out the symptomsSi corresponding to the prescription result Hi with the highest overall evaluation of each baseline model. Putting Si into our GSCCAM to generate prescription Hi−GSCCAM. By plotting a thermodynamic chart of the symptoms-herbs relationship of Hi, Hi−GSCCAM, and Si-labeled prescription Pilabel, the performance of our model versus the baseline models is more intuitively shown. As shown in Figure 5, the area in the ith row and jth column represents the relationship between the ith herb and the jth symptom. Green represents correlation, yellow represents irrelevance, and the darker color represents the heavier degree. It is easy to see from the visualization that our model can produce prescription results that are closer to the ground truth when compared to all baseline models. This shows that our model can still take into account the relationship between symptoms and herbs while considering the external knowledge of TCM herbs. And our model can balance the external knowledge of TCM herbs and the compatibility principles of TCM, and satisfactorily complete the task of prescription generation.Figure 5
Thermodynamic comparison chart of the symptoms-herbs relationship between the baseline models and our model (GSCCAM).
(a)
PKDHRlabel(b)
HKDHR−GSCCAM(c)
HKDHR(d)
PPTMlabel(e)
HPTM−GSCCAM(f)
HPTM(g)
PCoverage−Soft−Modellabel(h)
HCoverage−Soft−Model−GSCCAM(i)
HCoverage−Soft−Model(j)
PHerb−Knowlabel(k)
HHerb−Know−GSCCAM(l)
HHerb−Know(m)
PTPGenlabel(n)
HTPGen−GSCCAM(o)
HTPGen


## 4.5. Ablation Experiments

In this section, to further evaluate the effectiveness of the proposed cross-concept knowledge source guidance module (CKGM), task-qualified knowledge base matching module (TKMM), multidimensional complementary attention module (MCAM), we conduct several ablation experiments. Under the same training settings and the same dataset, we separately verify the performance of the modules mentioned in GSCCAM and evaluate them according to the above automatic quantitative evaluation metrics.


### 4.5.1. Double-Branch Task Analysis

To verify the effectiveness of the CKGM branch network for the dual-branch task in the proposed method, this paper chooses the base model (BM) without the addition of CKGM to compare with our model. Meanwhile, to illustrate the applicability of the decoder structure in CKGM, this paper adjusts it to the decoder structure of GSCCAM for ablation experiments. As shown in Table3, the BM (EnGRU, DeGPT2) without the addition of CKGM produces the worst results (precision is 23.38%, recall is 17.65%, and F1 score is 20.11%). Compared to the BM (EnGRU and DeGPT2), the BMEnGRUandDeGPT2+CKGMCKGM−encoderandDeGPT2 still yields unsatisfactory results, although the values of precision, recall, and F1 score are improved. We analyze that the reason for this phenomenon is that the new coverage mechanism in the DeGPT2 does not have a positive effect on the task of prescription extraction efficacy, but rather has a negative impact. In contrast, we find that adding CKGM which has CKGM-decoder as a decoder in the base model is the most effective. It achieves the precision, recall, and F1 scores of 37.39%, 25.04%, and 29.99% in the prescription generation task, respectively. By using the CKGM included the CKGM-decoder decoder to fully exploit the efficacy of prescriptions, the base model is conceptually aided in extracting the intermediate vectors of symptoms with TCM prescriptions knowledge. Therefore, we believe that using CKGM to guide the base model to extract the intermediate information of symptoms is effective.Table 3
Performance comparison of the model of no branch network or the model of decoder of replacing branching network and our model (GSCCAM).
ModelsPrecisionRecallF1-scoreBM (EnGRU,DeGPT2)0.23380.17650.2011BMEnGRU,DeGPT2+CKGMCKGM−encoder,DeGPT20.32440.22810.2679BMEnGRU,DeGPT2+CKGM (CKGM-encoder, CKGM-decoder) (ours)0.37390.25040.2999


### 4.5.2. Task-Qualified Knowledge Base Matching Module Analysis

To demonstrate the advantages of the TKMM, this paper compares the performance of our proposed GSCCAM with the model without TKMM. For simplicity, this paper only validates the effectiveness of TKMM on the basis of the model with the addition of the most effective dual-branch structure. The experimental results are shown in Figure6, which shows that the automatic quantitative evaluation metrics of the model are significantly reduced after removing TKMM. In noTKMM-GSCCAM, the precision, recall, and F1 score are 33.06%, 23.15%, and 27.23%, respectively, which are 4.33%, 1.89%, and 2.76% lower than those of GSCCAM, respectively. This means that TKMM can establish the HCP that is closer to the target task by screening the prescriptions with similar symptoms to be treated. The HCP can provide guidance on the direction of herbs selection for the generation of the final prescription, and help the model to come up with prescriptions that are more characteristic of TCM diagnostic thinking.Figure 6
Performance comparison of the models with and without TKMM.For the setting of the hyperparametersλ1 and λ2, this paper sets the different hyperparameter values by the traditional manual search method, so as to determine the best solution of the two similarity comparison methods. Since the hyperparameters λ1 and λ2 are synergistic, the basic condition of “λ1+λ2=1.0” needs to be satisfied. Therefore, this paper sets the values of λ1 to (0.0, 1.0), respectively, with 0.1 as the unit of change each time; λ2 corresponds to changing its value. As shown in Table 4, we find that the model performs the best overall when λ1 and λ2 are 0.4 and 0.6, respectively. We believe that this is due to the better sensitivity of the Euclidean distance similarity calculation method and the advantage of the spatial vector similarity calculation method that does not need to be normalized. And the optimal results are obtained by combining the advantages of each. Therefore, this paper uses 0.4 and 0.6 as the optimal values of λ1 and λ2.Table 4
Performance comparison of different combinations of hyperparameters in TKMM.
(λ1,λ2)PrecisionRecallF1-score(0.0,1.0)0.33960.20650.2568(0.1,0.9)0.34870.22980.2770(0.2,0.8)0.35210.23300.2804(0.3,0.7)0.36530.25090.2975(0.4,0.6)0.37390.25040.2999(0.5,0.5)0.37110.24850.2977(0.6,0.4)0.36620.24090.2906(0.7,0.3)0.36190.23370.2840(0.8,0.2)0.35500.22910.2785(0.9,0.1)0.34980.21340.2651(1.0,0.0)0.34020.19680.2493In addition, in order to evaluate the value of the number of candidate prescriptionsk selected from the KB to achieve the best performance of our model, this paper uses the best values of λ1 and λ2. While this paper uses the traditional manual search method to set the value of k to [5, 35] with 5 as the unit of variation each time. The experimental results are shown in Table 5. When k is taken as 20, our model has the best performance. After analysis, we conclude that when k is taken as less than 20, the number of herbs in the HCP is too small, which limits the range of model selection. When k is taken as greater than 20, the number of herbs in the HCP is too large, which lose the significance of building a targeted set of candidates herbs. Therefore, our model selects 20 as the optimal value of k.Table 5
Performance comparison of different number of candidate prescriptions in TKMM.
kPrecisionRecallF1-score50.35270.23960.2854100.35710.24020.2872150.36850.24680.2956200.37390.25040.2999250.35860.24510.2912300.34000.24130.2823350.33950.23780.2797


### 4.5.3. Multidimensional Complementary Attention Module Analysis

In order to demonstrate that the two candidate herb sets of the HCP and the CHL can promote each other during the model training process, this paper conducts ablation experiments on the multidimensional complementary attention module (MCAM). This paper removes the HCP and the CHL, respectively, and observes the performance changes of the no-candidate herbal set, the single-candidate herbal set and the double-candidate herbal set. The results are shown in Table6. Without any candidate herb set, the precision, recall, and F1 score can only reach 31.55%, 20.05%, and 24.52%, respectively. This means that without any candidates, the model can only autonomously generate the herbs that make up the prescription based on the experience obtained during training. Without the guidance of any external thinking of TCM, the effect is bound to be unsatisfactory. In the case of retaining only the CHL as candidates, the precision, recall, and F1 scores are 32.92%, 22.01%, and 26.38%, respectively. In the case of retaining only the HCP as candidates, the precision, recall, and F1 scores are 35.36%, 44.39%, and 28.87%, respectively. Judging from the situation of these two single-candidate herbal sets, it is possible to obtain better experimental results by properly guiding the model with the correct knowledge of TCM. Moreover, since the HCP contains targeted candidate herbs, it is closer to the main treatment thinking of the target task than the general high-frequency herbs in the CHL. Therefore, adding the HCP is more helpful for the model to generate prescriptions according to the TCM ideology. We can also see from the data in Table 6 that only-HCP-GSCCAM has 2.44% higher precision, 2.38% higher recall, and 2.49% higher F1 score than only-CHL-GSCCAM. When both herbal candidate sets are used in the model, the experimental results show significant improvements in precision, recall, and F1 score. This further illustrates that the double-candidate herbal set can complement strengths each other, and our proposed MCAM module can achieve this complementary operation.Table 6
Performance comparison of the no-candidate herbal set, the single-candidate herbal set, and the double-candidate herbal set.
ModelsPrecisionRecallF1-scorenoCHL-noHCP-GSCCAM0.31550.20050.2452Only-CHL-GSCCAM0.32920.22010.2638Only-HCP-GSCCAM0.35360.24390.2887GSCCAM0.37390.25040.2999


## 4.5.1. Double-Branch Task Analysis

To verify the effectiveness of the CKGM branch network for the dual-branch task in the proposed method, this paper chooses the base model (BM) without the addition of CKGM to compare with our model. Meanwhile, to illustrate the applicability of the decoder structure in CKGM, this paper adjusts it to the decoder structure of GSCCAM for ablation experiments. As shown in Table3, the BM (EnGRU, DeGPT2) without the addition of CKGM produces the worst results (precision is 23.38%, recall is 17.65%, and F1 score is 20.11%). Compared to the BM (EnGRU and DeGPT2), the BMEnGRUandDeGPT2+CKGMCKGM−encoderandDeGPT2 still yields unsatisfactory results, although the values of precision, recall, and F1 score are improved. We analyze that the reason for this phenomenon is that the new coverage mechanism in the DeGPT2 does not have a positive effect on the task of prescription extraction efficacy, but rather has a negative impact. In contrast, we find that adding CKGM which has CKGM-decoder as a decoder in the base model is the most effective. It achieves the precision, recall, and F1 scores of 37.39%, 25.04%, and 29.99% in the prescription generation task, respectively. By using the CKGM included the CKGM-decoder decoder to fully exploit the efficacy of prescriptions, the base model is conceptually aided in extracting the intermediate vectors of symptoms with TCM prescriptions knowledge. Therefore, we believe that using CKGM to guide the base model to extract the intermediate information of symptoms is effective.Table 3
Performance comparison of the model of no branch network or the model of decoder of replacing branching network and our model (GSCCAM).
ModelsPrecisionRecallF1-scoreBM (EnGRU,DeGPT2)0.23380.17650.2011BMEnGRU,DeGPT2+CKGMCKGM−encoder,DeGPT20.32440.22810.2679BMEnGRU,DeGPT2+CKGM (CKGM-encoder, CKGM-decoder) (ours)0.37390.25040.2999


## 4.5.2. Task-Qualified Knowledge Base Matching Module Analysis

To demonstrate the advantages of the TKMM, this paper compares the performance of our proposed GSCCAM with the model without TKMM. For simplicity, this paper only validates the effectiveness of TKMM on the basis of the model with the addition of the most effective dual-branch structure. The experimental results are shown in Figure6, which shows that the automatic quantitative evaluation metrics of the model are significantly reduced after removing TKMM. In noTKMM-GSCCAM, the precision, recall, and F1 score are 33.06%, 23.15%, and 27.23%, respectively, which are 4.33%, 1.89%, and 2.76% lower than those of GSCCAM, respectively. This means that TKMM can establish the HCP that is closer to the target task by screening the prescriptions with similar symptoms to be treated. The HCP can provide guidance on the direction of herbs selection for the generation of the final prescription, and help the model to come up with prescriptions that are more characteristic of TCM diagnostic thinking.Figure 6
Performance comparison of the models with and without TKMM.For the setting of the hyperparametersλ1 and λ2, this paper sets the different hyperparameter values by the traditional manual search method, so as to determine the best solution of the two similarity comparison methods. Since the hyperparameters λ1 and λ2 are synergistic, the basic condition of “λ1+λ2=1.0” needs to be satisfied. Therefore, this paper sets the values of λ1 to (0.0, 1.0), respectively, with 0.1 as the unit of change each time; λ2 corresponds to changing its value. As shown in Table 4, we find that the model performs the best overall when λ1 and λ2 are 0.4 and 0.6, respectively. We believe that this is due to the better sensitivity of the Euclidean distance similarity calculation method and the advantage of the spatial vector similarity calculation method that does not need to be normalized. And the optimal results are obtained by combining the advantages of each. Therefore, this paper uses 0.4 and 0.6 as the optimal values of λ1 and λ2.Table 4
Performance comparison of different combinations of hyperparameters in TKMM.
(λ1,λ2)PrecisionRecallF1-score(0.0,1.0)0.33960.20650.2568(0.1,0.9)0.34870.22980.2770(0.2,0.8)0.35210.23300.2804(0.3,0.7)0.36530.25090.2975(0.4,0.6)0.37390.25040.2999(0.5,0.5)0.37110.24850.2977(0.6,0.4)0.36620.24090.2906(0.7,0.3)0.36190.23370.2840(0.8,0.2)0.35500.22910.2785(0.9,0.1)0.34980.21340.2651(1.0,0.0)0.34020.19680.2493In addition, in order to evaluate the value of the number of candidate prescriptionsk selected from the KB to achieve the best performance of our model, this paper uses the best values of λ1 and λ2. While this paper uses the traditional manual search method to set the value of k to [5, 35] with 5 as the unit of variation each time. The experimental results are shown in Table 5. When k is taken as 20, our model has the best performance. After analysis, we conclude that when k is taken as less than 20, the number of herbs in the HCP is too small, which limits the range of model selection. When k is taken as greater than 20, the number of herbs in the HCP is too large, which lose the significance of building a targeted set of candidates herbs. Therefore, our model selects 20 as the optimal value of k.Table 5
Performance comparison of different number of candidate prescriptions in TKMM.
kPrecisionRecallF1-score50.35270.23960.2854100.35710.24020.2872150.36850.24680.2956200.37390.25040.2999250.35860.24510.2912300.34000.24130.2823350.33950.23780.2797


## 4.5.3. Multidimensional Complementary Attention Module Analysis

In order to demonstrate that the two candidate herb sets of the HCP and the CHL can promote each other during the model training process, this paper conducts ablation experiments on the multidimensional complementary attention module (MCAM). This paper removes the HCP and the CHL, respectively, and observes the performance changes of the no-candidate herbal set, the single-candidate herbal set and the double-candidate herbal set. The results are shown in Table6. Without any candidate herb set, the precision, recall, and F1 score can only reach 31.55%, 20.05%, and 24.52%, respectively. This means that without any candidates, the model can only autonomously generate the herbs that make up the prescription based on the experience obtained during training. Without the guidance of any external thinking of TCM, the effect is bound to be unsatisfactory. In the case of retaining only the CHL as candidates, the precision, recall, and F1 scores are 32.92%, 22.01%, and 26.38%, respectively. In the case of retaining only the HCP as candidates, the precision, recall, and F1 scores are 35.36%, 44.39%, and 28.87%, respectively. Judging from the situation of these two single-candidate herbal sets, it is possible to obtain better experimental results by properly guiding the model with the correct knowledge of TCM. Moreover, since the HCP contains targeted candidate herbs, it is closer to the main treatment thinking of the target task than the general high-frequency herbs in the CHL. Therefore, adding the HCP is more helpful for the model to generate prescriptions according to the TCM ideology. We can also see from the data in Table 6 that only-HCP-GSCCAM has 2.44% higher precision, 2.38% higher recall, and 2.49% higher F1 score than only-CHL-GSCCAM. When both herbal candidate sets are used in the model, the experimental results show significant improvements in precision, recall, and F1 score. This further illustrates that the double-candidate herbal set can complement strengths each other, and our proposed MCAM module can achieve this complementary operation.Table 6
Performance comparison of the no-candidate herbal set, the single-candidate herbal set, and the double-candidate herbal set.
ModelsPrecisionRecallF1-scorenoCHL-noHCP-GSCCAM0.31550.20050.2452Only-CHL-GSCCAM0.32920.22010.2638Only-HCP-GSCCAM0.35360.24390.2887GSCCAM0.37390.25040.2999


## 4.6. Case Analysis

In order to better demonstrate the feasibility and reliability of our model in practical applications, this paper selects two groups of symptoms and compares the similarity between prescriptions generated by our model, prescriptions generated by the baseline models, and label prescriptions, respectively. And at the same time, the human qualitative evaluation is performed by professional doctors. The details are shown in Table7. After comprehensively considering the performance of each model, the following conclusions are drawn.Table 7
Comparison of predicted cases among labeled prescriptions, baseline models and our model (GSCCAM), and their human qualitative evaluation scores. Herbs whose predicted prescriptions are consistent with the labeled prescriptions are marked in bold font, and herbs that appear in the candidates are underlined.
Case 1Case 2SymptomsSixty-four kinds of wind enter skin, crawling like insects, stiff waist and spine, disharmony of internal organs, inability to stretch hands and feet, urticaria turns into sores after being scratched, itches on the body when the wind blows, finally, the face swells, the hands cannot be raised over the head, the mouth cannot talk.TotalThe Yang Qi in the liver is weak, the yin and cold are condensed, the ribs under the armpit are painful and full of Qi, and the eyes are blurred.TotalLabel prescriptionPhotinia serratifolia, Dried Zingiber, Scutellaria baicalensis georgi, Asarum, dried Rehmannia glutinosa, Ligusticum chuanxiong Hort, Panax ginseng, ephedra, peeled cinnamomum cassia, Angelica sinensis, Glycyrrhiza, Zanthoxylum ailanthoides.8.5Areca catechu, old zingiber, Aconitum carmichaeli, Poria cocos, Evodia rutaecarpa, Pericarpium Citri reticulata, peeled cinnamomum cassia, Platycodon grandiflorus, Atractylodes macrocephala.8.8KDHR [18]Photinia serratifolia, Saposhnikovia divaricata, Anemarrhena asphodeloides Bunge, Akebia quinata, Cynanchum otophyllum, Poria cocos, Cimicifuga foetida, dendrobium, Bupleurum, Gardenia jasminoides, Rehmannia glutinosa, Ziziphus jujuba, Atractylodes macrocephala, Houpoea officinalis, Mentha, Pueraria lobata, Citrus reticulata, Tribulus terrestris, Panax notoginseng, Arctium lappa, Fallopia multiflora.3.9Areca catechu, Aconitum carmichaeli, Cinnamomum cassia, Dimocarpus longan, roasted Zingiber, curcuma, Bupleurum, dried Zingiber, Dendrobium, Panax ginseng, Citrus medica, Perilla frutescens, chrysanthemum, Mentha, Houpoea officinalis.4.3PTM [21]Photinia serratifolia,Zingiber, Saposhnikovia divaricata, Perilla frutescens, Phellodendron, corydalis yanhusuo, Corydalis decumbens, Coptis chinensis, curcuma, roasted Zingiber.5.1Areca catechu, Zingiber, Cinnamomi Ramulus, dried Zingiber, Eucommia ulmoides, Cinnamomum cassia, Lycium barbarum.5.5Coverage-Soft-Model [44]Photinia serratifolia, Phellodendron, folium pini, aconitum kusnezoffii, Arctium lappa, Codonopsis pilosula, Mylabris, Aconitum carmichaeli, Bambusa basihirsuta McClure.3.5Areca catechu, Zingiber, Syzygium aromaticum, Cinnamomum cassia, Curcuma, Ephedra, Asarum.4.0Herb-Know [24]Photinia serratifolia, Scutellaria baicalensis georgi, Anemarrhena asphodeloides Bunge, Asarum, Atractylodes macrocephala, roasted Zingiber, Achyranthes bidentata, Corydalis decumbens, Saposhnikovia divaricata, Coptis chinensis, Tribulus terrestris, Alumen, Pinellia ternate, Nepeta cataria, Pericarpium Citrus reticulata.5.7Areca catechu, Zingiber, Aconitum carmichaeli, Poria cocos, Cynanchum otophyllum, Astragalus membranaceus, Eucommia ulmoides, Citrus medica, Lycium barbarum, Cassia tora, Dendrobium.5.6TPGen [23]Photinia serratifolia, Zingiber, Scutellaria baicalensis georgi, Pinellia ternate, Ziziphus jujuba, Pericarpium Citrus reticulata, Angelica sinensis, Corydalis yanhusuo, Dendrobium, Panax notoginseng.5.4Areca catechu, Lycium barbarum, dried zingiber, Aconitum carmichaeli, Pericarpium Citri reticulata, Ziziphus jujuba, Dioscoreae, aconitum.5.8GSCCAMPhotinia serratifolia, Cinnamomi Ramulus, Angelica sinensis, Glycyrrhiza, Zingiber, Nepeta cataria, Scutellaria baicalensis georgi, Asarum, Panax ginseng, dried Rehmannia glutinosa, Zanthoxylum ailanthoides, Saposhnikovia divaricata, Angelica dahurica.7.6Areca catechu, Platycodon grandiflorus, Zingiber, Aconitum carmichaeli, Poria cocos, Cinnamomi Ramulus, Pericarpium Citri reticulata, Astragalus membranaceus, Evodia rutaecarpa.7.8For case 1, the similarity between the prescription predicted by KDHR and the label is very low, and onlyPhotinia serratifolia is overlapped with the label content. Moreover, KDHR tends to predict high-frequency common herbs, such as Houpoea officinalis, Panax notoginseng, and Ziziphus jujuba. The number of generated herbs is far more than the actual required number. And the compatibility among herbs is very poor, almost irrelevant to the compatibility concept followed by TCM. PTM, as a topic model, likes to predict herbs with similar efficacy, such as Zingiber and Roasted zingiber and Coptis chinensis and Phellodendron. Meanwhile, although PTM considers the external knowledge of TCM, it is far from integrating the theoretical knowledge of TCM prescribing, and the predicted prescription also has few herbs that matched the label. In the prescription generated by Coverage-Soft-Model, only Photinia serratifolia is used to treat symptoms. Some of the herbs (e.g., Mylabris) not only do not play a curative role but even contradict the pathological nature of the symptoms. It may aggravate the condition of patient or even affect his life and health. Although Herb-Know can generate more reasonable prescriptions, the herbs Photinia serratifolia, Nepeta cataria, Roasted zingiber, and Corydalis decumbens, those are useful for the main symptoms account for less than 26.67% of the total herbs. And the rest of the herbs are mainly used to alleviate the subordinate symptoms. This shows that although Herb-Know can combine the knowledge of symptoms and herbs, its learning ability is limited. And it cannot better reflect the theoretical thinking of TCM prescribing. Three herbs (Photinia serratifolia, Scutellaria baicalensis georgi, and Angelica sinensis) are prescribed by TPGen that overlapped with the label. Most of the remaining herbs are mild tonics that could not be used to treat symptoms, but would not harm the patient’s health. Our GSCCAM yields prescription that is roughly close to the labeled prescription. At the same time, our model predicts that Photinia serratifolia, Nepeta cataria, Saposhnikovia divaricata and Zingiber all target the “deficient wind and wind evil”, and the main function of these herbs is to dispel wind. Although they are not exactly the same as the Photinia serratifolia, Dried zingiber and Ephedra used in the labeled prescription, they are the more reasonable combination than the labeled prescription. Angelica sinensis, dried Rehmannia glutinosa, and Angelica dahurica are not treating the main symptoms, but they can be used to nourish the blood, invigorate the blood and calm the wind, and relieve the condition. As for other herbs predicted by GSCCAM, such as Cinnamomi Ramulus, Scutellaria baicalensis georgi, and Glycyrrhiza can be used to lower ascending and floating Qi and clear heat; Asarum and Zanthoxylum ailanthoides can be used to tonify the Yang energy of the spleen and stomach; and Panax ginseng can nourish Qi and support correctness.For case 2, KDHR generates far more herbs than the number of herbs in the label, but it generates prescription that is not appropriate for treating this group of symptoms. This shows that KDHR pays great attention to the influence of herbal properties on the generated prescriptions, but ignores the connections among herbs. Therefore, in the prescriptions generated by KDHR, there areMentha, Chrysanthemum, and other herbs those are used only for better eyesight. Prescriptions generated by PTM can be marginally effective in treating the symptoms. For example, Cinnamomum cassia can treat pain of the ribs under the armpit caused by the invasion of cold evil. However, because PTM has difficulty capturing higher-order correlations between herbs and symptoms, herbs with very similar efficacy (Dried zingiber and Zingiber) appear in the prescriptions it generated. Areca catechu, Zingiber, and Cinnamomum cassia generated by Coverage-Soft-Model all have a certain effect on the treatment of symptoms. However, Curcuma and Syzygium aromaticum are herbs that cannot be used together in the compatibility of TCM prescriptions, so this prescription has great side effects on the treatment of symptoms. Herb-Know generates herbs those can have a positive effect on treating symptoms. For example, the combination of Astragalus membranaceus and Eucommia ulmoides can nourish the liver and benefit Qi. However, there are still some herbs (Lycium barbarum, Dendrobium, etc.) in the prescription those can only achieve the most basic auxiliary functions for the treatment of symptoms. The similarity between the prescription generated by TPGen and the label prescription is relatively high. But the main feature of TPGen is the improvement of the model structure, which ignores the influence of TCM knowledge on prescription generation. So it generates herbs those are mild but useless for treating symptoms. The coincidence rate between the herbs predicted by our GSCCAM and the herbs in the label prescription is as high as 66.67%, and the remaining herbs not in the label are from herbal candidates. This group of symptoms in case 2 is mainly liver deficiency and cold invasion. In terms of the efficacy in treating symptoms, the herbs generated by our model have clear effects and reasonable collocation. For example, Aconitum carmichaeli can increase Yang Qi, dispel cold and relieve pain; Zingiber and Astragalus membranaceus can treat weakness and cold invasion; and Pericarpium Citri reticulata and Evodia rutaecarpa can nourish Yang Qi. From the overall performance of prescription, the prescription generated by our model is more reasonable than those generated by other baseline models.Overall, our model does not just treat symptoms based on their correspondence with herbs. But it is influenced by the idea of potential compatibility in the prescription-based herbal candidates, analyzes and differentiates symptoms as professional TCM doctors do. And then it predicts appropriate herbs based on traditional prescription compatibility knowledge, ultimately forming a prescription with holistic, comprehensive, and correlative properties. It can also be seen through the human qualitative evaluation of doctors that our GSCCAM outperforms other baseline models. In some cases, the prescriptions predicted by our model are more reasonable than the labeled prescriptions.


## 5. Conclusion and Future Work

In this paper, we propose a novel Chinese herb guided and prescription candidates attention depth model based on symptoms text, which can guide the automatic generation of prescriptions based on theoretical knowledge of TCM. In the process of generating TCM prescriptions, our model can provide prescription-based herbal candidates targeted for treating symptoms according to the idea of prescription compatibility. To our knowledge, which is the first such attempt in artificial intelligence generation of TCM prescriptions, our model uses the DIEM to extract symptom-related information from prescriptions corresponding to symptoms. And, in order to better reflect the compatibility idea of TCM prescriptions, we add the TKMM in this model. We combine public and clinical datasets in the training and testing process of the model. In the experiments, we comprehensively analyze the performance of our GSCCAM through automatic quantitative evaluation metrics such as precision, recall, and F1 score and human qualitative evaluation metrics of professional TCM doctors. Ultimately, our model achieves 37.39% precision, 25.04% recall, and 29.99% F1 score, and achieves an average doctor score of 7.7 out of 10. The experimental results show that our model has achieved excellent automatic evaluation effect values, and has been highly recognized by TCM professional doctors. We believe that the research of this paper is full of prospective significance. This is not only because our study is based on the computation of a large amount of data but also because it is very consistent with the theoretical knowledge of traditional Chinese medicine. The research perspective of this paper breaks the shackles of the original fixed thinking in the study of combining TCM prescribing science with computer technology. It moves the research in this direction toward a more cutting-edge direction. We hope that this work can lay a foundation for future research on TCM prescription generation and attract more researchers to focus on the combination of TCM prescription and artificial intelligence.In future work, we plan to study the association among herbs, the evolution pattern of symptoms, and herbal dosage and other information related to prescription. At the same time, we hope to introduce external knowledge of TCM such as syndrome element identification and syndrome guidance into the model. In addition, we will continue to collect more clinical data to further improve the model performance. The combination of TCM and computer technology is a very promising research. Given the serious and responsible attitude towards scientific research and the idea of seeking realism and stability, we will continue to increase our investment in this research and steadily explore the future planned work very fully, and make more and better down-to-earth achievements for this research direction.



---

*Source: 3301605-2023-01-05.xml*