Counterfactual reasoning: Testing language models' understanding of hypothetical scenarios

Jiaxuan Li, Lang Yu, Allyson Ettinger · DOI

Introduction

Large Language Models (LLMs) like GPT-3 and BERT exhibit impressive linguistic capabilities, yet a fundamental question remains: are these models performing systematic logical reasoning, or are they merely exploiting statistical correlations and lexical cues? Counterfactual reasoning—the ability to process "what if" scenarios that contradict known reality—serves as a rigorous stress test for this distinction.

To correctly process a counterfactual like "If cats were vegetarians," a model must suppress its internal world knowledge (that cats are carnivores) and follow the logical implications of the hypothetical premise (that they would eat vegetables). This paper investigates whether models are building a mental model of these hypothetical scenarios or if they are simply responding to word associations.

Experimental Methodology

The researchers employed a "cloze" task methodology across three distinct experiments to probe model behavior. In these tasks, models were asked to predict the probability of specific target words in varying contexts:

  1. Experiment 1 (Overriding World Knowledge): This compared a Counterfactual-World (CW) condition (e.g., "If cats were vegetarians...") against a Real-World (RW) condition ("Because cats are carnivores...").
  2. Experiment 2 (Impact of Cue Words): This introduced a "Counterfactual-to-Reality" (CR) condition. The prompt began with a counterfactual but pivoted back to reality: "If cats were vegetarians... In reality, families feed cats with [target]." A reasoning model should select the real-world completion ("fish"), while a model relying on keyword triggers (like "vegetarian") might erroneously select the counterfactual completion ("cabbages").
  3. Experiment 3 (Inferring Real-World State): To eliminate the influence of prior knowledge, the researchers used neutral subjects (e.g., "the pets"). This tested whether models could use linguistic structures like "If X were Y..." to infer that X is not Y in the real world.

Data and Models

The study utilized two datasets: a small-scale set of 128 items adapted from psycholinguistic literature and a large-scale synthetic dataset of over 10,000 items. The synthetic data allowed for rigorous control over syntax, tense, and subject/object positioning. Five models were evaluated: GPT-2, GPT-3 (text-davinci-003), BERT, RoBERTa, and MPNet.

Results and Key Insights

The Lexical Trigger Trap

Most models, particularly the BERT family, appeared to rely on simple word associations. The presence of a word like "vegetarian" would trigger a high probability for "cabbage," regardless of the sentence's logical structure. In Experiment 1, BERT only preferred the counterfactual completion 34.2% of the time, suggesting it struggled to move past its pre-trained associations.

GPT-3 as a Sophisticated Outlier

GPT-3 demonstrated a significantly higher level of sensitivity to linguistic markers. In Experiment 1, GPT-3 showed a 71.3% preference for counterfactual completions in the CW condition. Crucially, in Experiment 2, when the prompt pivoted back to reality ("In reality..."), GPT-3’s preference for the counterfactual word dropped sharply to 28.0%. In contrast, models like GPT-2 and MPNet barely changed their predictions, remaining anchored to the initial lexical triggers.

Knowledge and Reasoning

A surprising finding was that models with stronger real-world factual knowledge were actually better at overriding those facts in counterfactual settings. This suggests that a robust internal model of reality may be a prerequisite for successfully reasoning about deviations from it.

Conclusion and Future Work

While GPT-3 shows promise, even its performance is not perfect, particularly when faced with conflicting lexical cues in complex synthetic datasets. Furthermore, the study's focus on English—where counterfactuals are often marked by specific grammatical moods (e.g., the subjunctive "were")—leaves open the question of how models handle languages like Chinese, where such distinctions are often contextual. Future research is needed to determine if these reasoning capabilities generalize across different linguistic structures and more naturalistic datasets.

Summary updated

BibTeX
@inproceedings{li2023counterfactual,
  author = {Jiaxuan Li and Lang Yu and Allyson Ettinger},
  title = {{Counterfactual reasoning: Testing language models' understanding of hypothetical scenarios}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2023},
  doi = {10.18653/v1/2023.acl-short.70},
}
Figure