Generating Plausible Counterfactuals within the Latent Data Manifold

This direction is split into other directions: generative counterfactuals. Its last version stays readable and citable here.

Version 1 of 126 papers31 conceptsfrozen 2026-10-04

If a medical AI denies a patient a treatment, the patient doesn't just want to know why; they want to know what would have to change for the answer to be "yes." This is the essence of a counterfactual explanation (CFE): finding the smallest change to an input that flips a model's prediction.

However, traditional methods for generating these "what-if" scenarios often fall into the "adversarial trap." If you ask a model to change a picture of a "husky" into a "flute" by modifying raw pixels, it will likely produce a husky covered in imperceptible digital static—mathematically a flute to the classifier, but nonsensical to a human. To solve this, researchers are moving the search for explanations out of the raw input space and into the latent manifold of generative models.

Most high-dimensional data, like images or text, sits on a low-dimensional "manifold"—a structured surface of plausible examples within a sea of noise. When we perturb pixels directly to find a counterfactual, we almost inevitably push the data point off this manifold. The result is an "out-of-distribution" example that the classifier has never seen before, leading to overconfident but meaningless predictions.

Eoin D. Delaney and Mark T. Keane have highlighted these pitfalls, noting that without constraints, counterfactuals are often dangerously unrealistic. To provide meaningful recourse, an explanation must be "in-distribution"—it must look like a real data point that could actually exist.

Constraining Explanations to the Latent Space

The core intuition of this research direction is to leverage generative models like Variational Autoencoders (VAEs) or GANs. These models learn a latent space where every point corresponds to a realistic output. By searching for counterfactuals in this compressed space, we ensure the resulting explanation remains on the data manifold.

Researchers like Pin-Yu Chen and Amit Dhurandhar pioneered this with CEM-MAF (Contrastive Explanations with Monotonic Attribute Functions). Instead of asking "which pixels should I change?", their method asks "which high-level latent attributes should I shift?" This allows the system to identify what is "minimally absent" to change a classification—such as adding stripes to a horse to explain why it isn't a zebra—while keeping the image visually coherent.

Faster and More Diverse Recourse

Searching for these explanations can be computationally expensive, often requiring iterative optimization for every single user query. To make this practical for real-time systems, Dan Ley, Umang Bhatt, and Adrian Weller introduced amortized counterfactuals. By training a model to map inputs directly to their counterfactuals in the latent space, they achieved a 200x speedup, providing a suite of diverse "what-if" scenarios instantly.

Similarly, the SharpShooter framework by C. Bayan Bruss and colleagues uses latent space projection and interpolation. By projecting a sample into the latent space of a target class and interpolating between the original and the target, they generate "in-sample" explanations that are significantly more realistic than gradient-based alternatives.

Respecting Causal Laws and Geometry

A truly useful explanation shouldn't just be realistic; it should be logical. If a model suggests that you could get a loan by "decreasing your age," it is providing a counterfactual that is physically impossible.

To address this, Klaus-Rudolf Kladny and Bernhard Schölkopf developed DeepBC (Deep Backtracking Counterfactuals). This framework searches within the "latent noise space" of a generative model to identify the underlying conditions that would have led to a different outcome, ensuring the explanation respects causal laws.

For even greater precision, the GdVAE proposed by Anselm Haselhoff and Kevin Trelenberg structures the latent space so that the classifier becomes a simple linear function of the features. This allows counterfactuals to be found using closed-form analytical solutions, moving latent vectors along specific geometric directions to flip a prediction with mathematical certainty.

Beyond Images: Molecules and Text

The power of latent-space explanations extends to specialized domains. In drug discovery, Natasa Tagasovska and Andrew M. Watkins created MoleCLUEs, which optimizes molecular conformers by navigating the latent space of equivariant generative models. This helps scientists understand which structural changes would make a molecule more "in-distribution" for a predictive model, increasing the reliability of property forecasts.

In Natural Language Processing, Julia El Zini and Mariette Awad found that textual counterfactuals generated in the latent space of language models are more faithful and robust than those created by simply swapping words, as they better capture the statistical nuances of human language.

By grounding "what-if" reasoning in the learned distribution of the real world, these latent-space methods transform AI explanations from fragile mathematical curiosities into robust, human-interpretable tools for recourse.

Papers in this version

History & citationVersion 1 · 2026-10-04

Split into other directions · Permanent link

View frozen version 1

Cite this direction

Latest version (a living page):

@misc{lacuna_generating_plausible_counterfactuals_wit_dc5958a9,
  title = {Generating Plausible Counterfactuals within the Latent Data Manifold},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/generating-plausible-counterfactuals-within-the-latent-data-manifold/rdr_dc5958a9dfb64f2b941715ee08a04dd5},
  note = {Latest version of a living research direction; cite a version for a fixed text. Accessed 2026-11-21},
}

This exact version (version 1, frozen text):

@misc{lacuna_generating_plausible_counterfactuals_wit_dc5958a9_v1,
  title = {Generating Plausible Counterfactuals within the Latent Data Manifold},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/generating-plausible-counterfactuals-within-the-latent-data-manifold/rdr_dc5958a9dfb64f2b941715ee08a04dd5/v/1},
  note = {Version 1, frozen 2026-10-04. Accessed 2026-11-21},
}