# MKA: A Scalable Medical Knowledge-Assisted Mechanism for Generative Models on Medical Conversation Tasks

Authors: Ke Liang; Sifan Wu; Jiayi Gu
Journal: Computational and Mathematical Methods in Medicine
 (2021)

---

## Abstract

Using natural language processing (NLP) technologies to develop medical chatbots makes the diagnosis of the patient more convenient and efficient, which is a typical application in healthcare AI. Because of its importance, lots of researches have come out. Recently, the neural generative models have shown their impressive ability as the core of chatbot, while it cannot scale well when directly applied to medical conversation due to the lack of medical-specific knowledge. To address the limitation, a scalable medical knowledge-assisted mechanism (MKA) is proposed in this paper. The mechanism is aimed at assisting general neural generative models to achieve better performance on the medical conversation task. The medical-specific knowledge graph is designed within the mechanism, which contains 6 types of medical-related information, including department, drug, check, symptom, disease, and food. Besides, the specific token concatenation policy is defined to effectively inject medical information into the input data. Evaluation of our method is carried out on two typical medical datasets, MedDG and MedDialog-CN. The evaluation results demonstrate that models combined with our mechanism outperform original methods in multiple automatic evaluation metrics. Besides, MKA-BERT-GPT achieves state-of-the-art performance.


---

## Body

## 1. Introduction

Difficulty in seeing a doctor, long queuing time, and inconvenience of making appointments have long been hurdles facing patients when they try to access primary care services. To solve these challenges, many advanced artificial intelligence (AI) technologies [1–3] have been combined with healthcare to boost the availability of medical resources, such as applying pattern recognition methods on medical images [4, 5] and leveraging natural language processing (NLP) technologies to design medical chatbots [6, 7]. The medical chatbot is mainly aimed to offer the medical assistants including disease identification, self-reports based medical suggestions for drugs, foods and checks, and medical front desk service guiding the patient to suitable healthcare service department, etc [8, 9]. It has a significant potential to simplify the diagnostic process and relieve the cost of collecting information from patients. Besides, the preliminary diagnosis results generated by the model may assist doctors to make a diagnosis more efficiently.As the core of the medical chatbot, different methods have been investigated recently. In general, typical methods can be divided into two types [10], including information retrieval-based methods and neural generative methods. As for the first type, the methods usually match the response from the user-built question and answer (Q&A) pool based on the dialogue context, which means it can only provide the response that occurred in the existing pool. In another word, the poor-quality pool will influence a lot on the response. The second type of methods usually takes the dialogue context history as input and generates the suitable response word by word. Compared to retrieval-based methods, neural generative methods are more intelligent and flexible, which is what we focus on in this paper.Currently, different neural generative models are applied to medical domain, includingLSTM-based models, Transformer, GPT, and BERT-GPT. However, none of them performs well on the medical domain, which is reasonable. Here is the fact that the doctor makes diagnosis not only based on their experiences but also on the medical knowledge learned from professional books, especially when they meet rarely seen symptoms or diseases. The training procedure of the models only imitates the learning procedure of the experiences but leaves out the learning procedure from books. However, few works are about how to effectively integrate the medical knowledge with the neural generative models. Besides, patients are usually asked to fill in the patient self-report before the conversation starts with the doctor in real-world scenario. There are two common questions in the patient self-report, including “which department do you want to go?” and “what kind of the disease or symptom do you have?” Previous medical neural generative models will either leave out the information or roughly concatenate the original context in the patient self-report with the conversation history. It may cause either information loss or redundancy problem for the methods.To address the limitations, the objective of the paper is to propose a medical knowledge-assisted mechanism (MKA) to assist common neural generative models to achieve better performance for the medical conversation task. MKA is an effective and lightweight method to integrate the medical knowledge with neural generative models. The mechanism first introduces a medical knowledge generation module to generate the related medical knowledge, which generates the medical knowledge subgraph (MKGsub) generated from the patients’ self-report. The designed knowledge graphs contain related medical knowledge for each patient, including 6 types of entities (i.e., ϵdepartment, ϵdisease, ϵsymptom, ϵfood, ϵcheck, and ϵdrug) and 6 types of relations (i.e., γhas−disease, γhas−symptom, γneed−drug, γneed−check, γneed−food, and γno−food). Then, the medical knowledge information is fed into the token processor together with the dialogue contexts. Within the token processor, all the tokens will be reorganized based on the specific token concatenation policy. Finally, the processed data will be taken by selected generative models for training. In summary, we make the following contributions:
(1)
The paper proposes an effective and lightweight mechanism to integrate the medical knowledge into different neural generative models,MKA. Besides, the specific medical knowledge graph is designed to store the medical knowledge. To the best of our knowledge, MKA is the first scalable work that can integrate the medical knowledge into all kinds of neural generative models, especially for large-scale pretrained model, such as BERT-GPT(2)
To verify our method, we implement two models based on our mechanism,MKA-Transformer and MKA-BERT-GPT. The evaluation is carried out on 2 typical medical conversation benchmarks: MedDialog [11] and MedDG [12]. Our experiments show that the model combined with our method outperforms previous methods in multiple automatic evaluation metrics. Besides, the MKA-BERT-GPT achieves the best performance on the taskThe paper will be separated into 5 parts. Section2 will present the existing works related to medical dialogue generation tasks. Section 3 will explain the details of the proposed mechanism. Section 4 shows the experiment results and the analysis of the results. Section 5 concludes the advantages and disadvantages of our work and its potential future works.


## 2. Related Works

Recent research on medical chatbots focuses on natural language understanding which leverages different advanced natural language processing (NLP) techniques. In general, the medical dialogue methods can be divided into information retrieval-based methods and neural generative methods according to the types of the applied NLP techniques. The retrieval-based methods can be further classified into different subtypes, such as the entity inference [12, 13], relation prediction [14, 15], symptom matching and extraction [16, 17], and slot filling [18–20]. However, the retrieval-based methods are not so intelligent and flexible that they required a well-defined user-built question and answer (Q&A) pool, which can offer different potential response to different kinds of answer. In another word, the retrieval-based methods only predict the link between question and answers in the pool, instead of learning how to respond to different questions like the doctors. Therefore, the neural generative methods have drawn more and more attention.Nowadays, there is merely research on developing neural generative methods on medical domain. As an emerging research direction, most of the existing researches focus on testing different neural generative models on the benchmark domain-specific datasets. To figure out well the generative tasks inNLP, Hochreiter and Schmidhuber first proposed long short-term memory (LSTM) [21], which inspires multiple LSTM-based models [22–24]. Later, with the proposal of Transformer [25], researchers start to leverage Transformer units into novel dialogue generation models [26, 27]. Then, a more accurate and faster mechanism GPT is proposed [28]; different large-scale dialogue generative models are developed based on it [29, 30]. Meanwhile, some of the works also attempt to combine the different units to develop novel methods, where the state-of-the-art model is BERT-GPT model [31, 32]. However, the existing generative models for medical domain only learn the experience knowledge from the training procedure; few works effectively integrate the medical knowledge with the generative models.


## 3. Methodology

In this section, we discuss the methodology ofMKA, which is a scalable, effective, and lightweight mechanism to integrate the medical knowledge into neural generative models, especially for large-scale pretrained model, such as BERT-GPT.As shown in Figure1, our MKA consists of 3 parts, including the medical knowledge generation module, token processor, and neural generative model. The medical knowledge generation module is constituted by medical knowledge subgraph generator, topic detector, and medical knowledge extractor. It is aimed at generating related medical knowledge information tuple. The token processor is proposed to concatenate the medical knowledge information tuple with the dialogue context for each conversation turn. Besides, the neural generative model is leveraged for training and prediction. The details of each module will be illustrated in Sections 3.1, 3.2, and 3.3.Figure 1
Framework of our scalable medical knowledge-assisted generative model,MKA. In the figure, the ellipsoids represent the modules inside of our method. The orange ellipsoids show the automatic and scalable medical knowledge generation module. The figure legend inside of medical knowledge subgraph is corresponding to the entity types and relation types shown in Tables 1 and 2.


### 3.1. Medical Knowledge Generation Module

The medical knowledge generation module is proposed to generate the related medical knowledge information when the doctor handles a case. Within the module, there exist three parts, including medical knowledge subgraph generator, topic detector, and medical knowledge extractor. The medical knowledge subgraph generator first takes the patient self-report which contains the department and disease/symptom information described in Section1 as input and generates the medical knowledge subgraph (MKGsub) based on a global medical knowledge base (MKGbase). MKGbasecan be treated as a container which contains all the required medical professional books, while MKGsub stores the potential useful medical knowledge related to the specific case. Different questions will be asked in different turns for the multiturn conversation task. To reduce the redundant information, the topic detector inputs the patient question at ith turn and infers what question topic it related to. With the question topic and MKGsub, the medical knowledge extractor will extract the related medical knowledge information tuple. The details of each part will be shown as follows.


