Source-linked AI summary

Learning What Makes a Difference from Counterfactual Examples and Gradient Supervision

Damien Teney, Ehsan Abbasnedjad, Anton van den Hengel

arXiv:2004.09034v1cs.CVcs.LG

TL;DR

Models can learn spurious correlations rather than underlying task mechanisms, and more data from the same distribution may not address this generalization problem. The paper uses counterfactual pairs to orient model gradients and reports improved out-of-distribution generalization across four tasks.

  • Problem

    Models may rely on spurious correlations rather than task mechanisms, and adding examples from the same distribution cannot by itself address this generalization challenge.

    Source: §1 · pp. 1–2
  • Method

    The method uses minimally different, differently labeled counterfactual pairs to supervise the orientation of a model’s input gradient.

    Source: §1 · p. 3, §3.1 · p. 6
  • Results

    The method improves out-of-distribution generalization across VQA, multi-label image classification, sentiment analysis, and natural language inference.

    Source: §1 · p. 3
  • Takeaways & Limitations

    The authors conclude that the technique can make models more faithful to the causal mechanisms behind the data and more likely to be right for the right reasons.

    Source: §5 · p. 14

    The NLP experiments use simple models and relatively little data, leaving application to extremely large data regimes, including large language models, for future work.

    Source: §4.3 · p. 14

Abstract

from arXiv · show

One of the primary challenges limiting the applicability of deep learning is its susceptibility to learning spurious correlations rather than the underlying mechanisms of the task of interest. The resulting failure to generalise cannot be addressed by simply using more data from the same distribution. We propose an auxiliary training objective that improves the generalization capabilities of neural networks by leveraging an overlooked supervisory signal found in existing datasets. We use pairs of minimally-different examples with different labels, a.k.a counterfactual or contrasting examples, which provide a signal indicative of the underlying causal structure of the task. We show that such pairs can be identified in a number of existing datasets in computer vision (visual question answering, multi-label image classification) and natural language processing (sentiment analysis, natural language inference). The new training objective orients the gradient of a model's decision function with pairs of counterfactual examples. Models trained with this technique demonstrate improved performance on out-of-distribution test sets.

1 Introduction

The paper addresses poor generalization when models rely on spurious correlations rather than task-relevant properties. It uses relations between counterfactual examples as additional supervision and reports improved out-of-distribution generalization across four tasks.

1 Introduction

  • Models can rely on spurious correlations tied to dataset biases or sampling artifacts, so performance may suffer when those correlations do not hold at test time.The paper gives the example of an image model associating people with dining tables rather than visual evidence for each object.Source: §1 · p. 1
  • Pairs of minimally different, differently labeled examples provide a complementary signal that may be explicitly supplied or identified from existing annotations.The paper interprets these pairs as counterfactuals of one another.Source: §1 · p. 3
  • Relations between counterfactual examples indicate which input changes map to label changes, helping constrain the model’s decision-boundary geometry.This complements fitting the model to individual training points.Source: §1 · p. 3
  • The method improves out-of-distribution generalization on VQA, multi-label image classification, sentiment analysis, and natural language inference.The paper reports these gains using annotations in existing datasets that are usually disregarded.Source: §1 · p. 3

2 Related work

Related work connects poor generalization to dataset biases and spurious correlations, and frames causal mechanisms as one route to broader generalization. The paper distinguishes its use of paired counterfactual examples from domain adaptation, task-specific methods, and adversarial training.

2 Related work

  • Out-of-distribution evaluations expose models that exploit dataset-specific biases and artifacts rather than task properties, with performance potentially dropping when those biases do not hold.Dataset biases are correlations between inputs and labels that permit strong performance without solving the task of interest.Source: §2 · p. 4
  • Causal accounts propose that generalization depends on capturing real-world mechanisms; more data from one biased distribution may not suffice, motivating assumptions or additional types of supervision.The paper situates its paired-example approach alongside invariant risk minimization, which uses multiple training environments [6].Source: §2 · p. 4
  • Unlike domain adaptation, the paper aims for broader generalization using annotations indicative of task mechanisms, not adaptation to a particular new domain.The authors note that causal factors may vary in distribution across training domains.Source: §2 · p. 4
  • Prior VQA methods use task-specific priors or annotations, while adversarial-training approaches often mix generated examples through augmentation; this paper presents a more general use of relations between training points.The authors argue that shuffling examples destroys valuable relational information and distinguish their goal of generalizing on natural data from targeted adversarial robustness.Source: §2 · pp. 4–5

