LLM Evaluation
Bias and Fairness in LLMs
LLMs inherit and amplify societal biases present in their training data. Understanding, measuring, and mitigating these biases is essential for responsible deployment.
- Sources β Training data, annotation, algorithmic amplification
- Measurement β StereoSet, CrowS-Pairs, BBQ benchmarks
- Mitigation β Data curation, fine-tuning, prompting, and decoding
Fairness is not an act of kindnessβit is an act of justice.
Bias and Fairness in LLMs
LLMs inherit and amplify societal biases present in their training data. Understanding, measuring, and mitigating these biases is essential for responsible deployment across all applications.
Sources of Bias
1. Training Data Bias
The most fundamental source: the training corpus reflects historical and societal biases.
2. Annotation Bias
Human annotators bring their own biases when creating training data for instruction tuning or RLHF.
3. Algorithmic Amplification
Training objectives and architectural choices can amplify small data biases into large output biases.
Types of Bias in Detail
Understanding the different forms bias takes is essential for effective mitigation:
How Bias Manifests in LLMs
Bias can appear at multiple stages of the LLM pipeline:
- Data collection: Web crawls overrepresent certain demographics and viewpoints
- Pretraining: The model learns statistical associations from biased data
- Alignment/RLHF: Human raters may have systematic biases in preference data
- Deployment: Users may use outputs in ways that amplify existing biases
Measuring Bias
Benchmark-Based Evaluation
Several standardized benchmarks exist for measuring social bias:
| Benchmark | Approach | Bias Categories | Method |
|---|---|---|---|
| StereoSet | Sentence completion | Gender, race, religion, profession | Probability comparison |
| CrowS-Pairs | Sentence pairs | 9 categories | Relative likelihood |
| BBQ | Question answering | Ambiguous/disambiguated contexts | Accuracy parity |
| WinoBias | Coreference | Gender, occupation | Winograd schema |
| BBQ-Civil | QA | Intersectional | Context manipulation |
Counterfactual Evaluation
The counterfactual method measures bias by comparing outputs when demographic attributes are swapped:
Debiasing Techniques
Data-Level Debiasing
- Resampling: Balance representation of demographic groups
- Data augmentation: Generate counterfactual examples
- Toxicity filtering: Remove explicitly biased content
Training-Level Debiasing
The adversarial component encourages the model to produce outputs from which the demographic attribute cannot be predictedβenforcing demographic parity.
Inference-Level Debiasing
- Prompt-based debiasing: Instruct the model to be fair and unbiased
- Constrained decoding: Block stereotypical token sequences
- Output filtering: Post-hoc filtering of biased outputs
Fairness Metrics
| Metric | Definition | Property |
|---|---|---|
| Demographic Parity | P(Ε·=1 | g=0) = P(Ε·=1 | g=1) | Independence |
| Equalized Odds | P(Ε·=1 | g, y=1) equal across g | Separation |
| Predictive Parity | P(y=1 | Ε·=1, g) equal across g | Sufficiency |
| Counterfactual Fairness | P(Ε· | do(g=0)) = P(Ε· | do(g=1)) | Invariance |
Practice Exercises
-
Conceptual: Explain why equalized odds and demographic parity can conflict. Give a concrete example where satisfying one necessarily violates the other.
-
Mathematical: Given a model that predicts "doctor" with probability 0.8 for men and 0.3 for women in a template completion task, compute the counterfactual token bias. Is this model biased?
-
Practical: Using the StereoSet dataset, evaluate a small LLM's implicit bias across the four categories. Which category shows the most bias?
-
Research: Compare the effectiveness of data-level debiasing vs. inference-level debiasing. What are the tradeoffs in terms of bias reduction and capability preservation?
What to Learn Next
-> Hallucination Detection and Mitigation Detecting and reducing factual errors in LLM outputs.
-> LLM Safety and Red Teaming Systematic adversarial testing for safety vulnerabilities.
-> Constitutional AI Training models with explicit behavioral principles.
-> RLHF and Alignment Aligning language models with human preferences and values.
-> LLM Benchmarking Suites Comprehensive benchmarks including bias evaluation.
-> Copyright and Legal Issues Legal frameworks governing AI fairness and discrimination.
Extended Learning: Beyond the Basics
Key Concepts Summary
This lesson covers fundamental concepts that serve as building blocks for more advanced topics. Master these basics before moving to intermediate and advanced material.
Prerequisite Knowledge
Before studying this topic in depth, ensure you understand:
- Basic definitions and terminology
- Core formulas and their derivations
- Common applications in real-world scenarios
- Typical pitfalls and misconceptions
Step-by-Step Walkthrough
Let us work through a complete example to solidify understanding:
Step 1: Identify the problem type. Determine which category this problem falls into and which approach is most appropriate.
Step 2: Apply the relevant formula. Substitute known values into the appropriate equation, paying attention to units and constraints.
Step 3: Simplify and solve. Work through the algebra step by step, checking each intermediate result.
Step 4: Verify the answer. Check that the solution satisfies the original conditions and makes logical sense.
Common Mistakes to Avoid
- Misidentifying the problem type β Always start by categorizing the problem
- Incorrect formula application β Verify the formula applies to your specific case
- Unit errors β Always check units are consistent throughout
- Sign errors β Pay careful attention to positive and negative values
- Rounding too early β Keep full precision until the final answer
- Forgetting constraints β Check that solutions satisfy all given conditions
Real-World Applications
Understanding this concept is essential for:
- Advanced problem solving in examinations
- Building intuition for more complex topics
- Developing analytical thinking skills
- Applying mathematical reasoning to practical situations
Practice Exercises
- Basic: Solve 5 problems of increasing difficulty using the core concept.
- Intermediate: Apply the concept to word problems with multiple steps.
- Advanced: Combine this concept with 2-3 other topics in a comprehensive problem.
- Challenge: Create your own problem that requires this concept plus additional knowledge.
Interview and Exam Tips
- Common question patterns: Identify which exam or interview formats test this topic
- Time management: Practice completing problems within time constraints
- Common traps: Know the typical mistakes examiners set as distractors
- Verification strategy: Develop a quick method to check your answer
Related Topics
- Previous Topic β Build on the foundation laid here
- Next Topic β See how this concept extends to more advanced material
- Practice Problems β Additional exercises with solutions
- Video Explanation β Visual walkthrough of key concepts
Quick Reference Card
| Concept | Formula/Rule | Key Insight | Common Use |
|---|---|---|---|
| Core Definition | See main text | Understand the intuition | Foundation for all applications |
| Key Formula | See main text | Memorize the derivation | Direct problem solving |
| Special Case | See main text | Recognize when it applies | Simplifies complex problems |
| Edge Case | See main text | Know the limitations | Avoids errors |
Further Reading
For students who want to go deeper:
- Standard textbooks on the subject
- Research papers applying this concept
- Online courses with video explanations
- Practice problem collections with detailed solutions