DISCO : Distilling Counterfactuals with Large Language Models (2023)

Abstract: Models trained with counterfactually augmented data learn representations of the causal structure of tasks, enabling robust generalization. However, high-quality counterfactual data is scarce for most tasks and not easily generated at scale. When crowdsourced, such data is typically limited in scale and diversity; when generated using supervised methods, it is computationally expensive to extend to new counterfactual dimensions. In this work, we introduce DISCO (DIStilled COunterfactual Data), a new method for automatically generating high-quality counterfactual data at scale. DISCO engineers prompts to generate phrasal perturbations with a large general language model. Then, a task-specific teacher model filters these generations to distill high-quality counterfactual data. While task-agnostic, we apply our pipeline to the task of natural language inference (NLI) and find that on challenging evaluations such as the NLI stress test, comparatively smaller student models trained with DISCO generated counterfactuals are more robust (6% absolute) and generalize better across distributions (2%) compared to models trained without data augmentation. Furthermore, DISCO augmented models are 10% more consistent between counterfactual pairs on three evaluation sets, demonstrating that DISCO augmentation enables models to more reliably learn causal representations. Our repository are available at: https://github.com/eric11eca/disco

## introduction despite the tremendous progress made in nlp on a wide range of reasoning tasks @xcite @xcite , dataset biases continue to be a formidable challenge for robust model development @xcite @xcite @xcite . counterfactual data augmentation (cad) @xcite is one general approach to improve model robustness by training on edited instances that systematically alter the critical or causally salient parts of dataset instances that contributes to the label assignment. to date, two main approaches have been pursued as part of these efforts: human-centered approaches, where edits are obtained through direct human annotation and crowdsourcing @xcite @xcite ; and model-based approaches, where new examples are collected through automatic text generation @xcite @xcite . ## related work mitigating spurious correlations for nlu the augmentation methods described above are part of a large literature on model debiasing approaches, which also includes work on dataset filtering (bras et al., 2020), model ensembling @xcite , feature removal, and other learningbased techniques @xcite . @xcite also propose a new debiasing method called z-aug that learns to generate unbiased samples and filter out biased data using a z-statistic filter. in contrast to the debiasing and data generation techniques already discussed, our approach is unique in exploiting the power of llms such as gpt3 @xcite to create more diverse augmented datasets as a way to mitigate biases and shortcuts. counterfactual data augmentation augmenting models with counterfactual data is a popular recent approach for mitigating spurious correlation and improving model robustness. @xcite first recruits human workers to write counterfactual examples for augmentation. they find that counterfactually augmented data can help mitigate spurious patterns in the training data. as already discussed, however, creating counterfactual data using humans requires a high cost, is time-consuming, and can result in simple perturbations. later, @xcite and @xcite proposed frameworks that use text generation models to generate counterfactual data. these models require fine-tuning using pre-defined perturbation types. both methods have constraints: (1) the generation is un-targeted, thus unlabeled, and (2) the perturbation types are limited. to acquire new perturbation types, the models have to be retrained. unlike the previous methods, our method uses llms to generate more diverse perturbation types cheaply and efficiently. our method also improves over un-targeted generations by using a task-specific teacher model to verify the label. large model dataset creation leveraging the powerful generative ability of large language models to create datasets automatically has recently attracted considerable attention. this method reduces the cost of manually creating the dataset, can collect more diverse phenomena to expand the distribution, and can be adapted to a wide range of tasks in nlp. the most similar work to ours is wanli @xcite , an nli dataset fully generated by gpt-3 and annotated by human workers. the idea is to elicit ambiguous nli examples from gpt-3 to improve its performance on challenge evaluation benchmarks, which relies on the dataset cartography techniques from @xcite that we also use in our study for selecting instances to edit. our work also seeks to get diverse data from gpt-3 to improve model robustness. differently, we only make local perturbations on the premise instead of generating a new example. we did not label our training data using human workers but leveraged an nli model to filter out the counterfactual examples. ## counterfactual distillation the central idea of counterfactual data distillation is to prompt a large language model through in-context learning to generate perturbations that can flip the current label to a new one (ex. @xmath0. once we select a subset of a dataset (discussed in section 5.1), we first identify potential locations for performing counterfactual perturbations on the target instances. then we prompt the gpt-3 (text-davinci-002) model to overgenerate perturbations (3.1). we use a teacher language model specializing in the nli task to filter the generated perturbations based on the shift in model predictions from the orig-inal to the new label (3.2). formally, given an input premise-hypothesis @xmath1, h >, l where @xmath2, contradiction, n eutral} is the ground-truth label. we want to get a counterfactual @xmath3, h >, l ′ where we get p ′ by perturbing parts of the premise p and l ′ is the new label corresponding to the new input. ## conclusion in this paper, we introduced the disco framework for distilling high-quality counterfactual data from large language models (llms) using a taskspecific teacher model for nli. through automatic and human evaluations, we show that counterfactuals generated by llms have higher quality and accuracy than human-written examples while having more diverse perturbations. our evaluation results suggest that training or augmenting with distilled counterfactual data can help mitigate various types of distinct spurious patterns. counterfactual examples produced by disco significantly benefit model performance with improved robustness and out-of-distribution (ood) generalizability. despite a smaller data size, disco data help models achieve better performance on the evaluation sets than baselines with extensive data. furthermore, training on disco examples improves model performance on counterfactual accuracy and helps the model be more sensitive to the context changes between counterfactual and original examples. for future work, our method suggests several directions. while our efforts are limited to nli, generating counterfactual data using llms is more general and, we believe, can be fruitfully applied to a wider range of tasks. in specific, only a task-specific filter model and modification to llm prompts are needed to extend our generation pipeline to other tasks or even other languages. also, while our approach takes inspiration from knowledge distillation @xcite approaches and relies on a teacher filtering model, alternative strategies could be used to improve the quality. as a related direction, techniques for semisupervised learning over unfiltered llm output should also be investigated to help utilize the wide range of data produced by llms.