llm-eval-harness-rag

verified

0b7d4993-741a-4a19-a0bf-c417b1c828f3

Evaluate RAG quality — build question-answer evals, compute retrieval + generation metrics (recall@k, faithfulness, answer relevance), and iterate.

Metadata

Skill ID
0b7d4993-741a-4a19-a0bf-c417b1c828f3
Version
1
Owner
387274b7-2891-478b-81b8-e11d5adb9319
Tags
evaluationragllmevalsmetricstesting
Signature
verified
Integrity
OK
Content hash
f3d76107d9776bd42a4a0fec1bc1fe4915612b74caeff624eee13cb1bd95a0de
Created
2026-08-08T14:10:02Z

Skill file

Raw skill file (markdown source)
# Building an Eval Harness for RAG

Use when you need evidence that your RAG/LLM app is *actually* good, not just
plausible — to catch regressions, compare chunking/retrieval changes, and stop
shipping on vibes.

## Two halves: retrieval and generation

| side | measures | metric |
|------|----------|--------|
| retrieval | did we fetch the right docs? | recall@k, precision@k, MRR |
| generation | is the answer right and grounded? | faithfulness, answer relevance, exact/LLM-judged |

## Build ground-truth eval sets

- 50–200 Q/A pairs where each question has known-relevant document ids.
- Cover easy and adversarial cases: paraphrase, cross-doc, out-of-scope (should
  answer "don't know").
- Keep the set versioned; re-run on every retrieval/chunking change.

## Compute metrics

- **recall@k** = fraction of relevant docs present in top-k.
- **faithfulness** = every claim in the answer is supported by retrieved context
  (judge with a second LLM or entailment model).
- **answer relevance** = the answer addresses the question (not just grounded).

`lm-eval-harness`-style tooling and the `weights-and-biases` logger let you
track these per experiment; at minimum, print a scored table per run.

## Iterate the levers

Chunk size, overlap, embedding model, hybrid search, reranker, prompt template,
model — change one at a time and re-run the harness.

## Pitfalls

- Judging only "did it answer" while retrieval silently returns nothing useful.
- Eval set too small / non-adversarial — easy to overfit.
- Not holding out: tuning on your eval set leaks and misleads.
- Ignoring the "don't know" case that prevents hallucinated wrong answers.

## Verify

- Re-run the harness after every pipeline change; diff metric deltas.
- Ship the eval set + a single command to rerun it with the harness.

Attached files