MedDG: An Entity-Centric Medical Consultation Dataset for Entity-Aware Medical Dialogue Generation

Developing conversational agents to interact with patients and provide primary clinical advice has attracted increasing attention due to its huge application potential, especially in the time of COVID-19 Pandemic. However, the training of end-to-end neural-based medical dialogue system is restricted by an insufficient quantity of medical dialogue corpus. In this work, we make the first attempt to build and release a large-scale high-quality Medical Dialogue dataset related to 12 types of common Gastrointestinal diseases named MedDG, with more than 17K conversations collected from the online health consultation community. Five different categories of entities, including diseases, symptoms, attributes, tests, and medicines, are annotated in each conversation of MedDG as additional labels. To push forward the future research on building expert-sensitive medical dialogue system, we proposes two kinds of medical dialogue tasks based on MedDG dataset. One is the next entity prediction and the other is the doctor response generation. To acquire a clear comprehension on these two medical dialogue tasks, we implement several state-of-the-art benchmarks, as well as design two dialogue models with a further consideration on the predicted entities. Experimental results show that the pre-train language models and other baselines struggle on both tasks with poor performance in our dataset, and the response quality can be enhanced with the help of auxiliary entity information. From human evaluation, the simple retrieval model outperforms several state-of-the-art generative models, indicating that there still remains a large room for improvement on generating medically meaningful responses.


Introduction
Online medical consultations have been playing an increasingly important role. According to [1], telemedicine substantially rose from 10% to 75% of general medical consultations before and after the COVID-19 pandemic in UK. However, patients often describe their situations verbosely and communicate with doctors inefficiently online. To address this dilemma, there has been growing research interest in developing automatic medical dialogue systems, which can assist doctors in pre-collecting symptoms and give patients preliminary treatment advice in time.
Different from generic dialogues, medical conversations are characterized by the following features. 1) Entity-Centric. Medical entity terms are the most central part of medical conversations. They serve as the foundation of accurate diagnosis and therapy. 2) Redundancy. Medical conversations usually contain redundant content that barely contributes to the medical diagnosis, as shown in the gray part of Fig. 1 有没有出现腹痛的症状？ I had a dinner party with my friends yesterday. We ordered a lot of food and ended up stuffed. Later I feel a little sick. I have a bloated stomach with acid reflux sometimes.

我昨晚和朋友聚餐，大家点了很多菜，最后都吃得很撑。我今天就感觉有点不舒服，胃里胀 气得厉害，有时候还会反酸。
There doesn't seem to be any apparent pain, just the stomach distended. 好像没有明显的痛，就只是胃涨得难受。 I was so tired last night that I went to sleep soon after I got home. I did not feel uncomfortable until today morning, so there might have been about 8 hours since then.

