Finetuning Text-to-Image Diffusion Models for Fairness

Xudong Shen, Chao Du, Tianyu Pang, Min Lin, Yongkang Wong, Mohan Kankanhalli

Introduction

Text-to-image (T2I) models like Stable Diffusion have a well-documented "worldview" problem. Prompting these models for a "doctor" often yields a gallery of white men, while asking for a "housekeeper" skews heavily toward women of color. These biases restrict the utility of generative AI and propagate harmful stereotypes.

Existing fixes usually involve "prompt engineering" (e.g., automatically appending "male" or "female" to a query) or projecting out biased directions in the model's latent space. However, these methods are often brittle, struggle with complex prompts, and crucially lack user control over the final distribution. Fairness isn't always a strict 50/50 split; depending on the context, a user might want to align model output with specific real-world demographics or custom targets.

To address this, researchers have developed a novel way to "steer" text-to-image diffusion models toward fairer outcomes by framing fairness as a distributional alignment problem. By introducing an Adjusted Direct Finetuning (DFT) method and a specialized alignment loss, they can precisely control the demographic distribution of generated images—reducing gender and racial bias even when finetuning as few as five "soft tokens."

Methods: Steering the Distribution

The authors introduce two major technical innovations to achieve this controllable fairness:

1. Distributional Alignment Loss (DAL)

Instead of forcing every single image to be "neutral," DAL evaluates a batch of generated images. It uses pre-trained classifiers to estimate attributes (like gender or race) and then employs Optimal Transport to calculate the most efficient way to shift that batch's distribution to match a user-defined target.

2. Adjusted Direct Finetuning (Adjusted DFT)

Standard finetuning usually optimizes the intermediate "denoising" task. "Direct" finetuning, on the other hand, attempts to optimize the final generated image itself. However, backpropagating through the 50+ steps of a diffusion sampling process typically leads to "exploding gradients," causing the math to break down.

Comparison of gradient paths in Naive vs. Adjusted Direct Finetuning (DFT).

The authors' "Adjusted" version simplifies the gradient calculation. By removing complex coupled gradients and treating intermediate steps as independent variables, the optimization remains stable and effective.

Gradient magnitudes over time, illustrating how Adjusted DFT prevents the exploding gradients seen in exact gradient methods.

To ensure the model doesn't lose its creativity or image quality during this process, the researchers also include Semantics Preserving Losses using CLIP and DINO. These penalize the model if the debiased image strays too far from the original model's intended output.

Key Insights and Results

  • Fairness is a Spectrum, Not a Constant: Framing fairness as "distributional alignment" allows for immense flexibility. For example, the authors successfully tuned a model to produce a target distribution of 75% young and 25% old people while simultaneously debiasing for race and gender.
  • The Language Side is the "Sweet Spot": The authors found that finetuning the text encoder (the component that interprets the prompt) is often more effective than finetuning the U-Net (the component that draws the pixels). Finetuning the U-Net can lead to "overfitting," where the model learns to trick the classifier by adding subtle textures to skin rather than changing the actual demographic representation.
  • Minimal Intervention Works: Surprisingly, retuning the entire model is unnecessary. Finetuning just five soft tokens (virtual words added to the prompt) was enough to significantly reduce gender bias.
  • Significant Bias Reduction: On a dataset of 1,000 occupational prompts, the method reduced gender bias from 0.67 to 0.23 and racial bias from 0.42 to 0.44, while maintaining much better intersectional balance.
  • Strong Generalization and Scalability: The fairness behavior generalized to unseen occupations and artistic styles (e.g., a model trained on "photo of a doctor" still produced diverse results for a "magician in a digital art style"). Furthermore, the method scales to handle multiple concepts simultaneously, successfully debiasing occupations, sports, and personal descriptors at once without a significant drop in image quality.

Limitations and Future Work

While highly effective, the approach has limitations. The study relies on pre-trained classifiers for gender and race, which are currently restricted to binary gender and broad racial categories, failing to account for non-binary identities or mixed-race backgrounds. Consequently, the system is only as "fair" as the classifier used to train it; any blind spots in the face classifier will be baked into the finetuned model. Finally, while the paper successfully addresses human demographics, the authors acknowledge that broader "cultural bias" remains a complex, nuanced challenge for future research.

Summary updated

BibTeX
@inproceedings{shen2024finetuning,
  author = {Xudong Shen and Chao Du and Tianyu Pang and Min Lin and Yongkang Wong and Mohan Kankanhalli},
  title = {{Finetuning Text-to-Image Diffusion Models for Fairness}},
  booktitle = {International Conference on Learning Representations},
  year = {2024},
  url = {https://openreview.net/forum?id=hnrB5YHoYu},
}
Figure