Local Contrastive Editing of Gender Stereotypes

Marlene Lutz, Rochelle Choenni, Markus Strohmaier, Anne Lauscher · DOI

TL;DR

This paper introduces "local contrastive editing," a novel method to pinpoint and modify specific weights within language models (LMs) responsible for encoding gender stereotypes. By comparing a "target" model with a "reference" model, they demonstrate that a tiny fraction of weights (<0.5%) can be precisely edited to significantly reduce stereotypical bias while preserving overall model performance.

What Problem Does This Paper Address?

Language models (LMs), despite their impressive capabilities, often inherit and amplify societal biases, particularly gender stereotypes. While measuring and mitigating these biases is an active research area, a significant challenge remains: understanding where these biases are encoded within the vast parameter space of LMs. This lack of granular understanding hinders the development of targeted and efficient bias mitigation strategies. The authors aim to bridge this gap by developing a method to precisely locate and edit the specific weights that contribute to stereotypical gender associations in LMs.

Methods

The core of the paper is the local contrastive editing framework, a two-step process:

  1. Localization: This step identifies weights associated with a specific property (in this case, gender stereotypes). The authors employ unstructured magnitude pruning to discover subnetworks within both a "target" model (which may exhibit bias) and a "reference" model (which might have a different bias profile or be neutral). Two strategies are used to create a "localization mask":
  2. Mask-based Localization: Selects weights that are present in one subnetwork but pruned in the other, hypothesizing these are crucial for encoding the property.
  3. Value-based Localization: Selects weights present in both subnetworks but with the largest absolute difference in their values, assuming these steer the models in opposing directions.
  4. Weight Editing: Once a subset of weights is identified (indicated by the localization mask), various editing strategies are applied to modify the target model's weights relative to the reference model. These include:
  5. Weight Interpolation (IP): Moves target weights closer to reference weights, controlled by a weighting factor $\alpha \in [0, 1]$.
  6. Weight Extrapolation (EP): Moves target weights further away from or towards reference weights, controlled by $\alpha \in \mathbb{R} \setminus [0, 1]$. This allows for more aggressive modifications, including bias removal.
  7. Pruning (PR): Simply sets the selected weights to zero, aiming to eliminate the encoded property.
  8. Mask Switch (SW): A strategy specifically for mask-based localization, which applies the reference model's pruning mask to the target model.

The key novelty lies in the contrastive nature of the approach, using a reference model to guide the localization and editing process, and the focus on local editing of small weight subsets.

Datasets

  • English Wikipedia: Used as the base corpus for fine-tuning BERT models.
  • Counterfactual Data Augmentation (CDA): Applied to Wikipedia sentences to create two distinct datasets:
  • Stereotypical Dataset: Sentences are constructed to amplify gendered associations (e.g., associating "woman" with "child-care").
  • Anti-stereotypical Dataset: Sentences are constructed to counter these associations (e.g., associating "woman" with "programming").
  • Bias Benchmarks:
    • WEAT (Word Embedding Association Test): Measures differential associations between word sets.
  • StereoSet: Evaluates stereotypical bias at the sentence level.
  • CrowS-Pairs: Compares sentence pairs to measure stereotypical preferences.
  • GLUE Benchmark (MNLI and STS-B tasks): Used to evaluate the performance of edited models on downstream tasks.

Key Insights and Ideas

  • Bias is Highly Localized: The most striking finding is that a remarkably small fraction of weights (<0.5%) is sufficient to encode and control significant gender stereotypes. This suggests that bias is not diffusely spread but rather concentrated in specific parts of the model.
  • Contrastive Approach is Crucial: Uninformed editing (randomly selecting weights) yields minimal or no change in bias. This highlights the critical role of the localization step, which leverages the contrast between models to identify relevant weights.
  • Flexible Bias Control: The weighting factor $\alpha$ in interpolation and extrapolation allows for fine-grained control over the degree of bias modification, enabling researchers to steer bias levels smoothly, and even potentially remove it entirely.
  • Attention Layers are Key: Localization strategies consistently point to similar layers and components, particularly the last layers and attention output dense layers, aligning with prior work suggesting these are critical for encoding bias.

Key Results

  • Significant Bias Reduction: Local contrastive editing, especially with mask-based localization, effectively reduced gender bias across WEAT, StereoSet, and CrowS-Pairs benchmarks, often with less than 0.5% of weights edited.
  • Preservation of Model Performance: Most editing strategies resulted in only minor increases in perplexity and minimal drops in LM scores. This indicates that bias can be mitigated without severely degrading the model's core language modeling capabilities.
  • Downstream Task Performance: Edited models showed only minor performance losses on downstream tasks like MNLI and STS-B, suggesting the edits are largely compatible with general language understanding.
  • Value-Based Pruning is Detrimental: While effective for bias reduction, value-based pruning led to a significant increase in perplexity, indicating it can severely impair model functionality.

Limitations and Future Work

  • Single Model Architecture and Bias Type: The study was conducted on BERT and focused solely on binary gender bias. The authors acknowledge that computational constraints limited exploration of other architectures or bias types. However, they anticipate their findings might generalize broadly, citing related work on weight averaging and bias mitigation across different specifications.
  • Potential for Dual Use: The techniques developed for bias reduction could, in principle, be used to amplify or introduce biases. The authors emphasize the ethical implications of this dual-use potential.
  • Binary Gender Specification: The study uses a binary gender specification (male/female). The authors recognize that gender is a spectrum and this binary approach is a simplification for evaluation purposes.
  • Future Work: The authors suggest exploring local contrastive editing for other tasks and domains beyond gender bias. They also note that the effectiveness of using an anti-stereotypical reference model with a neutral target model yielded mixed results, warranting further investigation.

Summary updated

BibTeX
@inproceedings{lutz2024local,
  author = {Marlene Lutz and Rochelle Choenni and Markus Strohmaier and Anne Lauscher},
  title = {{Local Contrastive Editing of Gender Stereotypes}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2024},
  doi = {10.18653/v1/2024.emnlp-main.1197},
}
Figure