KatInterview

Design a Citation-Verified RAG Assistant for Litigation Review

Machine LearningModel answer
HardModel answerMachine Learningragllm-system-designprompt-injection

Last updated

Design a read-only, retrieval-grounded LLM system that summarizes case files, builds timelines, flags conflicting statements, and drafts briefs with verifiable citations and strong isolation.

Problem

A law-firm platform wants an AI assistant for attorneys preparing contested cases. Each case ("matter") holds a large pile of discovery material: pleadings, contracts, email threads, scanned exhibits, and deposition transcripts. The assistant should help the team build factual timelines, find places where witnesses or documents disagree, answer questions, and draft preparation briefs. It is a drafting aid only: it must not give legal advice, take outside actions, or state anything it cannot trace to a source.

Requirements

Functional

  • Ingest mixed formats (scanned PDFs with OCR, email threads, transcripts), each tied to exactly one matter.
  • Every factual sentence in an output must cite its exact source: page, paragraph, Bates number, or transcript page and line.
  • Detect and surface conflicting statements about the same event or claim across witnesses and documents.
  • Operate read-only with attorney review and approval before any draft is final. Refuse legal advice.

Non-functional and security

  • Documents may contain adversarial text that tries to hijack the model (indirect prompt injection). The design must neutralize it.
  • Immutable audit logs of queries and responses, per-matter encryption keys, and retention or deletion rules including litigation holds.
  • Citation precision above 99%. Hallucinated facts are unacceptable.

Scale

  • A typical matter has about 50,000 documents (~250,000 pages); the largest reach 1,000,000 documents.
  • 50 concurrent matters, peak 100 queries per second.
  • Ingestion of 10,000 pages in under 30 minutes.
  • Interactive Q&A must reach first token in under 4 seconds; long drafts stream.

What to cover

  1. End-to-end architecture: parsing, structure-aware chunking with Bates and speaker metadata, hybrid (dense + lexical) retrieval, and synthesis.
  2. How the model is constrained to produce verifiable claims, and how citations map back to text spans or page regions.
  3. How you detect contradictions across documents and witnesses.
  4. Security: separating instructions from untrusted content, matter isolation, injection defenses.
  5. An evaluation plan covering retrieval recall, faithfulness, citation precision, and advice refusal.

Hints

Hint 1

Treat the LLM as an untrusted component: never let it write citations itself. Have it reference opaque chunk handles plus verbatim quotes, and compute the human-readable citation from stored metadata.

Hint 2

Comparing every pair of passages for contradictions is quadratic and noisy. Extract structured event claims first, then group candidates by resolved entity and time window before running an NLI-style classifier.

Hint 3

For injection, combine layers: sanitize hidden text at ingestion, screen retrieved chunks, fence evidence as data in the prompt, and remove tools entirely so a successful injection has nothing to act on.