LLM Evaluation Harness
Build automated evaluation pipelines for LLM applications with benchmarks, regression tests, RAG evaluation (RAGAS), and human eval workflows.
Activation Triggers
Activate on: "evaluate LLM", "benchmark model", "regression test AI", "RAGAS evaluation", "eval pipeline", "LLM quality metrics", "compare model versions", "human evaluation workflow", "test AI responses"
NOT for: Traditional unit/integration testing (testing-expert), model training loops (ai-engineer), or prompt writing (prompt-engineer)
Quick Start
- Define eval dimensions — Correctness, faithfulness, relevance, coherence, safety. Pick the 2-3 that matter most for your use case.
- Build eval dataset — 50-200 curated test cases with expected outputs or rubrics. Include edge cases and adversarial inputs.
- Choose eval methods — LLM-as-judge for scalable scoring, exact-match for structured outputs, RAGAS for RAG systems, human eval for nuance.
- Automate in CI — Run evals on every prompt change, model upgrade, or pipeline modification. Fail the build if scores regress.
- Track trends — Store eval results over time. A 2% quality drop per release compounds into a 20% drop over 10 releases.
Core Capabilities
| Domain |
Technologies |
Notes |
| RAG Evaluation |
RAGAS, DeepEval, custom |
Faithfulness, answer relevance, context precision |
| LLM-as-Judge |
Claude, GPT-4o, Llama 3.1 as evaluators |
Rubric-based scoring with calibration |
| Exact Match |
Regex, JSON schema validation, string match |
For structured outputs: classification, extraction |
| Human Eval |
Argilla, Label Studio, custom UI |
Gold-standard quality, expensive, slow |
| Benchmarks |
MMLU, HumanEval, custom domain benchmarks |
Standardized comparison across models |
| CI Integration |
GitHub Actions, pytest, Vitest |
Eval-as-tests with pass/fail thresholds |
Architecture Patterns
Pattern 1: Multi-Method Evaluation Pipeline
Eval Dataset (N test cases)
│
├──→ [Exact Match] ──→ Precision/Recall/F1 (for structured outputs)
│
├──→ [LLM-as-Judge] ──→ Rubric scores 1-5 per dimension
│ │
│ └── Calibrate: run judge on 20 pre-scored examples first
│
├──→ [RAGAS] ──→ Faithfulness, Answer Relevance, Context Precision
│ │
│ └── For RAG systems only; measures retrieval + generation quality
│
└──→ [Human Eval] ──→ Gold-standard labels (sample 10-20%)
│
└── Use for calibrating LLM-as-judge, not as primary method
All results ──→ [Score Aggregation] ──→ [Trend Tracker] ──→ [CI Gate]
# LLM-as-judge evaluation
import json
JUDGE_RUBRIC = """
Score the following response on a scale of 1-5 for each dimension:
- **Correctness** (1-5): Is the information factually accurate?
- **Completeness** (1-5): Does it address all parts of the question?
- **Clarity** (1-5): Is it well-organized and easy to understand?
Question: {question}
Expected: {expected}
Response: {response}
Return JSON: {{"correctness": N, "completeness": N, "clarity": N, "reasoning": "..."}}
"""
async def evaluate_with_judge(test_cases: list[dict], model_output_fn) -> dict:
results = []
for case in test_cases:
response = await model_output_fn(case["question"])
judge_prompt = JUDGE_RUBRIC.format(
question=case["question"],
expected=case["expected"],
response=response
)
scores = await llm_call(judge_prompt, model="claude-sonnet-4-20250514", temperature=0)
results.append(json.loads(scores))
# Aggregate
return {
dim: sum(r[dim] for r in results) / len(results)
for dim in ["correctness", "completeness", "clarity"]
}
Pattern 2: RAG Evaluation with RAGAS
Test Case: (question, ground_truth, retrieved_contexts)
│
├──→ Faithfulness: Is the answer supported by retrieved contexts?
│ Score = (claims supported by context) / (total claims in answer)
│
├──→ Answer Relevance: Does the answer address the question?
│ Score = cosine_sim(question, generated_questions_from_answer)
│
├──→ Context Precision: Are relevant contexts ranked higher?
│ Score = weighted precision of relevant contexts in top-k
│
└──→ Context Recall: Were all ground-truth facts retrievable?
Score = (ground_truth_claims in contexts) / (total ground_truth_claims)
# RAGAS evaluation
from ragas import evaluate
from ragas.metrics import faithfulness, answer_relevancy, context_precision
from datasets import Dataset
eval_dataset = Dataset.from_dict({
"question": questions,
"answer": generated_answers,
"contexts": retrieved_contexts,
"ground_truth": expected_answers,
})
result = evaluate(eval_dataset, metrics=[
faithfulness, answer_relevancy, context_precision
])
print(result) # {'faithfulness': 0.87, 'answer_relevancy': 0.92, ...}
Pattern 3: CI Regression Gate
On PR / prompt change:
│
▼
[Run eval suite] ──→ scores
│
▼
[Compare to baseline]
├── Score >= baseline - tolerance (2%) ──→ PASS (merge allowed)
└── Score < baseline - tolerance ──→ FAIL (block merge)
│
└── Report: which test cases regressed, by how much
Anti-Patterns
- Evaluating without a baseline — A score of 4.2/5 means nothing without knowing the previous score was 4.5. Always track baselines and trends.
- LLM-as-judge without calibration — Judges have biases (verbosity preference, position bias). Calibrate on 20+ pre-scored examples and check inter-rater agreement.
- Too few test cases — 10 test cases produce noisy metrics. Target 50+ for reliable averages, 200+ for statistical confidence on sub-dimensions.
- Evaluating only happy paths — Include adversarial inputs, edge cases, ambiguous questions, and out-of-scope queries. The model should fail gracefully.
- Manual eval as the only method — Human evaluation is expensive and slow. Use it to calibrate automated methods, then run automated evals in CI.
Quality Checklist
1---
2license: Apache-2.0
3name: llm-evaluation-harness
4description: "Build automated LLM evaluation pipelines with benchmarks, regression tests, RAGAS, and human eval workflows. Activate on: LLM evaluation, benchmark testing, eval pipeline, RAGAS, model regression tests. NOT for: traditional software testing (testing-expert), model training (ai-engineer)."
5allowed-tools: Read,Write,Edit,Bash(python:*,pip:*,npm:*,npx:*)
6category: AI & Machine Learning
7tags:
8 - evaluation
9 - benchmarks
10 - ragas
11 - llm-testing
12 - regression
13pairs-with:
14 - skill: ai-engineer
15 reason: Evaluation validates LLM application quality before deployment
16 - skill: prompt-template-manager
17 reason: A/B test results feed into prompt version promotion decisions
18 - skill: fine-tuning-dataset-curator
19 reason: Eval sets curated alongside training data measure fine-tune effectiveness
20metadata:
21 source: https://skillmd.com/skills/curiositech/llm-evaluation-harness
22---
23
24# LLM Evaluation Harness
25
26Build automated evaluation pipelines for LLM applications with benchmarks, regression tests, RAG evaluation (RAGAS), and human eval workflows.
27
28## Activation Triggers
29
30**Activate on**: "evaluate LLM", "benchmark model", "regression test AI", "RAGAS evaluation", "eval pipeline", "LLM quality metrics", "compare model versions", "human evaluation workflow", "test AI responses"
31
32**NOT for**: Traditional unit/integration testing (testing-expert), model training loops (ai-engineer), or prompt writing (prompt-engineer)
33
34## Quick Start
35
361. **Define eval dimensions** — Correctness, faithfulness, relevance, coherence, safety. Pick the 2-3 that matter most for your use case.
372. **Build eval dataset** — 50-200 curated test cases with expected outputs or rubrics. Include edge cases and adversarial inputs.
383. **Choose eval methods** — LLM-as-judge for scalable scoring, exact-match for structured outputs, RAGAS for RAG systems, human eval for nuance.
394. **Automate in CI** — Run evals on every prompt change, model upgrade, or pipeline modification. Fail the build if scores regress.
405. **Track trends** — Store eval results over time. A 2% quality drop per release compounds into a 20% drop over 10 releases.
41
42## Core Capabilities
43
44| Domain | Technologies | Notes |
45|--------|-------------|-------|
46| **RAG Evaluation** | RAGAS, DeepEval, custom | Faithfulness, answer relevance, context precision |
47| **LLM-as-Judge** | Claude, GPT-4o, Llama 3.1 as evaluators | Rubric-based scoring with calibration |
48| **Exact Match** | Regex, JSON schema validation, string match | For structured outputs: classification, extraction |
49| **Human Eval** | Argilla, Label Studio, custom UI | Gold-standard quality, expensive, slow |
50| **Benchmarks** | MMLU, HumanEval, custom domain benchmarks | Standardized comparison across models |
51| **CI Integration** | GitHub Actions, pytest, Vitest | Eval-as-tests with pass/fail thresholds |
52
53## Architecture Patterns
54
55### Pattern 1: Multi-Method Evaluation Pipeline
56
57```
58Eval Dataset (N test cases)
59 │
60 ├──→ [Exact Match] ──→ Precision/Recall/F1 (for structured outputs)
61 │
62 ├──→ [LLM-as-Judge] ──→ Rubric scores 1-5 per dimension
63 │ │
64 │ └── Calibrate: run judge on 20 pre-scored examples first
65 │
66 ├──→ [RAGAS] ──→ Faithfulness, Answer Relevance, Context Precision
67 │ │
68 │ └── For RAG systems only; measures retrieval + generation quality
69 │
70 └──→ [Human Eval] ──→ Gold-standard labels (sample 10-20%)
71 │
72 └── Use for calibrating LLM-as-judge, not as primary method
73
74All results ──→ [Score Aggregation] ──→ [Trend Tracker] ──→ [CI Gate]
75```
76
77```python
78# LLM-as-judge evaluation
79import json
80
81JUDGE_RUBRIC = """
82Score the following response on a scale of 1-5 for each dimension:
83
84- **Correctness** (1-5): Is the information factually accurate?
85- **Completeness** (1-5): Does it address all parts of the question?
86- **Clarity** (1-5): Is it well-organized and easy to understand?
87
88Question: {question}
89Expected: {expected}
90Response: {response}
91
92Return JSON: {{"correctness": N, "completeness": N, "clarity": N, "reasoning": "..."}}
93"""
94
95async def evaluate_with_judge(test_cases: list[dict], model_output_fn) -> dict:
96 results = []
97 for case in test_cases:
98 response = await model_output_fn(case["question"])
99 judge_prompt = JUDGE_RUBRIC.format(
100 question=case["question"],
101 expected=case["expected"],
102 response=response
103 )
104 scores = await llm_call(judge_prompt, model="claude-sonnet-4-20250514", temperature=0)
105 results.append(json.loads(scores))
106
107 # Aggregate
108 return {
109 dim: sum(r[dim] for r in results) / len(results)
110 for dim in ["correctness", "completeness", "clarity"]
111 }
112```
113
114### Pattern 2: RAG Evaluation with RAGAS
115
116```
117Test Case: (question, ground_truth, retrieved_contexts)
118 │
119 ├──→ Faithfulness: Is the answer supported by retrieved contexts?
120 │ Score = (claims supported by context) / (total claims in answer)
121 │
122 ├──→ Answer Relevance: Does the answer address the question?
123 │ Score = cosine_sim(question, generated_questions_from_answer)
124 │
125 ├──→ Context Precision: Are relevant contexts ranked higher?
126 │ Score = weighted precision of relevant contexts in top-k
127 │
128 └──→ Context Recall: Were all ground-truth facts retrievable?
129 Score = (ground_truth_claims in contexts) / (total ground_truth_claims)
130```
131
132```python
133# RAGAS evaluation
134from ragas import evaluate
135from ragas.metrics import faithfulness, answer_relevancy, context_precision
136from datasets import Dataset
137
138eval_dataset = Dataset.from_dict({
139 "question": questions,
140 "answer": generated_answers,
141 "contexts": retrieved_contexts,
142 "ground_truth": expected_answers,
143})
144
145result = evaluate(eval_dataset, metrics=[
146 faithfulness, answer_relevancy, context_precision
147])
148print(result) # {'faithfulness': 0.87, 'answer_relevancy': 0.92, ...}
149```
150
151### Pattern 3: CI Regression Gate
152
153```
154On PR / prompt change:
155 │
156 ▼
157[Run eval suite] ──→ scores
158 │
159 ▼
160[Compare to baseline]
161 ├── Score >= baseline - tolerance (2%) ──→ PASS (merge allowed)
162 └── Score < baseline - tolerance ──→ FAIL (block merge)
163 │
164 └── Report: which test cases regressed, by how much
165```
166
167## Anti-Patterns
168
1691. **Evaluating without a baseline** — A score of 4.2/5 means nothing without knowing the previous score was 4.5. Always track baselines and trends.
1702. **LLM-as-judge without calibration** — Judges have biases (verbosity preference, position bias). Calibrate on 20+ pre-scored examples and check inter-rater agreement.
1713. **Too few test cases** — 10 test cases produce noisy metrics. Target 50+ for reliable averages, 200+ for statistical confidence on sub-dimensions.
1724. **Evaluating only happy paths** — Include adversarial inputs, edge cases, ambiguous questions, and out-of-scope queries. The model should fail gracefully.
1735. **Manual eval as the only method** — Human evaluation is expensive and slow. Use it to calibrate automated methods, then run automated evals in CI.
174
175## Quality Checklist
176
177- [ ] Eval dataset has 50+ test cases with expected outputs or rubrics
178- [ ] Multiple eval dimensions defined (correctness, completeness, safety, etc.)
179- [ ] LLM-as-judge calibrated against human scores (inter-rater agreement > 0.8)
180- [ ] Baseline scores established and tracked over time
181- [ ] Regression threshold defined (e.g., fail if any dimension drops > 2%)
182- [ ] Edge cases and adversarial inputs included in eval dataset (minimum 20%)
183- [ ] Eval runs automated in CI on every prompt/model/pipeline change
184- [ ] Results stored with timestamps for trend analysis
185- [ ] Human eval used for calibration, not as sole evaluation method
186- [ ] RAGAS metrics used for RAG systems (faithfulness, relevance, precision)