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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
A question is turned into a vector (numbers that capture meaning), the same way the passages were. The 20 closest passages come back.
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.
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.
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.
| Part | What it gave the team |
|---|---|
| Folder watcher | Checks the shared contracts folder every minute. A new file is picked up without anyone clicking anything. |
| PDF reader | Pulls the text out of each contract PDF. |
| Passage cutter | Cuts the text into short passages of about 300 characters, overlapping by 50 so a sentence isn't lost at the edge. |
| Contract details | Tags every passage with the contract's title, date and who added it, so each answer can name its source. |
| Meaning model | An OpenAI model (text-embedding-3-large) turns each passage into numbers that capture its meaning. The same model reads every question. |
| Contract store | A Supabase database holds every passage, ready to search by meaning. |
| Re-ranker | Cohere re-scores the 20 closest passages and keeps the best 5. |
| Assistant | An OpenAI chat model (gpt-4o-mini) writes the reply from those 5 passages and remembers the last 20 messages of the chat. |
Link the contracts folder, the database and the three AI services. Load the first batch of contracts.
Lawyers ask 30 real questions. We check the 5 passages that come back and adjust how contracts are cut up.
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.
A new contract lands in the folder. Its text is pulled out, cut into passages and filed in the database.
A question reaches the assistant. It searches the database, the re-ranker sorts the results, and it writes the reply.
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
| Step | Passages | What happens |
|---|---|---|
| 1 · Wide search | 20 | The question is matched by meaning against every stored passage. The 20 closest come back. Quick, but loose. |
| 2 · Re-rank | 20 → 5 | Cohere reads the question next to each passage and scores how well the passage answers it. The top 5 stay. |
| 3 · Answer | 5 | The chat model writes its reply from those 5 passages only, and names the contract each one came from. |
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.
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.
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.
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.
| Area | Before | After 90 days |
|---|---|---|
| Time per contract search | About 15 minutes of opening and reading files | About 5 minutes, including the source check |
| Hours on contract search | About 300 a month | About 140 a month, so 160 hours back |
| Searches that need a re-do | 360 a month (30%) | 168 a month (14%) |
| Where an answer came from | Memory, or an old email | Each passage names its contract |
The 90-day rollout
Half of contract searches went through the assistant. Lawyers checked every cited source. We fixed the searches that missed.
70% of searches used the assistant. We adjusted passage size and the number kept, using the questions that came back wrong.
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.
Faster searches, and more of them using the assistant.
By hand, about 15. With the assistant and a source check, near 5.
Better passages, so fewer go round again.
Month by month
| Measure | Before | Month 1 | Month 2 | Month 3 |
|---|---|---|---|---|
| Searches using the assistant | 0 | 600 | 840 | 960 |
| Minutes per assisted search | n/a | 7 | 6 | 5 |
| Hours spent on contract search | 300 | 220 | 174 | 140 |
| Hours saved | 0 | 80 | 126 | 160 |
| Value of time saved | $0 | $9,600 | $15,120 | $19,200 |
| Running cost | $0 | $180 | $192 | $198 |
hours back a month by month 3. About $19,000 of lawyer time for about $200 to run.