Abstract
Machine learning models in Natural Language Processing often perpetuate societal biases present in training data. While many fairness interventions target Demographic Parity, this objective can be inappropriate when label base rates differ across groups. We present Conditional Supervised Contrastive Learning (CSCL), a framework designed to achieve Equalized Odds (EO) by minimizing the conditional mutual information between learned representations and sensitive attributes. Our approach demonstrates superior stability and a better fairness-accuracy trade-off on standard benchmarks compared to adversarial baselines.
Introduction
The deployment of text classification models, such as toxicity detectors, often reveals significant performance disparities across demographic groups. For instance, dialectal variations can lead to the disproportionate flagging of comments from specific ethnic communities as "toxic," effectively silencing those voices. Addressing these biases is critical for the development of equitable AI.
Traditional fairness methods frequently optimize for Demographic Parity, which requires equal prediction rates across groups. However, in many real-world tasks, the ground-truth distribution of labels may naturally vary by group. In such cases, Equalized Odds (EO)—which requires equal True Positive and False Positive rates across groups—is a more appropriate desideratum. Achieving EO within representation learning, particularly in the popular contrastive learning paradigm, remains a significant challenge.
Methodology
We bridge the gap between fairness and contrastive learning through an information-theoretic lens. We prove that satisfying Equalized Odds is equivalent to minimizing the conditional mutual information $I(Z; A | Y)$, where $Z$ is the learned representation, $A$ is the sensitive attribute, and $Y$ is the task label.
To optimize this, we propose two primary objectives:
- Supervised Contrastive Loss ($L_{sup}$): Encourages representations of examples with the same label to cluster together in the embedding space, regardless of their demographic group.
- Conditional Supervised InfoNCE ($L_{CS-InfoNCE}$): This objective forces the model to distinguish between different examples even when they share both a label and a demographic attribute. This prevents the model from relying on the sensitive attribute as a predictive "shortcut."
We evaluate two implementation strategies: a Two-stage CL approach, where a fair encoder (e.g., BERT) is pre-trained and then frozen for classifier training, and a One-stage CL approach, which employs a joint loss function for end-to-end training of the encoder and classifier.
Experimental Setup
Our framework was tested on two standard benchmarks for algorithmic fairness in NLP:
- Jigsaw-Toxicity: A binary classification task for identifying toxic comments. The sensitive attribute is "race and ethnicity," specifically focusing on black vs. non-black identity mentions.
- Biasbios: A multi-class occupation classification task based on professional biographies. The sensitive attribute is binary gender (male vs. female).
Results and Discussion
The proposed CSCL methods consistently outperformed baselines such as Adversarial Training and Iterative Null-space Projection (INLP). As shown in the performance and fairness plots, our approach achieves a superior Pareto frontier, maintaining high F1 scores while significantly reducing the Equalized Odds gap across both datasets.
A key finding is the dominance of the Two-stage CL approach. By decoupling representation learning from the final classification task, the model can develop a cleaner, fairer embedding space. Furthermore, our contrastive approach exhibited greater stability and significantly lower variance across different random seeds and hyperparameter settings compared to adversarial methods, which are often notoriously difficult to tune.
Conclusion
Conditional Supervised Contrastive Learning offers a robust and stable framework for developing fair NLP models. By conditioning the contrastive objective on both labels and sensitive attributes, we can learn representations that respect Equalized Odds without sacrificing significant predictive accuracy. Future work will explore extending this framework to handle non-binary sensitive attributes and intersectional identities, potentially utilizing memory bank structures to address data scarcity in minority groups.
Summary updated