IRM - when it works and when it doesn't: A test case of natural language inference

Yana Dranker, He He, Yonatan BelinkovNeurIPS 2021

Invariant Risk Minimization (IRM) is a promising framework designed to help machine learning models ignore "shortcuts" (spurious correlations) and learn actual reasoning. This paper tests IRM on the complex task of Natural Language Inference (NLI) and finds that while it outperforms standard training in biased settings, its real-world advantage is often small, highly sensitive to data conditions, and prone to instability.

The Problem: Spurious Correlations in NLI

Deep learning models are notorious for being "lazy." Instead of learning the underlying logic of a task, they often latch onto spurious correlations—superficial patterns in the training data that happen to correlate with the label but fail to generalize to the real world.

In Natural Language Inference (NLI), where a model must decide if a "premise" entails a "hypothesis," common biases include:

  • Hypothesis Bias: The model ignores the premise entirely and just looks for "negation" words (like no or never) to predict a "contradiction."
  • Overlap Bias: The model predicts "entailment" simply because the two sentences share many of the same words.

IRM was proposed to solve this by training models across different "environments" where these biases vary. The goal is to force the model to find features that are invariant (consistent) across all environments—ideally, the actual causal features of language. However, most IRM research has stayed in the realm of toy problems (like colored digits). This paper asks a critical question: Does IRM actually work for complex, high-dimensional NLP tasks?

Methodology: Environment Generation

The authors compare standard Empirical Risk Minimization (ERM)—which minimizes average training loss—against IRMv1, the practical implementation of the IRM objective.

The core challenge in applying IRM to natural data is Environment Generation. IRM requires data to be split into groups where the bias-to-label correlation differs. To do this for natural language, the authors:

  1. Trained a "biased model" (e.g., a model that only sees the hypothesis).
  2. Used that model to score how "biased" each sample is.
  3. Categorized samples into Bias-aligned (the shortcut works), Bias-misaligned (the shortcut fails), and Unbiased.
  4. Sampled from these groups to create training environments with specific "bias strengths" (the probability that the biased feature matches the label).

Experimental Setup

The study progresses through three levels of complexity to test the limits of IRM:

  1. Toy Experiment: A synthetic XOR-based NLI task.
  2. Synthetic Bias Experiment: Real NLI data (SNLI) but with artificial "bias tokens" injected into the text.
  3. Natural Bias Experiment: Real NLI data (SNLI and MNLI) using existing, naturally occurring hypothesis and overlap biases.
  4. OOD Benchmarks: Evaluation on challenge sets like HANS and RevisedPremises to see if the debiasing generalizes to completely external distributions.
Examples of training and test instances across the different experimental setups, illustrating how biases align or misalign with the true labels.

Key Insights and Results

The results reveal a stark contrast between theoretical toy settings and messy real-world data.

  • The "Aha" on Complexity: In toy settings, IRM is a miracle worker, achieving 100% out-of-distribution (OOD) accuracy compared to 0% for ERM. But in natural settings, the gap shrinks significantly. Real-world "causal" features are much harder to learn than simple synthetic ones, and ERM doesn't rely exclusively on bias when complex features are available.
  • Synthetic Bias: On the most difficult "bias-misaligned" test set, IRM achieved 83.5% accuracy compared to ERM’s 79.16%.
  • Natural Bias: For hypothesis bias on SNLI, IRM improved performance on misaligned data (65.12% vs 62.63% for ERM). However, this often came at the cost of a slight performance drop on the "unbiased" and "bias-aligned" portions of the data.
Performance comparison between ERM and IRM on natural bias experiments, showing IRM's slight edge on bias-misaligned data.
  • The Three Pillars of Success: The authors identified three factors that govern whether IRM will actually beat ERM:
  • Bias Prevalence: How many examples in the set actually contain the biased feature?
  • Bias Strength: How strongly does the bias correlate with the label?
  • Data Size: IRM is data-hungry; it performs poorly in small-data regimes where ERM is more stable.
  • OOD Benchmarks: IRM did not consistently outperform ERM on external challenge sets like HANS. This suggests that while IRM helps mitigate the specific bias it was trained on, it doesn't necessarily make the model a "better reasoner" overall.

Limitations and Future Work

IRM is notoriously unstable. Different random seeds can lead to wildly different results, or even "model collapse," where the model fails to learn anything useful at all (converging to a "null" solution that performs at chance level). Better ways to tune the penalty weight ($\lambda$) are needed.

Furthermore, IRM is good at ignoring a known, targeted bias, but it struggles to extrapolate to new types of distribution shifts it didn't see during training. Its success is heavily dependent on how you define and split your environments—a "chicken and egg" problem in the real world where biases are often unknown beforehand.

The authors conclude that while IRM is a step in the right direction, we need more "naturalistic" benchmarks to truly evaluate out-of-distribution generalization in AI.

Summary updated

BibTeX
@inproceedings{dranker2021irm,
  author = {Yana Dranker and He He and Yonatan Belinkov},
  title = {{IRM - when it works and when it doesn't: A test case of natural language inference}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2021},
  url = {https://openreview.net/forum?id=iEKp5sxPOB},
}
Figure