On-disk RAG evaluation (corpus/ + train.json)
Purpose
Guide agents through NVIDIA RAG Blueprint filesystem benchmarks: preparing corpus/ and train.json, running scripts/eval/evaluate_rag.py, tuning retrieval and generation flags for quality comparisons, interpreting RAGAS JSON outputs, and triaging failures (HTTP/stream errors, empty contexts, collection mismatch, judge API).
For latency, throughput, and load testing, use the rag-perf skill (scripts/rag-perf, docs/performance-benchmarking.md) — not this skill.
When not to use
Do not use this skill for: deploying or repairing services (use rag-blueprint); evaluating APIs without the corpus/ + train.json layout; general ML experimentation unrelated to this evaluator; production monitoring/alerting; or latency/throughput benchmarking (use rag-perf).
Prerequisites
- Repo cloned; run commands from repo root (imports and paths assume this).
- Python 3.11+ and uv; eval deps:
uv sync --project scripts/eval.
- Reachable RAG server and ingestor (defaults often
localhost:8081 / 8082).
NVIDIA_API_KEY for RAGAS (see credential hygiene); optional RAG_EVAL_JUDGE_MODEL.
- Dataset roots passed to
--dataset-paths each contain corpus/ and train.json.
Instructions
- Prepare data — Ensure each dataset directory matches the layout and
train.json rules in references/dataset-and-conversion.md. When sources arrive as public links (sites or dataset pages), materialize documents under corpus/—prefer PDF for multimodal content so images stay embedded; convert CSV/JSONL/etc. using the patterns there.
- Run eval —
uv run --project scripts/eval python scripts/eval/evaluate_rag.py with --dataset-paths, --host, and --port. See references/benchmark-execution.md for command examples, outputs, and errors. Use references/evaluate-rag-cli.md for flag-level detail.
- Tune quality — Adjust
--top_k / --vdb_top_k, reranker and query-rewriting toggles, and generation overrides (--temperature, --top-p, --max-tokens) as documented in references/benchmark-execution.md when comparing retrieval/generation configs for RAGAS scores.
- Analyze results — Use
references/result-analysis.md for scripts; scan rag_*_evaluation_summary.json for headline RAGAS metrics.
- Triage errors — Use the error signal table and the Troubleshooting section below.
Examples
Set API key without putting secrets in shell history (preferred patterns): load from a gitignored env file or secrets manager; avoid committing .env; rotate keys if exposed. Details: references/benchmark-execution.md#credential-hygiene-nvidia_api_key.
Minimal eval (key already in environment):
uv sync --project scripts/eval
uv run --project scripts/eval python scripts/eval/evaluate_rag.py \
--dataset-paths /path/to/my_dataset \
--host localhost \
--port 8081
Pretty-print summary JSON:
python3 -m json.tool results/my_dataset/rag_my_dataset_evaluation_summary.json
More examples (skip ingestion, quality sweeps): references/benchmark-execution.md.
Limitations
- Evaluator behavior is fixed to the filesystem contract and
evaluate_rag.py; it does not substitute for custom offline judges or non-RAG benchmarks.
- Vector DB / embedding choices follow deployed ingestor and RAG env — not overridden by this CLI alone.
- Scores depend on retrieval quality, judge model availability, and
NVIDIA_API_KEY; empty contexts yield partial RAGAS metrics (see references).
- Large procedural detail lives under
references/ to keep routing concise; read those files when the user needs step-by-step conversion, full flags, or error tables.
Troubleshooting
| Error / signal |
Likely cause |
What to do |
Immediate exit mentioning NVIDIA_API_KEY |
Missing or invalid key |
Set key via secure channel; see credential hygiene in references/benchmark-execution.md. |
train.json must be a JSON array |
Wrong JSON shape |
Top-level array of objects; validate per references/dataset-and-conversion.md. |
Fewer rows in evaluation_data.json than train.json |
Per-query failures |
Check stderr: network or stream JSON errors; see error table in benchmark-execution. |
Empty generated_contexts everywhere |
Retrieval gap |
Verify collection, ingestion, top_k / vdb_top_k, and ingestor_server_url without /v1 suffix. |
| Ingestor 404 on upload |
Bad ingestor base URL |
Pass http://host:port only — code appends /v1/. |
Full signal table: references/benchmark-execution.md#common-error-cases-and-signals.
Gotchas
- Run from repo root: paths and imports in
scripts/eval/evaluate_rag.py assume this; a wrong directory silently breaks imports.
--ingestor_server_url: pass http://host:port without /v1—the code appends /v1/ automatically. Including /v1 causes 404s on ingestor calls.
- Vector DB / embedding settings: not set by this CLI; configure via the deployed ingestor and RAG server env vars (e.g.
APP_VECTORSTORE_URL, embedding model).
--model / --llm_endpoint: forwarded verbatim only when explicitly set; omit to keep the server's configured LLM.
- Stale collections: a previous run's ingested data persists unless you use
--force_ingestion. Use --collection with a unique name when comparing quality across isolated runs.
- Empty context metrics: if all
generated_contexts are empty, RAGAS scores only nv_accuracy and leaves the other two metrics blank—this is not a silent success.
Source of truth
| Piece |
Location |
| Driver |
scripts/eval/evaluate_rag.py (CORPUS_DIRECTORY = corpus, EVAL_DATA = train.json) |
| Human README (always in-repo) |
scripts/eval/README.md |
| Full CLI (flags, defaults) |
scripts/eval/evaluate_rag.py --help; references/evaluate-rag-cli.md |
| Dataset / conversion |
references/dataset-and-conversion.md |
| Runs, outputs, errors |
references/benchmark-execution.md |
| Result analysis scripts |
references/result-analysis.md |
| Latency / throughput |
rag-perf skill, docs/performance-benchmarking.md |
Agent playbook
- Run eval —
uv sync --project scripts/eval then uv run --project scripts/eval python scripts/eval/evaluate_rag.py with required --dataset-paths, --host, and --port (and env NVIDIA_API_KEY). Argument --ingestor_server_url is optional (defaults to http://localhost:8082); pass it only when overriding the ingestor endpoint.
- Quality tuning — See
references/benchmark-execution.md: --top_k/--vdb_top_k, reranker and query-rewriting toggles, --temperature, --top-p, --max-tokens.
- Data conversion — Follow
references/dataset-and-conversion.md.
- Analyze results —
references/result-analysis.md; quick scan: python3 -m json.tool results/<dataset>/rag_<dataset>_evaluation_summary.json.
- Error triage —
references/benchmark-execution.md#common-error-cases-and-signals.
Cross-Client Portability
This skill is written to stay usable across GitHub Copilot, Claude Code, and Codex.
- GitHub Copilot: keep the folder in a Copilot-visible skill path or wrap the
workflow in project instructions when folder discovery is unavailable.
- Claude Code: keep the folder in a local skills directory or a compatible plugin source.
- Codex: install or sync the folder into
$CODEX_HOME/skills/rag-eval and restart Codex after major changes.
MCP Availability And Fallback
Preferred MCP Server: None required
- Fallback prompt: "Use the On-disk RAG evaluation (
corpus/ + train.json) skill without MCP. Rely on its local instructions, bundled resources, standard shell or editor tools, and direct verification. Show the evidence used before concluding."
- Do not claim an MCP operation was used when the active host does not expose it.
- Treat local files, tests, rendered outputs, logs, or screenshots as the fallback evidence path.
Anti-Patterns
- Changing the eval dataset while comparing runs: It destroys the baseline and makes improvements meaningless.
- Confusing latency smoke tests with answer-quality evaluation: Fast responses can still be wrong or ungrounded.
- Claiming gains without showing the baseline, scorer, and prompt or config deltas that changed the outcome.
Verification Protocol
Before claiming "skill applied successfully":
- Pass/fail: The evaluation plan names the dataset, scorer, and baseline run before comparing variants.
- Pass/fail: Retrieval and generation quality are separated so failures are attributed to the correct stage.
- Pass/fail: Reported improvements include reproducible commands, configs, or artifacts that another maintainer can rerun.
- Pressure-test scenario: Re-evaluate a RAG change where latency improves but groundedness falls on the held-out set.
- Success metric: Quality claims survive a rerun on the same eval slice with no hidden configuration drift.
Related Skills
- development-workflow: Use it when the eval work needs a scoped implementation plan with explicit quality gates.
- documentation-verification: Use it when the output is an evaluation report or benchmark note that must stay source-backed.
- cloud-design-patterns: Use it when evaluation results drive bigger architecture changes in the RAG stack.
1---2name: rag-eval3description: NVIDIA RAG Blueprint evaluation guidance for measuring retrieval and answer quality with stable datasets, baselines, and reproducible scoring workflows.4license: Apache-2.05---6# On-disk RAG evaluation (`corpus/` + `train.json`)
7
8## Purpose
9
10Guide agents through NVIDIA RAG Blueprint **filesystem** benchmarks: preparing `corpus/` and `train.json`, running `scripts/eval/evaluate_rag.py`, tuning retrieval and generation flags for **quality** comparisons, interpreting RAGAS JSON outputs, and triaging failures (HTTP/stream errors, empty contexts, collection mismatch, judge API).
11
12For **latency, throughput, and load testing**, use the **rag-perf** skill (`scripts/rag-perf`, `docs/performance-benchmarking.md`) — not this skill.
13
14## When not to use
15
16Do **not** use this skill for: deploying or repairing services (use rag-blueprint); evaluating APIs without the `corpus/` + `train.json` layout; general ML experimentation unrelated to this evaluator; production monitoring/alerting; or latency/throughput benchmarking (use **rag-perf**).
17
18## Prerequisites
19
20- Repo cloned; **run commands from repo root** (imports and paths assume this).
21- Python **3.11+** and **uv**; eval deps: `uv sync --project scripts/eval`.
22- Reachable **RAG server** and **ingestor** (defaults often `localhost:8081` / `8082`).
23- **`NVIDIA_API_KEY`** for RAGAS (see [credential hygiene](references/benchmark-execution.md#credential-hygiene-nvidia_api_key)); optional **`RAG_EVAL_JUDGE_MODEL`**.
24- Dataset roots passed to `--dataset-paths` each contain **`corpus/`** and **`train.json`**.
25
26## Instructions
27
281. **Prepare data** — Ensure each dataset directory matches the layout and `train.json` rules in [`references/dataset-and-conversion.md`](references/dataset-and-conversion.md). When sources arrive as public links (sites or dataset pages), materialize documents under `corpus/`—prefer **PDF** for multimodal content so **images stay embedded**; convert CSV/JSONL/etc. using the patterns there.
292. **Run eval** — `uv run --project scripts/eval python scripts/eval/evaluate_rag.py` with `--dataset-paths`, `--host`, and `--port`. See [`references/benchmark-execution.md`](references/benchmark-execution.md) for command examples, outputs, and errors. Use [`references/evaluate-rag-cli.md`](references/evaluate-rag-cli.md) for flag-level detail.
303. **Tune quality** — Adjust `--top_k` / `--vdb_top_k`, reranker and query-rewriting toggles, and generation overrides (`--temperature`, `--top-p`, `--max-tokens`) as documented in [`references/benchmark-execution.md`](references/benchmark-execution.md) when comparing retrieval/generation configs for RAGAS scores.
314. **Analyze results** — Use [`references/result-analysis.md`](references/result-analysis.md) for scripts; scan `rag_*_evaluation_summary.json` for headline RAGAS metrics.
325. **Triage errors** — Use the [error signal table](references/benchmark-execution.md#common-error-cases-and-signals) and the **Troubleshooting** section below.
33
34## Examples
35
36**Set API key without putting secrets in shell history (preferred patterns):** load from a gitignored env file or secrets manager; avoid committing `.env`; rotate keys if exposed. Details: [`references/benchmark-execution.md#credential-hygiene-nvidia_api_key`](references/benchmark-execution.md#credential-hygiene-nvidia_api_key).
37
38**Minimal eval (key already in environment):**
39
40```bash
41uv sync --project scripts/eval
42uv run --project scripts/eval python scripts/eval/evaluate_rag.py \
43 --dataset-paths /path/to/my_dataset \
44 --host localhost \
45 --port 8081
46```
47
48**Pretty-print summary JSON:**
49
50```bash
51python3 -m json.tool results/my_dataset/rag_my_dataset_evaluation_summary.json
52```
53
54More examples (skip ingestion, quality sweeps): [`references/benchmark-execution.md`](references/benchmark-execution.md).
55
56## Limitations
57
58- Evaluator behavior is fixed to the **filesystem contract** and `evaluate_rag.py`; it does not substitute for custom offline judges or non-RAG benchmarks.
59- **Vector DB / embedding** choices follow deployed ingestor and RAG env — not overridden by this CLI alone.
60- **Scores depend on** retrieval quality, judge model availability, and `NVIDIA_API_KEY`; empty contexts yield partial RAGAS metrics (see references).
61- Large procedural detail lives under **`references/`** to keep routing concise; read those files when the user needs step-by-step conversion, full flags, or error tables.
62
63## Troubleshooting
64
65| Error / signal | Likely cause | What to do |
66|----------------|--------------|------------|
67| Immediate exit mentioning `NVIDIA_API_KEY` | Missing or invalid key | Set key via secure channel; see credential hygiene in [`references/benchmark-execution.md`](references/benchmark-execution.md). |
68| `train.json must be a JSON array` | Wrong JSON shape | Top-level array of objects; validate per [`references/dataset-and-conversion.md`](references/dataset-and-conversion.md). |
69| Fewer rows in `evaluation_data.json` than `train.json` | Per-query failures | Check stderr: network or stream JSON errors; see error table in benchmark-execution. |
70| Empty `generated_contexts` everywhere | Retrieval gap | Verify collection, ingestion, `top_k` / `vdb_top_k`, and `ingestor_server_url` **without** `/v1` suffix. |
71| Ingestor 404 on upload | Bad ingestor base URL | Pass `http://host:port` only — code appends `/v1/`. |
72
73Full signal table: [`references/benchmark-execution.md#common-error-cases-and-signals`](references/benchmark-execution.md#common-error-cases-and-signals).
74
75## Gotchas
76
77- **Run from repo root**: paths and imports in `scripts/eval/evaluate_rag.py` assume this; a wrong directory silently breaks imports.
78- **`--ingestor_server_url`**: pass `http://host:port` without `/v1`—the code appends `/v1/` automatically. Including `/v1` causes 404s on ingestor calls.
79- **Vector DB / embedding settings**: not set by this CLI; configure via the deployed ingestor and RAG server env vars (e.g. `APP_VECTORSTORE_URL`, embedding model).
80- **`--model` / `--llm_endpoint`**: forwarded verbatim only when explicitly set; omit to keep the server's configured LLM.
81- **Stale collections**: a previous run's ingested data persists unless you use `--force_ingestion`. Use `--collection` with a unique name when comparing quality across isolated runs.
82- **Empty context metrics**: if all `generated_contexts` are empty, RAGAS scores only `nv_accuracy` and leaves the other two metrics blank—this is not a silent success.
83
84## Source of truth
85
86| Piece | Location |
87|-------|----------|
88| Driver | `scripts/eval/evaluate_rag.py` (`CORPUS_DIRECTORY` = `corpus`, `EVAL_DATA` = `train.json`) |
89| Human README (always in-repo) | `scripts/eval/README.md` |
90| Full CLI (flags, defaults) | `scripts/eval/evaluate_rag.py --help`; [`references/evaluate-rag-cli.md`](references/evaluate-rag-cli.md) |
91| Dataset / conversion | [`references/dataset-and-conversion.md`](references/dataset-and-conversion.md) |
92| Runs, outputs, errors | [`references/benchmark-execution.md`](references/benchmark-execution.md) |
93| Result analysis scripts | [`references/result-analysis.md`](references/result-analysis.md) |
94| Latency / throughput | **rag-perf** skill, `docs/performance-benchmarking.md` |
95
96## Agent playbook
97
981. **Run eval** — `uv sync --project scripts/eval` then `uv run --project scripts/eval python scripts/eval/evaluate_rag.py` with required `--dataset-paths`, `--host`, and `--port` (and env `NVIDIA_API_KEY`). Argument `--ingestor_server_url` is optional (defaults to `http://localhost:8082`); pass it only when overriding the ingestor endpoint.
992. **Quality tuning** — See [`references/benchmark-execution.md`](references/benchmark-execution.md): `--top_k`/`--vdb_top_k`, reranker and query-rewriting toggles, `--temperature`, `--top-p`, `--max-tokens`.
1003. **Data conversion** — Follow [`references/dataset-and-conversion.md`](references/dataset-and-conversion.md).
1014. **Analyze results** — [`references/result-analysis.md`](references/result-analysis.md); quick scan: `python3 -m json.tool results/<dataset>/rag_<dataset>_evaluation_summary.json`.
1025. **Error triage** — [`references/benchmark-execution.md#common-error-cases-and-signals`](references/benchmark-execution.md#common-error-cases-and-signals).
103
104<!-- MCP:START -->
105
106<!-- PORTABILITY:START -->
107## Cross-Client Portability
108
109This skill is written to stay usable across GitHub Copilot, Claude Code, and Codex.
110
111- GitHub Copilot: keep the folder in a Copilot-visible skill path or wrap the
112 workflow in project instructions when folder discovery is unavailable.
113- Claude Code: keep the folder in a local skills directory or a compatible plugin source.
114- Codex: install or sync the folder into
115 `$CODEX_HOME/skills/rag-eval` and restart Codex after major changes.
116
117<!-- PORTABILITY:END -->
118
119## MCP Availability And Fallback
120
121Preferred MCP Server: None required
122
123- Fallback prompt: "Use the On-disk RAG evaluation (`corpus/` + `train.json`) skill without MCP. Rely on its local instructions, bundled resources, standard shell or editor tools, and direct verification. Show the evidence used before concluding."
124- Do not claim an MCP operation was used when the active host does not expose it.
125- Treat local files, tests, rendered outputs, logs, or screenshots as the fallback evidence path.
126
127<!-- MCP:END -->
128
129## Anti-Patterns
130
131- Changing the eval dataset while comparing runs: It destroys the baseline and makes improvements meaningless.
132- Confusing latency smoke tests with answer-quality evaluation: Fast responses can still be wrong or ungrounded.
133- Claiming gains without showing the baseline, scorer, and prompt or config deltas that changed the outcome.
134
135## Verification Protocol
136
137Before claiming "skill applied successfully":
138
1391. Pass/fail: The evaluation plan names the dataset, scorer, and baseline run before comparing variants.
1402. Pass/fail: Retrieval and generation quality are separated so failures are attributed to the correct stage.
1413. Pass/fail: Reported improvements include reproducible commands, configs, or artifacts that another maintainer can rerun.
1424. Pressure-test scenario: Re-evaluate a RAG change where latency improves but groundedness falls on the held-out set.
1435. Success metric: Quality claims survive a rerun on the same eval slice with no hidden configuration drift.
144
145## Related Skills
146
147- [development-workflow](../development-workflow/SKILL.md): Use it when the eval work needs a scoped implementation plan with explicit quality gates.
148- [documentation-verification](../documentation-verification/SKILL.md): Use it when the output is an evaluation report or benchmark note that must stay source-backed.
149- [cloud-design-patterns](../cloud-design-patterns/SKILL.md): Use it when evaluation results drive bigger architecture changes in the RAG stack.