#### 3.1.1. Medical Knowledge Subgraph Generator

Within the medical knowledge subgraph generator, the medical knowledge subbase can be generated from the medical knowledge base based on the medical-related information extracted from patient self-report. In this paper, the knowledge base is represented the knowledge graph (KG), which is constituted by entities and relations. Besides, it is formally defined as below:
(1)KG=E,R,G=E×R×E,where E represents the set of entities (e.g., persons), R represents the considered types of relations between entities (e.g., friendship between persons), and G is a set of 3-element fact tuples where each tuple represents a factual relation between two entities.Therefore, two kinds of the medical knowledge graph (MKG) are proposed, including the medical knowledge base (MKGbase) generated based on [33] by removing the redundant information and medical knowledge subgraph (MKGsub). Both MKGbase and MKGsub contain 6 types of entities and 6 types of relations as shown in Tables 1 and 2. The entity and relation types are decided based on the working experiences of the author for the common medical conversation topics.Table 1
Definition of entity types in medical knowledge graphs.
Entity typeDescriptionϵdepartmentEntities for the clinical departmentsϵdiseaseEntities for the diseasesϵsymptomEntities for the symptomsϵfoodEntities for the foodϵcheckEntities for the drugsϵdrugEntities for the checksTable 2
Definition of relation types in medical knowledge graphs.
Relation typeDescriptionγhas−diseaseRelations betweenϵdepartmententityand ϵdisease entityγhas−symptomRelations betweenϵdiseaseentity and ϵsymptom entityγneed−drugRelations betweenϵdisease/ϵsymptomentity and ϵdrug entityγneed−checkRelations betweenϵdisease/ϵsymptomentity and ϵcheck entityγneed−foodRelations betweenϵdisease/ϵsymptomentity and recommended ϵfood entityγno−foodRelations betweenϵdisease/ϵsymptomentity and not recommended ϵfood entityAccording to the definition of the entity and relation types,MKGbase contains 26910 entities (i.e., 54 ϵdepartment, 8807 ϵdisease, 5998 ϵsymptom, 4870 ϵfood, 3353 ϵcheck, and 3828 ϵdrug) and 158216 fact tuples regarding the different relations (i.e., 8844 γhas−disease, 5998 γhas−symptom, 59467 γneed−drug, 39422 γneed−check, 22238 γneed−food, and 22247 γno−food).As forMKGsub, it is specific for each case, which is generated based on Algorithm 1. Within the algorithm, two subgraphs, G1 and G2, are extracted from MKGbase to constitute MKGsub. G1 is the graph with the ϵdepartment type entity ϵ1∗ as the root. Besides, it only contains γhas−disease and γhas−symptom two types of relations. G2 is the graph with the ϵdisease/ϵsymptom type entity ϵ2∗ as the root. Besides, it may contain all kinds of types of relations except γhas−disease. For more details, see Algorithm 1.Meanwhile, it is worth noting that we propose a way to calculate the distance for entity matching as shown in(2)distu,v=αβ×distLevenshteinu,vdistHammingu,v,where α and β are two hyperparameters. The distance takes advantage of both the Hamming distance [34] and Levenshtein distance [35]. It can not only care about the meaning of the tokens like the Hamming distance but also the position of the tokens like Levenshtein distance.Algorithm 1: Pseudocode of the medical knowledge subgraph generator.
Algorithm 1: the generation of the medical knowledge subgraphInput:Medical knowledge baseMKGbase=Eb,Rb,Gb.Patient self-reportPSR. (PSR⟶Department represents the blank for the patient’s ideal clinical department, and PSR⟶Disease/Symptom represents the blank for the description of the patient’s disease or symptom.)Output:Medical knowledge subgraphMKGsub=Es,Rs,GsMain:1:ifPSR⟶Department exists then2:   Extract theInfo1 from PSR⟶Department.3:ϵ1∗=argminϵdistInfo1,ϵ, where ϵ∈ϵdepartment and ϵ∈Eb.4:G1=E1,R1,G1, where ∀ϵ11,ϵ12⊂Eb,∀g11,g12⊂Gb,γ11=γhas−disease,γ12=γhas−symptom,∃g11=ϵ1∗,γ11,ϵ11∈G1,g12=ϵ11,γ12,ϵ12∈G1.5:end if6:ifPSR⟶Disease/Symptom exists then7:   Extract theInfo2 from PSR⟶Department/Symptom8:ϵ2∗=argminϵdistInfo1,ϵ, where ϵ∈ϵdisease∣ϵsymptom and ϵ∈Eb.9:G2=E2,R2,G2, where∀ϵ21,ϵ22,ϵ23,ϵ24⊂Eb,∀g21,g22,g23,g24⊂Gb,γ21=γhas−disease,γ22=γhas−symptom,∀γ23⊂γneed−drug,γneed−check,γneed−food,γno−food, (1) if ϵ2∗∈ϵdisease, ∃g22=ϵ2∗,γ22,ϵ22∈G2,g23=ϵ2∗,γ23,ϵ23∈G2,g24=ϵ22,γ23,ϵ24∈G2; (2) if ϵ2∗∈ϵsymptom,∃g21=ϵ21,γ21,ϵ2∗∈G2,g22=ϵ21,γ22,ϵ22∈G2,g23=ϵ21,γ23,ϵ23∈G2,g24=ϵ2∗,γ23,ϵ24∈G2.10:end if11:MKGsub=Es,Rs,Gs=E1∪E2,R1∪R2,G1∪G2=G1∪G2


#### 3.1.2. Topic Detector

The medical knowledge is related to what medical topic the patient asks. As a preparation for medical knowledge extractor, the question topic should be determined first. The content in the topic set matches with the relation set (i.e., disease, symptom, drug, check, positive food, and negative food). Besides, the six key phrase sets (KPS) are built corresponding to six topics based on the users’ experiences. It consists of some specific phrases related to the question topic. Based on it, the question detector is proposed as shown in Algorithm 2.Algorithm 2: Pseudocode of the topic detector.
Algorithm 2: the detection of the question topicInput:Key phrase setKPS=KPSdi,KPSs,KPSdr,KPSc,KPSrf,KPSnrf. (KPSdi is the set for disease topic, KPSs is the set for symptom topic, KPSdr is the set for drug topic, KPSc is the set for check topic, KPSrf is the set for the positive food topic, and KPSnrf is the set for the negative food topic.)The patient question inith conversation turn PQi.Similarity coefficientδ for checking whether the phrase is inside of the patient questionOutput:Question topic tuple inith conversation turn QTiMain:1:QTi={}2:forkps in KPSdo3:forkp in kpsdo4:ifkpinPQi∣distPQi,kp>δthen5:ifkps=KPSdithen6:            Append the “disease” topic inQTi7:else ifkps=KPSsthen8:            Append the “symptom” topic inQTi9:else ifkps=KPSdrthen10:            Append the “drug” topic inQTi11:else ifkps=KPScthen12:            Append the “check” topic inQTi13:else ifkps=KPSrfthen14:            Append the “recommended food” topic inQTi15:else ifkps=KPSnrfthen16:            Append the “not recommended food” topic inQTi17:end if18:end for19:end for


#### 3.1.3. Medical Knowledge Extractor

The medical knowledge extractor is aimed at extracting the related medical knowledge information tuples based on question topic and medical knowledge subgraph from the previous two parts. It extracts all entities with the specific entity type and connected with specific relation type in the subgraph. Besides,ϵ1∗,ϵ2∗ extracted from patient self-report will be directly appended into the tuple, since they are also useful medical knowledge extracted from the source. The details are shown in Algorithm 3.Algorithm 3: Pseudocode of the medical knowledge extractor.
Algorithm 3: the extraction of medical knowledge information tupleInput:Medical knowledge baseMKGsub=Es,Rs,Gs.Question topic tuple inith conversation turn QTiCorrespondingϵdepartment and ϵdisease/ϵsymptomentities in patient self-report ϵ1∗,ϵ2∗⟶Table3Output:Medical knowledge information tuple inith conversation turn MKIiMain:1:MKIi=ϵ1∗,ϵ2∗2:forqt in QTido3:ifQTi=“disease”then4:      Append allϵdisease entities except ϵ2∗in MKGsub to MKIi5:else ifQTi=“symptom”then6:      Append allϵsymptom entities except ϵ2∗ in MKGsub to MKIi7:else ifQTi=“drug”then8:      Append allϵdrug entities in MKGsub to MKIi9:else ifQTi=“check”then10:      Append allϵcheck entities in MKGsub to MKIi11:else ifQTi=“recommendedfood”then12:      Append allϵfood entities connected with γneed−food relation in MKGsub to MKIi13:else ifQTi=“notrecommendedfood”then14:      Append allϵfood entities connected with γno−food relation in MKGsub to MKIi15:end if16:end for


