Case Study: A Legal Research Assistant
You'll learn to
- -Design a RAG system where a wrong or invented citation is unacceptable
- -Verify each citation against the retrieved sources with a simple check
- -Handle jurisdiction, dates, and superseded law
- -Plan human review, audit trails, and evaluation by experts
A lawyer asks a question, and the assistant answers with citations to cases and statutes. In most RAG products, a wrong answer is an annoyance. Here it can be a sanctionable error: courts have penalized lawyers who filed briefs citing cases that a chatbot invented. This case study is about designing for that level of stakes. The details change in other high-stakes areas, like medicine and finance, but the principles carry over.
An Analogy: The Law Clerk Who Must Show Their Sources
A good law clerk does not hand a judge a conclusion. They hand over the exact passages, with page numbers, so the judge can check each one. A clerk who invents a case, even once, ends their career. The assistant must behave like that clerk: nothing that it cannot point to, and a habit of saying "I could not find support for this" when that is true.
Requirements
- -Accuracy and traceability over fluency: every claim links to a passage that supports it.
- -Recall: missing a relevant precedent is a failure too, so retrieval must be thorough.
- -Jurisdiction and time: law differs by place and changes over time. A superseded statute is worse than none.
- -Confidentiality: client documents must stay isolated, and never leak into another client's answers or into model training.
- -Auditability: a record of what was asked, what was retrieved, and what was answered.
The Design
- -Corpus: statutes, regulations, cases, and secondary sources, each with metadata: jurisdiction, court, date, and status (good law or overruled).
- -Retrieval: hybrid search, because legal terms of art and citations need exact matching as well as meaning, with metadata filters for jurisdiction and date, and a reranker. Use the citation graph: cases that cite or are cited by a result are strong candidates.
- -Generation: answer only from retrieved passages, quote the relevant text, and mark each claim with the identifier of the source it came from.
- -Verification: after generation, check each cited claim against its source before showing it. This is the layer that catches inventions.
- -Abstention: if retrieval does not find strong support, say so, and show what was found.
- -Human review: the output is a draft for a lawyer, with the passages one click away.
A Citation Verifier
The code is a deliberately simple version of the verification step. It takes an answer with citations like [CASE-101] and the set of sources that retrieval returned. For each claim it checks two things: was the cited source actually retrieved, and does a reasonable share of the claim's words appear in that source? Real systems use an entailment model or a judge, validated as in the evals module, but even this crude check catches the worst error. Press Run and read each verdict.
Two of the four claims pass. The notice period and the late-fee limit both match their sources. The claim about triple damages cites CASE-777, which was never retrieved, so it is flagged as a possible invention and must not be shown as a citation. The claim that notice may be waived cites CASE-205, which is real, but only 43% of its words appear in that source, so it is marked as weakly supported. In practice you would block the invented citation, and send the weak one to a stronger entailment check or a human, rather than present it as settled.
Evaluation
- -An expert-labeled question set across jurisdictions and topics, with the correct authorities for each.
- -Retrieval: recall at k of the correct authorities. Missing a controlling case is a serious failure.
- -Generation: citation precision (the share of citations that are real and support the claim), citation recall, and the rate of unsupported claims. A single invented citation counts as a severe error.
- -Abstention: how often it says it does not know when it should, and how often it wrongly refuses.
- -Validated judges for faithfulness, checked against lawyers' labels, as in the judge validation chapter.
Failure Modes
- -Outdated or overruled law presented as current. Track status and dates, and show them.
- -Wrong jurisdiction. Filter by it, and ask the user when it is unclear.
- -Confident synthesis across cases that do not quite fit together. Prefer quoting to paraphrasing.
- -Prompt injection in documents: a hostile clause in an uploaded contract that tries to instruct the model. Treat document text as data.
Interview Signal is part of Pro
See a real weak answer next to a real strong one for this exact topic.
Quiz is part of Pro
Test what you just read with a short quiz, and bank the XP.
Discussion0
Join the Discussion
Sign in to leave comments, reply to others, or like insights.
No comments yet. Be the first to start the thread!