Faithful Explanations of Black-box NLP Models Using LLM-generated Counterfactuals

Yair Ori Gat, Nitay Calderon, Amir Feder, Alexander Chapanin, Amit Sharma, Roi Reichart

TL;DR

This paper introduces a framework for generating "order-faithful" causal explanations for black-box NLP models using Large Language Models (LLMs). The authors propose two model-agnostic approaches: a high-accuracy generative method that uses LLMs to create counterfactual text at inference time, and a high-efficiency matching method that uses LLMs during training to learn a causal embedding space. This matching approach enables explanation speeds up to 1,000x faster than direct generation while maintaining strong performance.

What Problem Does This Paper Address?

Understanding why a complex NLP model (like a transformer) makes a specific prediction is critical for safety and trust. However, most current explanation methods (like saliency maps or LIME) often conflate correlation with causation. They might highlight which words were "important," but they do not necessarily show the causal impact of high-level concepts (e.g., "Is the sentiment negative because of the food quality or the service?").

The gold standard for causal explanation is the counterfactual (CF): "How would the model's prediction change if the service was good instead of bad, while everything else stayed the same?" The challenge is that true counterfactuals are impossible to observe in the real world, and generating them manually is prohibitively expensive.

Examples of counterfactuals and matches alongside the assumed causal graph for restaurant reviews.

Methods

The authors propose two primary ways to approximate these counterfactuals:

  1. Counterfactual Generation (The "Gold Standard"): They prompt an LLM (like GPT-4) to rewrite a piece of text to change one specific concept (the "treatment") while keeping confounding concepts fixed. For example, rewriting a restaurant review to change "bad service" to "good service" without altering the description of the food.
  2. Causal Representation Learning for Matching (The "Efficient Alternative"): Because running an LLM at inference time is slow and expensive, the authors developed a matching approach. They use an LLM during the training phase to help a smaller encoder (like RoBERTa) learn a "causal embedding space."
    • In this space, a query example is mapped close to its LLM-generated counterfactuals and other "valid matches" (real examples with the same confounding variables).
  3. At inference time, the system simply finds the most similar examples in a pre-defined candidate set. This avoids the need for heavy LLM generation during live use.

Theoretical Contribution: The authors define Order-faithfulness, a property where an explanation method correctly ranks the relative impact of different concepts. They prove mathematically that counterfactual-based methods are inherently order-faithful, whereas non-causal methods are not.

Datasets

  • CEBaB: A benchmark of restaurant reviews where humans have annotated high-level concepts (Food, Service, Ambiance, Noise) and provided human-written counterfactuals.
  • New Stance Detection Benchmark: The authors used GPT-4 to create a new, challenging benchmark based on tweets. It tests the causal impact of a writer's age, gender, and job on a model's "stance" (support/oppose) regarding topics like climate change or atheism.

Key Insights and Ideas

  • LLMs as Causal Proxies: LLMs are surprisingly good at acting as "world models" that can generate plausible counterfactuals, effectively bypassing the need for expensive human annotation.
  • The Power of Top-K: The authors found that using Top-K matching (averaging the effects of the top 10 matches rather than just the single best match) universally improved the accuracy of explanations across all methods. This reduces the "noise" or variance inherent in a single approximation.
  • Training vs. Inference: You don't need a massive model at runtime to get causal insights. By "distilling" the LLM's causal logic into a specialized embedding space, you can achieve state-of-the-art (SOTA) explanations with much smaller, faster models.

Key Results

  • SOTA Performance: LLM-generated counterfactuals (specifically using a fine-tuned T5-base or GPT-4) provided the most accurate explanations, outperforming all previous model-agnostic baselines.
  • Efficiency: The proposed matching approach is 1,000x faster than the generative approach at inference time while still outperforming traditional matching baselines.
  • Robustness: The matching approach remained effective even in "out-of-distribution" scenarios (tested on the new Stance Detection benchmark), where the candidate set contained texts about different subjects than the query.
Performance comparison of generative and matching explanation methods across various target models, highlighting the impact of Top-K (K=10) matching.

Limitations and Future Work

  • Causal Graph Dependency: Both methods require a pre-defined causal graph (knowing which concepts affect which). In many real-world "in the wild" scenarios, this graph might be unknown or overly complex.
  • Candidate Set Quality: The matching approach is only as good as the "pool" of examples it has to choose from. If the candidate set is small or lacks variety, the approximations will be poor.
  • LLM Biases: The authors acknowledge that using LLMs to generate benchmarks or training data can bake in the LLM's own societal biases (e.g., gender or age stereotypes), which requires careful monitoring.

The authors suggest that future work should explore how to automatically discover these causal graphs and how to further bridge the performance gap between slow generation and fast matching.

Summary updated

BibTeX
@inproceedings{gat2024faithful,
  author = {Yair Ori Gat and Nitay Calderon and Amir Feder and Alexander Chapanin and Amit Sharma and Roi Reichart},
  title = {{Faithful Explanations of Black-box NLP Models Using LLM-generated Counterfactuals}},
  booktitle = {International Conference on Learning Representations},
  year = {2024},
  url = {https://openreview.net/forum?id=UMfcdRIotC},
}
Figure