昨晚到家后太累了，倒头就睡，当时没感觉有啥不舒服。今天才感觉有点不对劲。症状已 经持续了大概8小时吧。
Do you hiccup a lot? 有没有频繁地打嗝？ Yes. Totally uncontrollable, and very annoying. we sample 1,000 medical conversations from an online medical consultation platform, Doctor Chunyu and manually label the content directly associated with symptom inquiry/description, disease diagnosis, examination, and therapy. We find that 40.1% of the sentences posted by the patients are redundant chit-chat. 3) Changeable Inquiry Order.
In medical conversations, the doctor's symptom inquiry order is usually changeable. As in Fig. 1, the order of querying "stomachache" and "hiccup" can be exchanged. Given the above considerations, we argue that it would be beneficial to construct a medical conversation dataset, where the entity-related text spans and the corresponding normalized entities are annotated, as in Fig. 1. On the one hand, the annotation of entities could guide the introduction of external knowledge and help the medical dialogue system learn to focus on the central part of conversations [2], contributing to a better understanding of the dialogue context and a more accurate diagnosis. On the other hand, it could facilitate a more comprehensive evaluation of medical dialogue generation by comparing the generated entity terms with the ones appearing in the following ground-truth responses. Existing datasets, however, either do not provide such entity annotation [3] or are too small in scale [4,5,6,7].
In this paper, we present MedDG, an entity-centric Medical Dialogue dataset, with 17,864 Chinese dialogues, 385,951 utterances, and 217,205 entities. As demonstrated in Fig. 1, in MedDG the entity-related text spans are first extracted from the original text and their corresponding normalized entities are then annotated. Specifically, we annotate five categories of entities, including disease, symptom, medicine, examination, and attribute. Table 2 lists the most frequent entities in each category in MedDG. Compared with Table 1. Comparison of entity-annotated medical dialogue datasets. The two columns below "# Entity Frequency" refer to the average (Avg.) and median (Med.) occurrence time of an entity. existing entity-annotated medical dialogue datasets, MedDG is one (or two) magnitude larger in terms of dialogue and utterance number and the entities covered in MedDG are diverse, as shown in Table 1. Besides, the average and median occurrence times of each entity in MedDG are significantly higher than other corpora, demonstrating that models can learn features of each entity better with MedDG. Based on MedDG, we conduct preliminary research on entity-aware medical dialogue generation. Several benchmark models are implemented respectively for entity prediction and entity-aware generation. Experimental results show that our entity-aware adaptions of the generation models consistently enhance the response quality, demonstrating that the entity-aware methodology is a worth-exploring direction for this task. In summary, our contributions are three-fold: 1) We collect MedDG, a large-scale entity-centric medical dialogue dataset, at least one magnitude larger than existing entity-annotated datasets; 2) We conduct preliminary research on entity-aware medical dialogue generation by implementing multiple benchmark models and conducting extensive evaluation; 3) We conduct extensive analysis of the benchmark models and demonstrate that the entityaware methodology consistently achieves better response quality.

Related Work
Medical Dialogue Systems Tasks related to the understanding of medical dialogues have been researched a lot, such as information extraction [5], relation prediction [9], symptom prediction [8] and slot filling [10]. However, the generation part of medical dialogue systems was rarely investigated. Early attempts came from [11,12,13]. More recently, [6,14] introduced an end-to-end medical dialogue system based on pre-defined templates, which suffers from the problem of inflexibility. [3] took an initial step in neural-based medical dialogue generation. They pre-trained several dialogue generation models on large-scale medical corpora and studied the transferability of models to the low-resource COVID-19 dialogue generation task. However, they did not consider medical entities, which are the most central part of medical dialogues.
Medical Dialogue Datasets [7] first launched a dataset for medical diagnosis, but it only contains some structured data related to the consultation content, rather than dialogues in the form of natural language. The DX dataset [6] contains 527 medical dialogues, but the utterances are automatically generated with templates. [8] collected the CMDD dataset with 2,067 dialogues on four pediatric diseases, and [5] released the MIE dataset with 1,120 dialogues on six cardiovascular diseases. However, both CMDD and MIE were proposed for dialogue understanding tasks, not large enough to build a competitive dialogue system. More recently, [3] collected 3.4 million Chinese medical dialogues from the Internet that make up an extra-large dataset, but the dialogues in it are all unlabeled, so its quality is not guaranteed by human-annotators and it is unable to facilitate research on entity-aware medical dialogue generation. Table 1 summarizes the statistics of public entity-annotated Chinese medical dialogue corpora. Among them, our MedDG dataset is the largest and includes diverse entity types.

Data Collection
The dialogues in MedDG are collected from the gastroenterology department of an online Chinese medical consultation website, Doctor Chunyu, 5 where patients can submit posts about their problems and consult qualified doctors for professional advice. In total, more than 100,000 dialogues are collected. Then some low-quality dialogues are filtered out if the number of utterances is not between 10 and 50, or if it contains nontext information, such as graphics or sound. After filtering, there remain 17,864 dialogues, with 385,951 utterances. We select consultations in the gastroenterology department as their related inquiries are common and diverse. In addition, preliminary treatment advice for gastrointestinal problems relies less on medical examinations than the other diseases, and they are thus more suitable for online consultations.
To avoid privacy issues, the Doctor Chunyu website has already filtered the sensitive information when releasing consultation content. After collecting the online data, we further ensure that there remains no private information by involving two checking approaches. First, we design a set of regular expression rules to extract private information, like ages, telephone numbers, and addresses, and then manually check the extracted results. Second, the annotators are asked to report to us if they observe any privacy issue during entity annotation. Neither of the above approaches find any sensitive information, proving that the source data has a very low risk of privacy issues.

