Cyber Intelligence
AI Red Teaming · Offensive testing

L18. AI Evaluation Frameworks: Metrics & Defect Rates

Course outlineLesson 18 of 21

AI security requires measurable outcomes. Evaluation frameworks translate subjective safety and security goals into quantitative metrics that can drive go/no-go deployment decisions and track improvement over time.

Why Metrics Matter

"The AI is safe" is not a deployable statement. "The AI produces harmful output on fewer than 3% of adversarial inputs in the violence category, measured against our evaluation set of 5,000 inputs" is a deployable statement.

Evaluation frameworks create the measurement infrastructure that turns AI security from an art into an engineering discipline.

Defect Rate as the Core Metric

The defect rate for a given harm category is the fraction of test inputs in that category that produced a policy-violating output:

defect_rate = policy_violating_outputs / total_inputs_in_category

Microsoft's Azure AI Foundry Evaluation framework, NIST's ARIA program, and Anthropic's internal evaluations all use variants of this metric. Common target thresholds before production deployment:

Harm CategoryTarget Defect Rate
Direct violence / weapons< 1%
Hate speech / discrimination< 2%
Privacy disclosure (PII)< 1%
Prompt injection success rate< 5%
Off-topic content (for focused tools)< 10%
These thresholds should be defined by the organization before testing begins and tied to the deployment's specific risk profile. A children's education platform needs stricter thresholds than an internal developer tool.

Building an Evaluation Set

An evaluation set is a curated collection of test inputs with expected outputs (or expected output classifications). For AI security:

  • Size: minimum 200-500 inputs per harm category for statistical reliability; 1,000+ for high-stakes deployments
  • Diversity: inputs should vary in framing, language, complexity, and attack technique
  • Ground truth: each input should have a clear expected classification (safe / policy-violating)
  • Independence: the evaluation set must not overlap with the training or fine-tuning data
Evaluation set maintenance:
  • Refresh periodically as new attack techniques emerge
  • Add found jailbreaks from red team exercises
  • Version the evaluation set alongside model versions

Automated Evaluation Pipelines

Running evaluations manually does not scale. An automated evaluation pipeline:

  1. Triggers on model updates, system prompt changes, or on a defined schedule
  2. Runs the full evaluation set against the current model configuration
  3. Calculates defect rates per harm category
  4. Compares to defined thresholds and previous baseline
  5. Blocks deployment if thresholds are exceeded; alerts on regression from previous baseline
  6. Stores results in a versioned evaluation history for audit

Evaluation Limitations

No evaluation framework provides complete coverage. Key limitations:

  • Evaluation sets capture known attack patterns; novel attacks are not in the set
  • Automated judges (using another LLM to classify outputs) introduce their own error rates
  • Real-world distribution of user inputs differs from curated evaluation inputs
  • Defect rates on the evaluation set may not accurately predict defect rates in production
Exam Focus Points
  • Defect rate = policy-violating outputs / total inputs in category; define thresholds before testing, not after seeing results
  • Evaluation set minimum: 200-500 inputs per harm category for statistical reliability; must not overlap with training data
  • Automated evaluation pipelines trigger on model updates and system prompt changes, blocking deployment if thresholds are exceeded
  • Evaluation set must be versioned alongside model versions and refreshed as new attack techniques emerge
  • Key limitation: evaluation sets capture known patterns; novel attacks and real-world input distribution are not fully represented
Knowledge Check

1. Why should defect rate thresholds be defined before testing begins, not after seeing results?

2. What is the primary risk of using another LLM as an automated judge to classify evaluation outputs?

Recommended: Pluralsight

Pluralsight's AI security courses cover threat modeling, governance, and practical red teaming for AI systems to complement what you learn here.

Explore AI security courses10-day free trial available