Introduction
In the realm of causal reasoning, counterfactual generation seeks to answer "what-if" questions: How would this image look if a specific attribute were different? For instance, a clinician might ask how a chest X-ray would appear if the patient did not have a pleural effusion, or a designer might want to see a portrait of a subject smiling without altering their age or identity.
Diffusion models have become the gold standard for generating these high-fidelity counterfactuals. They typically rely on Classifier-Free Guidance (CFG) to ensure the generated image strongly reflects the desired intervention. However, standard CFG operates as a blunt instrument, applying a single, global guidance scale to the entire conditioning signal. This paper identifies a critical failure mode in this approach—attribute amplification—and introduces Factored Classifier-Free Guidance (FCFG), a flexible, inference-time technique that enables precise, attribute-wise control.
The Problem: Attribute Amplification
When generating counterfactuals, it is crucial to preserve the subject's core identity, a concept known as "axiomatic soundness." The authors demonstrate that standard CFG frequently violates this principle.
Because standard CFG strengthens the entire conditioning vector simultaneously, it inadvertently modifies attributes that should remain invariant. For example, if a user increases the guidance scale to make a face look older, the model might accidentally alter the person’s facial expression, gender, or ethnicity. The paper reveals that this attribute amplification is not merely an artifact of biased training data; it is actively induced by the standard CFG mechanism itself.
The Solution: Factored Classifier-Free Guidance (FCFG)
To transition from global to granular control, the authors propose FCFG. This method decouples the guidance scales for different attributes, ensuring that targeted features are modified while invariant features are preserved. FCFG operates through three core mechanisms:
- Attribute-Split Conditioning Embedder: Instead of processing all attributes through a single, monolithic neural network, FCFG utilizes small, independent Multi-Layer Perceptrons (MLPs) for each attribute. This ensures that distinct features (e.g., "Age," "Smiling," "Sex") occupy separate blocks in the embedding space, preventing early entanglement.
- Strategic Partitioning: At inference time, attributes are partitioned into distinct groups based on a causal graph. Typically, these are divided into affected attributes (the targets of the intervention) and invariant attributes (the background traits that must remain stable).
- Group-Wise Guidance: The model calculates the score—the directional update for the image pixels—for each group independently. Users can apply a high guidance weight to the intervention target to ensure the change takes effect, while maintaining a low or neutral weight on invariant attributes to preserve original details.
Crucially, FCFG is model-agnostic. It modifies the guidance rule during the sampling process, meaning it can be seamlessly integrated into existing pre-trained diffusion models and combined with advanced sampling refinements like CFG++ and Adaptive Projected Guidance (APG).
Experimental Validation
The authors evaluated FCFG across three diverse domains to demonstrate its versatility and safety:
- CelebA-HQ (64x64): A benchmark for natural face images, focusing on attributes like Smiling, Male, and Young.
- EMBED: A clinical dataset of breast mammography, analyzing Breast Density and the presence of Circular Skin Markers.
- MIMIC-CXR: A large-scale chest X-ray dataset, focusing on the disease label for Pleural Effusion alongside demographic factors like Race and Sex.
Key Findings
- Superior Trade-offs: FCFG achieves higher intervention effectiveness while actively reducing spurious changes. On CelebA-HQ, under a "Smiling" intervention, FCFG achieved a target change score of +13.1 while reducing off-target "Male" amplification to -1.5 (compared to +3.0 for standard CFG).
- Enhanced Reversibility: A robust counterfactual should be reversible (e.g., changing an image to "Smiling" and back to "Not Smiling" should yield the original image). Standard CFG fails this test at high guidance scales, whereas FCFG maintains high reversibility.
- Medical Safety: In medical AI, hallucinating anatomical changes is dangerous. FCFG prevents the model from altering unrelated clinical features (like bone structure) when simulating the progression or remission of a specific disease, preserving the integrity of the medical scan.
- Identity Preservation: Quantitative metrics, including Mean Absolute Error (MAE) and Learned Perceptual Image Patch Similarity (LPIPS), were consistently lower for FCFG, confirming its ability to keep the subject's identity intact. Qualitative results further show that FCFG avoids the artifacts (like suddenly appearing glasses or shifted skin tones) common in high-scale CFG.
Limitations and Future Directions
While FCFG offers significant improvements, the authors note a few limitations:
- Requirement of Causal Knowledge: FCFG does not perform causal discovery. It requires a predefined causal graph or semantic grouping to know which attributes are affected by an intervention.
- Manual Weight Tuning: The guidance weights for affected and invariant groups are currently chosen empirically. Future work could explore adaptive guidance, where the model dynamically selects optimal weights based on the image or diffusion step.
- Computational Overhead: Because FCFG evaluates the model multiple times per step (once for each attribute group), it is slightly slower than standard CFG. However, this inference-time overhead is negligible compared to the cost of retraining a model from scratch.
Conclusion
Factored Classifier-Free Guidance represents a significant step forward for counterfactual image generation. By diagnosing and solving the attribute amplification problem inherent in standard CFG, FCFG provides researchers and practitioners with the precision control needed to generate causally sound, reversible, and safe "what-if" images across both natural and medical domains.
Summary updated