Contrastive Novelty-Augmented Learning: Anticipating Outliers with Large Language Models (2023)

Abstract: In many task settings, text classification models are likely to encounter examples from novel classes on which they cannot predict correctly. Selective prediction, in which models abstain on low-confidence examples, provides a possible solution, but existing models are often overly confident on unseen classes. To remedy this overconfidence, we introduce Contrastive Novelty-Augmented Learning (CoNAL), a two-step method that generates OOD examples representative of novel classes, then trains to decrease confidence on them. First, we generate OOD examples by prompting a large language model twice: we prompt it to enumerate relevant novel classes, then generate examples from each novel class matching the task format. Second, we train a classifier with a novel contrastive objective that encourages lower confidence on generated OOD examples than training examples. When trained with CoNAL, classifiers improve in their ability to detect and abstain on novel class examples over prior methods by an average of 2.3% in terms of accuracy under the accuracy-coverage curve (AUAC) and 5.5% AUROC across 4 NLP datasets, with no cost to in-distribution accuracy.

## introduction recent progress in nlp has led to text classification models that are accurate not only in-distribution (id), but also on some out-ofdistribution (ood) data @xcite . nonetheless, some categories of real-world distribution shift still pose serious challenges. for instance, in open-set label shift @xcite , the test data includes examples from novel classes not present in the training data, making it impossible for a standard classifier to predict correctly @xcite . moreover, novel class examples can be difficult to detect with conventional ood detection methods, as they typically bear 1 code is available at github.com/albertkx/conal. a strong surface resemblance to training examples @xcite . in this paper, we frame open-set label shift as a selective prediction problem @xcite that we call open-set selective classification (ossc). ossc requires text classifiers to predict correctly on closed-set examples while abstaining on novel class examples. to perform well on ossc, a classifier must have lower confidence on novel class examples than closed-set examples by learning features which differentiate novel classes from closed-set classes @xcite . in order to supervise this representation learning, it is useful to identify what examples from novel classes might look like. prior work has explored automatically generating ood images by adding random perturbations to id examples @xcite . text inputs, however, are composed of discrete tokens, and modifying even a single token can unpredictably alter the meaning of a sentence. we seek an automatic generation method that addresses these limitations, leveraging the generative ability of large language models (llms) like gpt-3 @xcite . llms are a desirable source for novelty, as their generation is informed by a broad corpus of examples seen during pretraining, allowing them to reliably generate from classes outside a dataset. we present contrastive novelty-augmented learning (conal), a method to improve the ossc ability of a classifier by automatically generating ood examples, then training to abstain on them. to generate a diverse set of ood examples that anticipate different potential test-time shifts, we introduce novelty prompting, a method that augments a source dataset with novel class examples generated by a llm. we first perform label generation, prompting our llm to extend the closed-set labels with novel labels. we then prompt the llm to generate new examples conditioned on each novel label to form a large set of probable novel examples. ## method: conal here we describe contrastive novelty-augmented learning, a method for automatically improving ossc. at a high level, we generate novel examples and then train our model to be less confident on generated novel examples than closed-set examples. we first describe desiderata for useful novelty, then introduce a two-phased novel example generation method, novelty prompting, and finally introduce a contrastive confidence loss for classifier training. we illustrate the method in figure 1 . ## discussion and future work in this work, we introduce conal, a method for generating novel examples which simulate openset shift and training to abstain on them. through extensive experiments, we demonstrate that by presenting generated examples to a classifier, we can significantly improve its ability to abstain on examples from novel classes against state-of-the-art baselines. our work provides a generalizable framework for improving ossc and ood detection: in fact, we show through ccl training's strong performance with gold data that there remains headroom for novel example generation. additionally, conal is modular, as it provides additional supervision signal but does not alter the classifier's architecture. it thus remains extensible with other training objectives or classification metrics. finally, automatically diagnosing dataset issues and improving them is an important step towards making nlp safer and easier to apply. conal allows practitioners to deal with noise introduced by llm-generated data and apply these generated datasets in settings like open-set selective classification. the success of our method indicates that llms can be used to improve datasets with minimal human intervention. given interest in the emergent capabilities of llms, we hope that future work on classification in the presence of distribution shifts can better leverage large language models to both directly identify shifts and improve the abstention ability of smaller classifiers.