Abstract
Interpretability in deep learning often relies on feature attribution methods like heatmaps, which identify influential input regions but fail to provide actionable "what-if" scenarios. This paper introduces Attribute-Informed Perturbation (AIP), a framework for generating realistic, in-distribution counterfactual explanations for text and image classifiers. By optimizing perturbations within a semantically structured latent space, AIP identifies minimal changes required to flip a model's prediction while maintaining data coherence. Evaluations on Yelp, Amazon, and CelebA datasets demonstrate that AIP achieves high flipping ratios and produces semantically meaningful explanations that can reveal underlying model biases.
Introduction
As deep neural networks (DNNs) are increasingly deployed in critical decision-making processes, the need for robust interpretability methods grows. While feature attribution identifies which inputs were important for a prediction, it does not explain how the input would need to change to achieve a different outcome. Counterfactual explanations address this by providing "what-if" scenarios. However, generating counterfactuals for high-dimensional data like images and text is challenging, as perturbations must remain within the data distribution to be human-interpretable. Existing methods often produce adversarial examples—perturbations that flip labels but result in nonsensical or out-of-distribution data.
Methodology
The Attribute-Informed Perturbation (AIP) framework addresses these challenges by leveraging generative models, such as Variational Autoencoders (VAEs) or Generative Adversarial Networks (GANs), to operate in a structured latent space.
Instead of editing raw pixels or text directly, AIP partitions the latent representation into a raw feature embedding ($z$) and a semantic attribute vector ($a$). This separation allows the model to disentangle high-level concepts (e.g., sentiment or facial attributes) from the data's structural features. To generate a counterfactual, AIP performs a gradient-based search to find the minimal perturbation $(\Delta z, \Delta a)$ that flips the target model's prediction. The optimization objective balances Prediction Loss (ensuring the label change) and Perturbation Loss (minimizing the change to maintain proximity to the original input). The generative model's decoder then maps the perturbed latent vector back to the data space, ensuring the output remains a valid, realistic sample.
Experimental Results
The researchers evaluated AIP against several baselines, including TextBugger, DeepWordBug, and xGEMs, across text (Yelp, Amazon) and image (CelebA) datasets.
Quantitative Performance
A primary metric for counterfactual quality is the Flipping Ratio (FR), which measures the success rate in changing the target model's prediction.
As shown in the results, AIP consistently achieves high success rates. On the Yelp dataset, AIP reached an FR of 0.952, significantly outperforming other generative baselines like xGEMs (0.332). Additionally, AIP maintains a low Latent Perturbation Ratio (LPR), indicating that it identifies the most efficient path to a counterfactual state without unnecessary modifications to the input.
Qualitative Analysis and Bias Detection
Qualitatively, AIP produces smooth and realistic transitions. In image tasks, it can subtly modify facial features while preserving identity. In text tasks, it demonstrates "semantic control," replacing key sentiment words (e.g., changing "worst" to "best") rather than introducing character-level noise or typos typical of adversarial attacks. Furthermore, the authors demonstrated AIP's utility in bias detection. By generating counterfactuals for an age classifier, they discovered that the model relied on spurious correlations, such as associating "Male" and "Black Hair" with "Old" predictions, highlighting potential fairness issues in the target DNN.
Conclusion
AIP provides a robust framework for generating in-distribution counterfactual explanations by perturbing a structured latent space. By ensuring that "what-if" scenarios are both effective and coherent, it offers a powerful tool for model interpretability and bias detection. Future work could focus on generating diverse sets of counterfactuals and incorporating explicit causal models to improve the actionability of the explanations.
Summary updated