Case study · Legal AI

Helping lawyers review contracts against the playbook without giving up the final word

Every incoming contract was compared to the playbook by hand, clause by clause, under deadline. The goal was not to replace that judgement but to prepare it: extract the clauses, compare them to the playbook, and propose cited redlines a lawyer accepts, edits or rejects.

Case studyLegal · In-house and advisorySumanta Mukhopadhyay8 min read
#ai#llm#governance#security#architecture
CASE STUDY · CASE STUDY · LEGAL AI28 Oct 2026 · 01:36 GST
At a glance
SectorLegal · In-house and advisory
My roleAI architect
EngagementArchitecture, evaluation design and build
ScopeClause extraction, playbook modelling, comparison, review workflow, evaluation
What changed
  • Every contract arrives with clauses extracted and mapped to the playbook before a lawyer opens it
  • Suggestions cite both the contract text and the playbook position they rely on
  • Lawyers accept, edit or reject each suggestion, and those decisions feed evaluation
  • Playbook positions maintained as structured data rather than a document nobody updates
LLM with structured outputsJSON SchemaLong-context modelsRetrieval over playbook and precedentsDocument parsingEvaluation harnessReview UIAudit log

Anonymised composite. Client names, identifying details and confidential figures are withheld; public facts are cited in the references.

The situation

A legal team handled a steady flow of commercial agreements: supplier contracts, NDAs, services agreements, licences. Each one was checked against an internal playbook that set out preferred positions, acceptable fallbacks and red lines for clauses such as liability caps, indemnities, termination, governing law and data protection. The work was skilled but repetitive, and it bunched up at quarter end when everything was urgent.

The team had tried generic AI chat tools. The answers sounded plausible, cited nothing, and didn't know the playbook. Nobody trusted them, rightly.

What had to be true

  • The lawyer decides. The system prepares and proposes; it never sends a redline on its own.
  • Every suggestion is cited to the exact contract text and the playbook position it relies on.
  • Consistent structure, so outputs can be validated and compared, not just read.
  • Measured accuracy per clause type, on the team's own contracts, before anyone relies on it.
  • Confidentiality: contract text handled under the firm's existing data controls.

Contract review is a well-studied task: the CUAD dataset, built with legal experts, frames it as finding the clauses a reviewer needs to see across dozens of categories1. That framing, extraction first and judgement second, shaped the design.

Architecture

Intake
UploadWord, PDFParsingstructure, numberingContract typeclassified, confirmed
Extract
Clause extractionJSON Schema outputLocation anchorssection and spanValidationquotes must match source
Knowledge
Playbookstructured positionsFallback libraryapproved wordingPrecedentsretrieved, scoped
Compare
Playbook comparisonper clauseSuggested redlinewith citationsRisk flagred line breached
Review
Lawyer review UIaccept, edit, rejectAudit logwho decided whatEvaluation storedecisions as labels
Layered architecture: extraction and comparison are separate, validated steps; the lawyer is the last layer, not an optional one.

Extraction used structured outputs, where the model's response is constrained to a supplied JSON Schema2. Each clause came back with its type, section reference, verbatim quote and confidence. A deterministic check then confirmed that every quote actually appeared in the source document. See structured outputs for reliable LLM integration.

The data flow, end to end

  1. UploadContract parsed with its numbering and structure preserved
  2. ExtractClauses returned as schema-valid records with verbatim quotes
  3. VerifyQuotes checked against the source; mismatches flagged, not hidden
  4. RetrieveRelevant playbook positions and fallbacks for each clause type
  5. CompareClause against playbook; propose redline citing both texts
  6. ReviewLawyer accepts, edits or rejects; decision logged for evaluation
Two kinds of citation travel with every suggestion: where it is in the contract, and which playbook position it applies.

The hard part: long context versus retrieval

A single contract usually fits within a modern model's context window, so the temptation is to put everything in: the contract, the whole playbook, and a pile of precedents. Research on long contexts shows models use information at the start and end of the input more reliably than information in the middle3, which is a poor property when the clause that matters is on page fourteen.

