Counterfactual Reasoning with Knowledge Graph Embeddings

Lena Zellinger, Andreas Stephan, Benjamin Roth

TL;DR

This paper introduces CFKGR (CounterFactual Knowledge Graph Reasoning), a new task evaluating how AI models reason through "what-if" scenarios within a structured world state. The authors propose COULDD, a lightweight fine-tuning method that adapts pre-trained knowledge graph embeddings (KGEs) to hypothetical premises while preventing them from forgetting existing facts. The study reveals a fascinating trade-off: adapted KGEs excel at retaining background knowledge but struggle with non-standard logical leaps, whereas Large Language Models (LLMs) like ChatGPT excel at logical deduction but suffer from poor knowledge retention.

What Problem Does This Paper Address?

Knowledge Graph Embeddings (KGEs) are highly effective at predicting missing links in a static, real-world setting (Knowledge Graph Completion). However, the real world is dynamic, and humans frequently engage in counterfactual reasoning—imagining how a change to one fact ripples out to create new realities while leaving unrelated facts untouched.

For instance, if we introduce the hypothetical premise "If Paris was the capital of Japan," a robust reasoning system should deduce that Paris is now in Asia, while still maintaining the independent background fact that Elvis Presley was a musician.

Figure 1: A hypothetical scenario and its implications, expressed in the language of knowledge graph triples

Prior to this work, KGEs had not been explored for counterfactual reasoning. This paper addresses this gap by formalizing the CFKGR task to evaluate whether models can successfully balance two competing demands: inferring plausible changes induced by a hypothetical scenario and retaining unaffected background knowledge.

Methods

The authors frame CFKGR as a binary classification task where models predict whether a triple is valid within a modified "counterfactual graph." To solve this without retraining models from scratch, they introduce COULDD (COUnterfactual Reasoning with KnowLedge Graph EmbeDDings).

COULDD is a model-agnostic framework that adapts a pre-trained KGE model to a specific hypothetical scenario ($\tau^c$) using a targeted fine-tuning strategy:

  1. Targeted Fine-Tuning: The model is trained on a small batch containing the counterfactual triple alongside a set of randomly sampled true edges from the original graph (to anchor its background knowledge).
  2. Negative Sampling: Standard head and tail entity corruptions are introduced during this fine-tuning phase.
  3. Early Stopping: Crucially, training halts the exact moment the model assigns a valid classification score to the counterfactual premise. This prevents the model from over-adjusting and distorting its latent embedding space.
Figure 2: Overview over the different types of facts, given the hypothetical scenario that Elvis Presley is a citizen of Denmark. The green edge (Elvis Presley, speaks, Danish) emerges from adding the blue edge (Elvis Presley, citizen of, Denmark) to the knowledge graph. Purple and orange edges are present in the original KG and unaffected by the scenario. Grey edges are neither present in the original nor the counterfactual knowledge graph.

Datasets

The authors created a new benchmark suite, CFKGR-CoDEx, derived from the standard CoDEx knowledge graph completion datasets across three sizes: Small (S), Medium (M), and Large (L).

To automatically generate plausible consequences ($F^+$) for their hypothetical scenarios, they used the rule-mining tool AMIE3 to extract logical composition rules (e.g., if $X$ is in country $Y$, and country $Y$ is part of continent $Z$, then $X$ is in continent $Z$).

Additionally, they created CFKGR-CoDEx-M*, a subset verified by human annotators to evaluate how well these automatically generated logical rules align with actual human counterfactual intuition.

Key Insights and Ideas

  • Implicit Rule Learning: Standard KGE models implicitly capture logical graph regularities during their initial pre-training. They don't need explicit rule-based training to understand the structural patterns of the graph.
  • The KGE vs. LLM Dichotomy: The experiments highlight a stark contrast in capabilities between structured embeddings and autoregressive language models:
  • KGEs + COULDD possess excellent knowledge retention. They easily remember that unrelated facts remain true, but they struggle to generalize when a counterfactual scenario requires a leap that doesn't perfectly match a learned structural pattern.
  • ChatGPT (GPT-3.5) possesses superior inference capabilities for changed facts but suffers from terrible knowledge retention. When asked if an unrelated background fact was "still plausible," ChatGPT frequently misunderstood the task, attempting to logically deduce the fact from the prompt's context rather than relying on its internal world knowledge.

Key Results

  • COULDD consistently outperforms baselines: Across five distinct KGE architectures (RESCAL, TransE, ComplEx, ConvE, TuckER), applying COULDD consistently improved the overall F1-score on counterfactual graphs.
  • Significant boost on changed facts: For example, on the CFKGR-CoDEx-S dataset, the baseline TuckER model achieved only 15.01% accuracy on changed facts, which jumped to 35.99% when adapted via COULDD.
  • Comparison with ChatGPT: On the human-annotated subset (CFKGR-CoDEx-M), ChatGPT achieved the highest accuracy on changed facts (53.98% vs. COULDD-TuckER's 34.55%). However, ChatGPT performed poorly on unchanged facts, yielding an F1-score of just 62.34%, whereas the KGE models adapted with COULDD maintained near-perfect retention scores between 85% and 97%*.

Limitations and Future Work

  • Additions Only: The current dataset generation pipeline only models facts that emerge ($F^+$) due to a hypothetical scenario. It does not model facts that are explicitly negated or destroyed ($F^-$) by the premise, as automatically generating contradictions is highly complex.
  • Simplistic Rule Structures: The framework relies entirely on Horn rules mined from the graph, ignoring rule confidences or more complex, non-linear logical dependencies.
  • Verbalization Bias: Evaluating LLMs required translating graph triples into natural language sentences. Unintuitive phrasing or a lack of broader context may have negatively impacted ChatGPT's performance on background knowledge retention.

Summary updated

BibTeX
@inproceedings{zellinger2024counterfactual,
  author = {Lena Zellinger and Andreas Stephan and Benjamin Roth},
  title = {{Counterfactual Reasoning with Knowledge Graph Embeddings}},
  booktitle = {EACL},
  year = {2024},
}
Figure