Counterfactual Adversarial Learning with Representation Interpolation (2021)

Abstract: Deep learning models exhibit a preference for statistical fitting over logical reasoning. Spurious correlations might be memorized when there exists statistical bias in training data, which severely limits the model performance especially in small data scenarios. In this work, we introduce Counterfactual Adversarial Training framework (CAT) to tackle the problem from a causality perspective. Particularly, for a specific sample, CAT first generates a counterfactual representation through latent space interpolation in an adversarial manner, and then performs Counterfactual Risk Minimization (CRM) on each original-counterfactual pair to adjust sample-wise loss weight dynamically, which encourages the model to explore the true causal effect. Extensive experiments demonstrate that CAT achieves substantial performance improvement over SOTA across different downstream tasks, including sentence classification, natural language inference and question answering.

## introduction large-scale pre-trained language models such as bert @xcite , as one of the recent breakthroughs, have revolutionized the model development paradigm in natural language processing (nlp) and improved traditional task-specific models by a large margin. although the pre-training and fine-tuning framework has been shown to be effective in transferring the pre-learned knowledge to downstream tasks and boosting the model performance, it could be a double-edged sword if there exists statistical bias in the training dataset, especially in small data scenarios @xcite . taking sentiment analysis as an example, the downstream classifier can easily mistake a certain person 1 code is available at https://github.com/ shininglab/cat.git name for a sentimental word if it is imbalanced distributed in positive and negative samples. @xcite further show that when the capacity of the model to certain semantics is strong, it will in turn strengthen this bias, in which case the large pretrained model becomes an amplifier for spurious features. generally, such problem can be better solved from the perspective of causality @xcite . in the context of causal inference, causation is not correlation but something more essential with the mechanism of data generation @xcite . statistical bias, also named spurious correlations, is a result of confounder, a variable that can influence dependent variables and independent variables simultaneously @xcite . the study of causation aims to find the true causal effects between variables that help to unveil the true casual effect behind observation data and realize more robust inference. specifically, counterfactuals are one feasible way to discover the causation. counterfactual examples are defined as the ones that minimallydifferent from original ones but lead to different labels @xcite . recent work shows that counterfactual samples can significantly improve model generalization and boost model performance. @xcite and @xcite use additional human-labeled or augmented counterfactual examples to mitigate spurious correlations. @xcite proposes a two-stage training approach for named entity recognition tasks for better generalization. although these methods gain significant improvements in model performance, they are limited in practice since they are either designed for specific tasks or requiring human-labeled samples. additionally, no optimization is conducted on those counterfactual examples which could further improve the performance shown in our work. our work. we revisit the above problem in nlp domain from a causality perspective. following the definition of counterfactual examples, our motivation is to explore the following question: what would be the minimal intervention that alters the model output? as a result, we propose cat, an end-to-end and task-agnostic counterfactual adversarial training framework during fine-tuning to introduce counterfactual representations in training stage through latent space interpolation. concretely, to define our problem, we first introduce structural causal model (scm) to view our problem through a casual graph that depicts the data generation mechanism. to cut off the confounder, we conduct do-calculus @xcite for causal effect adjustments. specifically, we propose a counterfactual representation interpolation technique called cmix which is a variant of mixup @xcite to generate counterfactuals and approximately realize do-calculus in deep learning framework. for each example x in training set, cmix samples a counterpart x and generates a counterfactual representation by interpolating the representation of x and x , which is adaptively optimized by a novel counterfactual adversarial loss (cal) to minimize the differences from original ones but lead to drastic label change by definition. finally, to connect each original-counterfactual pair, besides the traditional empirical risk minimization (erm) @xcite , we extend it to a new counterpart, i.e., counterfactual risk minimization (crm), to allow the model to adjust sample-wise loss weight dynamically so as to explore the causal effect behind data rather than simple correlations memorization. we also extend cat to other complicated tasks besides simple classification, which are rarely studied by other mixup-based methods. through extensive experiments on text classification, natural language inference and question answering on two sota baselines, bert and roberta @xcite , we observe consistent improvement for cat in promoting the testing accuracy especially for small data in an extra-data-free manner. our contributions are summarized as follows: large-scale pre-trained language model. the most widely-used solution for alleviating spurious correlations is using large-scale dataset. yang et al. (2019) and liu et al. (2019) proposed to build the pre-trained language models utilizing even larger corpus to reduce the bias. data augmentation. data augmentation is another solution and has become a de facto technique used in state-of-the-art machine learning models. zhang et al. (2015) performed text augmentation by replacing words or phrases with their synonyms, and recently wei and zou (2019) proposed more operations. using word embedding, (wang and @xcite tried to find a similar word for replacement. in addition, back translations @xcite and contextual augmentation @xcite techniques have been proposed to replace target words. through shrinking the weight of the training data relative to l2 regularization, mixup @xcite trained a neural network on convex combinations of pairs of examples and their labels to generate new samples (x, ỹ) from (x i , y i ) and (x j , y j ), formally as adversarial training. adversarial training has been proven to be an effective approach for improving the robustness of neural network models @xcite @xcite . specifically, miyato et al. (2017) applied adversarial and virtual adversarial training to text domain by applying perturbations to the word embeddings, which achieved state-of-the-art results on multiple semi-supervised and purely supervised tasks. by minimizing the resultant adversarial risk inside different regions around input samples, zhu et al. (2019) proposed a novel adversarial training algorithm, freelb, that is capable of promoting higher invariance in the embedding space. causal inference. yue et al. (2020) explored estimating true causal effects on few-shot images classification, which is an intervention-based approach. similarly, (tang et al., 2020) focuses on long-tail data set. in addition, using counterfacutals is another way to discover the causation in training data. for example, kaushik et al. (2019) and teney et al. (2020) leveraged additional human-labeled counterfactual examples, while zeng et al. (2020) proposed a two-stage training approach for named entity recognition task. these studies have been proved that counterfactual samples are more valuable in boosting model performance compared to normal samples. ## cat in this section, we introduce how cat solves the problem of spurious correlations from a causal perspective (see figure 1 ). we first explicate our problem by introducing structural causal model (scm). then we illustrate our approach by answering the following questions: (1) how can we cut off the confounder for spurious bias elimination by counterfactual representations? (2) how can we optimize our counterfactual representations? (3) how can we learn from both original and counterfactual representations to debias the spurious correlations? ## experiments we evaluate cat on five widely used open-source benchmark datasets, including text classification, natural language inference and question answering. ## conclusion to alleviate the spurious correlation bias in training corpus and encourage causal discovery instead of simple correlations, we propose cat from the causality perspective for introducing counterfactual representations in the training stage through latent space interpolation. through extensive experiments on three benchmarks on the text classification, natural language inference and question answering tasks, we demonstrate that cat is effective in promoting testing accuracy especially in the small data scenario, which outperforms sota baselines across different pre-trained models.