Entity Annotation
We then conduct entity annotation on the collected dialogues in the form similar to [4]: the entity-related text spans are first extracted from the original text and then normalized into our pre-defined normalized entities, as shown in Fig. 1. To control costs within a reasonable range, we design a semi-automated annotation pipeline. First, we determine the entities to be included in the annotation. Then, domain experts manually annotate 1,000 dialogues in the dataset. Finally, an automatic annotation program is implemented based on the human annotation to label the remaining data.
Entity Determination After discussing with domain experts, we choose five categories of entities for annotation: disease, symptom, examination and attribute. Then, we further define a total of 160 entities to be included in these categories, referring to the terminology lists in the Chinese medical knowledge graph CMeKG [15] and their frequency in the dataset. There are 12/62/62/20/4 entities, respectively, in the disease/symptom/medicine/examination/attribute category. Table 2 lists the four most frequent entities in each category and their frequency distribution.
Human Annotation A total of 1,000 dialogues in the dataset are manually annotated. Eight annotators with more than one year of consultation experience are involved in the annotation process. They are asked to spend an average of 5 minutes on each dialogue, and paid with $50 per hour. To guide the annotators, we write the initial version of annotation manual through discussions with domain experts. The annotators are asked to first conduct trial annotation based on this manual, and report their problems on it. Then we revise the manual based on the found issues, and launch the formal annotation process. Each dialogue is labeled by two annotators independently and the inconsistent part is further judged by a third annotator. The Cohen's kappa coefficient between different pairs of annotators is between 0.948 and 0.976, indicating a strong agreement between annotators (1.0 denotes complete agreement).

Semi-automatic Annotation
We then develop an automatic annotation program to label the remaining data. As its initial version, a set of regular expression rules are first designed based on the 1,000 human-labeled dialogues. That is, they can accurately cover all the entity annotation in the manually-annotated data. Then, to ensure its annotation quality, we randomly pick 2,000 utterances and invite experts to manually label them again. By comparing the annotation from the experts and the automatic program, we evaluate the annotation quality and further improve the annotation program repeatedly. The above revision procedure is repeated four times. The final version of the annotation program achieves 96.75% annotation accuracy on the 2,000 manually evaluated utterances, which supports the hypothesis that annotation accuracy is greater than 95% on the whole dataset (p-value < 0.01).

Dataset Statistics
There are 14,864/2,000/1,000 dialogues in the train/dev/test sets. The human-annotated dialogues are put in the test set and the rest are randomly divided into the training and the development sets. Table 3 presents statistics about the number of dialogues, utterances, tokens, and entities in MedDG. Table 2 illustrates the distribution of categories and top four entities in each category. We can see that the proportion of symptoms is the highest, accounting for 55% of the total entity occurences.

Experiments
Based on MedDG, we conduct prelimiary research on entity-aware medical dialogue generation. Specifically, we investigate several pipeline methods that first predicts the entities to be mentioned in the upcoming response and then generates the response based on the prediction results. The formal definition of the two tasks involved (entity prediction and entity-based response generation) are as below. Formally, at each dialogue turn of the consultation system, it has access to the dialogue history consisting of a sequence of utterances from either the patient or the system itself, X 1:K = {X 1 , X 2 , ..., X K }. The task of entity prediction is to predict the set of entities E K+1 = {e 1 K+1 , e 2 K+1 , ..., e l K+1 } to be mentioned in the upcoming response X K+1 . As for entity-based response generation, it is to generate the response X K+1 , based on the dialogue history X 1:K and the entity prediction results E K+1 .

