Right for the Wrong Reasons: Diagnosing Syntactic Heuristics in Natural Language Inference

R. Thomas McCoy, Ellie Pavlick, Tal Linzen

Abstract

A machine learning system can score well on a given test set by relying on heuristics that are effective for frequent example types but break down in more challenging cases. We study this issue within natural language inference (NLI), the task of determining whether one sentence entails another. We hypothesize that statistical NLI models may adopt three fallible syntactic heuristics: the lexical overlap heuristic, the subsequence heuristic, and the constituent heuristic. To determine whether models have adopted these heuristics, we introduce a controlled evaluation set called HANS (Heuristic Analysis for NLI Systems), which contains many examples where the heuristics fail. We find that models trained on MNLI, including BERT, a state-of-the-art model, perform very poorly on HANS, suggesting that they have indeed adopted these heuristics. We conclude that there is substantial room for improvement in NLI systems, and that the HANS dataset can motivate and measure progress in this area.

Introduction: The "Clever Hans" Effect in NLI

Natural Language Inference (NLI) is a fundamental task in NLP, requiring a model to determine if a premise sentence entails a hypothesis. While modern neural networks, particularly Transformer-based models like BERT, have achieved impressive performance on standard benchmarks like MNLI, there is growing concern that these models are "cheating." Much like the horse "Clever Hans" who appeared to do arithmetic but was actually responding to subtle cues from his trainer, NLI models may be relying on statistical artifacts and shallow heuristics rather than true semantic reasoning.

The Heuristic Hypothesis

This research identifies three specific syntactic heuristics that models might adopt due to biases in training data:

  1. Lexical Overlap: Assuming entailment if the hypothesis uses only words found in the premise (e.g., The doctor paid the actor $\rightarrow$ The actor paid the doctor).
  2. Subsequence: Assuming entailment if the hypothesis is a contiguous subsequence of the premise (e.g., The doctor near the actor danced $\rightarrow$ The actor danced).
  3. Constituent: Assuming entailment if the hypothesis is a complete subtree in the premise's parse tree (e.g., If the artist slept, the actor ran $\rightarrow$ The artist slept).

In standard datasets like MNLI, these heuristics are often "correct" because of how the data was collected. However, they are logically fallible.

The HANS Dataset

To diagnose these shortcuts, the authors introduced HANS (Heuristic Analysis for NLI Systems). HANS consists of 30,000 examples specifically designed to test these three heuristics. Crucially, the dataset is balanced: for every example where a heuristic leads to the correct answer (the "entailed" cases), there is a corresponding example where the heuristic leads to an incorrect answer (the "non-entailed" cases).

Results: Models Fail to Generalize

When evaluated on HANS, models trained on the standard MNLI dataset showed a striking performance gap. While they achieved near-perfect accuracy on examples that supported the heuristics, their performance plummeted on examples that contradicted them.

Accuracy of models trained on MNLI on the HANS dataset. Models perform well on heuristic-supporting cases (top) but fail on heuristic-contradicting cases (bottom).

As shown in the figure above, accuracy for models like ESIM and SPINN on non-entailed cases was often near 0%. Even BERT, despite its massive pre-training, struggled significantly, particularly on cases involving subject-object swaps. This suggests that the training signal from the NLI dataset—which reinforces these shallow shortcuts—is more influential than the model's internal architecture.

Solution: The Power of Data Augmentation

The failure of these models is not necessarily a limitation of their architecture, but rather a reflection of the data they are fed. To test this, the authors augmented the MNLI training set with a small amount of HANS-like data (approximately 8% of the total training size).

Accuracy on HANS after training on the augmented MNLI+ dataset. Performance on non-entailed cases improves dramatically.

With this augmented dataset (MNLI+), models were forced to learn that lexical overlap does not guarantee entailment. As a result, performance on the HANS non-entailed cases improved dramatically without significantly degrading performance on the original MNLI test set. This demonstrates that models can learn more robust generalizations if the training data is sufficiently diverse and challenging.

Conclusion

The HANS dataset serves as a powerful diagnostic tool for NLI systems. It reveals that current state-of-the-art models are prone to adopting shallow syntactic heuristics that fail in complex scenarios. While data augmentation provides a temporary fix, the broader challenge remains: developing models and training procedures that naturally favor deep semantic understanding over superficial statistical shortcuts.

Summary updated

BibTeX
@inproceedings{mccoy2019right,
  author = {R. Thomas McCoy and Ellie Pavlick and Tal Linzen},
  title = {{Right for the Wrong Reasons: Diagnosing Syntactic Heuristics in Natural Language Inference}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2019},
  url = {https://openreview.net/forum?id=23BdRu0dR7},
}
Figure