CompDiff: Hierarchical Compositional Diffusion for Fair and Zero-Shot Intersectional Medical Image Generation

Mahmoud Ibrahim, Bart Elen, Chang Sun, Gokhan Ertaylan, Michel DumontierarXiv 2026

TL;DR

Standard diffusion models trained on imbalanced medical datasets inherit these biases, resulting in poor image generation for rare or completely unseen demographic intersections (e.g., "80+ Asian female"). CompDiff addresses this "imbalanced generator problem" at the representation level using a Hierarchical Conditioner Network (HCN) that factorizes demographics into single-attribute and pairwise embeddings. This architectural shift enables high-quality, equitable image synthesis and unlocks zero-shot generalization to demographic subgroups entirely absent during training.

What Problem Does This Paper Address?

Generative AI is frequently proposed as a tool to fix dataset imbalances in medical imaging by synthesizing data for underrepresented groups. However, the authors highlight a critical flaw: generative models themselves suffer from the imbalanced generator problem. If a diffusion model is trained on skewed data, its performance degrades significantly on rare subgroups.

Worse yet, for complex demographic intersections (combining specific ages, sexes, and races), data might be entirely missing. Existing solutions like FairDiffusion attempt to fix this at the optimization level using loss reweighting. However, reweighting cannot create a learning signal for a demographic combination the model has never seen. Furthermore, standard models pack demographic descriptors directly into text prompts, forcing them to compete for CLIP’s highly restricted 77-token budget alongside complex clinical findings.

Methods

CompDiff shifts the solution from optimization-level tweaks to representation-level architecture. Instead of embedding demographics inside the text prompt, CompDiff processes clinical findings and demographic attributes in parallel.

The core innovation is the Hierarchical Conditioner Network (HCN), which structures demographic identity into three factorized levels:

  1. Level 1: Attribute Embeddings ("Grandparents"): Independent embeddings for individual attributes like age, sex, and race.
  2. Level 2: Pairwise Fusion ("Parents"): Dedicated MLPs that model non-additive interactions between pairs of attributes (e.g., age and sex). This is crucial because demographic traits interact non-additively with human anatomy.
  3. Level 3: Final Composition ("Child"): An MLP that combines the pairwise interactions into a unified demographic representation ($h_{demo}$), which is then mapped to a variational latent space.
Fig. 1. CompDiff architecture and HCN internals. (a) The text-only baseline embeds demographics in the clinical prompt, competing for CLIP’s 77-token budget; CompDiff instead processes them in parallel through HCN, yielding a demographic token c con- catenated to Etext and consumed by the UNet via cross-attention. (b) HCN hierarchy: single-attribute embeddings (grandparents), pairwise interactions (parents), and full composition (child), mapped to a variational latent and projected to c; the auxiliary loss is applied on c.

The resulting demographic token is concatenated with the standard CLIP text embeddings and fed into the UNet via cross-attention.

To stabilize training, the authors introduce a compositional consistency loss ($\mathcal{L}_{comp}$) that anchors the network toward a simple additive baseline while still permitting non-additive interactions. They also apply an auxiliary classification loss ($\mathcal{L}_{aux}$) directly to the final token to ensure demographic information isn't lost during projection.

Datasets

The framework was evaluated on two distinct medical imaging modalities:

  • MIMIC-CXR: A large-scale dataset of chest X-rays. The authors utilized postero-anterior views split into 62,094 training, 1,300 validation, and 7,039 test images, complete with demographic metadata (age, sex, race) and clinical impressions.
  • FairGenMed: A dataset containing 10,000 scanning laser ophthalmoscopy (SLO) fundus images (6,000 training / 1,000 validation / 3,000 test) with prompts encoding race, sex, ethnicity, and clinical attributes like glaucoma and cup-disc ratio.

Key Insights and Ideas

  • Demographics are Compositional: The fundamental "aha moment" is that rare or unseen intersections can be effectively synthesized if the model thoroughly understands the constituent single-attribute and pairwise building blocks.
  • Structure Beats Reweighting: Optimization-level fixes fail in zero-shot settings because zero multiplied by any weight is still zero. By introducing structural inductive bias (the hierarchy), CompDiff forces parameter sharing across subgroups, allowing data-efficient generalization.
  • Preserving the Token Budget: Isolating demographics into a parallel network prevents them from diluting the clinical text embeddings, leading to better alignment with actual medical findings.

Key Results

CompDiff consistently outperformed standard fine-tuned Stable Diffusion (Baseline) and FairDiffusion across multiple dimensions:

  • Overall Image Quality & Clinical Accuracy: On chest X-rays, CompDiff achieved an FID of 64.3 (compared to FairDiffusion's 75.1) and a superior disease AUROC (0.82 vs 0.74), indicating much better alignment with clinical realities.
  • Subgroup Equity: CompDiff achieved the lowest Equity-Scaled FID (ES-FID) across age, sex, and race for both chest X-rays and fundus images, proving that fairness gains do not have to come at the expense of majority-group quality.
  • Zero-Shot Generalization: To test true generalization, the authors completely removed five rare intersectional subgroups from training. CompDiff improved FID on these held-out groups by up to 21%. Crucially, FairDiffusion actually performed worse than the baseline on the oldest Asian cohorts, confirming that loss reweighting struggles when training samples are entirely absent.
Fig. 2. Qualitative samples across both modalities (left: chest X-ray, MIMIC-CXR; right: fundus, FairGenMed), each shown for the three methods (Baseline, FairDiffu- sion, CompDiff) and three demographic strata (rows: common, rare, and zero-shot; one sample per cell). On common and rare intersections all methods are visually com- parable, but on the 80+ Male Asian intersection—held out from chest training (§3.3)— FairDiffusion produces an anatomically distorted radiograph, whereas CompDiff com- poses a coherent image from learned single-attribute and pairwise representations.
  • Downstream Utility: Classifiers trained on synthetic data generated by CompDiff showed higher mean AUCs and significantly lower underdiagnosis rates when tested on real-world data.

Limitations and Future Work

Despite its success, the authors note several limitations:

  1. Quantitative vs. Clinical Evaluation: The fairness and quality improvements were validated using quantitative metrics (like FID and classifier accuracy) rather than direct clinical evaluation by expert radiologists or ophthalmologists.
  2. Discrete Attribute Assumption: The hierarchical composition model assumes structured, categorical demographic attributes and does not naturally extend to continuous variables.
  3. The Residual Gap: While zero-shot generalization improved significantly, a performance gap still remains between rare/unseen intersections and well-represented groups. Representation-level fixes mitigate, but do not entirely eliminate, the challenges of severe data imbalance.

For future work, the authors plan to explore even richer conditioning mechanisms, such as graph-based interaction modeling.

Summary updated

BibTeX
@misc{ibrahim2026compdiff,
  author = {Mahmoud Ibrahim and Bart Elen and Chang Sun and Gokhan Ertaylan and Michel Dumontier},
  title = {{CompDiff: Hierarchical Compositional Diffusion for Fair and Zero-Shot Intersectional Medical Image Generation}},
  year = {2026},
  eprint = {2603.16551},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2603.16551},
}
Figure