The design split the jobs:

  • The contract is read whole for extraction, because cross-references and definitions matter.
  • The playbook is retrieved per clause, in the spirit of retrieval-augmented generation4, so each comparison sees only the relevant positions.
  • Comparison runs clause by clause, with small, focused prompts that are easier to evaluate.

The trade-offs are covered in long context vs RAG.

Contracts from counterparties are also untrusted input. Prompt injection tops the OWASP Top 10 for LLM applications5, so contract text was always treated as data, the model had no tools that could act on it, and outputs were constrained by schema. See prompt injection defence.

A suggestion a lawyer can verify in ten seconds is worth more than a fluent paragraph they have to check from scratch.

How the engagement ran

Lawyers
  1. Turn the playbook into positions
  2. Label a test set
  3. Review and decide
System
  1. Extract and verify
  2. Compare and cite
  3. Log every decision
AI lead
  1. Run evaluations per clause type
  2. Gate releases on results
  3. Tune prompts and schema
Lawyers define correctness; the evaluation gate decides what ships.
Phase 1Playbook as data
  • Clause taxonomy
  • Positions and fallbacks
  • Red lines
Phase 2Extraction
  • Schema design
  • Quote verification
  • Labelled test set
Phase 3Comparison
  • Per-clause retrieval
  • Cited suggestions
  • Review UI
Phase 4Operate
  • Evaluation gate
  • Decision feedback
  • More contract types
Phased delivery: one contract type end to end before broadening.

Key decisions and trade-offs

DecisionAlternativeWhy
Structured extraction firstFree-text review in one promptValidatable, comparable, displayable output
Verbatim quotes checked in codeTrust the model's quotesCatches fabricated or paraphrased citations
Playbook as structured positionsPlaybook document in the promptPrecise retrieval; easier to maintain
Evaluation per clause typeOne overall accuracy figureStrong clause types ship; weak ones wait
Lawyer decides every suggestionAuto-apply high-confidence redlinesAccountability stays with the profession

Building evaluation sets that hold up in production is covered in evaluation sets that predict production.

What I'd do again, and differently

Again: turn the playbook into data before writing a prompt, and treat lawyer decisions as the evaluation signal. Differently: involve lawyers in schema design from the start. The clause taxonomy is a legal decision, and the earlier they own it, the fewer rework cycles follow.

If you're considering AI for review work like this, the AI architect page describes how I run these engagements, or analyse your challenge and bring the result to a call.

References
  1. 1
    CUAD: An Expert-Annotated NLP Dataset for Legal Contract ReviewHendrycks et al. (arXiv; NeurIPS 2021 Datasets and Benchmarks) · 2021
  2. 2
    Structured outputsAnthropic documentation
  3. 3
  4. 4
  5. 5
    OWASP Top 10 for LLM Applications 2025OWASP GenAI Security Project
FAQ

Common questions

Can AI review contracts on its own?

It shouldn't. The reliable pattern is AI preparing the review: extracting clauses, comparing them to the playbook and proposing cited changes, with a lawyer making every decision.

Why structured outputs for clause extraction?

A schema forces the model to return the same fields every time, such as clause type, location, quoted text and playbook position, so the output can be validated, compared and displayed without fragile parsing.

Long context or RAG for contracts?

Both, for different jobs. The contract under review usually fits in context and should be read whole; the playbook, fallback positions and precedents are better retrieved selectively.

Keep reading

Related

Open to advisory, fractional CTO & select builds

Let's talk about what you're building.

The fastest route is a free 30-minute call. Prefer to write? Send a message and I'll reply personally within two business days.

Start a conversation

How would you like to reach me?

Book a 30-min callFastest. Pick any open slot on my calendar.→ Write in GmailOpens a pre-filled draft in your browser.→ Use my email appOutlook, Apple Mail or your default client.→

I reply personally within two business days. Time zones from the Americas and Europe to the Middle East and Asia-Pacific.