### 3.2. Token Processor

Compared to general neural generative models just taking dialogue contexts as inputs, our model generates the related medical knowledge information tuple which will be also fed into the models. To achieve this goal, a token processor is proposed to reorganize the tokens based on the policy shown in(3)X=MKIi⊕DRi−1⊕PQi=MKGsubUnseenFeatures⊕PSRSeenFeatures⊕DRi−1⊕PQi=AlltheelementsinMKIiexceptε1∗andε2∗⊕ε1∗⊕ε2∗⊕DRi−1⊕PQi,where X represents the sequence for neural generative models and PSR represents patient self-report. MKIi, DRi−1, and PQi represent the medical knowledge information tuple in ith conversation turn, the doctor response in i−1th conversation turn, and the patient question in ith conversation turn separately. Besides, ϵ1∗ andϵ2∗ are corresponding ϵdepartment and ϵdisease/ϵsymptom entities generated in Algorithm 1.


### 3.3. Neural Generative Model

In this paper, the neural generative model takes a source sequenceX=x1,x2,x3,⋯,xT consisting of T tokens generated from Section 3.2 and generates the response Y=y1,y2,y3,⋯,yT′ of length T′ tokens. In general, the model maximizes the generation probability of Y conditioned on X:py1,y2,y3,⋯,yT′∣x1,x2,x3,⋯,xT [8], and the objective function of the sequence-to-sequence generative models is defined as below. Besides, as for the multiturn conversation tasks, the doctor response at ith turn will be fed into the model as the existing dialogue context for next turn.
(4)py1,⋯,yT′∣x1,⋯,xT=py1∣x1,⋯,xT∏t=2T′pyt∣x1,⋯,xT,y1,⋯,yt−1.


## 3.1. Medical Knowledge Generation Module

The medical knowledge generation module is proposed to generate the related medical knowledge information when the doctor handles a case. Within the module, there exist three parts, including medical knowledge subgraph generator, topic detector, and medical knowledge extractor. The medical knowledge subgraph generator first takes the patient self-report which contains the department and disease/symptom information described in Section1 as input and generates the medical knowledge subgraph (MKGsub) based on a global medical knowledge base (MKGbase). MKGbasecan be treated as a container which contains all the required medical professional books, while MKGsub stores the potential useful medical knowledge related to the specific case. Different questions will be asked in different turns for the multiturn conversation task. To reduce the redundant information, the topic detector inputs the patient question at ith turn and infers what question topic it related to. With the question topic and MKGsub, the medical knowledge extractor will extract the related medical knowledge information tuple. The details of each part will be shown as follows.


### 3.1.1. Medical Knowledge Subgraph Generator

Within the medical knowledge subgraph generator, the medical knowledge subbase can be generated from the medical knowledge base based on the medical-related information extracted from patient self-report. In this paper, the knowledge base is represented the knowledge graph (KG), which is constituted by entities and relations. Besides, it is formally defined as below:
(1)KG=E,R,G=E×R×E,where E represents the set of entities (e.g., persons), R represents the considered types of relations between entities (e.g., friendship between persons), and G is a set of 3-element fact tuples where each tuple represents a factual relation between two entities.Therefore, two kinds of the medical knowledge graph (MKG) are proposed, including the medical knowledge base (MKGbase) generated based on [33] by removing the redundant information and medical knowledge subgraph (MKGsub). Both MKGbase and MKGsub contain 6 types of entities and 6 types of relations as shown in Tables 1 and 2. The entity and relation types are decided based on the working experiences of the author for the common medical conversation topics.Table 1
Definition of entity types in medical knowledge graphs.
Entity typeDescriptionϵdepartmentEntities for the clinical departmentsϵdiseaseEntities for the diseasesϵsymptomEntities for the symptomsϵfoodEntities for the foodϵcheckEntities for the drugsϵdrugEntities for the checksTable 2
Definition of relation types in medical knowledge graphs.
Relation typeDescriptionγhas−diseaseRelations betweenϵdepartmententityand ϵdisease entityγhas−symptomRelations betweenϵdiseaseentity and ϵsymptom entityγneed−drugRelations betweenϵdisease/ϵsymptomentity and ϵdrug entityγneed−checkRelations betweenϵdisease/ϵsymptomentity and ϵcheck entityγneed−foodRelations betweenϵdisease/ϵsymptomentity and recommended ϵfood entityγno−foodRelations betweenϵdisease/ϵsymptomentity and not recommended ϵfood entityAccording to the definition of the entity and relation types,MKGbase contains 26910 entities (i.e., 54 ϵdepartment, 8807 ϵdisease, 5998 ϵsymptom, 4870 ϵfood, 3353 ϵcheck, and 3828 ϵdrug) and 158216 fact tuples regarding the different relations (i.e., 8844 γhas−disease, 5998 γhas−symptom, 59467 γneed−drug, 39422 γneed−check, 22238 γneed−food, and 22247 γno−food).As forMKGsub, it is specific for each case, which is generated based on Algorithm 1. Within the algorithm, two subgraphs, G1 and G2, are extracted from MKGbase to constitute MKGsub. G1 is the graph with the ϵdepartment type entity ϵ1∗ as the root. Besides, it only contains γhas−disease and γhas−symptom two types of relations. G2 is the graph with the ϵdisease/ϵsymptom type entity ϵ2∗ as the root. Besides, it may contain all kinds of types of relations except γhas−disease. For more details, see Algorithm 1.Meanwhile, it is worth noting that we propose a way to calculate the distance for entity matching as shown in(2)distu,v=αβ×distLevenshteinu,vdistHammingu,v,where α and β are two hyperparameters. The distance takes advantage of both the Hamming distance [34] and Levenshtein distance [35]. It can not only care about the meaning of the tokens like the Hamming distance but also the position of the tokens like Levenshtein distance.Algorithm 1: Pseudocode of the medical knowledge subgraph generator.
Algorithm 1: the generation of the medical knowledge subgraphInput:Medical knowledge baseMKGbase=Eb,Rb,Gb.Patient self-reportPSR. (PSR⟶Department represents the blank for the patient’s ideal clinical department, and PSR⟶Disease/Symptom represents the blank for the description of the patient’s disease or symptom.)Output:Medical knowledge subgraphMKGsub=Es,Rs,GsMain:1:ifPSR⟶Department exists then2:   Extract theInfo1 from PSR⟶Department.3:ϵ1∗=argminϵdistInfo1,ϵ, where ϵ∈ϵdepartment and ϵ∈Eb.4:G1=E1,R1,G1, where ∀ϵ11,ϵ12⊂Eb,∀g11,g12⊂Gb,γ11=γhas−disease,γ12=γhas−symptom,∃g11=ϵ1∗,γ11,ϵ11∈G1,g12=ϵ11,γ12,ϵ12∈G1.5:end if6:ifPSR⟶Disease/Symptom exists then7:   Extract theInfo2 from PSR⟶Department/Symptom8:ϵ2∗=argminϵdistInfo1,ϵ, where ϵ∈ϵdisease∣ϵsymptom and ϵ∈Eb.9:G2=E2,R2,G2, where∀ϵ21,ϵ22,ϵ23,ϵ24⊂Eb,∀g21,g22,g23,g24⊂Gb,γ21=γhas−disease,γ22=γhas−symptom,∀γ23⊂γneed−drug,γneed−check,γneed−food,γno−food, (1) if ϵ2∗∈ϵdisease, ∃g22=ϵ2∗,γ22,ϵ22∈G2,g23=ϵ2∗,γ23,ϵ23∈G2,g24=ϵ22,γ23,ϵ24∈G2; (2) if ϵ2∗∈ϵsymptom,∃g21=ϵ21,γ21,ϵ2∗∈G2,g22=ϵ21,γ22,ϵ22∈G2,g23=ϵ21,γ23,ϵ23∈G2,g24=ϵ2∗,γ23,ϵ24∈G2.10:end if11:MKGsub=Es,Rs,Gs=E1∪E2,R1∪R2,G1∪G2=G1∪G2


### 3.1.2. Topic Detector

