Overview
Builds a robust, repeatable evaluation harness for LLMs. Covers golden dataset construction, golden answer types (exact, fuzzy, LLM-as-judge), metric selection (accuracy, BLEU/ROUGE/BERTScore, custom, faithfulness/relevance), eval runner script, LLM-as-judge prompt templates, regression tracking (diff between runs), and integration into CI or a dashboard.
When to Use This Skill
- Comparing multiple models or prompt versions on the same task.
- Establishing a quality baseline before shipping a feature that uses LLMs.
- Detecting quality regressions after model or prompt changes.
- The user wants "to measure how good this is" or "track quality over time".
Prerequisites
- A task with clear success criteria.
- A set of test cases (even 20-50 is valuable to start; aim for 100+ for statistical significance).
- Access to the models being evaluated.
- (Optional but recommended) A small amount of human-labeled "golden" answers.
Steps
Construct the eval dataset:
- Representative of real usage (include edge cases and common failures).
- Columns:
id, input, expected_output (or rubric), metadata (difficulty, category).
- Version the dataset (git + a simple JSONL or CSV).
Choose evaluation method per task:
- Exact match / contains (for extraction, classification).
- Fuzzy (Levenshtein, normalized edit distance).
- BLEU / ROUGE / BERTScore (for generation, summarization).
- LLM-as-judge (most flexible for open-ended tasks).
- Human evaluation for high-stakes (sample).
LLM-as-judge (when used):
- Write a strong judge prompt with clear rubric and few-shot examples.
- Ask for a score (1-5 or 0-1) + reasoning.
- Run the same judge on all candidates for fair comparison.
- Validate the judge against human labels on a small set.
Build the eval runner:
- Load dataset.
- For each example: call model → parse output → compute metric(s).
- Aggregate scores (mean, per-category breakdown, failure cases).
- Save detailed results (JSON) + summary.
Regression tracking:
- Store results with git commit / prompt version / model version.
- Simple diff script: "compare run A vs run B — which examples got worse?"
- Fail CI if score drops more than X% on key metrics.
Output:
- Golden dataset template (with 10-20 examples).
evaluate.py script that is model- and prompt-agnostic.
- LLM judge prompt template.
- Results viewer (simple pandas + print or Streamlit).
- CI integration example (GitHub Action step that runs eval and comments on PR).
Examples
A complete harness for "customer support ticket classification + draft response" task: golden dataset (JSONL), runner script, LLM-as-judge prompt for response quality, automatic metrics, and a regression diff report is included.
Edge Cases & Error Handling
- Judge bias: Use the same judge model/version for all comparisons. Calibrate against humans.
- Output parsing failures: Treat as score 0 and log the raw output.
- Cost of eval: Sample or use cheaper judge models for high-volume evals; run full eval nightly.
Verification
- The harness runs end-to-end on the golden set without crashing.
- Scores are reproducible when re-running the same model + prompt.
- LLM judge scores correlate reasonably with human judgment on a validation subset (report the correlation).
- A known-better prompt/model scores higher than a known-worse one.
- Regression detection works (intentionally degrade a prompt and see the harness flag it).
- Success: You have a trustworthy, automated way to know whether a change improved, hurt, or had no effect on quality.
References
1---2name: evaluation-harness3description: Builds an evaluation harness to measure LLM accuracy, reliability, and performance on a task. Use when benchmarking models, comparing prompts, or tracking quality regressions.4license: Apache-2.05compatibility: Claude Code, Codex, Gemini CLI6metadata:7 author: ai-skills8 version: "1.0"9 category: ai-ml10 tags: evaluation, llm, benchmark, ragas, llm-as-judge, regression-testing11---1213## Overview1415Builds a robust, repeatable evaluation harness for LLMs. Covers golden dataset construction, golden answer types (exact, fuzzy, LLM-as-judge), metric selection (accuracy, BLEU/ROUGE/BERTScore, custom, faithfulness/relevance), eval runner script, LLM-as-judge prompt templates, regression tracking (diff between runs), and integration into CI or a dashboard.1617## When to Use This Skill1819- Comparing multiple models or prompt versions on the same task.20- Establishing a quality baseline before shipping a feature that uses LLMs.21- Detecting quality regressions after model or prompt changes.22- The user wants "to measure how good this is" or "track quality over time".2324## Prerequisites2526- A task with clear success criteria.27- A set of test cases (even 20-50 is valuable to start; aim for 100+ for statistical significance).28- Access to the models being evaluated.29- (Optional but recommended) A small amount of human-labeled "golden" answers.3031## Steps32331. **Construct the eval dataset**:34 - Representative of real usage (include edge cases and common failures).35 - Columns: `id`, `input`, `expected_output` (or rubric), `metadata` (difficulty, category).36 - Version the dataset (git + a simple JSONL or CSV).37382. **Choose evaluation method per task**:39 - Exact match / contains (for extraction, classification).40 - Fuzzy (Levenshtein, normalized edit distance).41 - BLEU / ROUGE / BERTScore (for generation, summarization).42 - LLM-as-judge (most flexible for open-ended tasks).43 - Human evaluation for high-stakes (sample).44453. **LLM-as-judge** (when used):46 - Write a strong judge prompt with clear rubric and few-shot examples.47 - Ask for a score (1-5 or 0-1) + reasoning.48 - Run the same judge on all candidates for fair comparison.49 - Validate the judge against human labels on a small set.50514. **Build the eval runner**:52 - Load dataset.53 - For each example: call model → parse output → compute metric(s).54 - Aggregate scores (mean, per-category breakdown, failure cases).55 - Save detailed results (JSON) + summary.56575. **Regression tracking**:58 - Store results with git commit / prompt version / model version.59 - Simple diff script: "compare run A vs run B — which examples got worse?"60 - Fail CI if score drops more than X% on key metrics.61626. **Output**:63 - Golden dataset template (with 10-20 examples).64 - `evaluate.py` script that is model- and prompt-agnostic.65 - LLM judge prompt template.66 - Results viewer (simple pandas + print or Streamlit).67 - CI integration example (GitHub Action step that runs eval and comments on PR).6869## Examples7071A complete harness for "customer support ticket classification + draft response" task: golden dataset (JSONL), runner script, LLM-as-judge prompt for response quality, automatic metrics, and a regression diff report is included.7273## Edge Cases & Error Handling7475- **Judge bias**: Use the same judge model/version for all comparisons. Calibrate against humans.76- **Output parsing failures**: Treat as score 0 and log the raw output.77- **Cost of eval**: Sample or use cheaper judge models for high-volume evals; run full eval nightly.7879## Verification80811. The harness runs end-to-end on the golden set without crashing.822. Scores are reproducible when re-running the same model + prompt.833. LLM judge scores correlate reasonably with human judgment on a validation subset (report the correlation).844. A known-better prompt/model scores higher than a known-worse one.855. Regression detection works (intentionally degrade a prompt and see the harness flag it).866. Success: You have a trustworthy, automated way to know whether a change improved, hurt, or had no effect on quality.8788## References8990- [RAGAS](https://docs.ragas.io/)91- [ARES](https://github.com/stanford-futuredata/ARES)92- [LLM-as-a-Judge](https://arxiv.org/abs/2306.05685)93- [HELM](https://crfm.stanford.edu/helm/latest/)94- [Big-bench](https://github.com/google/BIG-bench)