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-evaluation3description: Golden dataset creation, automated scoring rubrics, and hallucination detection4---56# AI Evaluation78## Purpose910Design an evaluation framework for AI/LLM features, including golden dataset creation, automated scoring rubrics, hallucination detection, and regression testing infrastructure.1112## Inputs1314- AI feature being evaluated (what it does, expected behavior)15- Input data examples and edge cases16- Quality requirements (accuracy thresholds, hallucination tolerance)17- Existing evaluation infrastructure (if any)18- Production monitoring requirements1920## Process2122### Step 1: Define Evaluation Dimensions2324Identify what "good" means for this feature:25- **Correctness:** Does the output match the expected answer?26- **Faithfulness:** Does the output only use information from the provided context?27- **Relevance:** Does the output answer the actual question asked?28- **Completeness:** Does the output cover all aspects of the question?29- **Format compliance:** Does the output match the expected structure?30- **Safety:** Does the output avoid harmful, biased, or inappropriate content?3132### Step 2: Build Golden Dataset3334Create a high-quality evaluation dataset:35- **Size:** Minimum 50 examples, ideally 200+ for statistical significance36- **Distribution:** Cover common cases (60%), edge cases (25%), adversarial cases (15%)37- **Labeling:** Each example has input, expected output, and scoring criteria38- **Source:** Real user queries (anonymized) + synthetically generated edge cases39- **Versioning:** Dataset is version-controlled alongside the code4041### Step 3: Design Automated Scoring4243Create scoring rubrics that can run without human review:44- **Exact match:** For classification, extraction, or structured output (score: 0 or 1)45- **Semantic similarity:** Embedding-based comparison of generated vs expected (score: 0-1)46- **LLM-as-judge:** Use a stronger model to evaluate the output (score: 1-5 rubric)47- **Rule-based checks:** Required fields present, format valid, no PII leaked48- **Composite score:** Weighted combination of individual dimensions4950### Step 4: Design Hallucination Detection5152Build specific checks for fabricated content:53- **Reference validation:** Every cited fact must trace back to a source document54- **Entity verification:** Named entities (people, dates, numbers) must appear in context55- **Confidence calibration:** When the model says "I'm not sure," is it actually uncertain?56- **Contradiction detection:** Does the output contradict the provided context?57- **Fabrication patterns:** Common hallucination patterns to flag (fake URLs, invented citations)5859### Step 5: Design Regression Testing6061Build a CI/CD-compatible evaluation pipeline:62- **Trigger:** Run on prompt changes, model upgrades, or code changes affecting AI features63- **Threshold enforcement:** Fail the build if eval score drops below threshold64- **Comparison reporting:** Show score delta vs previous version, highlight regressions65- **Fast vs full:** Quick smoke test (20 examples) for every commit, full eval (200+) for releases6667### Step 6: Design Production Monitoring6869Plan ongoing quality monitoring:70- **Sampling:** Evaluate X% of production requests against automated scoring71- **Feedback loop:** User thumbs-up/down, explicit corrections72- **Drift detection:** Score distribution shift over time (model degradation, data drift)73- **Alerting:** Score drops below threshold, hallucination rate spikes, latency increases7475## Output Format7677```markdown78# AI Evaluation Framework7980## Evaluation Dimensions81| Dimension | Weight | Scoring Method | Threshold |82|-----------|--------|---------------|-----------|83| Correctness | 40% | LLM-as-judge (1-5) | ≥ 4.0 |84| Faithfulness | 30% | Reference validation | ≥ 95% |85| Relevance | 20% | Semantic similarity | ≥ 0.85 |86| Format compliance | 10% | Rule-based | 100% |8788## Golden Dataset89**Size:** [N examples]90**Distribution:**91| Category | Count | Description |92|----------|-------|-------------|93| Common cases | N | [Description] |94| Edge cases | N | [Description] |95| Adversarial | N | [Description] |9697**Storage:** [Location in repo]98**Versioning:** [Approach]99100## Scoring Rubric101### Correctness (LLM-as-Judge)102| Score | Criteria |103|-------|---------|104| 5 | Perfect — matches expected output in all aspects |105| 4 | Good — minor differences that don't affect usefulness |106| 3 | Acceptable — correct core answer with some issues |107| 2 | Poor — partially correct but missing key information |108| 1 | Wrong — incorrect or misleading answer |109110## Hallucination Detection111| Check | Method | Severity |112|-------|--------|----------|113| Reference validation | [Approach] | Critical |114| Entity verification | [Approach] | High |115| Contradiction detection | [Approach] | High |116117## Regression Testing Pipeline118```119[Code change] → [Smoke test (20 examples)] → [Pass?] → [Merge]120[Release] → [Full eval (200+ examples)] → [Pass threshold?] → [Deploy]121```122123**Threshold:** Composite score ≥ [X] to pass124**Reporting:** [Where results are published]125126## Production Monitoring127| Metric | Sample Rate | Alert Threshold |128|--------|------------|-----------------|129| Composite score | 5% of requests | < [X] |130| Hallucination rate | 5% of requests | > [X%] |131| User satisfaction | All feedback | < [X] thumbs-up rate |132```133134## Quality Checks135136- [ ] Golden dataset has at least 50 examples covering common and edge cases137- [ ] Scoring rubric has clear criteria for each score level (not subjective)138- [ ] Hallucination detection checks references against source documents139- [ ] Regression testing is automated and blocks deploys on score drops140- [ ] Production monitoring includes both automated scoring and user feedback141- [ ] Eval dataset is version-controlled alongside the code142143## Evolution Notes144<!-- Observations appended after each use -->