Bias in Language Models › Worked Example: Gendered Occupational Associations
Language AI HandbookAll chapters Bias in Language Models › Worked Example: Gendered Occupational AssociationsOne section · Sections in this chapter6 / 10 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
To make these concepts concrete, let's trace how a gender-occupation bias manifests in data and in model outputs, working through the mathematics explicitly.
Suppose we have a corpus of news articles, and we count how often each occupation co-occurs with gendered terms (pronouns, title words, names) within a window of 10 words.
We define the masculine co-occurrence ratio for an occupation as:
where:
- : the occupation word being measured (e.g., "doctor," "nurse")
- : the count of masculine-gendered terms co-occurring with in the corpus (e.g., "he," "him," "his," "Mr.")
- : the count of feminine-gendered terms co-occurring with (e.g., "she," "her," "Ms.")
- : values above 0.5 indicate masculine-leaning; values below indicate feminine-leaning
A ratio of exactly 0.5 represents equal masculine and feminine co-occurrence, which would be expected in an unbiased corpus if the actual population split for that occupation were 50/50.
For the occupation "doctor," suppose we find:
- Co-occurrences with masculine terms ("he," "him," "his," "Mr."): 4,200
- Co-occurrences with feminine terms ("she," "her," "hers," "Ms.," "Mrs."): 1,800
Applying the formula:
For the occupation "nurse," suppose we find:
- Masculine co-occurrences: 800
- Feminine co-occurrences: 3,600
The complement, , is the feminine co-occurrence ratio for "nurse."
These co-occurrence ratios appear directly in the training signal. But due to the amplification effects described above, a language model trained on this data may assign probabilities that exceed these ratios. When prompted with "The doctor examined the patient and then", the model might assign:
We can quantify the amplification by comparing the corpus odds ratio to the model's output odds ratio. In the corpus, the masculine-to-feminine odds for "doctor" are:
In the model's predictions, normalizing the gendered probabilities to sum to 1 (since ):
The amplification factor is:
This represents a 36% increase in the relative advantage assigned to masculine pronouns, above what the raw training data contained. Measuring bias at the data level alone is therefore insufficient. The model is a nonlinear function of its training data, and the biases it outputs cannot be fully predicted by counting co-occurrences in the corpus.