3 Proposed approach

The approach uses counterfactual pairs to constrain model behavior between labeled training points, then applies gradient supervision as an auxiliary objective. Its rationale is that local gradient alignment with pairwise input changes can shape decision boundaries and favor functions more faithful to the data-generating process.

3.1 Motivation

  • Counterfactual pairs are minimally changed examples with different labels, and their relations provide information about model behavior between labeled points.Such pairs may be explicitly present in datasets or derived by masking parts of inputs; the paper uses sentiment examples and COCO and VQA v2 annotations as examples.Source: §3.1 · p. 6

3.2 Gradient supervision

  • Gradient supervision uses a cosine-distance auxiliary loss to align the network’s input gradient with the displacement from an example to its counterfactual.This alignment constrains the decision-boundary geometry; the figure contrasts boundaries consistent with ordinary supervised loss against the boundary shaped by GS.Source: §3.2 · p. 6, Figure 2 · p. 6, Figure 3 · p. 7
  • For multiclass outputs, GS is applied only to classes with positive examples, and softmax models use logits so each class derivative depends on that class alone.Optimizing the combined main and GS losses requires two additional backpropagations per mini-batch.Source: §3.2 · p. 7

3.3 How gradient supervision improves generalization

  • Because counterfactuals are nearby, higher-order Taylor terms virtually vanish, making gradient alignment a local constraint on the change between their outputs.The authors also describe GS as modifying the optimization landscape so the trained minimizer is more likely to reflect the ideal function.Source: §3.3 · pp. 7–8

4 Applications

The applications test gradient supervision across four vision and language tasks, using counterfactual examples provided explicitly or derived from existing annotations. The reported results include improvements on out-of-distribution evaluations, with the NLP experiments limited to simple models and relatively little data.

4 Applications

  • The method is evaluated on four bias-prone vision and language tasks, using counterfactual examples supplied in datasets or generated from existing annotations.The experiments prioritize breadth and simple models over state-of-the-art performance on any single task.Source: §4 · p. 8

4.1 Visual question answering

  • On VQA-CP, counterfactual data and gradient supervision improve performance on most question types, with larger gains on the focused out-of-distribution test.Counterfactual examples are made by masking image features overlapping human attention and changing the answer labels; the focused test retains human-attended regions to assess robustness beyond question biases.Source: §4.1 · pp. 9–10, Table 1 · p. 9

4.2 Multi-label image classification

  • For COCO multi-label classification, edited examples are generated by masking objects, and the hard edited evaluation split contains class combinations absent from training.The edits use existing COCO annotations and inpainter-GAN-generated images.Source: §4.2 · pp. 10–12
  • 72.1→72.9% precision with gradient supervision, rising from 64.0→65.2% on edited images and 56.0→57.7% on hard edited images.Hard edited images contain object combinations absent from training; the random-relations ablation performs clearly worse.Source: Table 2 · p. 11, §4.2 · p. 12

4.3 NLP Tasks: sentiment analysis and natural language inference

  • In sentiment analysis, gradient supervision raises accuracy from 82.0→83.8% on original data and 88.7→91.2% on edited data; NLP gains also extend to other datasets and MultiNLI.On MultiNLI, edited-data augmentation alone hurts under domain shift, while gradient supervision raises performance above the original-data-only baseline; evaluation uses no fine-tuning.Source: §4.3 · pp. 13–14, Table 3 · p. 13
  • The NLP experiments use simple models and relatively little data, leaving application to large-data regimes and large language models for future work.The paper notes that current state-of-the-art sentiment and NLI systems use transformer models trained on vastly more data.Source: §4.3 · p. 14

5 Conclusions

The paper concludes that counterfactual-example relations provide complementary training information that can shape decision boundaries toward causal mechanisms and improve out-of-distribution performance. It also identifies extracting annotations from existing datasets and scaling to larger models as directions for further work.

