fairlib: A Unified Framework for Assessing and Improving Classification Fairness

Xudong Han, Aili Shen, Yitong Li, Lea Frermann, Timothy Baldwin, Trevor CohnarXiv 2022 · DOI · arXiv

Abstract

Algorithmic fairness research is currently hindered by fragmented methodologies, inconsistent evaluation metrics, and varying model selection criteria. We introduce fairlib, an open-source PyTorch framework that unifies 14 debiasing methods and a comprehensive suite of evaluation metrics. By providing a standardized ecosystem for data processing, model training, and analysis, fairlib enables reproducible comparisons and rigorous assessment of the trade-offs between model performance and social fairness. Our benchmarks on standard NLP datasets demonstrate that systematic hyperparameter tuning within fairlib can significantly improve results over originally reported figures, highlighting the necessity of a unified evaluation framework.

Introduction: The Fragmentation of Fairness Research

In the rush to make AI more equitable, the research community has produced a dizzying array of "debiasing" techniques. However, comparing these methods is currently a significant challenge. Different papers use different datasets, inconsistent evaluation metrics (like various "GAP" scores), and—most importantly—varying model selection criteria.

Because there is almost always a trade-off between a model's performance (accuracy) and its fairness, a researcher can make a method look superior simply by choosing a different point on that trade-off curve. Without a unified framework, it is difficult to discern if a new algorithm represents a genuine breakthrough or is merely the result of superior hyperparameter tuning. fairlib addresses this by providing a modular ecosystem for consistent, reproducible comparisons.

The fairlib Framework

The authors developed fairlib as a modular ecosystem consisting of four main components:

  1. Data Module: Handles diverse inputs (text, images, audio) and automates pre-processing debiasing like resampling.
  2. Model Module: Supports standard backbones (like BERT) and integrates 14 built-in debiasing methods categorized into pre-processing (adjusting training data), at-training-time (adversarial components), and post-processing (adjusting trained model predictions).
  3. Evaluation Module: Provides a standardized suite of metrics based on confusion matrices, such as Equal Opportunity and Predictive Equality.
  4. Analysis Module: Includes tools for Pareto frontier analysis and the DTO (Distance To the Optimal) metric.

Quantifying Success with DTO

By using Distance To the Optimal (DTO), researchers can finally compare models using a single, objective scalar that accounts for both competing goals simultaneously. DTO measures how close a model is to the "Utopia point"—the theoretical (and usually impossible) state of having 100% accuracy and 100% fairness.

Visualization of the Distance To the Optimal (DTO) metric, measuring proximity to the 'Utopia' point of perfect fairness and performance.

Visualizing the Trade-off

Instead of looking at a single number, fairlib encourages looking at the entire curve of possible models. The Pareto Trade-off plot filters out "sub-optimal" models, showing only those that provide the best possible fairness for a given level of performance. This allows for a more nuanced understanding of how different algorithms behave across the performance-fairness spectrum.

Pareto Trade-off plot comparing FairSCL and INLP, highlighting optimal models that offer the best fairness for a given performance level.

Experimental Insights

The framework was benchmarked using two standard NLP fairness datasets: MOJI (sentiment analysis of tweets with race as a protected attribute) and BIOS (professional biography classification with gender as a protected attribute).

Key findings include:

  • The Hyperparameter Trap: Systematic hyperparameter tuning within fairlib often led to better results than those originally reported in source papers. This highlights how much "performance" in fairness research can be attributed to the rigor of the experimental setup rather than the algorithm itself.
  • Methodological Nuance: Re-implementing 9 major debiasing methods showed that no single method dominates. For instance, BTEO (pre-processing) performed exceptionally well on BIOS, while INLP (post-processing) showed significant gains through better tuning. Methods like FAIRSCL demonstrated dataset-dependent efficacy, performing well on MOJI but struggling on BIOS.

Limitations and Future Work

A current limitation of fairlib is its reliance on the availability of protected attributes (like race or gender) during training, which may not always be feasible or legal. Future development will focus on privacy-preserving fairness, incorporating models that can debias without explicit access to protected labels, and expanding the framework's robust support for computer vision and audio processing modalities.

fairlib is released under the Apache License 2.0 and is available on GitHub.

Summary updated

Abstract

This paper presents fairlib, an open-source framework for assessing and improving classification fairness. It provides a systematic framework for quickly reproducing existing baseline models, developing new methods, evaluating models with different metrics, and visualizing their results. Its modularity and extensibility enable the framework to be used for diverse types of inputs, including natural language, images, and audio. In detail, we implement 14 debiasing methods, including pre-processing, at-training-time, and post-processing approaches. The built-in metrics cover the most commonly used fairness criterion and can be further generalized and customized for fairness evaluation.
BibTeX
@misc{han2022fairlib,
  author = {Xudong Han and Aili Shen and Yitong Li and Lea Frermann and Timothy Baldwin and Trevor Cohn},
  title = {{fairlib: A Unified Framework for Assessing and Improving Classification Fairness}},
  year = {2022},
  eprint = {2205.01876},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2205.01876},
}
Figure