nahyeonkaty/fairpro

Official PyTorch implementation of FairPro

12

stars

12

commits

Python

primary language

Apr 1, 2026

updated

fairpro-t2i.github.io
deep-learning
large-language-models
pytorch
t2i

README

Aligned but Stereotypical? The Hidden Influence of System Prompts on Social Bias in LLM-based Text-to-Image Models

NaHyeon Park*1, Na Min An*1, Kunhee Kim*1, Soyeon Yoon1, Jiahao Huo2, Hyunjung Shim1

1KAIST, 2HKUST(GZ)

arXiv Project page Hugging Face Dataset

Alt text

Summary

  • We find that LLM-based T2I models produce markedly more socially biased images than non-LLM-based models.
  • We introduce a 1,024 prompt benchmark spanning four levels of linguistic complexity and evaluate demographic bias across multiple attributes in a systematic manner.
  • Our analysis identifies system prompts, the predefined instructions guiding LLMs, as a primary driver of biased behavior.
  • We propose FairPro, a training-free meta-prompting framework that enables LLMs to self-audit and construct fairness-aware system prompts at test time.

Benchmark

We introduce a comprehensive benchmark for evaluating demographic bias in T2I models, consisting of 1,024 prompts organized across four levels of linguistic complexity. All prompts are based on 256 distinct occupations and span multiple demographic attributes.

Benchmark Structure

The benchmark data is located in the data/ folder with the following structure:

data/
├── fairpro_prompts.csv              # Main CSV file with all prompt levels
├── prompts_occupations.txt          # Level 1: Occupation (256 prompts)
├── prompts_simple.txt               # Level 2: Simple (256 prompts)
├── prompts_context.txt              # Level 3: Context (256 prompts)
└── prompts_occupations_rewrite.txt  # Level 4: Rewritten (256 prompts)

Prompt Levels

Our benchmark consists of four hierarchical levels, each designed to evaluate different aspects of bias manifestation:

  • (Level 1) Occupation: Neutral prompts describing a broad set of occupations (e.g., "An accountant"), following established practice in occupational bias evaluation. This level contains 256 prompts covering diverse professions.

  • (Level 2) Simple:
    Extends Level 1 by adding a single demographic attribute, uniformly sampled from predefined categories (e.g., "A male accountant"). Attributes are drawn from four groups:

    • Gender: male, female
    • Age: young, adult, old
    • Ethnicity: White, Black, Hispanic, Native American, Asian, Pacific Islander, Middle Eastern
    • Body type: slim, average, athletic, overweight

    This level enables controlled evaluation of model sensitivity to socially salient attributes.

  • (Level 3) Context:
    Builds on Level 2 by incorporating simple actions or contextual details to create semantically richer descriptions (e.g., "A male accountant is preparing financial reports"). This level examines how bias manifests as prompts become less minimal and more situational.

  • (Level 4) Rewritten: Automatically rewritten by a large language model (LLM), Qwen2.5-7B-Instruct, from Occupation prompts to generate more descriptive and stylistically varied formulations (e.g., "An accountant working at a desk, midday office lighting, professional attire, focused expression..."). This set captures the effects of recent LLM-based rewriting techniques, providing the highest degree of linguistic diversity and complexity.

CSV Format

The fairpro_prompts.csv file contains the following columns:

  • occupation: Base occupation from Level 1 (e.g., "an accountant")
  • label: Demographic attribute category (gender, age, race)
  • simple_prompt: Level 2 prompt with demographic attribute
  • prompt_with_context: Level 3 prompt with contextual action

About our dataset

Installation

Our code has been tested on Python 3.12 with NVIDIA A6000 GPU (48GB). It should work with Python 3.9+ and other modern NVIDIA GPUs.

Requirements

  • Python 3.9 - 3.12
  • CUDA-compatible GPU with sufficient VRAM
  • PyTorch 2.0+

Setup

# Create and activate virtual environment
uv venv --python 3.12
source .venv/bin/activate

# Install the package
uv pip install -e .

Usage

Step 1: Generate Fairness-Aware System Prompts

Generate custom system prompts using the FairPro meta-prompting approach:

python fairpro.py

Command-Line Options

