Legal and compliance RAG

Legal and compliance RAG are the strictest RAG use cases. Hallucinations aren't just embarrassing, they're legal exposure. Citations aren't optional, they're required by procedure. The bar for quality is higher, and the acceptable failure modes are narrower.

What makes it different

The content types

Each has structure and citation conventions specific to legal practice.

Parsing: high stakes

Legal documents are PDF-heavy and layout-dependent:

Commercial parsers (Azure DI, Llamaparse, Mathpix) or LLM vision parsers are often worth the cost here. See parsing PDFs.

Chunking: preserve structure

Legal chunks should align with legal units:

Chunk metadata must include:

Defined terms

Legal documents define terms early and use them throughout. When retrieving a chunk that uses a defined term, the definition should come along.

Two patterns:

Citation format

Legal citations follow strict formats:

Generated answers must cite in these formats, not in loose paraphrase. Post-processing or prompt engineering to enforce proper citation format.

Jurisdiction and date filtering

Legal advice depends heavily on:

Metadata filtering is essential. A query about employment law in California shouldn't retrieve New York precedents or pre-2020 rulings that have been overturned.

Hallucination risk is existential

A hallucinated citation (fake case, fake statute section) is malpractice. Mitigations:

The "I don't know" discipline

Legal RAG must be willing to say "I don't have information on that" rather than guess. Train users to expect this. A reliable "don't know" beats an unreliable answer every time.

Human-in-the-loop

Legal RAG is rarely fully autonomous. The pattern:

The value is saving lawyer hours, not replacing lawyers. Frame the UX around this.

Audit trail

Every answer must be reconstructible months or years later:

For regulated use (investment advice, compliance decisions), this audit trail is required by law.

Confidentiality

Self-hosted is typical

Legal organizations usually require:

Eval is human-intensive

Automated evaluation can catch obvious errors, but legal correctness requires human judgment:

The systems that work

Commercial legal AI (Harvey, CoCounsel, Relativity AI, Lexis+ AI) combines:

For internal legal RAG, borrow these patterns. Don't ship a naive vector RAG over legal documents and call it done, the quality bar is categorically higher.

Next: Multi-tenant RAG.