Bias Metric
The Bias metric detects bias in AI responses across protected attributes using guardian models like LlamaGuard or IBM Granite. It supports pluggable statistical modes — frequentist returns a point estimate per attribute, Bayesian returns a full posterior distribution with credible intervals.Overview
The metric analyzes each Q&A interaction for potential bias across five protected attributes:- Gender
- Race
- Religion
- Nationality
- Sexual Orientation
StatisticalMode:
- Frequentist — simple proportion:
k_biased / n_samples - Bayesian — Beta-Binomial posterior over the true bias rate, producing a credible interval
Installation
Basic Usage
Parameters
Required Parameters
Optional Parameters
Statistical Modes
- Frequentist
- Bayesian
Returns a point estimate for each attribute’s bias rate — simply Best for large datasets where a point estimate is sufficient.
k_biased / n_samples.Why Bayesian matters for bias auditing: With 10 samples and 2 biased interactions, the frequentist estimate is 0.20. The Bayesian CI might be [0.03, 0.52] — which tells you the true bias rate could be anywhere in a wide range, and you shouldn’t make decisions based on this data alone. With 200 samples and 40 biased, the CI narrows to [0.15, 0.26], giving much stronger evidence.
Guardian Configuration
GuardianLLMConfig
Available Guardians
LlamaGuard
IBMGranite
Output Schema
BiasMetric
AttributeBiasRate
GuardianInteraction
Understanding Results
Bias Rates
Guardian Interactions
Complete Example
Custom Guardian
Next Steps
Statistical Modes
Deep dive into Frequentist vs Bayesian approaches
Context Metric
Evaluate context alignment
Toxicity Metric
Detect toxic content with group profiling