Diffusion Counterfactual Generation with Semantic Abduction

Rajat R Rasal, Avinash Kori, Fabio De Sousa Ribeiro, Tian Xia, Ben Glocker

Introduction

Counterfactual reasoning—the ability to ask "what if?"—is a cornerstone of causal inference. In the context of computer vision, this involves generating an image that represents a specific intervention (e.g., "What would this person look like if they were wearing glasses?") while keeping all other characteristics, such as identity and background, invariant. While deep generative models like Variational Autoencoders (VAEs) and Generative Adversarial Networks (GANs) have historically been used for this task, they often struggle with image quality and scalability.

Diffusion models have emerged as the state-of-the-art for high-fidelity synthesis, yet they are notoriously difficult to control causally. They lack a naturally disentangled semantic latent space, meaning that modifying one attribute often leads to unintended changes in others. This paper introduces a novel framework that integrates Pearlian causal reasoning into the diffusion process to achieve high-fidelity counterfactual generation with rigorous identity preservation.

The Challenge: Abduction in Diffusion

Pearlian causal inference typically follows a three-step cycle: Abduction (inferring the latent state of the world given observations), Action (applying an intervention), and Prediction (simulating the outcome). In diffusion models, the "Abduction" step is particularly challenging. Standard methods like DDIM inversion can capture spatial noise, but they fail to explicitly model high-level semantic features, leading to "identity drift" where the subject's core characteristics change during the generation process.

Proposed Methodology

The authors propose a suite of mechanisms designed to decompose image noise into spatial, semantic, and dynamic components:

  1. Spatial Abduction: Utilizing DDIM inversion, the model extracts a spatial noise map ($u$) that encodes low-level structural information and textures.
  2. Semantic Abduction: To capture high-level identity, the authors integrate a CNN-based encoder that learns a "semantic noise" term ($z$). While spatial noise dictates the "where," semantic noise captures the "who," ensuring that identity-defining features remain fixed during intervention.
  3. Amortised Anti-Causal Guidance: The framework reframes classifier-free guidance through a causal lens. By treating guidance as an anti-causal score function, the model is forced to stay on a manifold that satisfies the new counterfactual conditions without requiring full model retraining.
  4. Dynamic Semantic Abduction: To combat the iterative drift inherent in diffusion, the authors introduce Counterfactual Trajectory Alignment (CTA). This algorithm fine-tunes guidance tokens at every timestep, ensuring the generated counterfactual remains as close as possible to the original image's non-target characteristics.

Experimental Evaluation

The framework was rigorously tested across three distinct domains:

  • Morpho-MNIST: Using a digit dataset with known causal relationships (thickness, intensity, slant), the authors demonstrated that their semantic mechanisms outperformed baselines like VCI and DiffSCM in both intervention accuracy and reconstruction error ($L_1$).
  • CelebA-HQ: On high-resolution facial images, the model was tasked with complex interventions like adding eyeglasses or changing expressions. The results showed that semantic abduction maintains identity stability even at high guidance scales, where traditional methods typically fail.
  • Medical Imaging (EMBED): In a critical real-world application, the model was used to remove medical artifacts (skin markers) from mammograms. The framework successfully removed over 95% of triangular markers and 91% of circular markers while preserving essential clinical features like breast density and cancer status.

Key Insights and Results

The research highlights a fundamental Identity Trade-off: there is an inherent tension between the effectiveness of an intervention and the preservation of the original identity. High guidance scales make the requested change more pronounced but often degrade the original subject's likeness. The proposed semantic abduction significantly shifts this Pareto frontier, allowing for stronger interventions with less identity degradation.

In the medical domain, the ability to remove artifacts while holding clinical variables fixed is vital for stress-testing AI classifiers against "shortcut learning," where models might rely on markers rather than actual pathology to make a diagnosis.

Limitations and Future Work

Despite its success, the framework faces several hurdles:

  • Computational Efficiency: Dynamic abduction is computationally intensive, requiring 3–5 minutes per image on high-end hardware (NVIDIA RTX 4090), which limits real-time utility.
  • Causal Assumptions: The model assumes a Markovian Structural Causal Model (SCM), which may not account for all hidden confounders in complex real-world data.
  • Identifiability: The VAE-style semantic prior is not yet strictly identifiable, suggesting a need for future work to integrate more rigorous proofs to ensure the uniqueness of the latent $z$.

Future research will focus on adapting these methods to Latent Diffusion Models (LDMs) to improve inference speed and scaling to even higher resolutions.

Summary updated

BibTeX
@inproceedings{rasal2025diffusion,
  author = {Rajat R Rasal and Avinash Kori and Fabio De Sousa Ribeiro and Tian Xia and Ben Glocker},
  title = {{Diffusion Counterfactual Generation with Semantic Abduction}},
  booktitle = {International Conference on Machine Learning},
  year = {2025},
  url = {https://openreview.net/forum?id=Wqrqcc8O2v},
}
Figure