Counterfactual Active Learning for Out-of-Distribution Generalization (2023)

Abstract: We study the out-of-distribution generalization of active learning that adaptively selects samples for annotation in learning the decision boundary of classification. Our empirical study finds that increasingly annotating seen samples may hardly benefit the generalization. To address the problem, we propose Counterfactual Active Learning (CounterAL) that empowers active learning with counterfactual thinking to bridge the seen samples with unseen cases. In addition to annotating factual samples, CounterAL requires annotators to answer counterfactual questions to construct counterfactual samples for training. To achieve CounterAL, we design a new acquisition strategy that selects the informative factual-counterfactual pairs for annotation; and a new training strategy that pushes the model update to focus on the discrepancy between factual and counterfactual samples. We evaluate CounterAL on multiple public datasets of sentiment analysis and natural language inference. The experiment results show that CounterAL requires fewer acquisition rounds and outperforms existing active learning methods by a large margin in OOD tests with comparable IID performance.

## introduction active learning (al) is widely applied to alleviate the scarcity of labeled data in various machine learning applications @xcite such as financial fraud detection @xcite where the annotation cost is high. existing research on al mainly focuses on the design of an acquisition strategy that adaptively selects informative samples for annotation from an unlabeled pool @xcite . while the models learned by al methods have comparable in-distribution performance with the ones learned from fully labeled @xcite in the learning procedure of the al method: entropy. data, they typically result in poor generalization on out-of-distribution samples @xcite . as ood samples widely exist in practice @xcite , it is critical to enhance the ood generalization of al. we first investigate how the ood generalization ability varies during the al procedure. figure 1 shows the empirical evidence on two text classification datasets @xcite of sentiment analysis and natural language inference with both iid and ood tests, where we evaluate a representative al method: entropy @xcite . the iid performance steadily increases, while the ood performance fluctuates at a much lower range close to the initial status as the number of annotations increases. we thus hypothesize that the seen samples selected from the unlabeled pool are not informative for ood generalization. the model will recognize some spurious correlations between input features and labels probably varying beyond the observed data. in other words, the model may over-emphasize some non-causal features to construct the decision boundary. counterfactual thinking @xcite is essential for bridging the gap between seen iid samples and unseen ood ones. it answers counterfactual questions like "what would the sentence be if its sentiment were negative?", indicating the causal features that change labels and break the spurious correlations in seen iid samples. along this line, counterfactual training @xcite is effective for enhancing ood generalization, which leverages factual and counterfactual samples to push the learning of decision boundary to focus on features causally affect the label @xcite . we thus believe that incorporating counterfactual samples into al can enhance ood generalization foot_0 . to embrace counterfactual samples, it is natural to consider combining al and counterfactual sample construction in a pipelined manner. as a pre-stage of al, we can first augment the entire unlabeled pool by pairing all samples with counterfactual samples, then perform al over the augmented pool. as a post-stage of al, with the factual samples acquired by an al method, we can construct counterfactual samples, and perform counterfactual training to obtain the final model. however, the pre-stage approach is cost unfriendly due to the large size of the unlabeled pool for counterfactual construction. the post-stage approach cannot consider the potential gain from the counterfactual samples in the acquisition of al. in this work, we consider combining sample annotation and counterfactual sample construction in the procedure of al. towards this end, we propose counterfactual active learning (counteral), which requires annotators to additionally perform counterfactual thinking on the selected samples. given a selected sample (x), in addition to the annotation (y), the annotator further imagines a counterfactual class (ȳ) and edits the factual features to be coherent with the counterfactual class, i.e., constructing the counterfactual feature (x * ȳ). coun-teral then updates model parameters over pairs of factual samples (x, y) and counterfactual samples (x * ȳ, ȳ) to enhance the ood generalization. the key to the success of counteral lies in: 1) an acquisition strategy that looks ahead the construction of counterfactual samples to select informative factual and counterfactual pairs; and 2) a training strategy that recognizes the discrepancy between each pair of factual and counterfactual samples. in the light that informative factualcounterfactual pairs are close to each other (label flip with fewer feature changes), we design a variability-based acquisition strategy to select factual samples with high variability to model up-dates (high probability of label flip). besides, we incorporate a new dropout to model training which masks the common features of factual and counterfactual samples to push the model to focus more on the discrepancy that implies causal features. lastly, we take two text classification problems of sentiment analysis and natural language inference as examples and validate the strong ood generalization ability of counteral on three public datasets. our main contributions are summarized as follows: ## methodology in this section, we first present the ood generalization issue in active learning, and then detail the proposed counteral framework, followed by several discussions on counteral. ## experiments we evaluate the proposed counteral framework over two text classification tasks about sentiment analysis (sa) and natural language inference (nli) to answer three research questions. rq1: how effective is the proposed counteral as compared to conventional active learning methods? rq2: how do the proposed acquisition strategy and training strategy influence the effectiveness of counteral? rq3: how do the counterfactual samples affect the learning procedure? ## conclusion we introduced a counterfactual active learning paradigm to improve the ood generalization of active learning. specifically, we developed novel acquisition and training strategies, which first acquire a diverse batch of informative factualcounterfactual pairs, and then capture the discrepancy between factual and counterfactual samples for model learning. experiments on two classic nlp problems validate that the proposed strategies can significantly enhance the ood performance. in the future, we consider building models for automatic counterfactual sample generation to reduce the labor cost of annotators. in addition, a promising research direction is devising more effective training methods to leverage counterfactual samples. furthermore, our method has higher potential in domains where human expertise and knowledge advantages are less captured by large language models, and we will consider the application to more datasets in vertical domains