Skip to main content

Design a RAG system that lets a law firm search and ask questions about 50,000 contracts.

RAG · Intermediate 2

Short answer

Parse contracts carefully, keeping clause structure and tables, and store metadata such as client, contract type, dates and parties. Use hybrid search with filters and a reranker, answer only from retrieved clauses with citations, and say so when the answer is not found. Enforce per-matter access control, keep data in an approved region, and evaluate with lawyers' real questions.

Deeper answer

Legal work needs precision and trust. Chunk by clause rather than fixed size, keep the clause number and heading with each chunk, and store structured fields so a lawyer can say 'indemnity clauses in supplier contracts signed after 2024'. Exact terms matter in law, so keyword search alongside vectors helps.

Every answer should quote and link the clause it relies on, and say 'not found' rather than guess. Access control is essential: lawyers must see only matters they are cleared for. Build a test set with the firm's lawyers, measure retrieval and answer accuracy, and keep a human lawyer responsible for any advice.

What a strong answer covers

Answer it out loud in the mock interview about 2.5 min

Follow-ups to expect

Common mistakes

Learn it

Build a RAG app

Today's AI turns are used

Lessons, roadmaps, videos, practice cards and the code playground stay free with your account, with no limit.