{'fraction_non_alphanumeric': 0.0316801398295827, 'fraction_numerical': 0.0064998907581385185, 'mean_word_length': 4.8947198969736, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Prototypical Q Networks for Automatic Conversational Diagnosis and Few-Shot New Disease Adaption

Spoken dialog systems have seen applications in many domains, including medical for automatic conversational diagnosis. State-of-the-art dialog managers are usually driven by deep reinforcement learning models, such as deep Q networks (DQNs), which learn by interacting with a simulator to explore the entire action space since real conversations are limited. However, the DQN-based automatic diagnosis models do not achieve satisfying performances when adapted to new, unseen diseases with only a few training samples. In this work, we propose the Prototypical Q Networks (ProtoQN) as the dialog manager for the automatic diagnosis systems. The model calculates prototype embeddings with real conversations between doctors and patients, learning from them and simulator-augmented dialogs more efficiently. We create both supervised and few-shot learning tasks with the Muzhi corpus. Experiments showed that the ProtoQN significantly outperformed the baseline DQN model in both supervised and few-shot learning scenarios, and achieves state-of-the-art few-shot learning performances.


Introduction
Recently spoken dialog systems have been a popular research topic in human language technology (HLT) area with various applications. Among these applications, dialog systems for clinical conversation (i.e., medical bot) is a rising direction for its widespread and impactful use [1]. Medical bot assists medical practitioners to converse with patients, collect information about their symptoms, physical and mental conditions, or even make suggestions on diagnosis. The bot has significant potential to make the diagnostic procedure more efficient. An example for automatic diagnosis dialog system is shown in Figure 1. Starting from a self-report, the medical bot collects and distills symptom information before it makes the disease prediction.
One of the core challenges of building such a dialog system is design and train a dialog policy manager that can reason and decide the action to take based on the understanding of user intentions and conversation context. It is more challenging for medical bot because of the need of integrating medical knowledge for reasoning and decision making. [1] proposed a reinforcement learning (RL) framework with a multi-layer perceptron deep Q networks (MLP-DQN) [2]. [3] extended the study by enhanceing the DQN with hand-crafted features among diseases and symptoms, generated from the training set. However, both models cannot directly learn from real doctor-patient conversations. For RL agent to fully explore the entire action space, Work done before the second author joined Amazon  the agent can only learn by interacting with rule-based user simulators, which can not learn from the dialog histories between real doctors and patients.
Another difficulty faced by RL-based manager is adapting trained policy to new tasks (e.g., adapt trained medical bot to serve new diseases), since adaptation data is usually limited and hard to collect. On the other hand, Meta-learning algorithms are proposed to improve the model performance when training or adaptation data is limited. [4,5]. Since both many-and fewshot learning heavily depend on the quality of learned representations, these studies encouraged us to combine meta-learning and deep reinforcement learning models to improve the dialog agents for automatic diagnosis in both scenarios by learning better representations of dialog actions and domain knowledge.
In this work, we propose prototypical Q networks (Pro-toQN) borrowing the ideas of prototypical networks [5] and matching networks [6]. We evaluate the model in the medical dialog domain, since it is important and medical conversation usually suffers from data scarcity. The model makes fully use of real doctor-patient conversations by calculating prototype disease and symptom embeddings by encoding the dialog histories in the training set. Experiment results have shown that by learning a shared prototype embedding space, the ProtoQN outperforms MLP-DQN under both experiment settings. The experiments in this paper will focus on medial dialog to show benefit of proposed method, but we believe the conclusion can be generalized to other domains, since we do not use handcrafted features or external domain specific information.

Deep Q Networks
The deep Q networks (DQNs) are proposed in [2] for handling Atari video games. [7] proposed a deep reinforcement learning architecture for mastering the game of GO. In the area of dialog systems, the DQN is a popular model for building dialog managers and learning dialog policies [8,9,10,11].
DQN is usually implemented as the following. The goal of the network is estimating q(s, a), the Q value of taking action a at state s. At each time step, an DQN-based agent selects an action with a -greedy strategy, i.e., epsilon % of the time selecting action with largest Q value given current state, and picking a random action for the rest. Meanwhile, the transition of the current step, (St, At, Rt, γ, St+1), is added to a memory buffer for future learning [12]. Here, St is the state at time t, At is the action taken at time t, Rt+1 stands for the immediate reward at time step t + 1, and γ is a discount rate. The objective function for training the neural network is where θ stands for the parameters set of the current network andθ is the parameters of the target network. The parameters are updated by stochastic gradient descent (SGD).

Spoken Dialog Systems
Task-oriented spoken dialog systems aim at completing a specific task by interacting with users through natural language. Conventionally a dialog manager is built to learn the dialog policy, which decides actions by reasoning from dialog state (the combined representation of user intentions and context) [13,14,15]. Dialog management is often formulated as a partially observable Markov decision process (POMDP), and solved as a reinforcement learning (RL) problem [16]. As of late, many state-of-the-art dialog systems achieve satisfactory results by leveraging DQNs [2,17], to learn policy and manage dialogs [8].
Typical applications include flight booking [18], movie recommendation [19], restaurant reservation [20], and vision grounding [21]. Medical bot also benefits from this line of research. [1] applies DQN to decide whether to collect more symptom information from patients by continuing the conversation or conclude the diagnosis with predicting a disease. [3] proposes a knowledge-routed DQN to integrate medical knowledge into dialog management. By considering the relations among diseases and symptoms during decision making, the accuracy of disease prediction is improved. In this work, we integrate meta-learning with DQN to improve the learning efficiency, and evaluate the proposed dialog manager on medical domain.

Meta-Learning
Recently meta learning starts gaining attention among the whole machine learning field for improving model performance when few labeled training data is available. Model-Agnostic Meta-Learning [4] optimizes parameter initialization over multiple out-of-domain subtasks for the initialization to be generalizable in targeted tasks after fine-tuning on few in-domain labels. Neural Turing machines [22] augment neural models with memory modules to improve performance in limiteddata regime. Metric-based meta learning, such as prototypical networks (ProtoNets) [5], siamese neural networks [23], and matching networks [6], learns embedding or metric space such that the space can be adapted to domains unseen in the training set with few examples from the unseen domains. Meta-learning models have also been applied in dialog generation [24] for quick policy adaption in different dialog domains. In this work, our proposed model is evaluated on the medical domain that requires not only dialog policy, but also multi-step reasoning with domain-specific knowledge.

Dialog State Representations
Following the method proposed in [1] for vectorizing the dialog states, each dialog state consists of 4 parts: I. UserAction: The user action of the previous dialog turn: • Request: A user sends a self-report containing a set of explicit symptoms and request for diagnosis. • Confirm: A user confirms the existence of an agentinquired symptom. • Deny: A user denies the existence of a symptom.
• NotSure: A user is not sure about the inquired symptom, usually happened when an unrelated symptom is inquired. II. AgentAction: The previous action of the dialog agent: • Initiate: The agent initiates the dialog and asks the user to send the self-report. • Request: The agent asks the user if a symptom exists.
• Inform: The system predicts and inform the disease. III. Slots: The set of symptoms appeared in the dialog history and their status. Each symptom has 4 possible status, • Confirmed: Existence of the symptom is confirmed.
• Denied: Existence is denied by the user.
• Unrelated: The symptom is not necessary for the doctor to make an accurate diagnosis. • NotInquired: The symptom has not been inquired. IV. NumTurns: The length of the dialog history, in other words, current number of turns.
In each dialog turn, we represent UserAction, AgentAction, and NumTurns with one-hot vectors a u , a r , and n respectively. We use a 66-dimension vector s to represent the Slots, where each dimension indicates the status of a symptom. A confirmed, denied, unrelated, and not inquired symptom possesses value 1, −1, −2, and 0 in the corresponding dimension. The final input of the neural networks at the t-th turn is represented as

Prototypical Q Networks
In this work, we propose the prototypical Q networks (Pro-toQNs) as well as corresponding training and evaluation pipelines, based on conventional DQNs and ProtoNets. We first define the notation of the our dataset as follows. The dataset S contains N doctor-patient conversations, {(x1, y1), (x2, y2), . . . , (xN , yN )}, where yi stands for the disease label of the i−th training case and xi stands for the corresponding dialog history, and xi can be further represented as Here E stands for explicit symptoms reported at the beginning of each dialog, a stands for agent follow-up inquiries, u stands for user responses, and D stands for the predicted disease. The core of the ProtoNets [5] is calculating and updating the prototype embeddings of the output classes. The network classifies examples by comparing the input embedding with the prototypes, and predict the class with its prototype closest to the input embedding. As compared to other single-stage reasoning task, such as image classification or object detection [5], medical dialog requires multi-stage reasoning to infer dialog action through states. As a result, we propose a method for computing action prototype via dialog state embedding.

Dialog state embedding
For each training conversation, xi, as defined in Equation 2, the dialog state s i j at time step j can be represented as s i j is then converted into a representation vector following Equation 1, denoted as fenc, to obtain the state embedding, e i j . That is e i j = fenc(s i j ) With the approach described above, for any conversation we can get et, the embedding of the dialog state at time step t (i.e., st).

Dialog action prediction
At each step of a dialog, where am is the embedding of the m-th dialog action, generated by mean-pooling a number of dialog states followed by am, and Here, 1(·) is the indicator function, and D is the set of examples used for computing prototypes. In training, D is a small subset of dialog states sampled from training set follwed by action am, while in evaluation, D is the entire training set. In Algorithm 1, we show the calculation of prototype embeddings.

Disease prediction and training
Each dialog starts from an explicit symptom set provided by a user goal, and the model inquiries a set of symptoms before making the final disease prediction. For each inquiry, the user simulator replies based on the implicit symptom set as described in Section 3.1. The conversation stops when the systems output a disease prediction. Summarizing the previous sections and descriptions, we provide the complete procedure of a medical dialog in Algorithm 2. For each simulated dialog described above, the model sees a success or failure reward when it informs the user a predicted disease. The ProtoQN updates its weights based on the reward Calculate P a with Equation 6 9: end for with stochastic gradient descent (SGD) following the standard pipeline of training a DQN applied in [1,3]. For evaluation, the ProtoQN generates prototype embeddings only once before the evaluation begins with all real dialog histories in the training corpus.

Data and Experiment Settings
In this work, we evaluate the models on Muzhi dataset [1]. The dataset contains 710 medical dialogs between real doctors and patients, and each is annotated as a user goal, covering 4 different diseases and 66 symptoms. In this work, we apply the official train-test split. 568 user goals are used from training and other 142 are used for evaluation.
Meanwhile, we apply a simulator for providing user response in the conversations. To simulate speech noises and mistakes led by user knowledge biases, we apply intent and slot noises to the simulator [3] to evaluate the model performances under different levels of noises. In our experiments, we apply 0%, 10%, 20%, and 30% error rates, i.e., the probability that the status of an inquired symptom is sampled at random rather than based on annotation.
We also conduct 2 groups of experiments for evaluating the model performances at various conditions. Firstly we train both (a) Noise = 0.0 ProtoQN and DQN on the entire training set. This is the conventional with fully supervised learning setting. Secondly, we adopt a meta-learning-like setting to evaluate the model performance at few-shot learning. We pre-train the models with 3 diseases, and fine-tune the models with randomly selected training samples from the trained diseases plus a few cases of the new disease. In both learning tasks, the neural models are evaluated on the entire public test set. In this paper we set the success reward of ProtoQN to 20, failure reward to 0, and the maximum number of turns is 44. For DQN, we keep the settings in [1].

Fully Supervised Learning
We first compare the ProtoQN with DQN at the normal supervised learning setting to evaluate their abilities of learning dialog policy with enough training data. Experimental results are shown in Table 1. We obtain the DQN performance directly from [1]. Experiments showed that the ProtoQN significantly outperformed the DQN baseline, without adding external knowledge and hand-crafted features [3]. The improvement showed that utilizing the dialog history between real doctors and patients to calculate prototype embeddings is effective and provides better ability for the model to learn the dialog policy. While DQN learns Q-values indirectly from simulated conversations, Pro-toQN directly relates Q-values with dialog actions and states in real conversation.

Few-shot New Disease Adaption
In this part, we investigate the model performance at the situation when a new disease appears after the model was trained, and only a few examples are available for training. To evaluate this situation, we adopt an experiment setting popular in few-shot learning, where we first pre-train the models on the training set from a subset of diseases. Then the models are finetuned (i.e., adapted) on a small number, N , of examples from a new disease. In order to prevent catastrophic forgetting [25], we also randomly select N samples from each pre-trained diseases to compose the adaptation set. Since the Muzhi corpus includes 4 diseases, we conduct 4 iterations of evaluation, with each corresponding to one of the 4 diseases as the new disease, and the remaining as the pre-trained ones. After fine-tuning, the models are also evaluated with the public test set. Also, we consider different noise levels in this task. Our purpose is evaluating how well the models learn new diseases with few examples and not forgetting the knowledge for the pre-trained diseases.
The experiment results of the new disease adaption are shown in Table 2. From the table we see that the ProtoQN significantly outperformed the DQN model and achieves SOTA performance under few-shot learning setting. The fact shows that learning shared embeddings from real conversations is more efficient when adapting the model for learning new diseases with few examples. Meanwhile, many shared knowledge from pre-trained diseases can still be applied for the new ones. The learned knowledge about symptoms allows the neural network to learn new diseases with a better initialization of dialog policy, and thus makes the adaptation faster and better. We also found that although the increasing of noise level degrades the performance of DQNs, ProtoQN yields steady success rate when the noise level varies. we believe the robustness results from the ensemble nature of ProtoNets inference mechanisms.

Conclusion and Future Work
In this work, we propose a novel dialog management model, prototypical Q network, for supervised and few-shot dialog policy learning. We apply this model in the area of automatic conversational diagnosis. Experiments showed that the Proto-QNs outperforms the DQN model in both supervised and fewshot settings. In the supervised setting, ProtoQNs achieve results comparable to SOTA without using domain-specific features. As for the few-shot experiment, ProtoQN learns new diseases using few training samples without forgetting previously learned, and achieves SOTA. The model also shows less degradation as we injecting noise to conversation. Our study suggests that modeling real conversations directly reinforces simulatorbased dialog policy learning. Embeddings of dialog actions are shareable among tasks (diseases, in our case) and benefits the fast adaptation to new ones. Here we show promising results in medical domain. In future, we will investigate more adaptive models as well as different domains and corpora toward the goal of modeling new dialog tasks better and with fewer examples.