Abstract: We address the problem of group fairness in classification, where the objective is to learn models that do not unjustly discriminate against subgroups of the population. Most existing approaches are limited to simple binary tasks or involve difficult to implement training mechanisms which reduces their practical applicability. In this paper, we propose FairGrad, a method to enforce fairness based on a re-weighting scheme that iteratively learns group specific weights based on whether they are advantaged or not. FairGrad is easy to implement, accommodates various standard fairness definitions, and comes with minimal overhead. Furthermore, we show that it is competitive with standard baselines over various datasets including ones used in natural language processing and computer vision.
Introduction
In the rapidly evolving field of Machine Learning, fairness has transitioned from an ethical consideration to a core engineering requirement. However, implementing fairness often involves complex constrained optimization, adversarial training, or significant architectural changes. FairGrad, presented at TMLR in 2023, offers a lightweight, "plug-and-play" re-weighting scheme that integrates directly into standard gradient descent, making fair training nearly as simple as swapping a loss function.
Problem Statement
Most machine learning models are "fairness-blind," minimizing average error across the entire dataset. If training data contains historical biases—such as hiring datasets where specific demographics were historically favored—the model will likely learn and perpetuate these biases.
Existing solutions typically fall into three categories: pre-processing (data cleaning), post-processing (adjusting predictions), and in-processing (modifying the training objective). While in-processing is often the most powerful, current methods are frequently limited to binary classification, require complex "inner-loop" optimizations, or introduce significant computational overhead. FairGrad addresses the need for a general-purpose, efficient method compatible with modern deep learning architectures and diverse fairness definitions like Demographic Parity or Equalized Odds.
Methodology
FairGrad treats fairness as a constrained optimization problem, aiming to minimize loss subject to the constraint that fairness violations remain below a threshold $\epsilon$.
Re-weighting via Lagrange Multipliers
The core innovation of FairGrad is the mathematical demonstration that the standard Lagrangian formulation of this problem can be rewritten as a weighted sum of group-wise error rates. The algorithm employs an alternating approach:
- Update Multipliers: After each batch, the algorithm assesses the current unfairness for each group and updates a set of Lagrange multipliers ($\lambda$).
- Update Model: Group-specific weights are calculated based on these multipliers. If a group is currently "advantaged," its weight is decreased; if it is "disadvantaged," its weight is increased.
- Gradient Descent: Model parameters are updated using standard backpropagation on this dynamically weighted loss.
The Necessity of Negative Weights
A distinctive feature of FairGrad is its support for negative weights. While most re-weighting schemes (like oversampling) use only positive values, the authors provide a mathematical lemma proving that for certain datasets and fairness notions (such as Accuracy Parity), it is impossible to reach a fair solution using only positive weights. To achieve parity, the model must sometimes be actively "discouraged" from certain patterns via negative gradients.
Experimental Evaluation
The authors evaluated FairGrad across diverse domains to demonstrate its versatility:
- Tabular: Adult Income and Law School datasets.
- Computer Vision: CelebA (predicting "smiling" while maintaining gender fairness) and UTKFace (predicting age/gender while maintaining racial fairness).
- NLP: Twitter Sentiment (predicting sentiment across African American English and Standard American English speakers).
- Synthetic: Gaussian toy datasets used to verify the negative weights theory.
Key Results
- Competitive Performance: FairGrad achieved fairness levels comparable to or better than state-of-the-art methods like FairBatch while maintaining high accuracy.
- Minimal Overhead: Because FairGrad utilizes predictions and losses already calculated during the forward pass, the computational penalty is negligible. In ResNet18 experiments, the fair version took only 0.42 seconds longer per epoch than the unconstrained version.
- Scalability and Stability: The method successfully scaled to large datasets like Twitter Sentiment (200k samples) and showed lower standard deviation across runs compared to notoriously unstable adversarial methods.
- Fine-tuning Efficiency: FairGrad is particularly effective for fine-tuning pre-trained models (e.g., BERT or ResNet), allowing practitioners to enforce fairness without destroying learned features.
Conclusion
FairGrad represents a significant step toward making Fair ML a standard component of the data science toolkit. By framing fairness as a dynamic re-weighting problem and acknowledging the necessity of negative weights, it provides a robust, scalable, and easy-to-implement solution for modern machine learning pipelines.
FairGrad is available as a PyPI package at: https://pypi.org/project/fairgrad
Summary updated