Formal Specification, Assessment, and Enforcement of Fairness for Generative AIs

Chih-Hong Cheng, Changshun Wu, Harald Ruess, Xingyu Zhao, Saddek Bensalem · DOI

Introduction

Traditional AI fairness techniques often rely on "design-time" interventions, such as balancing training datasets or modifying loss functions. However, these approaches are increasingly impractical for Generative AI (GenAI) for two primary reasons. First, the Black-Box Problem: many state-of-the-art models are proprietary, preventing researchers from accessing internal weights or retraining them. Second, the Context Problem: fairness is highly prompt-dependent. A model might exhibit diversity for one prompt (e.g., "doctors") but show significant bias for another (e.g., "homeless people").

This research introduces a framework for conditional fairness, shifting the focus to context-aware standards that can be monitored and enforced at runtime without requiring model retraining.

Methodology

The proposed framework utilizes a multi-layered approach to formalize and mitigate bias in black-box GenAI models:

Formal Specifications

Borrowing from Linear Temporal Logic (LTL), the authors define fairness as a sequence of events rather than a single output. A system is considered "fair" if every sensitive group (e.g., different ethnicities or genders) appears within a defined "deadline" or distance in the output stream. This moves away from static metrics toward a dynamic, time-bound understanding of diversity.

Intersectional Fairness via Combinatorial Testing

To address the complexity of intersectional attributes (race, gender, age), the framework employs k-way combinatorial testing. This ensures that all pairs of attributes (e.g., "Asian woman," "Elderly man") eventually appear, providing a computationally feasible alternative to covering every possible combination simultaneously.

Runtime Enforcement

The core contribution is a runtime monitoring agent. This agent tracks the sequence of generated images. If a specific demographic has not appeared for a duration approaching the fairness deadline, the agent intercepts the user's prompt and injects a hidden instruction (e.g., "Enforce the generated image such that it depicts a Latino person") to steer the model toward diversity. This "minimum intervention" approach preserves the model's creative freedom until a violation is imminent.

Evaluation and Results

The framework was evaluated using image sequences generated by OpenAI’s DALL-E 3 and ZHIPU AI’s GLM-4. To automate labeling, the vision-language model moondream was used to identify the gender, age, and ethnicity of subjects in real-time, allowing the monitor to track demographic distribution.

Key Results

The enforcement mechanism significantly improved diversity. Without intervention, models like GLM-4 achieved less than 40% coverage of all-paired attribute combinations, often failing to generate specific intersectional groups.

Comparison of image sequences showing standard outputs vs. enforced diverse outputs.

As illustrated in Figure 1, the enforcement algorithm (Row 5) successfully breaks the demographic repetition seen in standard outputs (Rows 1-4), ensuring a more balanced appearance of different groups over time. The researchers found that while "successful business leader" prompts often yielded diverse results naturally, "poor person" prompts were significantly more biased, highlighting the necessity of context-aware enforcement.

Discussion and Limitations

A key insight of this work is that fairness is conditional; inherent bias often remains hidden until triggered by specific semantic contexts. By focusing on the "worst-case" gap between appearances of a group, the framework provides a strict, human-centric metric for live services.

However, limitations remain. The system's efficacy is tied to the accuracy of the vision classifier (like moondream) used for labeling. If the classifier is biased, the enforcement will be flawed. Additionally, some models may ignore injected prompts if they conflict with internal safety filters. Future work will explore statistical fairness over time and large-scale organizational deployments where operational management of bias is critical.

Summary updated

BibTeX
@inproceedings{cheng2025formal,
  author = {Chih-Hong Cheng and Changshun Wu and Harald Ruess and Xingyu Zhao and Saddek Bensalem},
  title = {{Formal Specification, Assessment, and Enforcement of Fairness for Generative AIs}},
  booktitle = {RV},
  year = {2025},
  doi = {10.1007/978-3-032-05435-7\_5},
}
Figure