AI Evaluation
Purpose
Design an evaluation framework for AI/LLM features, including golden dataset creation, automated scoring rubrics, hallucination detection, and regression testing infrastructure.
Inputs
- AI feature being evaluated (what it does, expected behavior)
- Input data examples and edge cases
- Quality requirements (accuracy thresholds, hallucination tolerance)
- Existing evaluation infrastructure (if any)
- Production monitoring requirements
Process
Step 1: Define Evaluation Dimensions
Identify what "good" means for this feature:
- Correctness: Does the output match the expected answer?
- Faithfulness: Does the output only use information from the provided context?
- Relevance: Does the output answer the actual question asked?
- Completeness: Does the output cover all aspects of the question?
- Format compliance: Does the output match the expected structure?
- Safety: Does the output avoid harmful, biased, or inappropriate content?
Step 2: Build Golden Dataset
Create a high-quality evaluation dataset:
- Size: Minimum 50 examples, ideally 200+ for statistical significance
- Distribution: Cover common cases (60%), edge cases (25%), adversarial cases (15%)
- Labeling: Each example has input, expected output, and scoring criteria
- Source: Real user queries (anonymized) + synthetically generated edge cases
- Versioning: Dataset is version-controlled alongside the code
Step 3: Design Automated Scoring
Create scoring rubrics that can run without human review:
- Exact match: For classification, extraction, or structured output (score: 0 or 1)
- Semantic similarity: Embedding-based comparison of generated vs expected (score: 0-1)
- LLM-as-judge: Use a stronger model to evaluate the output (score: 1-5 rubric)
- Rule-based checks: Required fields present, format valid, no PII leaked
- Composite score: Weighted combination of individual dimensions
Step 4: Design Hallucination Detection
Build specific checks for fabricated content:
- Reference validation: Every cited fact must trace back to a source document
- Entity verification: Named entities (people, dates, numbers) must appear in context
- Confidence calibration: When the model says "I'm not sure," is it actually uncertain?
- Contradiction detection: Does the output contradict the provided context?
- Fabrication patterns: Common hallucination patterns to flag (fake URLs, invented citations)
Step 5: Design Regression Testing
Build a CI/CD-compatible evaluation pipeline:
- Trigger: Run on prompt changes, model upgrades, or code changes affecting AI features
- Threshold enforcement: Fail the build if eval score drops below threshold
- Comparison reporting: Show score delta vs previous version, highlight regressions
- Fast vs full: Quick smoke test (20 examples) for every commit, full eval (200+) for releases
Step 6: Design Production Monitoring
Plan ongoing quality monitoring:
- Sampling: Evaluate X% of production requests against automated scoring
- Feedback loop: User thumbs-up/down, explicit corrections
- Drift detection: Score distribution shift over time (model degradation, data drift)
- Alerting: Score drops below threshold, hallucination rate spikes, latency increases
Output Format
# AI Evaluation Framework
## Evaluation Dimensions
| Dimension | Weight | Scoring Method | Threshold |
|-----------|--------|---------------|-----------|
| Correctness | 40% | LLM-as-judge (1-5) | ≥ 4.0 |
| Faithfulness | 30% | Reference validation | ≥ 95% |
| Relevance | 20% | Semantic similarity | ≥ 0.85 |
| Format compliance | 10% | Rule-based | 100% |
## Golden Dataset
**Size:** [N examples]
**Distribution:**
| Category | Count | Description |
|----------|-------|-------------|
| Common cases | N | [Description] |
| Edge cases | N | [Description] |
| Adversarial | N | [Description] |
**Storage:** [Location in repo]
**Versioning:** [Approach]
## Scoring Rubric
### Correctness (LLM-as-Judge)
| Score | Criteria |
|-------|---------|
| 5 | Perfect — matches expected output in all aspects |
| 4 | Good — minor differences that don't affect usefulness |
| 3 | Acceptable — correct core answer with some issues |
| 2 | Poor — partially correct but missing key information |
| 1 | Wrong — incorrect or misleading answer |
## Hallucination Detection
| Check | Method | Severity |
|-------|--------|----------|
| Reference validation | [Approach] | Critical |
| Entity verification | [Approach] | High |
| Contradiction detection | [Approach] | High |
## Regression Testing Pipeline
[Code change] → [Smoke test (20 examples)] → [Pass?] → [Merge]
[Release] → [Full eval (200+ examples)] → [Pass threshold?] → [Deploy]
**Threshold:** Composite score ≥ [X] to pass
**Reporting:** [Where results are published]
## Production Monitoring
| Metric | Sample Rate | Alert Threshold |
|--------|------------|-----------------|
| Composite score | 5% of requests | < [X] |
| Hallucination rate | 5% of requests | > [X%] |
| User satisfaction | All feedback | < [X] thumbs-up rate |
Quality Checks
Evolution Notes
1---2name: ai-evaluation3department: "oracle"4description: "Golden dataset creation, automated scoring rubrics, and hallucination detection"5version: 16triggers:7 - "eval"8 - "evaluation"9 - "hallucination"10 - "golden dataset"11 - "scoring"12 - "benchmark"13 - "regression"14 - "quality"15 - "accuracy"16---1718# AI Evaluation1920## Purpose2122Design an evaluation framework for AI/LLM features, including golden dataset creation, automated scoring rubrics, hallucination detection, and regression testing infrastructure.2324## Inputs2526- AI feature being evaluated (what it does, expected behavior)27- Input data examples and edge cases28- Quality requirements (accuracy thresholds, hallucination tolerance)29- Existing evaluation infrastructure (if any)30- Production monitoring requirements3132## Process3334### Step 1: Define Evaluation Dimensions3536Identify what "good" means for this feature:37- **Correctness:** Does the output match the expected answer?38- **Faithfulness:** Does the output only use information from the provided context?39- **Relevance:** Does the output answer the actual question asked?40- **Completeness:** Does the output cover all aspects of the question?41- **Format compliance:** Does the output match the expected structure?42- **Safety:** Does the output avoid harmful, biased, or inappropriate content?4344### Step 2: Build Golden Dataset4546Create a high-quality evaluation dataset:47- **Size:** Minimum 50 examples, ideally 200+ for statistical significance48- **Distribution:** Cover common cases (60%), edge cases (25%), adversarial cases (15%)49- **Labeling:** Each example has input, expected output, and scoring criteria50- **Source:** Real user queries (anonymized) + synthetically generated edge cases51- **Versioning:** Dataset is version-controlled alongside the code5253### Step 3: Design Automated Scoring5455Create scoring rubrics that can run without human review:56- **Exact match:** For classification, extraction, or structured output (score: 0 or 1)57- **Semantic similarity:** Embedding-based comparison of generated vs expected (score: 0-1)58- **LLM-as-judge:** Use a stronger model to evaluate the output (score: 1-5 rubric)59- **Rule-based checks:** Required fields present, format valid, no PII leaked60- **Composite score:** Weighted combination of individual dimensions6162### Step 4: Design Hallucination Detection6364Build specific checks for fabricated content:65- **Reference validation:** Every cited fact must trace back to a source document66- **Entity verification:** Named entities (people, dates, numbers) must appear in context67- **Confidence calibration:** When the model says "I'm not sure," is it actually uncertain?68- **Contradiction detection:** Does the output contradict the provided context?69- **Fabrication patterns:** Common hallucination patterns to flag (fake URLs, invented citations)7071### Step 5: Design Regression Testing7273Build a CI/CD-compatible evaluation pipeline:74- **Trigger:** Run on prompt changes, model upgrades, or code changes affecting AI features75- **Threshold enforcement:** Fail the build if eval score drops below threshold76- **Comparison reporting:** Show score delta vs previous version, highlight regressions77- **Fast vs full:** Quick smoke test (20 examples) for every commit, full eval (200+) for releases7879### Step 6: Design Production Monitoring8081Plan ongoing quality monitoring:82- **Sampling:** Evaluate X% of production requests against automated scoring83- **Feedback loop:** User thumbs-up/down, explicit corrections84- **Drift detection:** Score distribution shift over time (model degradation, data drift)85- **Alerting:** Score drops below threshold, hallucination rate spikes, latency increases8687## Output Format8889```markdown90# AI Evaluation Framework9192## Evaluation Dimensions93| Dimension | Weight | Scoring Method | Threshold |94|-----------|--------|---------------|-----------|95| Correctness | 40% | LLM-as-judge (1-5) | ≥ 4.0 |96| Faithfulness | 30% | Reference validation | ≥ 95% |97| Relevance | 20% | Semantic similarity | ≥ 0.85 |98| Format compliance | 10% | Rule-based | 100% |99100## Golden Dataset101**Size:** [N examples]102**Distribution:**103| Category | Count | Description |104|----------|-------|-------------|105| Common cases | N | [Description] |106| Edge cases | N | [Description] |107| Adversarial | N | [Description] |108109**Storage:** [Location in repo]110**Versioning:** [Approach]111112## Scoring Rubric113### Correctness (LLM-as-Judge)114| Score | Criteria |115|-------|---------|116| 5 | Perfect — matches expected output in all aspects |117| 4 | Good — minor differences that don't affect usefulness |118| 3 | Acceptable — correct core answer with some issues |119| 2 | Poor — partially correct but missing key information |120| 1 | Wrong — incorrect or misleading answer |121122## Hallucination Detection123| Check | Method | Severity |124|-------|--------|----------|125| Reference validation | [Approach] | Critical |126| Entity verification | [Approach] | High |127| Contradiction detection | [Approach] | High |128129## Regression Testing Pipeline130```131[Code change] → [Smoke test (20 examples)] → [Pass?] → [Merge]132[Release] → [Full eval (200+ examples)] → [Pass threshold?] → [Deploy]133```134135**Threshold:** Composite score ≥ [X] to pass136**Reporting:** [Where results are published]137138## Production Monitoring139| Metric | Sample Rate | Alert Threshold |140|--------|------------|-----------------|141| Composite score | 5% of requests | < [X] |142| Hallucination rate | 5% of requests | > [X%] |143| User satisfaction | All feedback | < [X] thumbs-up rate |144```145146## Quality Checks147148- [ ] Golden dataset has at least 50 examples covering common and edge cases149- [ ] Scoring rubric has clear criteria for each score level (not subjective)150- [ ] Hallucination detection checks references against source documents151- [ ] Regression testing is automated and blocks deploys on score drops152- [ ] Production monitoring includes both automated scoring and user feedback153- [ ] Eval dataset is version-controlled alongside the code154155## Evolution Notes156<!-- Observations appended after each use -->