TL;DR
Dense retrieval models often favor male-gendered documents over female ones, but the internal mechanics driving this bias have long been a black box. This paper uses mechanistic interpretability to trace gender bias back to its origin in input embeddings and reveals how it propagates through a small set of late-layer attention heads. Crucially, these heads are not a dedicated "bias circuit"—they jointly encode both gender and relevance, making targeted debiasing a delicate balancing act.
What Problem Does This Paper Address?
Dense retrieval models (like bi-encoders) power modern search engines and recommendation systems. However, they suffer from documented gender biases, such as scoring a document higher simply because it contains male pronouns or terms rather than female or neutral ones.
While we know this bias exists at a behavioral level, we haven't known how it travels through a model's internal architecture. Existing debiasing methods—like adversarial training or data augmentation—are computationally expensive and often force a trade-off between fairness and retrieval performance. To build better interventions, we first need to localize the exact internal components responsible for gender sensitivity.
Methods
The authors employ several state-of-the-art mechanistic interpretability techniques to reverse-engineer the model's internal computations:
- Activation Patching (AP): A causal intervention method used to pinpoint which layers and token positions carry the gender signal. Activations from a "clean" run (e.g., a neutral document) are systematically substituted into a "corrupted" run (e.g., a gendered document) to see which swaps eliminate the score disparity.
- Path Patching (PP): A more granular approach that traces the specific computational pathways between an upstream "sender" component (like an early layer embedding) and a downstream "receiver" component (like a late-layer attention head), distinguishing direct causal effects from indirect ones.
- Mean Ablation: Overwriting the output of specific attention heads with their average activation across the dataset to verify whether turning them "off" actually mitigates the bias.
- Activation Steering (ActAdd): An inference-time intervention where a "steering vector" (derived from the difference in activations between contrastive gender pairs) is added to the model's internal representations to actively control its behavior without retraining.
Datasets
The study evaluates five distinct bi-encoder models from the Sentence Transformers family using the Grep-BiasIR Dataset.
- This dataset contains 118 gender-neutral web search queries (e.g., "how to become CEO" or "salary negotiation tips").
- For each query, documents are provided in three identical variants except for gendered terms: Male (e.g., men, he), Female (e.g., women, she), and Neutral (e.g., adults, they).
Key Insights and Ideas
- The Bias Starts Early: Activation patching reveals that the gender signal is already fully present at Layer 0 within the input embeddings, confirming that models inherit bias right at the starting line.
- Architecture Dictates Routing: The pooling mechanism changes how bias moves. In CLS-pooled models, the gender signal is progressively routed from individual gendered tokens into the
[CLS]token at later layers. In mean-pooled models, the signal remains distributed across the residual stream without routing behavior.
- The Shared "Relevance" Bottleneck: Path patching localized the bias propagation to a tiny, shared set of late-layer attention heads (specifically heads 5.3 and 5.11 in DistilBERT variants).
- Entangled Signals: These late-layer heads are not a isolated "gender circuit." Instead, they are general aggregation sites that jointly encode both gender and query-document term matching. Because gender and relevance are deeply entangled in the same components, blindly turning off these heads can harm the model's core retrieval capability.
Key Results
- Baseline Bias Confirmed: Across all models, male variants consistently scored higher than female variants, and both gendered variants generally scored lower than neutral ones.
- Ablation Successfully Reduces Gap: Mean-ablating the identified late-layer attention heads successfully closed the score gap for most documents. However, it failed for documents where the neutral term itself was part of the query (e.g., the word "partner" in both query and document), proving that these heads are simultaneously computing crucial relevance signals.
- Steering Level Matters: Intervening at different points yielded completely different control dynamics:
- Embedding-level steering acted as a blunt neutralizer, collapsing score differences toward zero regardless of the steering direction.
- Attention-level steering acted as a directional dial, allowing the authors to precisely shift the model's preference to favor either the male or female variant depending on the sign of the steering coefficient ($\alpha$).
Limitations and Future Work
- Attention-Centric Focus: The authors focused primarily on attention heads because they showed the largest patching effects. However, preliminary results indicate that Multi-Layer Perceptrons (MLPs) also play a role in gender sensitivity and warrant deeper investigation.
- Single Steering Method: The study only evaluated additive activation steering (ActAdd). Future work should explore alternative methods like projection-based or Sparse Autoencoder (SAE)-based steering.
- The Disentanglement Challenge: Since gender and relevance are jointly encoded in the same attention heads, the ultimate open challenge is finding a way to mathematically disentangle these signals so that bias can be steered away without sacrificing search accuracy.
Summary updated