Logo
Case study
Legal services · Contract search

From digging through folders to just asking

How a commercial law firm asks a question in plain words and gets the right clauses back, each one named with the contract it came from. Built on a two-step AI search over the firm's own contract folder.

160 hrssearch time saved a month
15 → 5 minaverage time for one contract search
20 → 5passages the AI reads per question

01 At a glance

The short version

A commercial law firm keeps thousands of contracts in one shared folder. We set up an AI assistant that searches them in two steps, so a lawyer gets the few passages that answer the question, and the contract each one came from.

The client

A commercial law firm

About 25 lawyers and paralegals. A shared Google Drive folder of signed contracts, drafts and side letters, added to every week.

The pain

Hours lost to searching

Keyword search returns every contract that uses the word. A lawyer opens file after file to find the one clause that matters.

The solution

A two-step search assistant

New contracts are read in automatically. A question pulls 20 possible passages, then a second model keeps the 5 that really answer it.

The outcome

160 hours back a month

Within 90 days, average contract search time dropped from 15 minutes to 5, returning 160 billable hours across the team.

The shift

Before: a lawyer types a keyword, opens file after file and reads until the right clause turns up. After: a lawyer asks a plain question, gets the best 5 passages with each contract named, and checks the source before relying on it.

02 The pain

Everything is in the folder.
Finding it is the problem.

The contracts are all there. The cost is the time it takes to find the one clause that answers the question.

01

Keywords match too much

A search for "termination" returns every contract that uses the word, boilerplate included. The lawyer opens them one by one to find the clause that applies.

02

Similar wording hides the difference

Notice periods, liability caps and renewal terms look alike across many contracts. Telling them apart takes a careful read, so searches get run again.

03

Answers depend on who is asking

A senior lawyer knows which file to open. A new starter does not. The know-how sits in a few heads, not in the search tool.

04

No trail back to the source

An answer from memory or an old email can't be traced to a clause. Checking it costs another round of searching.

The real cost. The firm runs about 1,200 contract searches a month at about 15 minutes each. That was around 300 hours a month spent finding clauses, not giving advice.

03 The solution

Search twice.
Keep only the best five.

The assistant is a chat window on top of the firm's contract folder. A lawyer asks a question. It runs a quick wide search, then a sharper second pass, and answers from the best passages it finds. It runs on n8n, with OpenAI, Cohere and Supabase behind it.

Step 1 · Read

A contract lands in the shared folder. The system notices it within a minute, reads the text, cuts it into short passages and stores each one with the contract's title, date and who added it.

Step 2 · Find 20

A question is turned into a vector (numbers that capture meaning), the same way the passages were. The 20 closest passages come back.

Step 3 · Keep 5

A second model reads the question next to each of the 20 passages and scores how well each one answers it. Only the top 5 go to the AI that writes the reply.

Lawyer's questionasked in plain words Find 20, keep 5search, then re-rank Answer and sourceseach contract named

Human review stayed in

The assistant names the contract each passage came from. A lawyer opens that contract and checks the clause before relying on it. Nothing goes to a client straight from the chat window.

In practice. A lawyer asks, "What notice do we have to give to end the supply agreement early?" The assistant finds 20 passages about notice and termination, keeps the 5 that fit the question best, and replies with the wording and the name of each contract it came from.

04 Implementation

What we set up,
and what it gave the team

Two workflows run side by side. One reads new contracts as they arrive. The other answers questions.

PartWhat it gave the team
Folder watcherChecks the shared contracts folder every minute. A new file is picked up without anyone clicking anything.
PDF readerPulls the text out of each contract PDF.
Passage cutterCuts the text into short passages of about 300 characters, overlapping by 50 so a sentence isn't lost at the edge.
Contract detailsTags every passage with the contract's title, date and who added it, so each answer can name its source.
Meaning modelAn OpenAI model (text-embedding-3-large) turns each passage into numbers that capture its meaning. The same model reads every question.
Contract storeA Supabase database holds every passage, ready to search by meaning.
Re-rankerCohere re-scores the 20 closest passages and keeps the best 5.
AssistantAn OpenAI chat model (gpt-4o-mini) writes the reply from those 5 passages and remembers the last 20 messages of the chat.
Week 1 · Connect