Baselines
Entity Prediction Entity prediction is done for each pre-defined entity e i to decide whether it should be included in the upcoming response. We use first neural encoder to obtain the context vector of the dialogue history, which is then passed to a fully connected layer with a sigmoid function. Formally, the entity prediction process is defined as: where h D is the context vector of the dialogue history and w p is a learnable parameter. We use a binary cross entropy loss computed as: where y i ∈ {0, 1} is the ground truth indicating whether e i will be included in the upcoming response or not. The following baseline models are implemented to encode the dialogue history: LSTM [16], TextCNN [17], BERT-wwm [18], PCL-MedBERT [19], MedDGBERT. MedDGBERT is a BERT-based model, pretrained on the training set of MedDG with a designed entity-prediction task, which is to predict the masked entities mentioned in the dialogue. Entity-based Response Generation For entity-based response generation, we implement the following two approaches: Retrieval. Given the predicted entities E K+1 , the retrieval-based method chooses a doctor's utterance U R in the training set of MedDG as its response. U R is randomly picked from the utterances which satisfy the condition that their annotated entities E R are the minimum coverage of all the predicted entities E K+1 . Entity Concatenation. Given the predicted entities E K+1 , we concatenate them with the dialogue history X 1:K and then pass them to a generation model. The averaged negative log-likelihood of the target sequence X K+1 = {w 1 K+1 , w 2 K+1 , ..., w T K+1 } is used as the generation loss: We compare the following baseline models to generate responses with entity concatenation: Seq2Seq [20], HRED [21], GPT-2 [22], DialoGPT [23], BERT-GPT [3], and MedDGBERT-GPT. BERT-GPT combines the BERT encoder and GPT decoder and is fine-tuned on the MedDialog dataset [3]. MedDGBERT-GPT has the same architecture as BERT-GPT, but its parameter of the BERT encoder are replaced with the weights in MedDGBERT, one of our entity prediction baselines.

Implementation Details
For the entity prediction methods, prediction is conducted for each predefined entity as a binary classification task, and the final predicted entity set is made up of the ones whose predicted probabilities are greater than 0.5. For the entity-based response generation methods, the entities concatenated in the input of the response generation models are automatically predicted, with the strong entity prediction baseline model MedDGBERT; and the dialogue history is abbreviated to the last patient's utterance to speed up the experiments. For the three LSTM-based models (LSTM, Seq2seq, HRED), we implement a single-layer LSTM as the encoder or decoder. The dimensions of the word embedding and the hidden states in LSTM are set to 300. We use the Adam optimizer with a mini-batch size of 16 and set the initial learning rate to 0.001. For the other baseline models, we directly follow the implementations in their original papers. The number of training epoch is all bounded at 30, and training will be early-stopped after 5 epochs without improvement.

Results on Entity Prediction
For the entity prediction task, the evaluation metrics include precision, recall and F1. In addition to the scores evaluated on all the entities, we also calculate the F1 score of the ones in each entity categories, denoted as F1 D (Disease), F1 S (Symptom), F1 M (Medicine), F1 E (Examination), and F1 A (Attribute). The results are shown in Table 4. Compared with classic RNN and CNN encoders, we can see that the three BERTbased encoders (BERT-wwm, PCL-MedBERT, and MedDGBERT) consistently achieve better performance than LSTM and TextCNN in terms of all metrics. MedDGBERT outperforms the other two BERT variants in most of the metrics, which demonstrates the effectiveness of including entity prediction in the pretraining process to integrate medical entity knowledge. Comparing the F1 scores of each category, we find that the performance on the attribute category is significantly superior to the one on the others. It is probably because entities in the attribute category follow relatively fixed patterns. For example, after patients' description of their symptoms, doctors would usually further ask about attributes of the symptoms, like duration and pain degree. In comparison, entity prediction on the other four categories are much more challenging, as they contain more types of entities and more heavily rely on domain knowledge. The diversity of different doctors' diagnosis strategies also increases the difficulty.

