All cases
Legal function, contract work

AI contract review: diffing against a reference template and flagging risky wording

First-pass contract review: key fields extracted, clause-by-clause diff against a reference template, risky wording flagged with an explanation. From 1-2 hours of reading to a report in minutes.

Scale
PDF and DOCX, clause-level report
Stage
In production
Delivered
April 2026

TL;DR. Manually diffing an incoming contract against the reference template cost a lawyer 1-2 hours per document. The system parses PDF or DOCX, extracts the key fields, compares clause by clause against the template, and flags higher-risk wording — liability, deadlines, penalties — with an explanation of why the clause is risky.

Situation: where a lawyer's time goes

A contract from a counterparty arrives in their own edit. To see what changed against the company's own template, the lawyer reads the whole document: checks the structure, hunts for added and deleted clauses, marks wording that shifts liability.

One contract took 1-2 hours. With any real volume of documents, the first pass became the bottleneck: the lawyer spent most of their time proofreading rather than deciding.

Task

  1. Automate the first pass, before a human picks the document up.
  2. Show differences from the reference template clause by clause, not "in general".
  3. Flag higher-risk wording separately, with the reason.
  4. Leave the decision with the lawyer: the system prepares material, it doesn't rule.

What we built

The pipeline accepts a contract as PDF or DOCX. The document is parsed with its clause structure intact — which matters, because the comparison runs clause by clause rather than over flat text.

Key fields are extracted: parties, subject, deadlines, amounts, payment terms, liability, termination procedure. The extracted structure is matched against the company's reference template, and the system shows which clauses were added, which were deleted and which were rewritten.

A language model works on top of that comparison: it marks higher-risk clauses by category — liability, deadlines, penalties — and states in words what the risk actually is. The output is a structured report, and the lawyer starts from the flagged passages.

Contract report: differences from the template and higher-risk clauses

Result

Key technical decisions

  1. Parsing that preserves clause structure. The contract is parsed as a tree of clauses, not flat text. Without that, comparing against the template produces noise: a moved paragraph reads as a change of substance.
  2. Template diffing kept separate from LLM flagging. Differences from the reference are computed deterministically. The language model only rates risk and explains it, so a structural discrepancy can never be blamed on a hallucination.
  3. Risk categories rather than one overall score. Liability, deadlines and penalties are separated: the lawyer needs to know where the balance shifted, not how "bad" the contract is as a single number.
  4. An explanation on every flag. A flagged clause without a reason is useless — it has to be reread anyway. The model states what in the text creates the risk.

FAQ

Does the system replace a lawyer?

No. It covers the first pass: extracting fields, diffing against your template, flagging risky clauses. Legal judgement and the decision stay with a human, who simply starts from a marked-up document rather than a blank one.

Which contract formats are supported?

PDF and DOCX, including scans and documents with awkward layout — the parser pulls out clause structure, not just the text layer.

Can we use our own contract template?

Yes, the reference template is an input to the system. The comparison runs against the document the company treats as its own standard, not against some abstract model form.

Does contract data go to external services?

That depends on the perimeter. The review can be built on local inference, the same way the call analytics project keeps recordings on the client's servers. It gets settled during the audit stage, before work starts.

What would come next

The natural continuation is building up statistics per counterparty: which edits each of them makes to the template routinely, where the company systematically concedes. After that, wiring it to the counterparty check by tax ID, so a contract review arrives together with a report on the signing company.

If contract review has become your bottleneck, let's talk it through in 30 minutes.

Stack

  • Python
  • LlamaCloud
  • LLM API
  • PDF/DOCX parsing
  • structured report

Same process in your company? Cortex IT writes a mini-audit in 2-3 days, free of charge.

Request a mini-audit