Introduction
Recently, there has been a surge of excitement in developing chatbots for various purposes in research and enterprise. Data-driven approaches offered by common bot building platforms (e.g. Google Dialogflow, Amazon Alexa Skills Kit, Microsoft Bot Framework) make it possible for a wide range of users to easily create dialog systems with a limited amount of data in their domain of interest. Although most task-oriented dialog systems are built for a closed set of target domains, any failure to detect out-of-domain (OOD) utterances and respond with an appropriate fallback action can lead to frustrating user experience. There have been a set of prior approaches for OOD detection which require both in-domain (IND) and OOD data BIBREF0 , BIBREF1 . However, it is a formidable task to collect sufficient data to cover in theory unbounded variety of OOD utterances. In contrast, BIBREF2 introduced an in-domain verification method that requires only IND utterances. Later, with the rise of deep neural networks, BIBREF3 proposed an autoencoder-based OOD detection method which surpasses prior approaches without access to OOD data. However, those approaches still have some restrictions such that there must be multiple sub-domains to learn utterance representation and one must set a decision threshold for OOD detection. This can prohibit these methods from being used for most bots that focus on a single task.
The goal of this paper is to propose a novel OOD detection method that does not require OOD data by utilizing counterfeit OOD turns in the context of a dialog. Most prior approaches do not consider dialog context and make predictions for each utterance independently. We will show that this independent decision leads to suboptimal performance even when actual OOD utterances are given to optimize the model and that the use of dialog context helps reduce OOD detection errors. To consider dialog context, we need to connect the OOD detection task with the overall dialog task. Thus, for this work, we build upon Hybrid Code Networks (HCN) BIBREF4 since HCNs achieve state-of-the-art performance in a data-efficient way for task-oriented dialogs, and propose AE-HCNs which extend HCNs with an autoencoder (Figure FIGREF8 ). Furthermore, we release new dialog datasets which are three publicly available dialog corpora augmented with OOD turns in a controlled way (exemplified in Table TABREF2 ) to foster further research.
METHODS
In this section, we first present the standard HCN model. Then we introduce the proposed AE-HCN(-CNN) model, consisting of an autoencoder and a reconstruction score-aware HCN model. Finally, we describe the counterfeit data augmentation method for training the proposed model.
HCN
As shown in Figure FIGREF8 , HCN considers a dialog as a sequence of turns. At each turn, HCN takes a tuple, INLINEFORM0 , as input to produce the next system action INLINEFORM1 , where INLINEFORM2 is a user utterance consisting of INLINEFORM3 tokens, i.e., INLINEFORM4 , INLINEFORM5 a one-hot vector encoding the previous system action and INLINEFORM6 a contextual feature vector generated by domain-specific code. The user utterance is encoded as a concatenation of a bag-of-words representation and an average of word embeddings of the user utterance: DISPLAYFORM0
where INLINEFORM0 denotes a word embedding layer initialized with GloVe BIBREF5 with 100 dimensions. HCN then considers the input tuple, INLINEFORM1 , to update the dialog state through an LSTM BIBREF6 with 200 hidden units: DISPLAYFORM0
Finally, a distribution over system actions is calculated by a dense layer with a softmax activation: DISPLAYFORM0
AE-HCN
On top of HCN, AE-HCN additionally takes as input an autoencoder's reconstruction score INLINEFORM0 for the user utterance for dialog state update (Figure FIGREF8 ): DISPLAYFORM0
The autoencoder is a standard seq2seq model which projects a user utterance into a latent vector and reconstructs the user utterance. Specifically, the encoder reads INLINEFORM0 using a GRU BIBREF7 to produce a 512-dimensional hidden vector INLINEFORM1 which in turn gets linearly projected to a 200-dimensional latent vector INLINEFORM2 : DISPLAYFORM0 DISPLAYFORM1
The output of the decoder at step INLINEFORM0 is a distribution over words: DISPLAYFORM0 DISPLAYFORM1
where INLINEFORM0 has 512 hidden units. The reconstruction score INLINEFORM1 is the normalized generation probability of INLINEFORM2 : DISPLAYFORM0
AE-HCN-CNN
AE-HCN-CNN is a variant of AE-HCN where user utterances are encoded using a CNN layer with max-pooling (following BIBREF8 ) rather than equation EQREF5 : DISPLAYFORM0
The CNN layer considers two kernel sizes (2 and 3) and has 100 filters for each kernel size.
Counterfeit Data Augmentation
To endow an AE-HCN(-CNN) model with a capability of detecting OOD utterances and producing fallback actions without requiring real OOD data, we augment training data with counterfeit turns. We first select arbitrary turns in a dialog at random according to a counterfeit OOD probability INLINEFORM0 , and insert counterfeit turns before the selected turns. A counterfeit turn consists of a tuple INLINEFORM1 as input and a fallback action INLINEFORM2 as output. We copy INLINEFORM3 and INLINEFORM4 of each selected turn to the corresponding counterfeit turns since OOD utterances do not affect previous system action and feature vectors generated by domain-specific code. Now we generate a counterfeit INLINEFORM5 and INLINEFORM6 . Since we don't know OOD utterances a priori, we randomly choose one of the user utterances of the same dialog to be INLINEFORM7 . This helps the model learn to detect OOD utterances because a random user utterance is contextually inappropriate just like OOD utterances are. We generate INLINEFORM8 by drawing a sample from a uniform distribution, INLINEFORM9 , where INLINEFORM10 is the maximum reconstruction score of training data and INLINEFORM11 is an arbitrary large number. The rationale is that the reconstruction scores of OOD utterances are likely to be larger than INLINEFORM12 but we don't know what distribution the reconstruction scores of OOD turns would follow. Thus we choose the most uninformed distribution, i.e., a uniform distribution so that the model may be encouraged to consider not only reconstruction score but also other contextual features such as the appropriateness of the user utterance given the context, changes in the domain-specific feature vector, and what action the system previously took.
DATASETS
To study the effect of OOD input on dialog system's performance, we use three task-oriented dialog datasets: bAbI6 BIBREF9 initially collected for Dialog State Tracking Challenge 2 BIBREF10 ; GR and GM taken from Google multi-domain dialog datasets BIBREF11 . Basic statistics of the datasets are shown in Table TABREF22 . bAbI6 deals with restaurant finding tasks, GM buying a movie ticket, and GR reserving a restaurant table, respectively. We generated distinct action templates by replacing entities with slot types and consolidating based on dialog act annotations.
We augment test datasets (denoted as Test-OOD in Table TABREF22 ) with real user utterances from other domains in a controlled way. Our OOD augmentations are as follows:
These two augmentation types reflect a specific dialog pattern of interest (see Table TABREF2 ): first, the user utters a request from another domain at an arbitrary point in the dialog (each turn is augmented with the probability INLINEFORM0 , which is set to 0.2 for this study), and the system answers accordingly. This may go on for several turns in a row —each following turn is augmented with the probability INLINEFORM1 , which is set to 0.4 for this study. Eventually, the OOD sequence ends up and the dialog continues as usual, with a segment-level OOD content of the user affirming their mistake. While we introduce the OOD augmentations in a controlled programmatic way, the actual OOD content is natural. The OOD utterances are taken from dialog datasets in several foreign domains: 1) Frames dataset BIBREF12 — travel booking (1198 utterances); 2) Stanford Key-Value Retrieval Network Dataset BIBREF13 — calendar scheduling, weather information retrieval, city navigation (3030 utterances); 3) Dialog State Tracking Challenge 1 BIBREF14 — bus information (968 utterances).
In order to avoid incomplete/elliptical phrases, we only took the first user's utterances from the dialogs. For segment-level OOD content, we mined utterances with the explicit affirmation of a mistake from Twitter and Reddit conversations datasets — 701 and 500 utterances respectively.
EXPERIMENTAL SETUP AND EVALUATION
We comparatively evaluate four different models: 1) an HCN model trained on in-domain training data; 2) an AE-HCN-Indep model which is the same as the HCN model except that it deals with OOD utterances using an independent autoencoder-based rule to mimic BIBREF3 – when the reconstruction score is greater than a threshold, the fallback action is chosen; we set the threshold to the maximum reconstruction score of training data; 3) an AE-HCN(-CNN) model trained on training data augmented with counterfeit OOD turns – the counterfeit OOD probability INLINEFORM0 is set to 15% and INLINEFORM1 to 30. We apply dropout to the user utterance encoding with the probability 0.3. We use the Adam optimizer BIBREF15 , with gradients computed on mini-batches of size 1 and clipped with norm value 5. The learning rate was set to INLINEFORM2 throughout the training and all the other hyperparameters were left as suggested in BIBREF15 . We performed early stopping based on the performance of the evaluation data to avoid overfitting. We first pretrain the autoencoder on in-domain training data and keep it fixed while training other components.
The result is shown in Table TABREF23 . Since there are multiple actions that are appropriate for a given dialog context, we use per-utterance Precision@K as performance metric. We also report f1-score for OOD detection to measure the balance between precision and recall. The performances of HCN on Test-OOD are about 15 points down on average from those on Test, showing the detrimental impact of OOD utterances to such models only trained on in-domain training data. AE-HCN(-CNN) outperforms HCN on Test-OOD by a large margin about 17(20) points on average while keeping the minimum performance trade-off compared to Test. Interestingly, AE-HCN-CNN has even better performance than HCN on Test, indicating that, with the CNN encoder, counterfeit OOD augmentation acts as an effective regularization. In contrast, AE-HCN-Indep failed to robustly detect OOD utterances, resulting in much lower numbers for both metrics on Test-OOD as well as hurting the performance on Test. This result indicates two crucial points: 1) the inherent difficulty of finding an appropriate threshold value without actually seeing OOD data; 2) the limitation of the models which do not consider context. For the first point, Figure FIGREF24 plots histograms of reconstruction scores for IND and OOD utterances of bAbI6 Test-OOD. If OOD utterances had been known a priori, the threshold should have been set to a much higher value than the maximum reconstruction score of IND training data (6.16 in this case).
For the second point, Table TABREF25 shows the search for the best threshold value for AE-HCN-Indep on the bAbI6 task when given actual OOD utterances (which is highly unrealistic for the real-world scenario). Note that the best performance achieved at 9 is still not as good as that of AE-HCN(-CNN). This implies that we can perform better OOD detection by jointly considering other context features.
Finally, we conduct a sensitivity analysis by varying counterfeit OOD probabilities. Table TABREF26 shows performances of AE-HCN-CNN on bAbI6 Test-OOD with different INLINEFORM0 values, ranging from 5% to 30%. The result indicates that our method manages to produce good performance without regard to the INLINEFORM1 value. This superior stability nicely contrasts with the high sensitivity of AE-HCN-Indep with regard to threshold values as shown in Table TABREF25 .
CONCLUSION
We proposed a novel OOD detection method that does not require OOD data without any restrictions by utilizing counterfeit OOD turns in the context of a dialog. We also release new dialog datasets which are three publicly available dialog corpora augmented with natural OOD turns to foster further research. In the presence of OOD utterances, our method outperforms state-of-the-art dialog models equipped with an OOD detection mechanism by a large margin — more than 17 points in Precision@K on average — while minimizing performance trade-off on in-domain test data. The detailed analysis sheds light on the difficulty of optimizing context-independent OOD detection and justifies the necessity of context-aware OOD handling models. We plan to explore other ways of scoring OOD utterances than autoencoders. For example, variational autoencoders or generative adversarial networks have great potential. We are also interested in using generative models to produce more realistic counterfeit user utterances.

Question: By how much does their method outperform state-of-the-art OOD detection?
Answer: AE-HCN outperforms by 17%, AE-HCN-CNN outperforms by 20% on average