Let’s talk

Legal document intelligence

Ask the contract library a question, get a cited answer.

Client
An in-house legal team
Sector
Legal
Status
Delivered
  1. Business problem

    What problem are we actually solving?

    A legal team held thousands of executed agreements, precedent clauses and internal guidance notes, but answering a simple question (what indemnity language did we accept on similar deals, which agreements have a change-of-control clause) meant knowing which documents to open and reading them. Institutional knowledge lived in a few senior people's heads, and every query interrupted them.

  2. Target users

    Who is this for, and what does their day look like?

    In-house lawyers and paralegals, and secondarily the commercial and property teams who needed a fast first answer before involving legal.

  3. Current process

    How does it work today, and where does it hurt?

    Keyword search across a shared document library, followed by manual reading. No semantic search, no way to ask a question in plain language, and no record of what had been asked before. Simple questions took 30 to 60 minutes; complex ones went to the senior lawyers' queue.

  4. Desired outcomes

    What does better look like?

    • Natural-language questions answered from the organisation's own documents, with the source passage cited every time.
    • New documents automatically ingested as they were added, with no manual reindexing.
    • A first answer available in seconds, so senior lawyers only see the questions that need them.
    • An audit trail of questions and answers.
  5. Constraints

    What limits, systems, data or rules apply?

    • Confidential legal material: nothing could leave the organisation's controlled environment, and self-hosted components were preferred over managed SaaS where possible.
    • Every answer had to cite the exact source chunk. An uncited answer was worse than no answer.
    • No budget for an enterprise search platform; it had to be built from existing tooling.
    • Had to be maintainable by the team after handover, not just by its builder.
  6. Success metrics

    How will we know it worked?

    • Time to answer a routine document question, against the 30 to 60 minutes it took by hand.
    • Share of questions resolved without escalation to senior counsel.
    • Documents indexed and kept current automatically.

What was built

  • A retrieval-augmented generation pipeline orchestrated entirely in N8N.
  • Ingestion flow: watches the document library for new or changed files, extracts text (including OCR for scanned PDFs), splits it into overlapping chunks with document and section metadata, generates embeddings and upserts them into Supabase with pgvector.
  • Query flow: receives a question from a simple web form, embeds it, retrieves the top matching chunks, and passes them with the question to Claude through the Anthropic API under a strict system prompt: answer only from the provided context, and cite every claim.
  • Response: returns the answer with document name, section and quoted passage for each citation, and logs the exchange for audit.
  • Guardrails: refuses to answer when retrieval confidence is low rather than guessing, and flags questions that need a lawyer.
  • Deployed in Docker, self-hosted, with the whole pipeline visible and editable in N8N so the team could adjust chunking, prompts or sources without a developer.