Counterfactual Inference for Text Classification Debiasing (2021)

Abstract: Today’s text classifiers inevitably suffer from unintended dataset biases, especially the document-level label bias and word-level keyword bias, which may hurt models’ generalization. Many previous studies employed data-level manipulations or model-level balancing mechanisms to recover unbiased distributions and thus prevent models from capturing the two types of biases. Unfortunately, they either suffer from the extra cost of data collection/selection/annotation or need an elaborate design of balancing strategies. Different from traditional factual inference in which debiasing occurs before or during training, counterfactual inference mitigates the influence brought by unintended confounders after training, which can make unbiased decisions with biased observations. Inspired by this, we propose a model-agnostic text classification debiasing framework – Corsair, which can effectively avoid employing data manipulations or designing balancing mechanisms. Concretely, Corsair first trains a base model on a training set directly, allowing the dataset biases ‘poison’ the trained model. In inference, given a factual input document, Corsair imagines its two counterfactual counterparts to distill and mitigate the two biases captured by the poisonous model. Extensive experiments demonstrate Corsair’s effectiveness, generalizability and fairness.

## methodology problem formalization let x and y denote the input (text document) and output (category) spaces, respectively. given a labeled training set d @xmath0, y i ) ∈ x × y} (i.e., the observed data), the goal is to learn a text classifier m on d train , which serves as a mapping function f (•) : @xmath1. considering that the dataset biases would not be completely eliminated via data manipulations, employing data manipulations (e.g., resampling) or designing balancing mechanisms (e.g., reweighting) may be not a directly-reasonable solution. inspired by the success of counterfactual inference in mitigating biases in computer vision @xcite @xcite @xcite , we propose a counterfactual-inference-based text-classification debiasing framework (corsair), which is able to make unbiased decisions with biased observations. the core idea of corsair is to train a "poisonous" text classifier regardless the dataset biases and post-adjust the biased predictions according to the causes of the biases in inference. it's worth mentioning that our proposed corsair can be applied to almost any parameterized base model, including traditional one-stage classifiers (e.g., textcnn @xcite , rcnn @xcite and leco @xcite ) and currently prevalent two-stage classifiers foot_0 (e.g., ulm- biased learning (on training set) bias distillation (on testing set) w1 w2 w3 w8 y1 w1 w2 w3 w4 … vocabulary y1 y2 … y3 categories w2 w5 wn y2 w6 w1 w8 w2 w8 ym factual output (i.e., factual prediction) bias removal (on testing set) x̃m y counterfactual world (partially-blindfolded) m y x counterfactual world (fully-blindfolded) w5 w4 w3 w2 w1 imagination see nothing counterfactual input w5 w4 w3 w2 w1 imagination see some counterfactual input w5 w4 w3 w2 w1 factual input x m y factual world (traditional inference) counterfactual output (i.e., label bias) counterfactual output (i.e., keyword bias) x m y factual learning elastic scaling (on validation set) label bias keyword bias λ λ λ* λ* λ* λ* = counterfactual prediction factual prediction label bias keyword bias f(x)=y2 c(x)=y4 x probability distribution or logit vector document word-masked document element-wise subtraction scaling factor λ λ w5 fit @xcite , bert @xcite and roberta @xcite ). for brevity, we will elaborate corsair by taking roberta (a robustly optimized bert-shape language model) as the example base model, and binary sentiment analysis as the example application. the high-level architecture of corsair is illustrated in figure 1 , which consists of three main components: biased learning, bias distillation and bias removal. ## evaluation baselines we choose four types of representative text classifiers as the base models of our proposed framework, covering classical, data-manipulation-based, model-balancing-based, as well as large-scale and two-stage methods. textcnn @xcite is a classical classifier that uses convolutional neural networks (cnn) with scale-variant convolution filters to capture local textual features, which may potentially capture spurious correlations between certain keywords and categories. leco @xcite utilizes the combination of the implicit encoding of deep linguistic information and the explicit encoding of morphological features, which would also capture the keyword bias inadvertently. besides, it uses a sentence-level over-sampling mechanism @xcite to mitigate the label bias, and we further enhance it via a powerful word-level augmentation technique (eda) @xcite to mitigate the keyword bias, denoted as lecoeda. weight @xcite is a most recent debiasing text classifier that uses a specially-designed reweighting technique under an unbiased objective for fair (i.e., nondiscrimination) learning, which is proven effective to mitigate the unfairness or discrimination issue caused by unintended dataset biases. roberta @xcite is an improved version of bert, whose effective modifications allow roberta to generalize better and match or exceed the performance of many post-bert methods, serving as a very strong baseline in recent work @xcite . ## related work text classification is a backbone component in many downstream tasks or applications @xcite @xcite . earlier text classification methods focus on manual feature engineering @xcite @xcite . the key factor of text classification lies in the quality of text representation @xcite @xcite @xcite . benefiting from high-quality word vectors, some subsequent studies explored different types of downstream text classification models, including support vector machine @xcite , maximum entropy model @xcite , naive bayes @xcite , word clustering (baker and @xcite and neural networks @xcite @xcite @xcite . to solve the dataset bias issue, a straightforward solution is to perform data-level manipulations to prevent models from capturing the unintended dataset biases in model training, including data balance @xcite @xcite @xcite (a.k.a. resampling) and data augmentation @xcite . another common paradigm for text classification is typically to design model-level balancing mechanisms, including unbiased embedding @xcite , threshold correction @xcite @xcite and instance weighting @xcite @xcite . ## conclusion we have designed a counterfactual framework for text classification debiasing. extensive experiments demonstrated the framework's good effectiveness, generalizability and fairness. future work will design a joint-learning technique to dynamically decide each document's main content. we hope the paradigm can illuminate a promising technical direction of causal inference in natural language processing.