NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

An investigation of structures responsible for gender bias in BERT and DistilBERT

Thibaud Leteno, Antoine Gourru, Charlotte Laclau, Christophe Gravier

Abstract

As Large Language Models (LLMs) are increasingly integrated into critical decision-making systems, understanding the internal mechanisms of model bias is essential. This paper investigates whether gender bias is localized within specific layers or attention heads of BERT and its compressed counterpart, DistilBERT. Through a series of internal comparisons using Jensen-Shannon (JS) divergence and SVCCA, alongside head ablation experiments, we demonstrate that gender bias is distributed across the network architecture rather than confined to a single "bias layer." Furthermore, we find that DistilBERT exhibits a more homogeneous distribution of bias across its heads, potentially offering greater robustness to certain data imbalances compared to the full BERT model.

Introduction

The rapid adoption of Transformer-based models has brought the challenge of algorithmic bias to the forefront of AI engineering. While distillation techniques are commonly used to create efficient "student" models like DistilBERT, it remains unclear whether this compression process mitigates or amplifies the prejudices of the "teacher" model. This study addresses two primary questions: can specific internal structures be identified as the source of gender bias, and how does the distillation process affect the internal representation of this bias?

Methodology

To isolate the effects of training data on internal model representations, we established two primary fine-tuning scenarios: a balanced model ($M_b$) and an imbalanced model ($M_i$), both trained on the Bias in Bios dataset. This dataset contains over 217,000 professional biographies across 28 occupations, characterized by significant gender and class imbalances.

Neural Exploration Protocols

  1. Internal Comparisons: We utilized Jensen-Shannon (JS) divergence to measure differences in attention weights and Singular Vector Canonical Correlation Analysis (SVCCA) to compare hidden state representations across layers between the $M_b$ and $M_i$ variants.
  2. Head Ablation: To test the sensitivity of individual components, we systematically "noised out" specific attention heads during inference to observe fluctuations in the model's fairness score, measured via Equalized Odds (EO).
Architecture of BERT layers showing the head ablation (noising) process used to identify bias localization.

Key Results and Analysis

Distributed Bias vs. Localization

Our findings suggest that there is no single "smoking gun" layer responsible for gender bias. While fine-tuning predominantly impacts the upper layers of the network, the divergence between biased and unbiased models is observable across the entire architecture. As shown in the layer-wise analysis, internal representation differences tend to accumulate as information progresses through the network.

Jensen-Shannon divergence of attention weights across 12 layers, comparing models trained on balanced (Mb) and imbalanced (Mi) data.

The Distillation Effect and Homogeneity

One of the most significant insights is the difference in "homogeneity" between BERT and DistilBERT. DistilBERT's attention heads produce more similar representations than those in BERT. This lack of "wild card" heads makes DistilBERT more robust; while BERT may have specific heads that become extremely biased in edge cases (such as professions with "double imbalance"), DistilBERT maintains a more stable, albeit distributed, bias profile.

Fairness and Performance Trade-offs

Models trained on imbalanced data ($M_i$) exhibited a significantly higher Equalized Odds (EO) score of 0.42, compared to 0.13 for the balanced model ($M_b$). While head ablation can identify biased components, removing these heads significantly degrades the model's overall F-score, indicating that these structures also encode vital task-specific information.

Conclusion

Gender bias in BERT and DistilBERT is a systemic property of the network rather than a localized defect. While DistilBERT's homogeneity offers some protection against extreme sensitivity to class imbalance, the distributed nature of bias suggests that simple architectural pruning is insufficient for mitigation. Future work should focus on developing neutralization strategies that preserve classification accuracy while addressing the underlying representational disparities identified in the "CLS" token and attention patterns.

Summary updated

BibTeX
@inproceedings{leteno2023investigation,
  author = {Thibaud Leteno and Antoine Gourru and Charlotte Laclau and Christophe Gravier},
  title = {{An investigation of structures responsible for gender bias in BERT and DistilBERT}},
  booktitle = {IDA},
  year = {2023},
}
Figure