Standard machine learning models operate on a simple principle: minimize the aggregate error across the entire training dataset. While this approach maximizes overall accuracy, it introduces a "majority rules" bias. If a demographic subgroup is underrepresented or exhibits different statistical patterns, the optimizer will happily sacrifice that group's accuracy to eke out marginal gains on the majority population.
To prevent this, researchers use in-processing fairness via constrained optimization. By integrating formal mathematical definitions of equity directly into the training phase, the optimizer is forced to find decision boundaries that preserve both utility and fairness.
The Limitation of Post-Hoc Adjustments
Historically, a common way to handle algorithmic bias was through post-hoc adjustments—taking a fully trained, biased model and shifting its decision thresholds for different groups after the fact. However, Blake Woodworth et al. demonstrate in Learning Non-Discriminatory Predictors that post-hoc corrections are fundamentally suboptimal.
Because the initial model was optimized solely for accuracy, it may have already discarded the subtle, predictive features necessary to make accurate and fair decisions for minority groups. In-processing avoids this information loss by treating fairness as a core constraint while the model is actively learning its representations. As Solon Barocas et al. note in Big Data, Data Science, and Civil Rights, embedding these mathematical definitions of equity directly into the model-building process ensures fairness is treated as a primary objective rather than an afterthought.
Mathematical Formulations: Penalties vs. Hard Constraints
To force an optimizer to respect fairness boundaries, researchers generally modify the objective function in one of two ways: soft penalties or hard constraints.
Soft Penalties (Regularization)
The most straightforward implementation adds a fairness penalty directly to the loss function:
$$\mathcal{L}_{\text{total}} = \mathcal{L}_{\text{accuracy}} + \lambda \cdot \mathcal{L}_{\text{fairness}}$$
Here, $\mathcal{L}_{\text{fairness}}$ quantifies demographic disparities (such as differences in selection rates or error rates between groups). For instance, Kazuto Fukuchi et al. introduce an $\eta$-neutrality penalty in Neutralized Empirical Risk Minimization with Generalization Neutrality Bound to ensure that predictions remain statistically independent of a sensitive attribute. Similarly, Arjun Subramonian et al. apply a penalty term in Networked Inequality: Preferential Attachment Bias in Graph Neural Network Link Prediction to counteract the "rich-get-richer" effect in graph embeddings, balancing predictive accuracy with an equitable distribution of recommendations.
Hard Constraints and Lagrangian Optimization
While soft penalties are simple, they require tedious manual tuning of the hyperparameter $\lambda$. If $\lambda$ is too small, the model remains biased; if it is too large, accuracy collapses. To bypass this, fairness can be framed as a strict constrained optimization problem:
$$\min \mathcal{L}_{\text{accuracy}} \quad \text{subject to} \quad C_{\text{fairness}} \le \epsilon$$
where $\epsilon$ represents an explicit numerical tolerance bound for disparity. Juan Ramirez leverages this framework in Balancing Act: Constraining Disparate Impact in Sparse Models to ensure that network pruning does not cause individual subgroups to experience a performance drop significantly worse than the model's average degradation.
To solve these constrained problems, algorithms often employ Lagrangian multipliers. This transforms training into a minimax game where the model attempts to minimize error while a Lagrange multiplier dynamically scales up the penalty whenever a fairness constraint is breached. Han Xu et al. utilize this approach in To be Robust or to be Fair: Towards Fairness in Adversarial Training, dynamically adjusting training hyperparameters to prevent the optimization process from sacrificing the performance of difficult classes to maximize aggregate robustness.
The Game-Theoretic Intuition
An elegant way to understand why constrained fairness optimization works is through a two-player game. Imagine a Learner (the model) competing against a Regulator (the fairness constraint).
The Learner's goal is to minimize predictive error. The Regulator's goal is to maximize the penalty on demographic disparities. By forcing these two forces to reach a Nash equilibrium, the training process stabilizes. As Yunpeng Jiang et al. demonstrate in Understanding and Reducing the Class-Dependent Effects of Data Augmentation with A Two-Player Game Approach, this competitive framework prevents the model from over-optimizing for a single majority category, resulting in a more stable convergence and an equitable distribution of accuracy across all classes.
Generalization Across Modern Paradigms
Constrained fairness optimization has expanded far beyond simple tabular classification, proving adaptable to complex, decentralized, and sequential learning environments:
- Federated Learning: In distributed systems where data privacy prevents centralized bias auditing, Lingyang Chu et al. formulate federated fairness constraints in Training Fair Models in Federated Learning without Data Privacy Infringement. This allows local nodes to contribute to global group fairness objectives without exposing sensitive client data.
- Reinforcement Learning: Enforcing fairness in sequential decision-making is notoriously difficult because actions have compounding downstream effects. Zhun Deng et al. show in Reinforcement Learning with Stepwise Fairness Constraints that treating fairness as a strict constraint at every single time step yields highly predictable agent behavior, avoiding the mathematical instability common in scalarized reward functions that mix utility and social goals.
- Preference Optimization (RLHF/DPO): In large language models, alignment techniques can inadvertently introduce biases, such as favoring longer responses. Sheng Ouyang et al. demonstrate in Towards Reward Fairness in RLHF: From a Resource Allocation Perspective that integrating fairness penalties directly into the log-probability ratios of Direct Preference Optimization (DPO) successfully mitigates length and social biases without requiring a standalone reward model.