Can LLMs Explain Themselves Counterfactually?

Zahra Dehghanighobadi, Asja Fischer, Muhammad Bilal Zafar

TL;DR

This paper investigates whether Large Language Models (LLMs) can generate counterfactual explanations for their own predictions. The study finds that while LLMs can generate counterfactuals, these explanations often fail to align with the model's own reasoning, suggesting a significant gap in their ability to truly explain themselves.

What Problem Does This Paper Address?

As LLMs become increasingly powerful and integrated into various applications, understanding why they make certain decisions is crucial. Traditional explainability methods often rely on complex techniques like gradient computation or optimization. This paper explores a more direct approach: "self-explanation," where the LLM itself is prompted to explain its outputs. Specifically, it focuses on self-generated counterfactual explanations (SCEs). A counterfactual explanation is a modified input that would lead the model to a different output. The core problem is to determine if LLMs can generate these counterfactuals reliably and if these explanations genuinely reflect the model's internal reasoning process, rather than just being plausible-sounding text.

Methods

The authors propose a three-step procedure for generating and evaluating SCEs:

  1. Prediction on input (x): The LLM makes its initial prediction.
  2. Generate SCE (x_CE): The LLM is prompted to create a modified input (x_CE) that would lead to a different target output (y_CE). They explore three prompting strategies:
  3. Unconstrained prompting: Simply asking for a counterfactual.
  4. Rationale-based prompting: Asking the model to first identify rationales for its prediction and then modify them.
  5. Chain-of-Thought (CoT) prompting: Encouraging step-by-step reasoning.
  6. Predict on SCE (f(x_CE)): The LLM predicts on the generated counterfactual to check if it indeed produces the intended different output.

They evaluate SCEs using metrics like generation percentage (Gen), counterfactual validity (Val - whether the SCE yields the target output), and edit distance (ED - how much the SCE differs from the original input). They also analyze the impact of providing context (original prediction and SCE instruction) during the final prediction step.

Datasets

The study uses six diverse datasets across different domains:

  • DiscrimEval: Hypothetical decision-making scenarios.
  • FolkTexts: Textual descriptions for income prediction.
  • Twitter Financial News: Sentiment classification of financial tweets.
  • SST2: Sentiment classification of movie reviews.
  • GSM8K: Grade school math problems.
  • Multi-Genre Natural Language Inference (MGNLI): Sentence relationship classification.

Key Insights and Ideas

  • LLMs can generate counterfactuals, but validity is the issue: While LLMs can produce text that looks like a counterfactual explanation, the crucial part is whether that explanation actually leads to the desired different outcome when fed back into the model. This is where they often fail.
  • Context matters, perhaps too much: The LLM's ability to produce a valid counterfactual prediction is significantly influenced by whether the original prediction and the SCE instruction are present in its context window. This suggests LLMs might be "looking up" answers from the context rather than performing independent reasoning.
  • No clear scaling law for counterfactual reasoning: Counterfactual reasoning ability doesn't consistently improve with model size, perplexity, or leaderboard rank. Smaller models sometimes outperform larger ones on this specific task.
  • LLMs aren't natural causal thinkers: The authors hypothesize that LLMs' core training on next-token prediction, rather than on understanding causal relationships, is a fundamental limitation for true counterfactual reasoning.

Key Results

  • Generation is common, validity is not: Most LLMs can generate SCEs (RQ1), but the percentage of valid SCEs (where the model's prediction on the SCE matches the target counterfactual output) is often low, especially for complex tasks like GSM8K (under 20% validity).
  • Rationale-based and CoT prompting offer modest improvements: While these prompting strategies can sometimes boost validity, they don't solve the core problem.
  • Edit distance doesn't predict validity: The amount of change made to the input (edit distance) doesn't reliably indicate whether the generated SCE will be valid.
  • Contextual information significantly impacts validity: For some datasets (e.g., GSM8K), validity increases substantially when the model has access to the original prediction and SCE instruction in its context window (Valc vs. Val).

Limitations and Future Work

  • Limited task scope: The study primarily focused on classification and math problems with integer solutions, as evaluating SCEs for more open-ended tasks requires extensive human annotation.
  • Privacy concerns: Detailed explanations could potentially be exploited for adversarial attacks or to unfairly influence outcomes.
  • Future directions: The authors suggest incorporating counterfactual example pairs into LLM training to enhance their reasoning capabilities. They also highlight the need for scaling analysis to more complex generation tasks and exploring the impact of attention mechanisms on reasoning.

Summary updated

BibTeX
@inproceedings{dehghanighobadi2025can,
  author = {Zahra Dehghanighobadi and Asja Fischer and Muhammad Bilal Zafar},
  title = {{Can LLMs Explain Themselves Counterfactually?}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2025},
}
Figure