Source-linked AI summary
Unmasking Contextual Stereotypes: Measuring and Mitigating BERT's Gender Bias
Marion Bartl, Malvina Nissim, Albert Gatt
TL;DR
The paper investigates whether BERT encodes gender bias and develops methods to measure and mitigate it. Using template-based association tests, workforce comparisons, and CDS-based fine-tuning, it finds that English BERT reflects stereotypes and that mitigation reduces some associations, while the method transfers poorly to German.
Problem
Biases in language data can leak into NLP systems and affect decisions such as resume ranking, motivating assessment of gender bias in contextualized embeddings.
Method
The study uses BEC-Pro templates and BERT masked-language-model probabilities to measure gender–profession associations, then fine-tunes English BERT on CDS-applied GAP data.
Results
English BERT encodes both workforce-reflective and stereotypical gender associations, while CDS-based fine-tuning reduces some associations; the English method is impaired in German by gender marking.
Takeaways & Limitations
Gender-bias measurement and mitigation methods for contextualized models should be evaluated across languages rather than assumed to transfer from English.
Takeaways & Limitations
In German, grammatical gender agreement influences associations, limiting direct transfer of the English measurement method.
Abstract
from arXiv · showhide
Contextualized word embeddings have been replacing standard embeddings as the representational knowledge source of choice in NLP systems. Since a variety of biases have previously been found in standard word embeddings, it is crucial to assess biases encoded in their replacements as well. Focusing on BERT (Devlin et al., 2018), we measure gender bias by studying associations between gender-denoting target words and names of professions in English and German, comparing the findings with real-world workforce statistics. We mitigate bias by fine-tuning BERT on the GAP corpus (Webster et al., 2018), after applying Counterfactual Data Substitution (CDS) (Maudslay et al., 2019). We show that our method of measuring bias is appropriate for languages such as English, but not for languages with a rich morphology and gender-marking, such as German. Our results highlight the importance of investigating bias and mitigation techniques cross-linguistically, especially in view of the current emphasis on large-scale, multilingual language models.
1 Introduction
The paper examines how to measure and mitigate gender bias in BERT, relating its associations to workforce statistics and testing English methods in German. It contributes datasets, bias analyses, and evidence that BERT encodes both real-world patterns and stereotypes.
- Research Questions: The study asks how gender bias in BERT can be measured and mitigated, whether its associations relate to workforce participation, and whether English methods transfer to German.The cross-lingual question reflects challenges posed by rich morphology and grammatical gender.
- Contributions: BEC-Pro is a template-based English-German corpus designed to measure gender bias across profession groups.The dataset and experiment code are publicly released.
- Contributions: Querying BERT’s masked language model with diverse sentence contexts supports bias detection in contextualized word embeddings.The method is based on Kurita et al. (2019).
- Contributions: Comparing BERT associations with U.S. workforce statistics shows that the model encodes both real-world biases and stereotypes.This comparison distinguishes associations aligned with participation patterns from those that render actual participation less visible.
- Contributions: The study reports successful bias mitigation on BERT and finds that an English bias-measurement method is impaired by German morphological gender marking.The study treats gender as binary and notes that this excludes non-binary identities.
2 Background and Previous Work
Prior work adapts embedding-bias methods to contextualized representations, while this paper uses BERT’s masked language model and extends evaluation across languages. The background emphasizes that grammatical gender can obscure semantic associations and complicate debiasing.
- Bias Measurement: Contextualized word-embedding methods must use sentence contexts because representations depend on the words surrounding the target.Previous approaches include templates and randomly sampled corpus sentences.
- Bias Measurement: Kurita et al. query BERT’s native masked language model to obtain single-token probabilities, enabling contextual bias measurement.BERT’s bidirectional masked-language-modeling objective makes this probability available.
- Cross-Linguistic Bias: Most prior NLP research focuses on English, limiting evidence for languages with grammatical gender.Grammatical gender can veil word semantics and make English methods unreliable across languages.
- Cross-Linguistic Bias: In German and Italian, grammatical-gender similarity has undermined standard embedding debiasing, motivating preprocessing approaches such as counterfactual data augmentation.Agreement between articles and adjectives can make same-gender noun contexts more similar.
- Present Work: The present work applies masked-language-model querying to diverse professional templates, compares associations with workforce statistics, and fine-tunes BERT using counterfactual data.The mitigation approach adapts Maudslay et al.’s version of counterfactual data augmentation.
3 Data
The study builds English and German template corpora linking gender-denoting person phrases with professions, supplements them with existing corpora, and uses workforce data to organize profession groups. BEC-Pro contains 5,400 sentences per language.
- 3.1 Existing Corpora: The study uses the EEC for preliminary gender- and emotion-bias assessment and the GAP corpus for BERT fine-tuning.GAP contains ambiguous pronoun-name pairs in Wikipedia contexts.
- 3.2 BEC-Pro: BEC-Pro contains English and German template sentences pairing gender-denoting person phrases with profession terms for BERT bias measurement.The templates were translated from English into German.
- 3.2 BEC-Pro: Professions are grouped using U.S. workforce participation statistics into highly female-participating, highly male-participating, and balanced categories.The source covers professions with more than 50,000 U.S. employees; selected groups contain 20 professions each.
- 3.2 BEC-Pro: German profession terms were translated into masculine and feminine forms, with native-speaker correction and attention to feminine-form frequency.The authors note that low-frequency feminine forms can influence language-model probabilities.
- 3.2 BEC-Pro: The EEC’s preliminary results are not discussed, and the German corpus design follows translated, template-based constructions.The paper states that it omits EEC results to focus on associations with professions.
- 3.2 BEC-Pro: Each language contributes 5,400 sentences from 5 templates, 18 person words, 20 professions, and 3 profession groups.The corpus design crosses sentence templates, gender-denoting person words, and profession categories.
4 Method
The method measures gender associations in BERT using masked-token probabilities over English and German profession templates, then evaluates mitigation through CDS-based fine-tuning on GAP.
- 4.1 Technical Specifications and Models: The study uses uncased English BERTBASE and cased German BERT, with German capitalization motivating the cased model choice.All experiments use the Huggingface PyTorch implementation with random seed 42.
- 4.4 Measuring Association Bias: The evaluation masks target words to create prior and target settings, while masking multi-token profession attributes token by token.Only target words, not determiners, are masked; attribute phrases with multiple tokens are masked individually.
- 4.2 Bias Evaluation Corpus with Professions: BEC-Pro supplies English and German sentence templates pairing gender-denoting person phrases with profession terms for bias evaluation.The corpus includes five template patterns, including statements about work, applications, and desired professions.
- 4.4 Measuring Association Bias: BERT’s association score compares target probabilities with and without a profession attribute, interpreting positive or negative values as increased or decreased target likelihood.Targets are gender-denoting person words, while attributes are professions.
- 4.5 Bias Mitigation: Bias mitigation applies name-based CDS to GAP, then fine-tunes English BERT on the gender-swapped corpus and repeats the same bias evaluation.The training procedure uses standard MLM masking and three epochs with AdamW at a learning rate of 5×10^-5.
5 Results
English BERT associations broadly reflect workforce gender distributions, while fine-tuning reduces several gendered associations; German measurements are confounded by grammatical gender and the method is ineffective there.
- Overall results: Positive pro-typical and negative anti-typical pre-associations confirm that English BERT bias corresponds to real-world workforce statistics.The study reports significant Wilcoxon tests for all English rows, with N=900 per row.
- Overall results: Female person words had a -0.35 pre-association with balanced professions that became 0.20 after fine-tuning, whereas male person words remained comparatively stable.The negative pre-association indicates that real-world gender parity was not reflected for female terms before fine-tuning.
- Overall results: Male person words were relatively stable and less affected by fine-tuning, suggesting that non-stereotypical professions are more often discussed with male terms.Female representations were more marked and more readily adapted after fine-tuning.
- English profession results: Female person-word associations with predominantly male professions shifted from mostly negative before fine-tuning to almost entirely positive afterward, bringing male and female associations closer.The reported exception is “taper,” whose ambiguity may explain its different behavior.
- Balanced professions: Balanced professions showed mostly negative pre-associations for female person words that generally became positive after fine-tuning, despite lacking a corresponding real-world gender bias.Some negative male associations involved highly specific, potentially low-frequency professions.
- German profession results: German associations were similar across male-, female-, and balanced-profession groups, so post-associations were not reported because the method was ineffective.German profession forms encode grammatical gender, which likely drives the common association pattern.
6 Discussion and Conclusions
The paper presents BEC-Pro and MLM-based association analysis for measuring gender bias in BERT, and finds that CDS-based fine-tuning reduces some English associations. It also concludes that the English method does not transfer straightforwardly to German because grammatical gender affects associations.
- 6 Discussion and Conclusions: BEC-Pro uses profession groups and person words to make contextual gender associations measurable and visualizable across models.The corpus is template-based and was released with experiment code.
- 6 Discussion and Conclusions: CDS applied to GAP before fine-tuning supports reducing gender bias associations in English BERT.The method reduced associations for female person words with female-typical professions and increased associations in both anti-typical settings.
- 6 Discussion and Conclusions: Female person words had larger absolute pre-associations and greater post-association changes than male person words.The authors suggest male bias or the slight surplus of female terms in the CDS-processed GAP corpus as possible explanations.
- 6 Discussion and Conclusions: German association results are confounded by grammatical gender, with feminine forms consistently showing higher associations than masculine forms.The authors therefore conclude that a method successful in English is not necessarily transferable to German.
- 6 Discussion and Conclusions: The study is limited by using one uncased BERTBASE model and researcher choices in template-based measurement.Curated person and profession lists, as well as template wording, can introduce human influence.
Appendix
The appendix documents the profession vocabulary used in the study and illustrates German profession-level associations. It supports interpreting the German results as affected by grammatical agreement rather than direct gender-bias measurement.
- Appendix: The profession list derives from U.S. Bureau of Labor Statistics data and is shortened and translated into German masculine and feminine forms.These terms are documented in Table 6 for the template-based BEC-Pro.
- Appendix: Figure 6 illustrates associations for individual German professions across balanced, female, and male profession groups.The figure is used to discuss why grammatical agreement prevents the associations from directly capturing German gender bias.