ArgumentDefaultDescription
--prompt_filedata/prompts_occupations.txtPath to file containing prompts
--output_pathfairpro_sp.jsonOutput JSON file path
--gpu_id0GPU device ID
--model_nameQwen/Qwen2.5-7B-InstructHuggingFace model for prompt generation
--seeds10Number of seeds per prompt

Note: FairPro uses the same LLM that is used for the T2I pipeline. Adjust --model_name accordingly.

Step 2: Generate Comparison Images

After generating the system prompts, compare images generated with default vs. FairPro system prompts:

python generate.py

Command-Line Options

ArgumentDefaultDescription
--input_jsonfairpro_sp.jsonInput JSON with FairPro prompts
--output_diroutputBase output directory
--model_nameQwen/Qwen-ImageT2I model name
--gpu_ids0 1Two GPU IDs for model distribution
--height1024Image height
--width1024Image width
--num_inference_steps20Number of diffusion steps
--true_cfg_scale4.0CFG scale

Note: For Qwen-Image with GPU VRAM > 48GB, you may disable DF11 for improved performance.

GenEval Evaluation

To reduce confusion, all GenEval setup and evaluation details are documented separately in geneval/README.md.

Quick entry point:

./run_geneval.sh --model qwenimage --fairpro

Quick Single-Prompt Smoke Test

Use generate_fairpro.py for fast qualitative checks:

python generate_fairpro.py \
  --prompt "A doctor examining a patient" \
  --compare \
  --fairpro-batch-size 8 \
  --fairpro-num-candidates 4 \
  --fairpro-select-best \
  --output-dir outputs/smoke

Citation

If you find this work useful, please cite our paper:

@article{park2025fairpro,
  title   = {Aligned but Stereotypical? Understanding and Mitigating Social Bias in LLM-Based Text-to-Image Models},
  author  = {Park, NaHyeon and An, Namin and Kim, Kunhee and Yoon, Soyeon and Huo, Jiahao and Shim, Hyunjung},
  journal = {arXiv preprint},
  year    = {2025},
  eprint  = {arXiv:2512.04981}
}

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributors

nahyeonkaty

7 commits

kunheek

5 commits

nahyeonkaty/fairpro

Official PyTorch implementation of FairPro

12

stars

12

commits

Python

primary language

Apr 1, 2026

updated

fairpro-t2i.github.io
deep-learning
large-language-models
pytorch
t2i

README

Aligned but Stereotypical? The Hidden Influence of System Prompts on Social Bias in LLM-based Text-to-Image Models

NaHyeon Park*1, Na Min An*1, Kunhee Kim*1, Soyeon Yoon1, Jiahao Huo2, Hyunjung Shim1

1KAIST, 2HKUST(GZ)

arXiv Project page Hugging Face Dataset

Alt text

Summary

  • We find that LLM-based T2I models produce markedly more socially biased images than non-LLM-based models.
  • We introduce a 1,024 prompt benchmark spanning four levels of linguistic complexity and evaluate demographic bias across multiple attributes in a systematic manner.
  • Our analysis identifies system prompts, the predefined instructions guiding LLMs, as a primary driver of biased behavior.
  • We propose FairPro, a training-free meta-prompting framework that enables LLMs to self-audit and construct fairness-aware system prompts at test time.

Benchmark

We introduce a comprehensive benchmark for evaluating demographic bias in T2I models, consisting of 1,024 prompts organized across four levels of linguistic complexity. All prompts are based on 256 distinct occupations and span multiple demographic attributes.

Benchmark Structure

The benchmark data is located in the data/ folder with the following structure:

data/
├── fairpro_prompts.csv              # Main CSV file with all prompt levels
├── prompts_occupations.txt          # Level 1: Occupation (256 prompts)
├── prompts_simple.txt               # Level 2: Simple (256 prompts)
├── prompts_context.txt              # Level 3: Context (256 prompts)
└── prompts_occupations_rewrite.txt  # Level 4: Rewritten (256 prompts)

Prompt Levels

