TL;DR
FairBatch is a "plug-and-play" batch selection algorithm that improves model fairness by adaptively adjusting the ratio of sensitive groups in training minibatches. By framing fairness as a bilevel optimization problem, it achieves state-of-the-art results across various fairness metrics with minimal implementation effort—often requiring just a one-line change to existing PyTorch code.
What Problem Does This Paper Address?
As machine learning (ML) models are increasingly deployed in sensitive domains like healthcare, hiring, and finance, ensuring they do not discriminate based on attributes like race, gender, or age is critical. However, most existing "fairness-aware" algorithms are difficult to adopt in practice. They typically fall into two invasive camps:
- Pre-processing: Requires modifying the entire dataset before training.
- In-processing: Requires changing the model's underlying architecture or custom-engineering the loss function.
For engineers working with complex, production-grade systems, these approaches are often too rigid. There is a clear need for a "low-friction" method that can improve fairness without forcing a total system overhaul or sacrificing significant predictive accuracy.
Methods
The authors introduce FairBatch, which addresses fairness through the lens of bilevel optimization.
In this framework, the "inner" problem is the standard model training loop (e.g., Stochastic Gradient Descent). The "outer" problem is the FairBatch algorithm, which acts as a controller. It monitors the fairness of the model at the end of each epoch and then adjusts the sampling probabilities for the next epoch.
If the model is performing poorly (or unfairly) on a specific sensitive group, FairBatch increases the "batch-size ratio" for that group in the next round. This forces the model to pay more attention to the disadvantaged group. The paper provides specific update rules for three major fairness measures:
- Equal Opportunity (EO): Ensuring equal true positive rates across groups.
- Equalized Odds (ED): Ensuring equal accuracy (both true positive and false positive rates) across groups.
- Demographic Parity (DP): Ensuring the model predicts the positive outcome at the same rate for all groups.
The beauty of this approach is its simplicity: in PyTorch, it essentially replaces the standard data sampler, leaving the rest of the training pipeline untouched.
Datasets
The researchers evaluated FairBatch on a mix of synthetic and real-world benchmark datasets:
- Synthetic Dataset: 3,000 examples designed with intentional bias to test the algorithm's limits.
- ProPublica COMPAS: A well-known dataset used for predicting criminal recidivism.
- AdultCensus: A dataset used to predict whether an individual's income exceeds $50k/year.
- UTKFace: A large-scale face dataset with 23,708 images, used to demonstrate FairBatch's effectiveness in deep learning and image recognition tasks.
Key Insights and Ideas
- Fairness via Sampling, Not Just Loss: The core insight is that you don't necessarily need to change how a model learns (the loss function); you can achieve fairness by changing what it sees (the data distribution in each batch).
- The Bilevel Perspective: By treating batch selection as an outer optimization loop, the authors provide a theoretical foundation for why adaptive sampling converges to a fair solution.
- Fine-Tuning for Fairness: FairBatch isn't just for training from scratch. The authors showed it can be used to "fix" pre-trained, unfair models (like ResNet18 or GoogLeNet) through a short fine-tuning process.
- Speed is a Feature: Unlike ensemble-based fairness methods (like AdaFair) that require training multiple models, FairBatch works within a single training run. This makes it significantly faster—between 22x and 96x faster in some experiments.
Key Results
- State-of-the-Art Performance: FairBatch consistently matched or outperformed existing complex methods (like Fairness Constraints or Adversarial Debiasing) in the trade-off between accuracy and fairness. As seen in the Demographic Parity benchmarks, it achieves the lowest disparity scores while maintaining competitive accuracy.
- Robustness: On the COMPAS dataset, FairBatch successfully minimized "ED disparity" (accuracy difference between groups) while maintaining high overall accuracy.
- Deep Learning Success: When applied to ResNet18 on the UTKFace dataset, FairBatch reduced fairness violations without the massive accuracy drops seen in simpler methods like "Cutting" (which just removes data to balance groups).
- Compatibility: The authors demonstrated that FairBatch can be combined with other batch selection techniques (like importance sampling) to improve both fairness and training speed simultaneously.
Limitations and Future Work
- Theoretical Constraints: While the algorithm works well in practice for multiple disparities, the strongest theoretical convergence guarantees are currently limited to cases with a single disparity measure.
- Non-Convexity: The outer optimization problem isn't always convex, meaning there's no absolute guarantee of finding the global optimum, though the authors found it to be "quasi-convex" in many practical scenarios.
- Expanding Fairness Definitions: The current work focuses on group fairness. Extending FairBatch to handle individual fairness (treating similar individuals similarly) or causality-based fairness is a promising next step.
- Data Collection Bias: FairBatch addresses how we use data, but it cannot fix fundamental biases in how data was originally collected (e.g., if certain populations are entirely missing from the dataset).
Summary updated