The medical knowledge is related to what medical topic the patient asks. As a preparation for medical knowledge extractor, the question topic should be determined first. The content in the topic set matches with the relation set (i.e., disease, symptom, drug, check, positive food, and negative food). Besides, the six key phrase sets (KPS) are built corresponding to six topics based on the users’ experiences. It consists of some specific phrases related to the question topic. Based on it, the question detector is proposed as shown in Algorithm 2.Algorithm 2: Pseudocode of the topic detector.
Algorithm 2: the detection of the question topicInput:Key phrase setKPS=KPSdi,KPSs,KPSdr,KPSc,KPSrf,KPSnrf. (KPSdi is the set for disease topic, KPSs is the set for symptom topic, KPSdr is the set for drug topic, KPSc is the set for check topic, KPSrf is the set for the positive food topic, and KPSnrf is the set for the negative food topic.)The patient question inith conversation turn PQi.Similarity coefficientδ for checking whether the phrase is inside of the patient questionOutput:Question topic tuple inith conversation turn QTiMain:1:QTi={}2:forkps in KPSdo3:forkp in kpsdo4:ifkpinPQi∣distPQi,kp>δthen5:ifkps=KPSdithen6:            Append the “disease” topic inQTi7:else ifkps=KPSsthen8:            Append the “symptom” topic inQTi9:else ifkps=KPSdrthen10:            Append the “drug” topic inQTi11:else ifkps=KPScthen12:            Append the “check” topic inQTi13:else ifkps=KPSrfthen14:            Append the “recommended food” topic inQTi15:else ifkps=KPSnrfthen16:            Append the “not recommended food” topic inQTi17:end if18:end for19:end for


### 3.1.3. Medical Knowledge Extractor

The medical knowledge extractor is aimed at extracting the related medical knowledge information tuples based on question topic and medical knowledge subgraph from the previous two parts. It extracts all entities with the specific entity type and connected with specific relation type in the subgraph. Besides,ϵ1∗,ϵ2∗ extracted from patient self-report will be directly appended into the tuple, since they are also useful medical knowledge extracted from the source. The details are shown in Algorithm 3.Algorithm 3: Pseudocode of the medical knowledge extractor.
Algorithm 3: the extraction of medical knowledge information tupleInput:Medical knowledge baseMKGsub=Es,Rs,Gs.Question topic tuple inith conversation turn QTiCorrespondingϵdepartment and ϵdisease/ϵsymptomentities in patient self-report ϵ1∗,ϵ2∗⟶Table3Output:Medical knowledge information tuple inith conversation turn MKIiMain:1:MKIi=ϵ1∗,ϵ2∗2:forqt in QTido3:ifQTi=“disease”then4:      Append allϵdisease entities except ϵ2∗in MKGsub to MKIi5:else ifQTi=“symptom”then6:      Append allϵsymptom entities except ϵ2∗ in MKGsub to MKIi7:else ifQTi=“drug”then8:      Append allϵdrug entities in MKGsub to MKIi9:else ifQTi=“check”then10:      Append allϵcheck entities in MKGsub to MKIi11:else ifQTi=“recommendedfood”then12:      Append allϵfood entities connected with γneed−food relation in MKGsub to MKIi13:else ifQTi=“notrecommendedfood”then14:      Append allϵfood entities connected with γno−food relation in MKGsub to MKIi15:end if16:end for


## 3.1.1. Medical Knowledge Subgraph Generator

Within the medical knowledge subgraph generator, the medical knowledge subbase can be generated from the medical knowledge base based on the medical-related information extracted from patient self-report. In this paper, the knowledge base is represented the knowledge graph (KG), which is constituted by entities and relations. Besides, it is formally defined as below:
(1)KG=E,R,G=E×R×E,where E represents the set of entities (e.g., persons), R represents the considered types of relations between entities (e.g., friendship between persons), and G is a set of 3-element fact tuples where each tuple represents a factual relation between two entities.Therefore, two kinds of the medical knowledge graph (MKG) are proposed, including the medical knowledge base (MKGbase) generated based on [33] by removing the redundant information and medical knowledge subgraph (MKGsub). Both MKGbase and MKGsub contain 6 types of entities and 6 types of relations as shown in Tables 1 and 2. The entity and relation types are decided based on the working experiences of the author for the common medical conversation topics.Table 1
Definition of entity types in medical knowledge graphs.
Entity typeDescriptionϵdepartmentEntities for the clinical departmentsϵdiseaseEntities for the diseasesϵsymptomEntities for the symptomsϵfoodEntities for the foodϵcheckEntities for the drugsϵdrugEntities for the checksTable 2
Definition of relation types in medical knowledge graphs.
Relation typeDescriptionγhas−diseaseRelations betweenϵdepartmententityand ϵdisease entityγhas−symptomRelations betweenϵdiseaseentity and ϵsymptom entityγneed−drugRelations betweenϵdisease/ϵsymptomentity and ϵdrug entityγneed−checkRelations betweenϵdisease/ϵsymptomentity and ϵcheck entityγneed−foodRelations betweenϵdisease/ϵsymptomentity and recommended ϵfood entityγno−foodRelations betweenϵdisease/ϵsymptomentity and not recommended ϵfood entityAccording to the definition of the entity and relation types,MKGbase contains 26910 entities (i.e., 54 ϵdepartment, 8807 ϵdisease, 5998 ϵsymptom, 4870 ϵfood, 3353 ϵcheck, and 3828 ϵdrug) and 158216 fact tuples regarding the different relations (i.e., 8844 γhas−disease, 5998 γhas−symptom, 59467 γneed−drug, 39422 γneed−check, 22238 γneed−food, and 22247 γno−food).As forMKGsub, it is specific for each case, which is generated based on Algorithm 1. Within the algorithm, two subgraphs, G1 and G2, are extracted from MKGbase to constitute MKGsub. G1 is the graph with the ϵdepartment type entity ϵ1∗ as the root. Besides, it only contains γhas−disease and γhas−symptom two types of relations. G2 is the graph with the ϵdisease/ϵsymptom type entity ϵ2∗ as the root. Besides, it may contain all kinds of types of relations except γhas−disease. For more details, see Algorithm 1.Meanwhile, it is worth noting that we propose a way to calculate the distance for entity matching as shown in(2)distu,v=αβ×distLevenshteinu,vdistHammingu,v,where α and β are two hyperparameters. The distance takes advantage of both the Hamming distance [34] and Levenshtein distance [35]. It can not only care about the meaning of the tokens like the Hamming distance but also the position of the tokens like Levenshtein distance.Algorithm 1: Pseudocode of the medical knowledge subgraph generator.
Algorithm 1: the generation of the medical knowledge subgraphInput:Medical knowledge baseMKGbase=Eb,Rb,Gb.Patient self-reportPSR. (PSR⟶Department represents the blank for the patient’s ideal clinical department, and PSR⟶Disease/Symptom represents the blank for the description of the patient’s disease or symptom.)Output:Medical knowledge subgraphMKGsub=Es,Rs,GsMain:1:ifPSR⟶Department exists then2:   Extract theInfo1 from PSR⟶Department.3:ϵ1∗=argminϵdistInfo1,ϵ, where ϵ∈ϵdepartment and ϵ∈Eb.4:G1=E1,R1,G1, where ∀ϵ11,ϵ12⊂Eb,∀g11,g12⊂Gb,γ11=γhas−disease,γ12=γhas−symptom,∃g11=ϵ1∗,γ11,ϵ11∈G1,g12=ϵ11,γ12,ϵ12∈G1.5:end if6:ifPSR⟶Disease/Symptom exists then7:   Extract theInfo2 from PSR⟶Department/Symptom8:ϵ2∗=argminϵdistInfo1,ϵ, where ϵ∈ϵdisease∣ϵsymptom and ϵ∈Eb.9:G2=E2,R2,G2, where∀ϵ21,ϵ22,ϵ23,ϵ24⊂Eb,∀g21,g22,g23,g24⊂Gb,γ21=γhas−disease,γ22=γhas−symptom,∀γ23⊂γneed−drug,γneed−check,γneed−food,γno−food, (1) if ϵ2∗∈ϵdisease, ∃g22=ϵ2∗,γ22,ϵ22∈G2,g23=ϵ2∗,γ23,ϵ23∈G2,g24=ϵ22,γ23,ϵ24∈G2; (2) if ϵ2∗∈ϵsymptom,∃g21=ϵ21,γ21,ϵ2∗∈G2,g22=ϵ21,γ22,ϵ22∈G2,g23=ϵ21,γ23,ϵ23∈G2,g24=ϵ2∗,γ23,ϵ24∈G2.10:end if11:MKGsub=Es,Rs,Gs=E1∪E2,R1∪R2,G1∪G2=G1∪G2


## 3.1.2. Topic Detector