Our benchmark consists of four hierarchical levels, each designed to evaluate different aspects of bias manifestation:

  • (Level 1) Occupation: Neutral prompts describing a broad set of occupations (e.g., "An accountant"), following established practice in occupational bias evaluation. This level contains 256 prompts covering diverse professions.

  • (Level 2) Simple:
    Extends Level 1 by adding a single demographic attribute, uniformly sampled from predefined categories (e.g., "A male accountant"). Attributes are drawn from four groups:

    • Gender: male, female
    • Age: young, adult, old
    • Ethnicity: White, Black, Hispanic, Native American, Asian, Pacific Islander, Middle Eastern
    • Body type: slim, average, athletic, overweight

    This level enables controlled evaluation of model sensitivity to socially salient attributes.

  • (Level 3) Context:
    Builds on Level 2 by incorporating simple actions or contextual details to create semantically richer descriptions (e.g., "A male accountant is preparing financial reports"). This level examines how bias manifests as prompts become less minimal and more situational.

  • (Level 4) Rewritten: Automatically rewritten by a large language model (LLM), Qwen2.5-7B-Instruct, from Occupation prompts to generate more descriptive and stylistically varied formulations (e.g., "An accountant working at a desk, midday office lighting, professional attire, focused expression..."). This set captures the effects of recent LLM-based rewriting techniques, providing the highest degree of linguistic diversity and complexity.

CSV Format

The fairpro_prompts.csv file contains the following columns:

  • occupation: Base occupation from Level 1 (e.g., "an accountant")
  • label: Demographic attribute category (gender, age, race)
  • simple_prompt: Level 2 prompt with demographic attribute
  • prompt_with_context: Level 3 prompt with contextual action

About our dataset

Installation

Our code has been tested on Python 3.12 with NVIDIA A6000 GPU (48GB). It should work with Python 3.9+ and other modern NVIDIA GPUs.

Requirements

  • Python 3.9 - 3.12
  • CUDA-compatible GPU with sufficient VRAM
  • PyTorch 2.0+

Setup

# Create and activate virtual environment
uv venv --python 3.12
source .venv/bin/activate

# Install the package
uv pip install -e .

Usage

Step 1: Generate Fairness-Aware System Prompts

Generate custom system prompts using the FairPro meta-prompting approach:

python fairpro.py

Command-Line Options

ArgumentDefaultDescription
--prompt_filedata/prompts_occupations.txtPath to file containing prompts
--output_pathfairpro_sp.jsonOutput JSON file path
--gpu_id0GPU device ID
--model_nameQwen/Qwen2.5-7B-InstructHuggingFace model for prompt generation
--seeds10Number of seeds per prompt

Note: FairPro uses the same LLM that is used for the T2I pipeline. Adjust --model_name accordingly.

Step 2: Generate Comparison Images

After generating the system prompts, compare images generated with default vs. FairPro system prompts:

python generate.py

Command-Line Options

ArgumentDefaultDescription
--input_jsonfairpro_sp.jsonInput JSON with FairPro prompts
--output_diroutputBase output directory
--model_nameQwen/Qwen-ImageT2I model name
--gpu_ids0 1Two GPU IDs for model distribution
--height1024Image height
--width1024Image width
--num_inference_steps20Number of diffusion steps
--true_cfg_scale4.0CFG scale

Note: For Qwen-Image with GPU VRAM > 48GB, you may disable DF11 for improved performance.

GenEval Evaluation

To reduce confusion, all GenEval setup and evaluation details are documented separately in geneval/README.md.

Quick entry point:

./run_geneval.sh --model qwenimage --fairpro

Quick Single-Prompt Smoke Test

Use generate_fairpro.py for fast qualitative checks:

python generate_fairpro.py \
  --prompt "A doctor examining a patient" \
  --compare \
  --fairpro-batch-size 8 \
  --fairpro-num-candidates 4 \
  --fairpro-select-best \
  --output-dir outputs/smoke

Citation

If you find this work useful, please cite our paper:

@article{park2025fairpro,
  title   = {Aligned but Stereotypical? Understanding and Mitigating Social Bias in LLM-Based Text-to-Image Models},
  author  = {Park, NaHyeon and An, Namin and Kim, Kunhee and Yoon, Soyeon and Huo, Jiahao and Shim, Hyunjung},
  journal = {arXiv preprint},
  year    = {2025},
  eprint  = {arXiv:2512.04981}
}

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributors

nahyeonkaty

7 commits

kunheek

5 commits

Languages

Python

93.5%

Shell

4.9%

Dockerfile

1.6%