Abstract
Pre-trained contextualized embeddings such as BERT and RoBERTa have become foundational to modern Natural Language Processing (NLP). However, these models frequently inherit and amplify societal biases present in their massive training datasets. This paper introduces a lightweight, architecture-agnostic fine-tuning method designed to strip social biases—specifically gender prejudice—from these models. By enforcing mathematical orthogonality between neutral terms and gendered attributes across all model layers, the proposed method significantly reduces bias while preserving the models' pre-trained linguistic knowledge and downstream performance.
Introduction
While methods exist to debias "static" word vectors, contextualized embeddings present a unique challenge. In these models, a word's representation changes based on its surrounding context, and bias is often distributed across hundreds of millions of parameters. Previous attempts at debiasing often required computationally expensive retraining or targeted only specific layers, leaving bias "smeared" throughout the architecture. This research addresses the need for an efficient fine-tuning approach that can clean up these models without sacrificing their inherent utility.
Methodology
The proposed approach utilizes a joint loss function during fine-tuning to balance two competing objectives:
- Debiasing Loss ($L_i$): This component enforces orthogonality between "target words" (e.g., stereotypical occupations like doctor or nurse) and "attribute words" (gender-definitional terms like he or she). By minimizing the inner product between these vectors, the model effectively hides gender information from neutral terms.
- Regularization Loss ($L_{reg}$): To prevent the model from losing its linguistic capabilities, a squared $\ell_2$ distance penalty is applied. This ensures the debiased embeddings remain as close as possible to the original pre-trained representations.
As shown in Figure 1, the researchers experimented with different granularities—token-level (targeting specific words) and sentence-level (targeting the entire context)—as well as different layer depths (first layer, last layer, or all layers simultaneously).
Experimental Setup
The models were fine-tuned using sentences from the News-commentary-v15 corpus. Evaluation was conducted across several dimensions:
- Bias Measurement: Using the Sentence Encoder Association Test (SEAT) to measure associations between concepts (e.g., career vs. family) and gender, and MNLI templates to test if logical reasoning is swayed by gendered stereotypes.
- Performance Preservation: The GLUE benchmark was used to ensure the models maintained high accuracy on standard NLP tasks like sentiment analysis and linguistic similarity.
Results and Discussion
The "All Layers" Necessity
A critical finding of this work is that bias is not localized; it exists throughout the transformer architecture. Consequently, debiasing only the first or last layer proved insufficient. The most effective results were achieved when the debiasing loss was applied across all layers simultaneously.
Bias Reduction Across Architectures
The "all-token" method consistently achieved the lowest bias scores. In BERT, for instance, the number of SEAT categories showing significant bias was reduced to zero in several configurations.
As illustrated in Figure 2, the debiasing process (blue triangles) tends to pull the embeddings toward a more neutral diagonal compared to the original embeddings (yellow dots), indicating a reduction in gender-specific skew. However, the plots also reveal that models like RoBERTa and ALBERT are more sensitive to this fine-tuning, sometimes experiencing a greater shift in their underlying representation space.
Performance Trade-offs
While BERT and ELECTRA maintained nearly identical performance to their original versions on GLUE tasks (e.g., BERT dropping only from 75.8 to 74.9), RoBERTa and ALBERT showed higher sensitivity, suggesting that certain architectures may require more specialized regularization to preserve their pre-trained "knowledge" during the debiasing process.
Conclusion
This research demonstrates that a targeted fine-tuning approach can effectively mitigate social biases in contextualized embeddings. By focusing on token-level orthogonality across all layers, it is possible to create fairer AI models without the need for massive retraining. Future work will look toward extending this framework to address racial and religious biases, as well as automating the discovery of biased word associations beyond pre-defined lists.
Summary updated