The medical knowledge is related to what medical topic the patient asks. As a preparation for medical knowledge extractor, the question topic should be determined first. The content in the topic set matches with the relation set (i.e., disease, symptom, drug, check, positive food, and negative food). Besides, the six key phrase sets (KPS) are built corresponding to six topics based on the users’ experiences. It consists of some specific phrases related to the question topic. Based on it, the question detector is proposed as shown in Algorithm 2.Algorithm 2: Pseudocode of the topic detector.
Algorithm 2: the detection of the question topicInput:Key phrase setKPS=KPSdi,KPSs,KPSdr,KPSc,KPSrf,KPSnrf. (KPSdi is the set for disease topic, KPSs is the set for symptom topic, KPSdr is the set for drug topic, KPSc is the set for check topic, KPSrf is the set for the positive food topic, and KPSnrf is the set for the negative food topic.)The patient question inith conversation turn PQi.Similarity coefficientδ for checking whether the phrase is inside of the patient questionOutput:Question topic tuple inith conversation turn QTiMain:1:QTi={}2:forkps in KPSdo3:forkp in kpsdo4:ifkpinPQi∣distPQi,kp>δthen5:ifkps=KPSdithen6:            Append the “disease” topic inQTi7:else ifkps=KPSsthen8:            Append the “symptom” topic inQTi9:else ifkps=KPSdrthen10:            Append the “drug” topic inQTi11:else ifkps=KPScthen12:            Append the “check” topic inQTi13:else ifkps=KPSrfthen14:            Append the “recommended food” topic inQTi15:else ifkps=KPSnrfthen16:            Append the “not recommended food” topic inQTi17:end if18:end for19:end for


## 3.1.3. Medical Knowledge Extractor

The medical knowledge extractor is aimed at extracting the related medical knowledge information tuples based on question topic and medical knowledge subgraph from the previous two parts. It extracts all entities with the specific entity type and connected with specific relation type in the subgraph. Besides,ϵ1∗,ϵ2∗ extracted from patient self-report will be directly appended into the tuple, since they are also useful medical knowledge extracted from the source. The details are shown in Algorithm 3.Algorithm 3: Pseudocode of the medical knowledge extractor.
Algorithm 3: the extraction of medical knowledge information tupleInput:Medical knowledge baseMKGsub=Es,Rs,Gs.Question topic tuple inith conversation turn QTiCorrespondingϵdepartment and ϵdisease/ϵsymptomentities in patient self-report ϵ1∗,ϵ2∗⟶Table3Output:Medical knowledge information tuple inith conversation turn MKIiMain:1:MKIi=ϵ1∗,ϵ2∗2:forqt in QTido3:ifQTi=“disease”then4:      Append allϵdisease entities except ϵ2∗in MKGsub to MKIi5:else ifQTi=“symptom”then6:      Append allϵsymptom entities except ϵ2∗ in MKGsub to MKIi7:else ifQTi=“drug”then8:      Append allϵdrug entities in MKGsub to MKIi9:else ifQTi=“check”then10:      Append allϵcheck entities in MKGsub to MKIi11:else ifQTi=“recommendedfood”then12:      Append allϵfood entities connected with γneed−food relation in MKGsub to MKIi13:else ifQTi=“notrecommendedfood”then14:      Append allϵfood entities connected with γno−food relation in MKGsub to MKIi15:end if16:end for


## 3.2. Token Processor

Compared to general neural generative models just taking dialogue contexts as inputs, our model generates the related medical knowledge information tuple which will be also fed into the models. To achieve this goal, a token processor is proposed to reorganize the tokens based on the policy shown in(3)X=MKIi⊕DRi−1⊕PQi=MKGsubUnseenFeatures⊕PSRSeenFeatures⊕DRi−1⊕PQi=AlltheelementsinMKIiexceptε1∗andε2∗⊕ε1∗⊕ε2∗⊕DRi−1⊕PQi,where X represents the sequence for neural generative models and PSR represents patient self-report. MKIi, DRi−1, and PQi represent the medical knowledge information tuple in ith conversation turn, the doctor response in i−1th conversation turn, and the patient question in ith conversation turn separately. Besides, ϵ1∗ andϵ2∗ are corresponding ϵdepartment and ϵdisease/ϵsymptom entities generated in Algorithm 1.


## 3.3. Neural Generative Model

In this paper, the neural generative model takes a source sequenceX=x1,x2,x3,⋯,xT consisting of T tokens generated from Section 3.2 and generates the response Y=y1,y2,y3,⋯,yT′ of length T′ tokens. In general, the model maximizes the generation probability of Y conditioned on X:py1,y2,y3,⋯,yT′∣x1,x2,x3,⋯,xT [8], and the objective function of the sequence-to-sequence generative models is defined as below. Besides, as for the multiturn conversation tasks, the doctor response at ith turn will be fed into the model as the existing dialogue context for next turn.
(4)py1,⋯,yT′∣x1,⋯,xT=py1∣x1,⋯,xT∏t=2T′pyt∣x1,⋯,xT,y1,⋯,yt−1.


## 4. Experiments

### 4.1. Experiment Settings

Our approach is implemented in Python 3.7 and PyTorch 1.4.0. We implement two MKA-Diagen models, including MKA-Transformer and MKA-BERT-GPT. The neural generative models within them are trained with the default parameters in [11, 25]. The hyperparameters α and β in Equation (2) are set as 0.1 and -1, and the hyperparameter δ is set as 0.7. We perform all the experiments on the Matpool server with 11 GB NVIDIA GeForce RTX 2080 Ti. Our experiments were performed on Chinese MedDialog dataset [11] and MedDG [12] with the ratio 0.8 : 0.1 : 0.1 of training set : validation set : test set.The MKA-Transformer and MKA-BERT-GPT were compared with the baseline models (i.e., Transformer and BERT-GPT) and another typical nonsequence to sequence GPT-based model [11]. We followed the automatic evaluation metrics on the datasets to evaluate the performance of our method, including perplexity, NIST-2,4 [36], BLEU-2,4 [37], METEOR [38], Entropy-4 [39], and Dist-1,2 [40]. The perplexity shows the language quality of the generated responses. NIST-n, BLEU-n, and METEOR measure the similarity between the generated responses and ground truth and Entropy-n and Dist-n measure the lexical diversity of generated responses based on n-gram matching. The model with better performance will have the lower value of perplexity, the higher value of the other metrics.


### 4.2. Experiment Results and Analysis

In this part, the experiment results are shown together with the in-depth analysis of the results. Tables3 and 4 show the performance on the MedDialog-CN test set and MedDG test set separately. From the tables, we make the following observations.Table 3
Comparison of the models on MedDialog-CN, where the best results are in bold.
ModelDialog-GPTTransformerBERT-GPTMKA-TransformerMKA-BERT-GPTPerplexity9.719.528.238.818.04BLEU-25.21%4.92%4.88%5.02%5.71%BLEU-41.83%0.90%0.97%0.99%1.35%NIST-20.360.420.400.430.44NIST-40.320.400.390.400.43METEOR12.32%13.11%12.83%13.4%13.94%Entropy-413.7313.5113.813.7214.1Dist-10.02%0.03%0.03%0.03%0.04%Dist-22.01%2.02%2.14%2.11%2.22%Table 4
Comparison of the models on MedDG, where the best results are in bold.
ModelDialog-GPTTransformerBERT-GPTMKA-TransformerMKA-BERT-GPTPerplexity8.538.525.988.415.95BLEU-26.41%6.30%7.62%6.62%8.09%BLEU-42.12%2.08%2.57%2.40%2.87%NIST-20.380.370.420.390.43NIST-40.350.350.390.380.41METEOR13.78%14.32%16.25%14.88%16.63%Entropy-410.5610.1713.3810.2813.37Dist-10.01%0.01%0.02%0.01%0.02%Dist-21.72%1.67%2.00%1.69%2.00%


#### 4.2.1. Ablation Analysis

Focusing on the comparison between MKA-Transformer and Transformer and the performance comparison between MKA-BERT-GPT and BERT-GPT, it is easy to extract Table5. It is easy to observe that our mechanism improves the performance from all aspects on both two datasets. It means that our method is effective and scalable to be applied to different neural generative models and different datasets.Table 5
Improvements of the models with MKA compared to the baseline model on MedDialog-CN and MedDG test sets.
DatasetModelPerplexityBLEU-2,4NIST-2,4METEOREntropy-4Dist-1,2MedDialog-CNMKA-Transformer-0.710.10%, 0.09%0.01, 00.29%0.210.00%, 0.09%MKA-BERT-GPT-0.190.83%, 0.38%0.04, 0.041.11%0.30.01%, 0.08%MedDGMKA-Transformer-0.110.32%, 0.32%0.02, 0.030.56%0.110.00%, 0.02%MKA-BERT-GPT-0.030.47%, 0.30%0.01, 0.020.38%-0.010.00%, 0.00%


#### 4.2.2. Performance Comparison Analysis

