Legal RAG Pipeline — interactive demo

A first-line sweep of a conveyancing handbook: grounded answers whose citations are machine-checked against the retrieved text before you see them — so the citation leads you to retrieved text, on a page that text covers, to read and judge for yourself. (The check confirms the citation falls inside what was retrieved; it does not confirm the exact paragraph exists or that it supports the claim.)

What this is: a guided simulation of the real pipeline's logic, running entirely in this page. All handbook content here comes from the project's wholly synthetic sample handbook (the fictional jurisdiction of Erewhon) — no real, copyrighted handbook text appears anywhere in this demo or this repository. The real pipeline runs these exact stages in Python; see the README quickstart to run it yourself.

1  Pick a question a colleague might ask

2  Watch the pipeline handle it

Query expansion (claude-haiku)

Staff phrase questions colloquially; the handbook doesn't. Three quick rewrites bridge the vocabulary gap. The original question always keeps the loudest vote in retrieval.

Hybrid retrieval — keyword + semantic, fused

🔤 BM25 keyword arm

    🧭 Vector (semantic) arm

      Legal questions hinge on exact tokens ("Form VX-9", "s.72"); keyword search catches what semantic search fuzzes past — and vice versa. Reciprocal-rank fusion merges both rankings.

      Answer drafting (claude-sonnet)

      The model must answer from the retrieved extracts only, citing paragraph and page for every statement — or refuse with one exact sentence.

      🛡️ The grounding gate — every citation checked

      Each cited (paragraph, page) must match a chunk that was actually retrieved: a related section number, on a page that chunk covers. This is the fabricated-locator safeguard: a locator pointing outside what was retrieved has nothing to match, so it cannot pass. (It proves the citation falls inside retrieved text — not that the exact paragraph exists, nor that the text supports the claim; that is the reader's judgment, at the cited page.)