Exercise ex-ragas-mock — RAGAS's three metrics, judged by a fixture instead of a model

Evaluating RAG named faithfulness, answer relevance and context precision as RAGAS's three headline metrics, each one backed by an LLM judge call. ex-citation-check was the deterministic warm-up: no judge, a red row you can read. This exercise is the real shape — three metrics computed from a judge's answers — but the judge is still deterministic: MockJudge answers from a fixed fixture instead of calling a model, so every score below is exact, not "roughly right". That is also the calibration move a real eval harness needs: build the arithmetic against a judge you can trust completely, then swap in the real one.

~90 minruns locally · uv + pytest 6 checksex-ragas-mock

What you're building

MockJudge, EvalRow and the similarity helper ship already written in the starter — read them first, they're the contract the four functions above are graded against. The tests are ordinary pytest and ship in the public folder with the starter; the names below are the check list. Solutions are not published. This runs locally, same as ex-citation-check, because f1-build reuses this exact module for its RAGAS report.

Get the repo (once)

Needs git. uv installs the right Python itself, so nothing else is required.

# once, anywhere on your machine
git clone https://github.com/theDocWho/ai-ml-roadmap.git
cd ai-ml-roadmap

No git? Download the ZIP, unzip it, and cd into the unzipped folder instead.

Run it

From the repo root:

# one-time: uv (https://docs.astral.sh/uv/) manages the venv and pins Python ≥ 3.12
cd exercises/ex-ragas-mock && uv sync && uv run pytest -q

# the same bar the reference solution clears
uv run ruff check . && uv run mypy src

Done when uv run pytest -q prints 6 passed. Rerun after every edit; pytest's -q output is the only readout this exercise has.

The checks

Files

This is self-attestation — the site cannot see your terminal, so the box and the button are you telling The Path the suite went green on your machine.

If you get stuck