Compared to the current state-of-the-art models, our MKA-BERT-GPT outperforms all the other methods. It achieves the lowest perplexity. It is because its baseline generative model, BERT-GPT, is pretrained on a large collection of corpora before training on the medical specific datasets. The pertaining procedure helps it to better understand the linguistic structure among words; meanwhile, the medical knowledge-assisted mechanism enables the model more learnable for medical conversation task. Meanwhile, as for the machine translation metrics (i.e., NIST-4, BLEU-2, BLEU-4, and METEOR), the performance of the MKA-BERT-GPT also is the best. It even overturns the performance comparison between BERT-GPT and Transformer. It indicates that our method highly improves the overlap between the generated response and the ground truth. Besides, although the MKA-BERT-GPT improves the value on diversity metrics (i.e., Entropy and Dist), the improvement is still minor. It indicates that our model cannot make a big breakthrough on the capability in generating diverse responses.


#### 4.2.3. Case Study Analysis

Tables6 and 7 represent the generated response of the models on two examples in the MedDialog-CN and MedDG test set. Since the dataset contains some Chinese medical dialogues, the translation is provided as well as the raw contents. The response generated by MKA-BERT-GPT is clinically informative and accurate. It prescribes “gastrointestinal functional problem.” Meanwhile, it can offer the detailed suggestions with rich medical knowledge information such as what kind of vegetables and fruits is recommended. Besides, the language quality of all the models is great, since all the responses are readable. Besides, there are still some spaces for the further improvement. For example, the responses generated from the models are not that overlap with the ground truth. It is because the ground truth is a Chinese medical response, which contains the concept of “qi,” which is not that easy for a general model to understand and provide the response. However, the responses of MKA-BERT-GPT are still relatively reasonable and also mention the conclusion of “the blood flow is not smooth.”Table 6
An example of generated responses on the MedDialog-CN test set.
Patient self-report科室 department: 男科 andrology疾病/症状 disease/symptom: 静索静脉曲张 varicose veinsPatient question 1我很怕是高位结扎手术引起的附睾炎, 希望大夫能给我说说是怎么回事, 该怎么处理?I am very afraid that it is the epididymitis associated with the high ligation operation. I hope the doctor can tell me how to deal with it quickly.Doctor response 1Ground truth中医药调理。You can recuperate yourself with Chinese medicine.Dialog-GPT手术部位不会引发附睾炎。The surgical part does not cause epididymitis.Transformer可能是近期没有充分休息, 免疫力下降。建议早点休息。It may be that you do not have enough rest and cause the decrease on the immunity. It is recommended to sleep early.BERT-GPT不要趴着睡觉, 影响伤口恢复。建议多休息。Do not sleep on your stomach, which will affect the recovery of the wound. It is recommended to rest more.MKA-Transformer可以吃营养的健康食品, 比如西兰花, 鸡蛋等, 同时注重卫生清洁, 每晚可以热敷缓解疼痛。You can eat nutritious and healthy foods, such as broccoli and eggs; meanwhile, pay attention to your hygiene and cleanliness. You can heat the area around your wound every night to relieve yourself.MKA-BERT-GPT不可以吃冷饮, 少吃辛辣刺激的食物, 影响伤口恢复。建议多吃蔬果类, 比如苹果。不要久坐不动, 少穿紧身裤。Do not drink cold drinks, and eat less spicy food, which will affect the recovery of the wound. It is recommended to eat more fruits and vegetables, such as apples. Do not sit for a long time and do not wear tight pants.Patient question 2请问我这是附睾炎吗?或是什么?恳请大夫您为我指点!感谢。Is this epididymitis? Or what? I hope you, the doctor, to give me some advice! Thanks!Doctor response 2Ground truth局部气血不畅。The flow of the blood and qi in the local area is not that smooth.Dialog-GPT放宽心, 只是心理作用。Relax, it is just a psychological effect.Transformer只是术后伤口疼痛。It is just that the wound is painful after the operation.BERT-GPT常见血流不通问题。It is the common problem about the blood.MKA-Transformer可能是运动过量导致提睾肌过度收缩, 导致疼痛。Excessive exercise may cause excessive contraction of the cremaster muscle. It will make you feel painful.MKA-BERT-GPT血流不通, 建议过几天复查伤口恢复情况, 减轻心理负担。The blood flow is not smooth. It is recommended to review the situation of the recovery of the wound after a few days. Besides, you need to reduce the psychological burden.Table 7
An example of generated responses on the MedDG test set.
Patient self-report科室 department: 肛肠科 anorectal branch疾病/症状 disease/symptom: 便秘,便血 constipation, blood in the stoolPatient question 1医生你好, 最近我大便总是很干燥, 而且有好几次大便之后, 发现有血, 我这个是什么情况?Hello, doctor. Recently, I have found my stools were very dry. Besides, there is blood inside of them if I poop for several times. What is wrong with me?Doctor response 1Ground truth你好, 可能存在痔疮出血!但还是建议您做个肠镜!Hello, there may be bleeding from hemorrhoids! But it is still recommended that you have a colonoscopy!Dialog-GPT你好, 这种情况容易出现内痔Hello, this situation is prone to internal hemorrhoids.Transformer你好, 考虑是痔疮。Hello, it is considered as hemorrhoids.BERT-GPT你好, 可能存在痔疮, 大便干结多久了?Hello, there may be hemorrhoids, and how long have the stools been dry and clumpy?MKA-Transformer你好, 可能是痔疮, 建议您做个肠镜。Hello, it may be hemorrhoids. It is recommended that you have a colonoscopy.MKA-BERT-GPT你好, 可能是痔疮出血。此外, 建议您做个肠镜。Hello, it may be bleeding from hemorrhoids. In addition, it is recommended that you have a colonoscopy.Patient question 2为什么我的大便是一粒一粒的, 很干燥, 像羊屎那样的?Why do my stools come in pieces, very dry, like sheep feces?Doctor response 2Ground truth大便干结是功能性问题, 建议您多吃水果蔬菜, 养成排便习惯!The dry stool is a functional problem. It is recommended that you eat more fruits and vegetables to develop a bowel habit!Dialog-GPT你好, 可能存在痔疮。Hello, there may be hemorrhoids.Transformer注意饮食, 多吃蔬菜水果。Pay attention to your diet and eat more fruits and vegetables.BERT-GPT建议您多吃蔬菜水果。It is recommended that you eat more fruits and vegetables.MKA-Transformer考虑是肠胃功能性紊乱, 建议您多吃水果蔬菜。It is considered as a gastrointestinal dysfunction. It is recommended that you eat more fruits and vegetables, like apples.MKA-BERT-GPT考虑是肠胃功能问题, 建议您多吃水果蔬菜, 比如梨, 香蕉。若还是这样的话建议您做个肠镜。It is considered as the gastrointestinal functional problem. It is recommended that you eat more fruits and vegetables, such as pears and bananas. If this is still the case, it is recommended that you have a colonoscopy.


## 4.1. Experiment Settings

Our approach is implemented in Python 3.7 and PyTorch 1.4.0. We implement two MKA-Diagen models, including MKA-Transformer and MKA-BERT-GPT. The neural generative models within them are trained with the default parameters in [11, 25]. The hyperparameters α and β in Equation (2) are set as 0.1 and -1, and the hyperparameter δ is set as 0.7. We perform all the experiments on the Matpool server with 11 GB NVIDIA GeForce RTX 2080 Ti. Our experiments were performed on Chinese MedDialog dataset [11] and MedDG [12] with the ratio 0.8 : 0.1 : 0.1 of training set : validation set : test set.The MKA-Transformer and MKA-BERT-GPT were compared with the baseline models (i.e., Transformer and BERT-GPT) and another typical nonsequence to sequence GPT-based model [11]. We followed the automatic evaluation metrics on the datasets to evaluate the performance of our method, including perplexity, NIST-2,4 [36], BLEU-2,4 [37], METEOR [38], Entropy-4 [39], and Dist-1,2 [40]. The perplexity shows the language quality of the generated responses. NIST-n, BLEU-n, and METEOR measure the similarity between the generated responses and ground truth and Entropy-n and Dist-n measure the lexical diversity of generated responses based on n-gram matching. The model with better performance will have the lower value of perplexity, the higher value of the other metrics.


## 4.2. Experiment Results and Analysis

In this part, the experiment results are shown together with the in-depth analysis of the results. Tables3 and 4 show the performance on the MedDialog-CN test set and MedDG test set separately. From the tables, we make the following observations.Table 3
Comparison of the models on MedDialog-CN, where the best results are in bold.
ModelDialog-GPTTransformerBERT-GPTMKA-TransformerMKA-BERT-GPTPerplexity9.719.528.238.818.04BLEU-25.21%4.92%4.88%5.02%5.71%BLEU-41.83%0.90%0.97%0.99%1.35%NIST-20.360.420.400.430.44NIST-40.320.400.390.400.43METEOR12.32%13.11%12.83%13.4%13.94%Entropy-413.7313.5113.813.7214.1Dist-10.02%0.03%0.03%0.03%0.04%Dist-22.01%2.02%2.14%2.11%2.22%Table 4
Comparison of the models on MedDG, where the best results are in bold.
ModelDialog-GPTTransformerBERT-GPTMKA-TransformerMKA-BERT-GPTPerplexity8.538.525.988.415.95BLEU-26.41%6.30%7.62%6.62%8.09%BLEU-42.12%2.08%2.57%2.40%2.87%NIST-20.380.370.420.390.43NIST-40.350.350.390.380.41METEOR13.78%14.32%16.25%14.88%16.63%Entropy-410.5610.1713.3810.2813.37Dist-10.01%0.01%0.02%0.01%0.02%Dist-21.72%1.67%2.00%1.69%2.00%


