Detecting Compositionally Out-of-Distribution Examples in Semantic Parsing (2021)

Abstract: While neural networks are ubiquitous in state-of-the-art semantic parsers, it has been shown that most standard models suffer from dramatic performance losses when faced with compositionally out-of-distribution (OOD) data. Recently several methods have been proposed to improve compositional generalization in semantic parsing. In this work we instead focus on the problem of detecting compositionally OOD examples with neural semantic parsers, which, to the best of our knowledge, has not been investigated before. We investigate several strong yet simple methods for OOD detection based on predictive uncertainty. The experimental results demonstrate that these techniques perform well on the standard SCAN and CFQ datasets. Moreover, we show that OOD detection can be further improved by using a heterogeneous ensemble.

## introduction neural network (nn) based models are ubiquitous in natural language processing (nlp). in particular, sequence-to-sequence models have found adoption in neural machine translation (nmt @xcite ), neural semantic parsing (nsp @xcite ), and beyond. while basic sequence-to-sequence models have shown impressive results on these tasks, recent work @xcite @xcite have presented the disconcerting finding that these models fail to generalize to novel combinations of elements observed in the training set (see section 2). therefore, several models and methods with improved compositional generalization have recently been proposed @xcite @xcite @xcite @xcite @xcite in this work, we consider the task of detecting compositionally out-of-distribution (ood) exam-ples, which, to the best of our knowledge has not been investigated before. the ability to detect ood inputs is important, as it helps us to decide whether the model's prediction on the input can be trusted, which is crucial for safe deployment of the model and could be useful to build more efficient systems. to this end, we analyse the ood detection performance of recurrent neural network (rnn) and transformer-based models using methods relying on predictive uncertainty. in addition, we propose to use a heterogeneous ensemble of transformer and rnn-based models that combines the strengths of both to improve the detection of compositionally ood examples. ## background several recent works have investigated the generalization properties of commonly used sequence-tosequence models, in particular their ability to learn to process and produce novel combinations of elements observed during training @xcite @xcite . @xcite propose the scan dataset, which consists of natural language utterances (input) and action sequences (output), and perform an analysis of the generalization performance of sequence-to-sequence models on different splits of the dataset. the different splits are aimed at testing the ability of networks to (1) generalize to novel combinations of tokens observed only in isolation during training (the jump and turn_left settings) and (2) generalize to longer sequence lengths (the length setting). for the jump setting, the training set consists of the basic example "jump" → [jump] as well as all other simple and composed examples (e.g. "run twice") while the test set contains all composed examples with "jump" (e.g. "jump twice"). they observe that standard sequence-to-sequence models fail on the jump and length splits (accuracy below 10%) while they perform well (near 100%) on a random test split. @xcite performed their analysis on the cfq dataset that provides tens of thousands of automatically generated question/sparql-query pairs and provides maximum compound divergence (mcd) splits. the mcd splits are generated such that the distributions over compounds (phrases combining atomic elements) are maximally different between the train and test sets while the distributions over the atomic elements (entities, relations, question patterns) are kept similar. keysers et al. (2019) also provide mcd splits for the scan dataset. experiments using standard neural sequence-to-sequence models (transformers and rnn+attention) reveal that while the random splits result in near-perfect accuracy, the mcd splits suffer dramatic losses in performance (< 20% accuracy for cfq's mcd splits @xmath0. ## detecting ood examples in this work, we focus on ood detection methods that build on the predictive distributions of discriminative task-specific models (extending the work of @xcite ). these methods have the advantage that they are easy to use in existing models and do not require additional models or additional training (unlike for example generative modeling @xcite ). previous work has shown that neural network models can produce incorrect predictions with high confidence on ood inputs @xcite , which can be detrimental for detecting such inputs. we investigate whether this is the case for compositionally ood examples in semantic parsing models as well. we compare the following measures quantifying the uncertainty of the prediction based on the output distributions of a trained model: (1) the average negative log-likelihood (nll) for the generated sequence, (2) the sum of the nlls, and (3) the average entropy of the output distributions. more specifically, our approach for measuring uncertainty proceeds as outlined: first, the input x is encoded and an output sequence ŷ is generated by the decoder. the model's output probability distributions p(ŷ i |ŷ <i , x) for every decoding step i are then used to compute the sum of nll as ## experiments 1 datasets: we experiment with the scan @xcite and cfq @xcite datasets mentioned in section 2. ## results the ood detection performance for the different splits of the scan dataset are reported in ## analysis and discussion in the results obtained in