5 Conclusions

  • The method combines gradient supervision with unused training signals in datasets to improve neural-network generalization.The conclusion characterizes the signals as relations between counterfactual examples and says they complement information from individual examples.Source: §5 · p. 14
  • The authors report that the technique can shape decision boundaries toward data-generating causal mechanisms and improve performance on out-of-distribution tests.They describe the resulting models as more likely to be “right for the right reasons.”Source: §5 · p. 14
  • The required annotations can be extracted from existing datasets, while applying the method to more tasks and scaling it to state-of-the-art vision and NLP models remain future directions.The paper lists additional tasks and datasets as potential applications.Source: §5 · p. 14

A Application to VQA

The VQA experiments generate counterfactual examples by masking image features using human attention maps, then evaluate models with held-out validation data and a focused test set. The section also describes baseline choices and cautions about test-set model selection and the limits of existing VQA evaluation.

A Application to VQA

  • Counterfactual VQA examples are generated on-the-fly by masking image features whose bounding boxes overlap human attention maps above a 0.2 threshold.The threshold was manually checked to mask most relevant visual evidence; the red boxes in Fig. 6 mark candidate regions.Source: A Application to VQA · p. 15, Figure 6 · p. 16
  • Model selection uses a random 8,000-question validation set held out from VQA-CP training, rather than the VQA-CP test split.The authors warn that test-set selection undermines an out-of-distribution evaluation and that ‘number’ and ‘yes/no’ accuracy can be unusually high by chance.Source: A Application to VQA · p. 15
  • The focused test set masks background features while retaining regions needed to answer, but includes only test questions with human attention maps.It is a subset of the official VQA-CP test set, using a manually checked 0.8 overlap threshold.Source: A Application to VQA · p. 15
  • The experiments compare the BUTD baseline and a stronger unshuffling baseline, and report that improvements over both indicate the method is not redundant with language-bias approaches.The authors could not replicate a prior attention-map method’s reported performance and cite errors, inconsistent results, and sensitivity to a hyperparameter as concerns.Source: A Application to VQA · pp. 15, 17
  • The VQA experiments use attention-map masking, whereas the COCO experiments use another counterfactual-generation technique to showcase multiple approaches.The authors say human attention maps are specific to VQA and do not apply to COCO experiments.Source: A Application to VQA · p. 17

B Application to image classification with COCO

The COCO experiments pair original images with edited images that mask selected objects, then use separate training, validation, and test splits. The section describes a hard edited subset, a tuned multilabel classifier, and the lack of directly comparable published results for this task.

B Application to image classification with COCO

C Application to NLP tasks

The NLP experiments use paired original and counterfactual examples for sentiment analysis and natural language inference, with simple bag-of-words models and separate evaluation on original and edited data. The section also notes a correction to the Yelp results column in Table 4.

C Application to NLP tasks

  • Sentiment experiments use paired IMDb examples, evaluate original and edited test examples separately, and test transfer on Amazon, Semeval 2017, and Yelp reviews.The paired training split contains 3,414 examples.Source: C Application to NLP tasks · p. 19
  • The sentiment model averages 50-dimensional word embeddings into a bag-of-words sentence representation and uses a linear sigmoid classifier with gradient supervision.The best regularizer weight was λ=20, and reported results use an ensemble of six models.Source: C Application to NLP tasks · p. 19
  • NLI experiments use SNLI examples with edited premises and hypotheses, evaluate original and edited examples separately, and test transfer on MultiNLI.MultiNLI is described as more diverse and linguistically complex than SNLI.Source: C Application to NLP tasks · p. 19
  • Table 4 reports Yelp results; its Yelp column was missing from Table 3 because a code-generation error duplicated Amazon values there.Source: Table 4 · p. 20
  • The NLI model separately encodes premise and hypothesis as averaged frozen-GloVe bag-of-words representations before combining them for classification.The model uses a three-layer ReLU stack and an ensemble of six copies; the best gradient-supervision weight was λ=0.01.Source: C Application to NLP tasks · p. 20
Loading 2004.09034v1…