CORE : A Retrieve-then-Edit Framework for Counterfactual Data Generation (2022)

Abstract: Counterfactual data augmentation (CDA) – i.e., adding minimally perturbed inputs during training – helps reduce model reliance on spurious correlations and improves generalization to out-of-distribution (OOD) data. Prior work on generating counterfactuals only considered restricted classes of perturbations, limiting their effectiveness. We present Counterfactual Generation via Retrieval and Editing (CORE), a retrieval-augmented generation framework for creating diverse counterfactual perturbations for CDA. For each training example, CORE first performs a dense retrieval over a task-related unlabeled text corpus using a learned bi-encoder and extracts relevant counterfactual excerpts. CORE then incorporates these into prompts to a large language model with few-shot learning capabilities, for counterfactual editing. Conditioning language model edits on naturally occurring data results in more diverse perturbations. Experiments on natural language inference and sentiment analysis benchmarks show that CORE counterfactuals are more effective at improving generalization to OOD data compared to other DA approaches. We also show that the CORE retrieval framework can be used to encourage diversity in manually authored perturbations.

## introduction contrast sets @xcite and counterfactual data @xcite provide minimal input perturbations that change model predictions, and serve as an effective means to evaluate brittleness to out-of-distribution data @xcite . counterfactual data augmentation (cda) has shown to improve model robustness to ood data and input perturbations @xcite @xcite . alternate methods like debiasing data @xcite have also shown promising results on 1 code at https://github.com/tanay2001/core ## related work counterfactual data augmentation there is growing interest in the area of cda for model robustness, with early efforts focused on humanauthored counterfactuals @xcite . however, manual rewrites can be costly and prone to systematic omissions. techniques have been proposed for the automatic generation of counterfactual data or contrast sets @xcite @xcite @xcite @xcite . existing techniques rely on using rules/heuristics for perturbing sentences @xcite @xcite , or using sentence-level semantic representations (eg. srl) and a finite set of structured control codes @xcite @xcite . however, @xcite find that a limited set of perturbation types further exacerbates biases, resulting in poor generalization to unseen perturbation types. generally, creating an assorted set of instance-specific perturbations is challenging, often requiring external knowledge @xcite . retrieval augmented generation retrieving taskrelevant knowledge from a large corpus of unstructured and unlabeled text has proven to be very effective for knowledge-intensive language generation tasks like question answering @xcite , machine translation @xcite and dialogue generation @xcite . retrieval has also been used for paraphrase generation @xcite and style-transfer @xcite to specifically address the lack of diversity in generations from pretrained language models. in a similar vein, core uses learned retrieval for counterfactual generation. while @xcite use off-the-shelf retrieval models to generate counterfactuals for qa, learning to retrieve counterfactuals is non-trivial for problems other than qa. core provides a recipe to train retrieval for general tasks. in-context learning massive language models like gpt-3 have been found to be effective at controlled generation tasks like arbitrary style-transfer @xcite , counterfactual reasoning @xcite , step-wise reasoning for complex problems @xcite , and dataset generation @xcite , by learning in-context from few-shot demonstrations and natural language instructions @xcite . while gpt-3 has been used for data augmentation, it has not been used for counterfactual generation, which is fundamentally different in nature. ## method a high level overview of core is shown in figure 2 . the first stage ( §3.1) retrieves counterfactual excerpts from a large unlabeled corpus related to the target task. in the second stage ( §3.2), retrieved ## experimental setup we generate core counterfactuals for two taskssentiment classification of movie reviews and natural language inference. we describe task-specific details about core training and inference below. ## experimental results we first list the various augmentation strategies against which we compare core ( §5.1.1) followed by data augmentation results ( §5.1.2). in ( §5.2) we highlight the need for a counterfactual retriever, and in ( §5.3) we intrinsically evaluate core counterfactuals on their quality and perturbation diversity. ## conclusion we present core, a retrieval-augmented generation framework for creating diverse counterfactual perturbations for cda. core first learns to retrieve relevant text excerpts and then uses gpt-3 few-shot editing conditioned on retrieved text to make counterfactual edits. core encourages diversity with the use of additional knowledge for this task, explicitly via retrieval and implicitly (parametric knowledge), via gpt-3 editing. conditioning language model edits on naturally occurring data results in diversity ( §5.3). core counterfactuals are more effective at improving generalization to ood data compared to other approaches, on natural language inference and sentiment analysis( §5.1.2). core's retrieval framework can also be used to reduce priming effects and encourage diversity in manually authored perturbations ( §5.3).