### 4.2.1. Ablation Analysis

Focusing on the comparison between MKA-Transformer and Transformer and the performance comparison between MKA-BERT-GPT and BERT-GPT, it is easy to extract Table5. It is easy to observe that our mechanism improves the performance from all aspects on both two datasets. It means that our method is effective and scalable to be applied to different neural generative models and different datasets.Table 5
Improvements of the models with MKA compared to the baseline model on MedDialog-CN and MedDG test sets.
DatasetModelPerplexityBLEU-2,4NIST-2,4METEOREntropy-4Dist-1,2MedDialog-CNMKA-Transformer-0.710.10%, 0.09%0.01, 00.29%0.210.00%, 0.09%MKA-BERT-GPT-0.190.83%, 0.38%0.04, 0.041.11%0.30.01%, 0.08%MedDGMKA-Transformer-0.110.32%, 0.32%0.02, 0.030.56%0.110.00%, 0.02%MKA-BERT-GPT-0.030.47%, 0.30%0.01, 0.020.38%-0.010.00%, 0.00%


### 4.2.2. Performance Comparison Analysis

Compared to the current state-of-the-art models, our MKA-BERT-GPT outperforms all the other methods. It achieves the lowest perplexity. It is because its baseline generative model, BERT-GPT, is pretrained on a large collection of corpora before training on the medical specific datasets. The pertaining procedure helps it to better understand the linguistic structure among words; meanwhile, the medical knowledge-assisted mechanism enables the model more learnable for medical conversation task. Meanwhile, as for the machine translation metrics (i.e., NIST-4, BLEU-2, BLEU-4, and METEOR), the performance of the MKA-BERT-GPT also is the best. It even overturns the performance comparison between BERT-GPT and Transformer. It indicates that our method highly improves the overlap between the generated response and the ground truth. Besides, although the MKA-BERT-GPT improves the value on diversity metrics (i.e., Entropy and Dist), the improvement is still minor. It indicates that our model cannot make a big breakthrough on the capability in generating diverse responses.


### 4.2.3. Case Study Analysis

Tables6 and 7 represent the generated response of the models on two examples in the MedDialog-CN and MedDG test set. Since the dataset contains some Chinese medical dialogues, the translation is provided as well as the raw contents. The response generated by MKA-BERT-GPT is clinically informative and accurate. It prescribes “gastrointestinal functional problem.” Meanwhile, it can offer the detailed suggestions with rich medical knowledge information such as what kind of vegetables and fruits is recommended. Besides, the language quality of all the models is great, since all the responses are readable. Besides, there are still some spaces for the further improvement. For example, the responses generated from the models are not that overlap with the ground truth. It is because the ground truth is a Chinese medical response, which contains the concept of “qi,” which is not that easy for a general model to understand and provide the response. However, the responses of MKA-BERT-GPT are still relatively reasonable and also mention the conclusion of “the blood flow is not smooth.”Table 6
An example of generated responses on the MedDialog-CN test set.
Patient self-report科室 department: 男科 andrology疾病/症状 disease/symptom: 静索静脉曲张 varicose veinsPatient question 1我很怕是高位结扎手术引起的附睾炎, 希望大夫能给我说说是怎么回事, 该怎么处理?I am very afraid that it is the epididymitis associated with the high ligation operation. I hope the doctor can tell me how to deal with it quickly.Doctor response 1Ground truth中医药调理。You can recuperate yourself with Chinese medicine.Dialog-GPT手术部位不会引发附睾炎。The surgical part does not cause epididymitis.Transformer可能是近期没有充分休息, 免疫力下降。建议早点休息。It may be that you do not have enough rest and cause the decrease on the immunity. It is recommended to sleep early.BERT-GPT不要趴着睡觉, 影响伤口恢复。建议多休息。Do not sleep on your stomach, which will affect the recovery of the wound. It is recommended to rest more.MKA-Transformer可以吃营养的健康食品, 比如西兰花, 鸡蛋等, 同时注重卫生清洁, 每晚可以热敷缓解疼痛。You can eat nutritious and healthy foods, such as broccoli and eggs; meanwhile, pay attention to your hygiene and cleanliness. You can heat the area around your wound every night to relieve yourself.MKA-BERT-GPT不可以吃冷饮, 少吃辛辣刺激的食物, 影响伤口恢复。建议多吃蔬果类, 比如苹果。不要久坐不动, 少穿紧身裤。Do not drink cold drinks, and eat less spicy food, which will affect the recovery of the wound. It is recommended to eat more fruits and vegetables, such as apples. Do not sit for a long time and do not wear tight pants.Patient question 2请问我这是附睾炎吗?或是什么?恳请大夫您为我指点!感谢。Is this epididymitis? Or what? I hope you, the doctor, to give me some advice! Thanks!Doctor response 2Ground truth局部气血不畅。The flow of the blood and qi in the local area is not that smooth.Dialog-GPT放宽心, 只是心理作用。Relax, it is just a psychological effect.Transformer只是术后伤口疼痛。It is just that the wound is painful after the operation.BERT-GPT常见血流不通问题。It is the common problem about the blood.MKA-Transformer可能是运动过量导致提睾肌过度收缩, 导致疼痛。Excessive exercise may cause excessive contraction of the cremaster muscle. It will make you feel painful.MKA-BERT-GPT血流不通, 建议过几天复查伤口恢复情况, 减轻心理负担。The blood flow is not smooth. It is recommended to review the situation of the recovery of the wound after a few days. Besides, you need to reduce the psychological burden.Table 7
An example of generated responses on the MedDG test set.
Patient self-report科室 department: 肛肠科 anorectal branch疾病/症状 disease/symptom: 便秘,便血 constipation, blood in the stoolPatient question 1医生你好, 最近我大便总是很干燥, 而且有好几次大便之后, 发现有血, 我这个是什么情况?Hello, doctor. Recently, I have found my stools were very dry. Besides, there is blood inside of them if I poop for several times. What is wrong with me?Doctor response 1Ground truth你好, 可能存在痔疮出血!但还是建议您做个肠镜!Hello, there may be bleeding from hemorrhoids! But it is still recommended that you have a colonoscopy!Dialog-GPT你好, 这种情况容易出现内痔Hello, this situation is prone to internal hemorrhoids.Transformer你好, 考虑是痔疮。Hello, it is considered as hemorrhoids.BERT-GPT你好, 可能存在痔疮, 大便干结多久了?Hello, there may be hemorrhoids, and how long have the stools been dry and clumpy?MKA-Transformer你好, 可能是痔疮, 建议您做个肠镜。Hello, it may be hemorrhoids. It is recommended that you have a colonoscopy.MKA-BERT-GPT你好, 可能是痔疮出血。此外, 建议您做个肠镜。Hello, it may be bleeding from hemorrhoids. In addition, it is recommended that you have a colonoscopy.Patient question 2为什么我的大便是一粒一粒的, 很干燥, 像羊屎那样的?Why do my stools come in pieces, very dry, like sheep feces?Doctor response 2Ground truth大便干结是功能性问题, 建议您多吃水果蔬菜, 养成排便习惯!The dry stool is a functional problem. It is recommended that you eat more fruits and vegetables to develop a bowel habit!Dialog-GPT你好, 可能存在痔疮。Hello, there may be hemorrhoids.Transformer注意饮食, 多吃蔬菜水果。Pay attention to your diet and eat more fruits and vegetables.BERT-GPT建议您多吃蔬菜水果。It is recommended that you eat more fruits and vegetables.MKA-Transformer考虑是肠胃功能性紊乱, 建议您多吃水果蔬菜。It is considered as a gastrointestinal dysfunction. It is recommended that you eat more fruits and vegetables, like apples.MKA-BERT-GPT考虑是肠胃功能问题, 建议您多吃水果蔬菜, 比如梨, 香蕉。若还是这样的话建议您做个肠镜。It is considered as the gastrointestinal functional problem. It is recommended that you eat more fruits and vegetables, such as pears and bananas. If this is still the case, it is recommended that you have a colonoscopy.


## 4.2.1. Ablation Analysis

