Standard machine learning models are designed to be "loss minimizers." They search for a mathematical function that minimizes the average error across a training set. However, if a dataset contains a majority group and a minority group, the model can achieve a very low average error by simply perfecting its predictions for the majority while ignoring the patterns of the minority. This "majority rules" bias is the root of many algorithmic inequities.
To solve this, a growing body of research moves beyond simply cleaning data (pre-processing) or tweaking results (post-processing). Instead, researchers are "in-processing" fairness by embedding equity directly into the model’s objective function using differentiable regularization.
The Fairness Penalty
The core intuition behind this approach is to treat unfairness as a form of "overfitting" to social biases. In a standard training loop, a model minimizes a task loss ($L_{task}$), such as cross-entropy. In-processing methods add a second term: a fairness penalty ($L_{fair}$).
$$L_{total} = L_{task} + \lambda L_{fair}$$
The hyperparameter $\lambda$ acts as a dial. When $\lambda$ is zero, the model cares only about accuracy. As $\lambda$ increases, the model is increasingly penalized for making decisions that correlate with sensitive attributes like gender or race.
As Muhammad Bilal Zafar and colleagues demonstrated in Learning Fair Classifiers, this allows fairness to be treated as a constrained optimization problem. By bounding the "decision boundary covariance"—a measure of how much the model's predictions shift based on a sensitive feature—they showed that models can learn to be fair while still being efficient to train.
Making Fairness Differentiable
The primary challenge of in-processing is that many fairness definitions, like "Demographic Parity" (equalizing the percentage of people hired across groups), are discrete and non-differentiable. You cannot take the gradient of a "count" of people. To use backpropagation, researchers must find continuous proxies for these metrics.
Several clever strategies have emerged to bridge this gap:
- Loss Disparity: Aili Shen and others in Optimising Equal Opportunity Fairness in Model Training suggest penalizing the difference in loss between groups. If the model is struggling more on one group than another, the penalty increases, forcing the gradient to prioritize the underperforming group.
- Distributional Distance: Alberto Gonzalez Sanz and his team utilized Wasserstein-2 regularization to measure the distance between the distributions of model outputs for different groups. By making this distance differentiable, they created an architecture-agnostic way to enforce statistical parity.
- Attention Redistribution: In NLP, Yacine Gaci introduced AttenD, which penalizes models when they assign disparate "attention" scores to tokens belonging to different social categories, effectively forcing the model to "look" at protected groups with equal intensity.
Why In-Processing Wins
While post-processing (like re-ranking a list of job candidates after the model has scored them) is easier to implement, it often destroys the utility of the model. As Ashudeep Singh and Thorsten Joachims argue in Policy Learning for Fairness in Ranking, post-hoc fixes trust biased scores that may be fundamentally unreliable.
In-processing is more robust because it forces the model to learn fair representations. When Kamrun Naher Keya and colleagues applied this to Neural Fair Collaborative Filtering, they found that the model learned to "scrub" bias from its internal embeddings. By the time the model makes a recommendation, the bias has already been filtered out of the features it uses to make that decision.
The Pareto Frontier of Equity
The ultimate goal of this research direction is to navigate the "accuracy-fairness trade-off." By using differentiable regularizers, researchers can map out a Pareto frontier—a curve showing the best possible fairness for any given level of accuracy.
Recent work even suggests that fairness doesn't always come at a cost. In Fairness-Aware Demand Prediction, researchers found that adding fairness regularizers actually improved accuracy by preventing the model from overfitting to biased historical noise. By penalizing unfairness, we aren't just making models more ethical; we are often making them more generalizable and robust.