Skip to content

Ch 22: AI Safety & Alignment - Advanced

Track: Advanced | Try code in Playground | Back to chapter overview

Read online or run locally

You can read this content here on the web. To run the code interactively, either use the Playground or clone the repo and open chapters/chapter-22-ai-safety-and-alignment/notebooks/03_fairness_and_redteam.ipynb in Jupyter.


Chapter 22: AI Safety & Alignment — Notebook 03 (Fairness & Red-Teaming)

Two more measurable safety tools: fairness metrics that quantify disparate treatment, and a red-team harness that actively hunts for failures.

What you'll learn

Topic Section
Demographic parity difference §1
Disparate impact and the four-fifths rule §2
Red-teaming with a judge §3

Time estimate: 2.5 hours


Key concepts

  • Demographic parity — equal positive rates across groups.
  • Disparate impact — the ratio of group rates; below 0.8 is a legal red flag.
  • Red-teaming — adversarial probing to surface failures before users do.
  • No single metric — fairness definitions can conflict; pick deliberately.

Demographic parity and disparate impact quantify fairness; red-teaming actively surfaces failures. Each turns a safety principle into a trackable number — the prerequisite for improving it.

Run the full notebook in the chapter folder for code and outputs.


Generated by Berta AI