Focusing on the comparison between MKA-Transformer and Transformer and the performance comparison between MKA-BERT-GPT and BERT-GPT, it is easy to extract Table5. It is easy to observe that our mechanism improves the performance from all aspects on both two datasets. It means that our method is effective and scalable to be applied to different neural generative models and different datasets.Table 5
Improvements of the models with MKA compared to the baseline model on MedDialog-CN and MedDG test sets.
DatasetModelPerplexityBLEU-2,4NIST-2,4METEOREntropy-4Dist-1,2MedDialog-CNMKA-Transformer-0.710.10%, 0.09%0.01, 00.29%0.210.00%, 0.09%MKA-BERT-GPT-0.190.83%, 0.38%0.04, 0.041.11%0.30.01%, 0.08%MedDGMKA-Transformer-0.110.32%, 0.32%0.02, 0.030.56%0.110.00%, 0.02%MKA-BERT-GPT-0.030.47%, 0.30%0.01, 0.020.38%-0.010.00%, 0.00%


## 4.2.2. Performance Comparison Analysis

Compared to the current state-of-the-art models, our MKA-BERT-GPT outperforms all the other methods. It achieves the lowest perplexity. It is because its baseline generative model, BERT-GPT, is pretrained on a large collection of corpora before training on the medical specific datasets. The pertaining procedure helps it to better understand the linguistic structure among words; meanwhile, the medical knowledge-assisted mechanism enables the model more learnable for medical conversation task. Meanwhile, as for the machine translation metrics (i.e., NIST-4, BLEU-2, BLEU-4, and METEOR), the performance of the MKA-BERT-GPT also is the best. It even overturns the performance comparison between BERT-GPT and Transformer. It indicates that our method highly improves the overlap between the generated response and the ground truth. Besides, although the MKA-BERT-GPT improves the value on diversity metrics (i.e., Entropy and Dist), the improvement is still minor. It indicates that our model cannot make a big breakthrough on the capability in generating diverse responses.


## 4.2.3. Case Study Analysis

Tables6 and 7 represent the generated response of the models on two examples in the MedDialog-CN and MedDG test set. Since the dataset contains some Chinese medical dialogues, the translation is provided as well as the raw contents. The response generated by MKA-BERT-GPT is clinically informative and accurate. It prescribes “gastrointestinal functional problem.” Meanwhile, it can offer the detailed suggestions with rich medical knowledge information such as what kind of vegetables and fruits is recommended. Besides, the language quality of all the models is great, since all the responses are readable. Besides, there are still some spaces for the further improvement. For example, the responses generated from the models are not that overlap with the ground truth. It is because the ground truth is a Chinese medical response, which contains the concept of “qi,” which is not that easy for a general model to understand and provide the response. However, the responses of MKA-BERT-GPT are still relatively reasonable and also mention the conclusion of “the blood flow is not smooth.”Table 6
An example of generated responses on the MedDialog-CN test set.
Patient self-report科室 department: 男科 andrology疾病/症状 disease/symptom: 静索静脉曲张 varicose veinsPatient question 1我很怕是高位结扎手术引起的附睾炎, 希望大夫能给我说说是怎么回事, 该怎么处理?I am very afraid that it is the epididymitis associated with the high ligation operation. I hope the doctor can tell me how to deal with it quickly.Doctor response 1Ground truth中医药调理。You can recuperate yourself with Chinese medicine.Dialog-GPT手术部位不会引发附睾炎。The surgical part does not cause epididymitis.Transformer可能是近期没有充分休息, 免疫力下降。建议早点休息。It may be that you do not have enough rest and cause the decrease on the immunity. It is recommended to sleep early.BERT-GPT不要趴着睡觉, 影响伤口恢复。建议多休息。Do not sleep on your stomach, which will affect the recovery of the wound. It is recommended to rest more.MKA-Transformer可以吃营养的健康食品, 比如西兰花, 鸡蛋等, 同时注重卫生清洁, 每晚可以热敷缓解疼痛。You can eat nutritious and healthy foods, such as broccoli and eggs; meanwhile, pay attention to your hygiene and cleanliness. You can heat the area around your wound every night to relieve yourself.MKA-BERT-GPT不可以吃冷饮, 少吃辛辣刺激的食物, 影响伤口恢复。建议多吃蔬果类, 比如苹果。不要久坐不动, 少穿紧身裤。Do not drink cold drinks, and eat less spicy food, which will affect the recovery of the wound. It is recommended to eat more fruits and vegetables, such as apples. Do not sit for a long time and do not wear tight pants.Patient question 2请问我这是附睾炎吗?或是什么?恳请大夫您为我指点!感谢。Is this epididymitis? Or what? I hope you, the doctor, to give me some advice! Thanks!Doctor response 2Ground truth局部气血不畅。The flow of the blood and qi in the local area is not that smooth.Dialog-GPT放宽心, 只是心理作用。Relax, it is just a psychological effect.Transformer只是术后伤口疼痛。It is just that the wound is painful after the operation.BERT-GPT常见血流不通问题。It is the common problem about the blood.MKA-Transformer可能是运动过量导致提睾肌过度收缩, 导致疼痛。Excessive exercise may cause excessive contraction of the cremaster muscle. It will make you feel painful.MKA-BERT-GPT血流不通, 建议过几天复查伤口恢复情况, 减轻心理负担。The blood flow is not smooth. It is recommended to review the situation of the recovery of the wound after a few days. Besides, you need to reduce the psychological burden.Table 7
An example of generated responses on the MedDG test set.
Patient self-report科室 department: 肛肠科 anorectal branch疾病/症状 disease/symptom: 便秘,便血 constipation, blood in the stoolPatient question 1医生你好, 最近我大便总是很干燥, 而且有好几次大便之后, 发现有血, 我这个是什么情况?Hello, doctor. Recently, I have found my stools were very dry. Besides, there is blood inside of them if I poop for several times. What is wrong with me?Doctor response 1Ground truth你好, 可能存在痔疮出血!但还是建议您做个肠镜!Hello, there may be bleeding from hemorrhoids! But it is still recommended that you have a colonoscopy!Dialog-GPT你好, 这种情况容易出现内痔Hello, this situation is prone to internal hemorrhoids.Transformer你好, 考虑是痔疮。Hello, it is considered as hemorrhoids.BERT-GPT你好, 可能存在痔疮, 大便干结多久了?Hello, there may be hemorrhoids, and how long have the stools been dry and clumpy?MKA-Transformer你好, 可能是痔疮, 建议您做个肠镜。Hello, it may be hemorrhoids. It is recommended that you have a colonoscopy.MKA-BERT-GPT你好, 可能是痔疮出血。此外, 建议您做个肠镜。Hello, it may be bleeding from hemorrhoids. In addition, it is recommended that you have a colonoscopy.Patient question 2为什么我的大便是一粒一粒的, 很干燥, 像羊屎那样的?Why do my stools come in pieces, very dry, like sheep feces?Doctor response 2Ground truth大便干结是功能性问题, 建议您多吃水果蔬菜, 养成排便习惯!The dry stool is a functional problem. It is recommended that you eat more fruits and vegetables to develop a bowel habit!Dialog-GPT你好, 可能存在痔疮。Hello, there may be hemorrhoids.Transformer注意饮食, 多吃蔬菜水果。Pay attention to your diet and eat more fruits and vegetables.BERT-GPT建议您多吃蔬菜水果。It is recommended that you eat more fruits and vegetables.MKA-Transformer考虑是肠胃功能性紊乱, 建议您多吃水果蔬菜。It is considered as a gastrointestinal dysfunction. It is recommended that you eat more fruits and vegetables, like apples.MKA-BERT-GPT考虑是肠胃功能问题, 建议您多吃水果蔬菜, 比如梨, 香蕉。若还是这样的话建议您做个肠镜。It is considered as the gastrointestinal functional problem. It is recommended that you eat more fruits and vegetables, such as pears and bananas. If this is still the case, it is recommended that you have a colonoscopy.


## 5. Conclusions

In this paper, we propose a scalable medical knowledge-assisted mechanism (MKA) to assist general neural generative models, especially the large-scale pretrained model, such as BERT-GPT, to achieve better performance on the medical conversation task. The mechanism introduces a medical specific knowledge graph, which contains 6 types of medical-related information, including department, drug, check, symptom, disease, and food. Besides, it also leverages the specific designed token concatenation policy and neural generative models. The promising experiment results have proven our mechanism is effective and scalable to different generative models on different medical conversation datasets. Besides, it also shows that MKA-BERT-GPT has achieved the state-of-the-art performance based on multiple automatic evaluation metrics compared to other existing models. In the future, we plan to apply the graph neural networks to extract and predict the related medical knowledge based on the medical knowledge base. Besides, it is also worthwhile to carry out the research on leveraging the advantages of both information retrieve methods and the neural generative methods to build a powerful dialogue generation system.



---

*Source: 5294627-2021-12-23.xml*