Text-to-Image Models for Counterfactual Explanations: A Black-Box Approach

Guillaume Jeanneret, Loïc Simon, Frédéric JurieWACV 2024

TL;DR

This paper introduces TIME, a novel black-box approach for generating counterfactual explanations (CEs) using text-to-image (T2I) models like Stable Diffusion. TIME distills classifier knowledge into T2I models, enabling it to generate explanations without needing access to the classifier's internal workings, a significant advancement for privacy-sensitive applications.

What Problem Does This Paper Address?

Explainable Artificial Intelligence (XAI) aims to understand how deep neural networks (DNNs) make decisions. Counterfactual explanations (CEs) are a key XAI technique that answers "What needs to change in an input to alter its prediction from Y to Z?". This is crucial for debugging models and providing actionable feedback to users. However, generating CEs for image classifiers, especially in a "black-box" setting (where only input-output pairs are accessible, not model internals like gradients), is challenging. Existing methods often require access to model gradients or involve computationally expensive optimization loops during explanation generation. This paper tackles the problem of generating effective CEs for image classifiers in a black-box manner, leveraging the power of pre-trained T2I models.

Methods

TIME employs a three-step distillation approach:

  1. Context Bias Distillation: The method first learns a "context bias" from the entire training dataset using textual inversion. This captures general image formation characteristics (e.g., object placement) learned by the T2I model.
  2. Class Bias Distillation: Next, it filters images predicted as the source class by the target classifier and uses textual inversion to learn a "class bias" specific to that class. This distills the classifier's understanding of class-specific features.
  3. Counterfactual Generation: For a given input image classified as source class i and a target class j, TIME uses a modified inversion technique (EDICT) to revert the image to a latent noise representation using the source class embedding (C<sub>i</sub>). Then, it denoises this latent representation using the target class embedding (C<sub>j</sub>) as a prompt, effectively generating the counterfactual explanation. A key innovation here is the use of "negative guidance" in the diffusion process, which actively steers the generation away from the source distribution, helping to achieve the desired class flip.

Datasets

  • CelebAHQ: Used for training and evaluating the method on tasks like smile and age classification.
  • BDD100k: Used to test TIME in more complex scenarios involving scene understanding (move/stop classification).

Key Insights and Ideas

  • T2I Models as Explanation Tools: The paper demonstrates that powerful pre-trained T2I models, when properly conditioned, can be effectively repurposed for generating counterfactual explanations, even for black-box classifiers.
  • Distillation for Black-Box XAI: Distilling knowledge from the target classifier into the T2I model's textual embeddings is a viable strategy for black-box XAI, circumventing the need for gradient access.
  • Negative Guidance for Class Flipping: Introducing negative guidance during the denoising process is crucial for effectively steering the generation towards the target class and away from the source class, thereby achieving successful counterfactual flips.
  • Context and Class Biases are Key: Separately learning and combining context and class biases allows for more nuanced and effective control over the counterfactual generation process.

Key Results

  • Competitive Performance: TIME achieves comparable performance to state-of-the-art methods on the CelebAHQ dataset in terms of Success Ratio (SR), FID, FS, and CD, despite being a black-box approach.
  • Efficiency: TIME is significantly more efficient than some prior methods, requiring approximately 98 TFLOPs and 45 seconds per explanation, compared to ACE's 279 TFLOPs and 62 seconds.
  • Qualitative Improvements: Qualitative results show that TIME produces more realistic changes compared to DiME (which can generate out-of-distribution noise) and ACE (which can create blurry image sections).
  • BDD100k Limitations: On the more complex BDD100k dataset, TIME modifies more parts of the image, indicating that current T2I-based counterfactual methods may struggle with highly complex scenes where decisions depend on multiple interacting factors.

Limitations and Future Work

  • Complex Scenes: TIME, like other general-purpose counterfactual methods, struggles with highly complex scenes (e.g., BDD100k) where decisions are influenced by numerous interacting elements. The authors suggest that specialized architectures might be needed for such tasks.
  • Hyperparameter Tuning: While TIME is efficient, achieving optimal results may require tuning hyperparameters like the number of inversion steps (τ) and the guidance scale (w).
  • Future Work: The authors believe their work opens doors for further research into black-box counterfactual methods using T2I models. They suggest exploring more sophisticated distillation techniques and investigating how to adapt these methods for tasks involving complex scenes.

Summary updated

BibTeX
@inproceedings{jeanneret2024text,
  author = {Guillaume Jeanneret and Loïc Simon and Frédéric Jurie},
  title = {{Text-to-Image Models for Counterfactual Explanations: A Black-Box Approach}},
  booktitle = {IEEE/CVF Winter Conference on Applications of Computer Vision},
  year = {2024},
}
Figure