Chapter 3: Testing and Evaluation
Quality Metricsβ
| Metric | What It Measures | How to Evaluate |
|---|---|---|
| Accuracy | Factual correctness | Manual verification |
| Relevance | On-topic responses | Rubric scoring |
| Completeness | All requirements met | Checklist |
| Consistency | Same quality across runs | Multiple tests |
| Format compliance | Matches requirements | Pattern matching |
Creating Test Casesβ
Test Suite: Customer Support Prompt
Test Case 1: Simple inquiry
Input: "What are your business hours?"
Expected: Direct answer with hours
Test Case 2: Complaint
Input: "Your product broke after one week!"
Expected: Empathetic response + solution options
Test Case 3: Edge case - multiple issues
Input: "Wrong item sent AND it was damaged AND late"
Expected: Address all three issues systematically
Automated Evaluationβ
For scale, automate what you can:
Automated Checks:
- [ ] Response length within bounds
- [ ] Contains required sections
- [ ] No forbidden words
- [ ] JSON/format validity
- [ ] Sentiment matches expectation
Manual Review:
- Quality of reasoning
- Appropriateness of tone
- Accuracy of specific claims
Scoring Rubricsβ
Content Quality (1-5):
5 - Exceptional, exceeds requirements
4 - Good, meets all requirements
3 - Acceptable, meets most requirements
2 - Poor, significant gaps
1 - Unacceptable, doesn't address task
Format Compliance (Pass/Fail):
- Correct structure
- Within length limits
- Required elements present
Human Evaluationβ
For nuanced quality, use human reviewers:
Reviewer Guidelines:
1. Read the original prompt
2. Review the AI output
3. Score on: Accuracy, Relevance, Tone, Completeness
4. Note specific issues
5. Suggest improvements
Key Takeawaysβ
Summary
- Define metrics before testing
- Create diverse test cases including edge cases
- Automate format/structure checks
- Use rubrics for consistency
- Human review for nuanced quality