Skip to main content
QUICK REVIEW

[论文解读] Detecting Gender Bias in Transformer-based Models: A Case Study on BERT

Bingbing Li, Hongwu Peng|arXiv (Cornell University)|Oct 15, 2021
Topic Modeling参考文献 19被引用 11
一句话总结

该论文提出了一种基于注意力图的新方法,通过分析性别代词与职业之间的注意力分数,检测 BERT 中的性别偏见。结果表明,查询和键矩阵($Δ⁡⁡⁡\mathbf{W_q}$, $Δ⁡⁡⁡\mathbf{W_k}$)引入的性别偏见显著多于其他模块,且偏见在模型中周期性传播,在 $Δ⁡⁡⁡\mathbf{Q}$, $Δ⁡⁡⁡\mathbf{K}$, $Δ⁡⁡⁡\mathbf{V}$ 和残差层中被放大,但通过平均注意力被减弱。

ABSTRACT

In this paper, we propose a novel gender bias detection method by utilizing attention map for transformer-based models. We 1) give an intuitive gender bias judgement method by comparing the different relation degree between the genders and the occupation according to the attention scores, 2) design a gender bias detector by modifying the attention module, 3) insert the gender bias detector into different positions of the model to present the internal gender bias flow, and 4) draw the consistent gender bias conclusion by scanning the entire Wikipedia, a BERT pretraining dataset. We observe that 1) the attention matrices, Wq and Wk introduce much more gender bias than other modules (including the embedding layer) and 2) the bias degree changes periodically inside of the model (attention matrix Q, K, V, and the remaining part of the attention layer (including the fully-connected layer, the residual connection, and the layer normalization module) enhance the gender bias while the averaged attentions reduces the bias).

研究动机与目标

  • 探究性别偏见是否存在于 BERT 内部表征中,特别是与职业相关者。
  • 开发一种利用注意力图检测性别偏见的方法,避免评估中出现位置偏差。
  • 追踪性别偏见在 Transformer 架构不同组件中的传播路径。
  • 利用大规模基于 Wikipedia 的数据集,分析偏见在各层中的分布与增强模式。

提出的方法

  • 该方法使用性别互换的句子对,消除偏见检测中的位置效应,比较男性/女性代词与职业之间的注意力分数。
  • 提取并比较性别代词与职业标记之间的注意力分数($\mathbf{AS}$),以计算性别倾向值。
  • 在模型的多个位置(嵌入层、$Δ⁡⁡⁡\mathbf{Q}$, $Δ⁡⁡⁡\mathbf{K}$, $Δ⁡⁡⁡\mathbf{V}$, $Δ⁡⁡⁡\mathbf{AvgAttention}$ 和层输出)插入性别偏见检测器,以追踪内部偏见流动。
  • 使用标准 Transformer 公式推导注意力分数矩阵($\mathbf{AS}$)和平均注意力($\mathbf{AvgAttention}$):$\mathbf{AS} = \mathrm{Softmax}(\frac{\mathbf{Q}\mathbf{K}^T}{\sqrt{D_k}})$ 和 $\mathbf{AvgAttention} = \mathbf{AS} \cdot \mathbf{V}$。
  • 通过男性与女性代词相对于职业的注意力分数差异量化偏见程度,并在完整的 Wikipedia 预训练数据集上验证一致性。
  • 使用箱线图和差异曲线,在 144 个注意力头和 12 个层中对偏见分布和增强概率进行统计分析。

实验结果

研究问题

  • RQ1性别偏见是否在 BERT 的内部表征中出现,特别是在注意力机制中?
  • RQ2注意力机制如何在不同层和组件中放大或减少性别偏见?
  • RQ3自注意力模块的哪些特定组件——$Δ⁡⁡⁡\mathbf{W_q}$, $Δ⁡⁡⁡\mathbf{W_k}$, $Δ⁡⁡⁡\mathbf{W_v}$, $Δ⁡⁡⁡\mathbf{Q}$, $Δ⁡⁡⁡\mathbf{K}$, $Δ⁡⁡⁡\mathbf{V}$, $Δ⁡⁡⁡\mathbf{AvgAttention}$ 或残差层——对性别偏见影响最大?
  • RQ4性别偏见在整个预训练数据集中是否一致,是否表现出周期性的增强或缓解模式?

主要发现

  • 查询($Δ⁡⁡⁡\mathbf{W_q}$)和键($Δ⁡⁡⁡\mathbf{W_k}$)矩阵引入的性别偏见显著多于其他组件,包括嵌入层。
  • 偏见程度呈周期性变化:$Δ⁡⁡⁡\mathbf{Q}$, $Δ⁡⁡⁡\mathbf{K}$, $Δ⁡⁡⁡\mathbf{V}$ 和注意力层的残差部分会增强性别偏见,而平均注意力($Δ⁡⁡⁡\mathbf{AvgAttention}$)则会减弱它。
  • 偏见增强的概率在 $Δ⁡⁡⁡\mathbf{W_q}$ 和 $Δ⁡⁡⁡\mathbf{W_k}$ 处最高,$Δ⁡⁡⁡\mathbf{W_v}$ 对较少的有偏注意力头有贡献。
  • 性别偏见值的分布显示,$Δ⁡⁡⁡\mathbf{Q}$ 和 $Δ⁡⁡⁡\mathbf{K}$ 的偏见幅度大于其他组件,包括 $Δ⁡⁡⁡\mathbf{W_v}$。
  • 有偏注意力头的百分比在 $Δ⁡⁡⁡\mathbf{W_q}$, $Δ⁡⁡⁡\mathbf{W_k}$ 和最终层输出处显著增加,表明这些组件会放大偏见。
  • 在整个 Wikipedia 预训练数据集中,性别偏见结论的一致性确认了所观察到的偏见模式是稳健的,而非特定输入的产物。

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。