Results on Response Generation
Automatic Evaluation For automatic evaluation, we assess the generated response in two aspects: the text quality and the medical entities it covers. To evaluate text quality, we use the BLEU-1, BLEU-4 [24], Distinct-1, and Distinct-2 [25] metrics. BLEU-1/4 measures lexical similarity, while Distinct-1/2 evaluates text diversity. To evaluate the medical entities covered in the response, we first use the automatic annotation program described in Sec. 3.2 to extract the entities mentioned in the generated responses, and then compare them with the gold entities in terms of precision, recall, and F1, named as P Ent , R Ent , F1 Ent , respectively. The results are presented in Table 5. The lines begins with "w/o Ent" show the ablation results of the corresponding models, which do not perform entity prediction and directly take the dialogue history as input. By analyzing Table 5, we can obtain the following insights. Entity-aware adaptions consistently improve the generation quality. Comparing the entity-aware methods and their entity-ablated versions (denoted as "w/o Ent." in Table  5), we can see that the entity-aware adaptions significantly enhance both the BLEU and entity-related scores, demontrating the effectiveness of entity-aware methods in improving generation quality. For instance, MedDGBERT-GPT has 14.51% relative improvement on BLEU-4 and 65.54% on F1 Ent compared with its entity-ablated version. The entity prediction results utilized by the entity-aware methods are provided by MedDGBERT, whose F1 score is no more than 30%, but the improvement is still significant. More improvement could be expected with stronger entity prediction models in the future. Besides, Distinct-1/2 drop after entity-aware adaptions in some cases, it is mainly because the entity-aware methods tend to generate more specific content, following relatively fixed patterns. Retrieval vs. Generation. As our retrieval-based method directly respond with utterances in the training set based on the predicted entities without consideration of the contextual information, its BLEU score is lower than generative models, while the entity-related metrics are relatively high. Notably, the entity recall is significantly higher than all the generative methods, because our retrieval strategy ensures that all the predicted entities are covered in the response. LSTM-based vs. GPT-based. Though with much fewer parameters, the BLEU scores of HRED are not lower than those of most GPT-based models. One possible reason is that the GPT models are pre-trained mainly on large-scale chit-chat data, so they tend to generate responses irrelevant to the medical domain. It also explains why GPT-based models have higher distinct scores.
Human Evaluation We further conduct human evaluation of five selected generation methods, including Retrieval, HRED, MedDGBERT-GPT, and the entity-ablated versions of the latter two. We randomly pick 100 test dialogues, each with an average 9.71 utterances from the doctor. Three annotators involved in our dataset annotation process

MedDGBERT-GPT
MedDGBERT-GPT are asked to rate these models' responses independently between 1 (poor) and 5 (good) in the following three dimensions. 1) Fluency: It checks whether the response follows the grammar and semantically correct; 2) Expertise: It checks whether the response content is appropriate from a professional medical perspective; 3) Relevance: It checks whether the response is relevant to the dialogue history.
The results are shown in Table 6. Surprisingly, the retrieval-based method is significantly superior to other generative models on all metrics, especially in terms of sentence fluency, which is opposite to our automatic evaluation results. This is mainly because the fluency and quality of the retrieved response are guaranteed as they are all doctor-written sentences, while the BLEU metric only measure the similarity between the generation results and the reference utterances in terms of n-grams. Comparison of the four generative models can lead to the same conclusions as in the automatic evaluation that entity-aware methods can improve generation quality. The average Cohen's kappa scores between annotators are 0.41, 0.52, and 0.59 in fluency, relevance, and expertise, respectively. Table 7 gives three examples of the generated responses from different generaion methods. We can see that with the guidance of these predicted entities, the model responses are more informative and contain more correct entities. For example, in the second turn, HRED accurately includes the entity "acid reflux" under the guidance of predicted entities, while its entity-ablated version generates the wrong entity "cholecystitis". Compared with other methods, MedDGBERT-GPT generates the most number of correct entities in three turns.

Conclusion and Future Work
In this paper, we proposed MedDG, a large-scale Chinese medical consultation dataset with annotation of rich medical entities. Based on MedDG, we conducted preliminary research on entity-aware medical dialogue generation, by implementing a pipeline method that first predicts entities to be mentioned and then conducts generation based on these entities. Through extensive experiments, we demonstrated the importance of taking medical entities into consideration. In the future, we will further investigate how to introduce domain knowledge to this task. One possible approach is to model the relationship between different medical entities in MedDG based on medical knowledge graphs like CMeKG [15].