Debiasing LLMs by Masking Unfairness-Driving Attention Heads
Tingxu Han, Wei Song, Ziqi Ding, Ziming Li, Chunrong Fang, Yuekang Li, Dongfang Liu, Zhenyu Chen, Zhenting Wang
TL;DR
This paper investigates why LLMs produce unfair outputs and reveals that Direct Answer prompting activates a small set of bias-causing attention heads, while Chain-of-Thought prompting redirects computation away from these heads. By comparing DA and CoT prompts, the authors develop DiffHeads, a lightweight, three-stage framework that identifies differential unfair heads via a per-head contribution score and masks them during inference, achieving substantial fairness improvements (around 40–50% on key models) with minimal impact on utility. The approach reframes bias mitigation as a mechanistic, head-level intervention that requires no retraining or external classifiers, and it provides an auditing signal through token-to-head contribution analysis. Practically, DiffHeads offers a deployment-friendly debiasing technique applicable to many LLMs, along with insights into how prompting styles influence internal mechanisms and bias pathways.
Abstract
Large language models (LLMs) increasingly mediate decisions in domains where unfair treatment of demographic groups is unacceptable. Existing work probes when biased outputs appear, but gives little insight into the mechanisms that generate them, leaving existing mitigations largely fragile. In this paper, we conduct a systematic investigation LLM unfairness and propose DiffHeads, a lightweight debiasing framework for LLMs. We first compare Direct-Answer (DA) prompting to Chain-of-Thought (CoT) prompting across eight representative open- and closed-source LLMs. DA will trigger the nature bias part of LLM and improve measured unfairness by 534.5%-391.9% in both one-turn and two-turn dialogues. Next, we define a token-to-head contribution score that traces each token's influence back to individual attention heads. This reveals a small cluster of bias heads that activate under DA but stay largely dormant with CoT, providing the first causal link between prompting strategy and bias emergence. Finally, building on this insight, we propose DiffHeads that identifies bias heads through differential activation analysis between DA and CoT, and selectively masks only those heads. DiffHeads reduces unfairness by 49.4%, and 40.3% under DA and CoT, respectively, without harming model utility.
