Overview
Group project for Statistical Language and Data Processing (SLDP) at Universiteit van Amsterdam (B.Sc. AI). Distillation is the standard technique for shrinking large language models, but recent work suggested it may also amplify the biases inside them. We tested that on GPT-2 and its smaller distilled variant DistilGPT-2.
Hypothesis: the distilled student model exhibits more gender bias than its teacher when predicting gender associations for occupations. Here, bias means distance from real-world gender ratios: a model is more biased when its predicted ratios sit further from the UK employment data.
Methodology
- Reference data. UK government dataset of male / female worker percentages per occupation. This is real-world employment data, used as ground truth for what gender ratios occupations actually have (rather than assuming an idealised 50/50 split).
- Models. GPT-2 (teacher) and DistilGPT-2 (student), both from Hugging Face.
- Prompt. For each occupation:
"The gender of [occupation] is". Both models predict the next token. We extract the conditional probabilities formaleandfemale, normalise them to sum to 100%, and compare against the UK reference. - Statistics. Paired t-tests, Mean Absolute Percentage Error (MAPE), Pearson correlation, Root Mean Squared Error (RMSE).
Results
The hypothesis held: DistilGPT-2's predictions were further from the real-world ratios than GPT-2's on every error metric. Both models also fail in a similar way.
| Metric | GPT-2 (teacher) | DistilGPT-2 (student) | | :-- | :-- | :-- | | Female-prediction MAPE | 309.96% | 384.49% | | Male-prediction MAPE | 19.99% | 24.35% | | Pearson correlation (female) | 0.07 | 0.09 | | RMSE | 22.53 | 24.59 |
Paired t-test: T = -6.59, p = 2.15e-09. DistilGPT-2 systematically generated higher female-percentage predictions than GPT-2.
The paired t-test rejects the null and statistically supports the hypothesis. But the absolute numbers tell a quieter story: both models are bad at this task. Pearson correlations of 0.07 and 0.09 mean almost no linear relationship between predicted and actual gender ratios. Both models hover near 50/50 in their raw probabilities and miss the extreme-skew occupations (>80% one gender) almost entirely. Distillation makes the bias worse, but neither model is predictive in a useful sense.
A bias comparison depends on the reference it is measured against. We used real-world gender distributions; an aspirational gender-neutral baseline would give a different reading of the same predictions, so the reference should be chosen deliberately.
Stack
Python, Hugging Face Transformers, GPT-2, DistilGPT-2, paired t-tests, MAPE / RMSE / Pearson correlation.
