Chapter 36: Bias and Safety Evaluations
A fairness or safety claim is only as good as its measurement. This chapter builds the measurements. Bias is measured as a difference: the same prompt template with only a group term changed, scored on the same metric, with a confidence interval on the gap. Safety evals need a scorer you trust, which means a deterministic one (a lexicon, a classifier with known precision) before an LLM judge. Small models fail differently, not less: a 10M-parameter story model will not produce dangerous instructions, but it will reproduce stereotypes from its corpus, so you measure what your model can actually do. And an eval is a test: fixed prompts, fixed seeds, a threshold, and a place in the release gate.
Concepts from other sections (9)
This section uses these ideas. Each has a short definition and a link to the section that explains it in full. Tap a dotted term in the text to preview it.
- Confidence interval: a procedure that, over repeated samples, produces intervals covering the fixed true parameter at the stated rate. Read more: 13.11 Probability problem set, part c: limit theorems and confidence intervals in Mathematics
- LLM judge: a language model used as a scorer, treated as a noisy instrument whose malformed replies are missing readings. Read more: 29.3 LLM judge with position control
- Release gate: a check that passes a row only when its interval bound clears the limit, and fails missing rows. Read more: 36.1 Bias and safety evals
- Wilson interval: a confidence interval for a rate obtained by inverting the score test, honest at zero events and small . Read more: 36.1 Bias and safety evals
- Model card: the model’s interface documentation: details, intended and out-of-scope use, evaluation with uncertainty, limitations, and data. Read more: 35.1 Datasheet and model card
- Bias gap: the mean paired difference over templates and pairs, with a bootstrap interval over the pairs. Read more: 36.1 Bias and safety evals
- Over-refusal rate: the share of benign prompts the model refuses, the guard against passing by refusing everything. Read more: 36.1 Bias and safety evals
- Average precision: the step sum over decreasing thresholds. Read more: 36.1 Bias and safety evals
- Stereotype preference: the share of non-tied sentence pairs in which the stereotypical sentence scores higher; 0.5 is no preference. Read more: 36.1 Bias and safety evals
The chapter’s single section, Bias and safety evals, is a build. You write paired-template bias evals and a toxicity scorer in Python, compute Wilson intervals for every rate and bootstrap intervals for every gap, run them through EvalSuite, gate the release on interval bounds, and hand the rows to the model card. Running the suite on every release candidate turns a one-time audit into a regression test.
Learning objectives
- Measure a bias gap as a paired counterfactual difference with a bootstrap interval, and name the confounds (length, frequency) it cannot separate.
- Report toxicity, refusal, and over-refusal rates with Wilson intervals from a seeded generator.
- Build a noisy-OR lexicon scorer and measure its ROC-AUC and average precision on labelled data.
- Gate a release on interval bounds, failing any missing row.
Before you begin
Section titled “Before you begin”You need the model evaluation harness from The evaluation harness and the model zoo in AI Engineering, the confidence intervals and paired tests of Probability & Statistics in Mathematics, and the model card from Model and Data Cards, where these numbers are reported. Reading BBQ and RealToxicityPrompts, then the HELM sections on bias and toxicity metrics, is good preparation.
In this chapter
Section titled “In this chapter”- Bias and safety evals: paired templates and the bias gap, stereotype preference, Wilson intervals, a noisy-OR toxicity scorer and how to measure it, seeded safety rates, and a release gate that decides on evidence, with an annotated walkthrough of the full solution.
For eval runners, judges, and A/B experiments at platform scale, see LLM Evaluation in AI Engineering. What you do about the failures these evals find is the subject of the next chapter, Usage Policy.
Further reading
Section titled “Further reading”- Parrish et al., BBQ: A Hand-Built Bias Benchmark for Question Answering (free).
- Gehman et al., RealToxicityPrompts (free).
- Liang et al., Holistic Evaluation of Language Models (HELM) (free).
- Nangia et al., CrowS-Pairs (free).
- Weidinger et al., Ethical and social risks of harm from Language Models (free).