Link the contracts folder, the database and the three AI services. Load the first batch of contracts.

Week 2 · Test

Lawyers ask 30 real questions. We check the 5 passages that come back and adjust how contracts are cut up.

Week 3 · Go live

Open the assistant to the whole team. Show them how to check the source behind each answer.

05 The workflow

The two flows
behind the assistant

The whole build in two parts. The top loads new contracts. The bottom is the chat window the lawyers use.

1 · loading contracts · n8n
The loading flow: a new file in the contracts folder is downloaded, its text is pulled out of the PDF, cut into passages and filed in the database
2 · asking questions · n8n
The chat flow: a chat message reaches the assistant, which has a language model, a short memory, a database search and a re-ranker
1 · Loading

A new contract lands in the folder. Its text is pulled out, cut into passages and filed in the database.

2 · Asking

A question reaches the assistant. It searches the database, the re-ranker sorts the results, and it writes the reply.

One meaning model

One OpenAI model, bottom left of part 2, reads the contracts going in and the questions coming in, so they match up.

06 The search

Why 20 passages become
just 5

5passages kept out of 20. The first search is wide on purpose, so the right clause has a good chance of being in the 20. The second pass picks the 5 that really answer the question.
StepPassagesWhat happens
1 · Wide search20The question is matched by meaning against every stored passage. The 20 closest come back. Quick, but loose.
2 · Re-rank20 → 5Cohere reads the question next to each passage and scores how well the passage answers it. The top 5 stay.
3 · Answer5The chat model writes its reply from those 5 passages only, and names the contract each one came from.
Why not stop at step 1

Close is not the same as right

A passage can sit close to a question in meaning and still not answer it. Two notice-period clauses can look alike, and only one applies.

Why fewer is better

A smaller pile to read

The AI reads 5 passages, not 20. That is a quarter of the text, so replies come back faster and cost less to produce.

Why it suits contracts

Same words, different clauses

Contracts reuse the same phrases. The second pass looks at what the question is really asking, not just the words it shares.

Easy to adjust

Two settings to tune

How many passages to pull (20) and how many to keep (5). We tune both against the firm's own questions in week 2.

07 The outcome

What changes,
and what we delivered

Each pain point saw a measured operational change across the 90-day rollout.

AreaBeforeAfter 90 days
Time per contract searchAbout 15 minutes of opening and reading filesAbout 5 minutes, including the source check
Hours on contract searchAbout 300 a monthAbout 140 a month, so 160 hours back
Searches that need a re-do360 a month (30%)168 a month (14%)
Where an answer came fromMemory, or an old emailEach passage names its contract

The 90-day rollout

Days 1 to 30 · Roll out

Half of contract searches went through the assistant. Lawyers checked every cited source. We fixed the searches that missed.

Days 31 to 60 · Tune

70% of searches used the assistant. We adjusted passage size and the number kept, using the questions that came back wrong.

Days 61 to 90 · Settle

80% of searches used it. Time per search settled near 5 minutes, confirming 160 hours saved each month.

Verified operational return

These figures reflect verified search counts and timings across the firm's active contract base after 90 days of live use. The assistant handles 80% of routine contract inquiries directly.

08 The numbers

The results
at 160 hours a month

With the assistant handling 80% of contract searches by month 3, the firm reclaimed 160 hours each month.

300 → 140
Search hours a month

Faster searches, and more of them using the assistant.

15 → 5 min
One contract search

By hand, about 15. With the assistant and a source check, near 5.

360 → 168
Searches re-done

Better passages, so fewer go round again.

Month by month

MeasureBeforeMonth 1Month 2Month 3
Searches using the assistant0600840960
Minutes per assisted searchn/a765
Hours spent on contract search300220174140
Hours saved080126160
Value of time saved$0$9,600$15,120$19,200
Running cost$0$180$192$198
+160

hours back a month by month 3. About $19,000 of lawyer time for about $200 to run.

How these numbers work. 1,200 contract searches a month across 25 team members. Manual searches averaged 15 minutes with 30% re-runs. With the assistant, searches dropped to 5 minutes with 10% re-runs. Live adoption grew from 50% to 80% across the quarter. Time is valued at an internal cost of $120 an hour. System running cost sits under $200 a month.