Composite scenario, not a real company. Assembled from common industry patterns; every number is illustrative and its assumptions are listed at the end.
This case belongs to Data and Retrieval Architecture for AI Systems.
Context
- The knowledge team of a commercial law firm maintains 6,500 precedent agreements and negotiated contracts, split into clauses (about 80 per agreement): 6,500 x 80 = 520,000 clause-level passages.
- Some questions are paraphrases: "which of our supply agreements let the buyer walk away on short notice?"
- Others name something exact: a clause number ("clause 14.3(b) of the 2019 supply agreement") or a defined term ("Permitted Disclosure", "Change of Control").
- A first assistant used embeddings only: retrieve the five nearest clauses, then ask a model to answer from them.
Problem statement
An evaluation set of 200 answerable questions (60 exact, 140 paraphrase) showed the split. A further 30 questions had no answer in the library.
| Measure | Result now |
|---|---|
| Right clause in top five, 60 exact questions | 21 (35%) |
| Right clause in top five, 140 paraphrases | 119 (85%) |
| Right clause in top five, all 200 | 140 (70%) |
| Unanswerable questions answered anyway | 22 of 30 (73.3%) |
The worst failure is the confident wrong one. Asked whether clause 14.3(b) of the 2019 supply agreement allows assignment without consent, the retriever returned an assignment clause from a different agreement, and the model answered from it.
Goal: the right clause in the top five for at least 90% of both groups, and at most 3 of the 30 unanswerable questions answered.
Constraints
- Fixed: every answer quotes the clause and names agreement, clause number and version.
- Fixed: a lawyer is accountable for the conclusion; the tool finds and reads clauses.
- Fixed: confidential agreements stay inside the firm's approved environment.
- Negotiable: a few seconds of latency, and the number of candidates reranked.
- Limit: the team has no search specialist; the lexical component must come from an existing engine.
Why the traditional approach fell short
| Approach | Strength | Why it fell short |
|---|---|---|
| Boolean keyword search | Finds "14.3(b)" and "Change of Control" exactly | Misses "terminate for convenience" when the text says "exit on notice" |
| Embedding-only retrieval | Matches meaning | Treats a clause number as noise: "14.3(b)" is near "14.3(c)" and near "12.1" of another agreement |
| Hand-tagged clause libraries | Covers anticipated types | Nothing outside those types |
Options considered
| Option | Why accepted or rejected |
|---|---|
| A. Keyword and boolean only, no AI: add clause-number and defined-term fields to the existing search | Kept as one half of the final design and as the fallback; exact, but blind to paraphrase |
| B. Embeddings only (the first assistant) | Rejected: misses exact terms and does not know when it is wrong |
| C. Hybrid lexical plus vector, rank fusion, reranker of the top 20, abstention | Accepted. Keep the reranker only if the evaluation shows it lifts the 90% target: it adds a model pass per candidate |
Solution architecture
Figure 1. Hybrid retrieval components
How to read this: two searches feed one merged list, a reranker orders it, and the orchestrator decides between answering and abstaining.
Figure 2. One question with the abstain path
How to read this: the two searches run side by side, and two checks, the score threshold and the quote check, stand between the retriever and the lawyer.
How AI solved it, step by step
Step through the clause 14.3(b) question, then switch to "Without the fix".
Under the hood
BM25 scores a passage by how often query terms appear in it, how rare each term is across the library, and the passage's length against the average. Elasticsearch's similarity documentation gives the defaults:
| Parameter | Default | Controls |
|---|---|---|
| k1 | 1.2 | How quickly repeated occurrences stop adding score |
| b | 0.75 | How strongly length matters |
Anthropic's contextual retrieval post says BM25 is "particularly effective for queries that include unique identifiers or technical terms", with the example of the error code "TS-999". A clause number and a defined term behave like those identifiers. Test whether "14.3(b)" survives your analyser as one token, or index clause numbers in a separate exact-match field.
Fusion uses reciprocal rank fusion. Cormack, Clarke and Büttcher define RRFscore(d) as the sum over rankings of 1 / (k + r(d)), "where k = 60 was fixed during a pilot investigation". Worked example: clause C (the one asked about) is 7th in the vector list and 1st in the lexical list; A is 1st and 2nd; B is 2nd in the vector list only. D to G are invented placeholders filling the vector list.
Score(A) = 1/61 + 1/62 = 0.0325; score(C) = 1/67 + 1/61 = 0.0313; score(B) = 1/62 = 0.0161. Fused order: A, C, B, then D to G. C moved from 7th to 2nd, and the reranker can promote it to 1st. Anthropic publishes that on its own datasets a reranked, contextual-embedding-plus-BM25 pipeline cut the top-20 retrieval failure rate by 67% (5.7% to 1.9%); treat that as a pointer to test. Details: Under the hood: BM25 and hybrid search.
What went wrong / failure modes
| Failure | Mitigation |
|---|---|
| Tokenisation splits the clause number: "14.3(b)" becomes fragments that match many clauses | Test it on the evaluation set; index clause numbers as exact fields |
| Defined terms in lowercase: the same words in their ordinary sense match too | Boost capitalised defined terms and check them against the agreement's definitions clause |
| Right clause, wrong version: a superseded amendment ranks first | Index the operative version and show its date |
| Threshold set too high: the system abstains on answerable questions | Set it on the evaluation set, track the abstain rate, and always offer keyword search |
Results
These are illustrative targets, not measurements.
| Measure | Now | Target |
|---|---|---|
| Exact questions, right clause in top five | 21 of 60 (35%) | 54 of 60 (90%) |
| Paraphrases | 119 of 140 (85%) | 126 of 140 (90%) |
| All 200 answerable | 140 (70%) | 180 (90%) |
| Unanswerable questions answered | 22 of 30 (73.3%) | at most 3 (10%) |
| Cost | none | A second search per query, plus 20 reranker passes per question |
Tradeoffs and when NOT to use this approach
- Two indexes must be kept in sync. If questions are almost all paraphrases, vectors alone may be enough.
- The reranker adds latency and cost. Skip it if the fused list already meets the target.
Design rules extracted
- Exact identifiers need lexical search; paraphrase needs vectors; legal text has both, so run both.
- Merge by rank, not by raw score, because the two scores are not comparable.
- Define when the system must say "no matching clause" and test it with questions that have no answer.
- Verify that every quote appears verbatim in the passage it cites.
- Keep the evaluation set split by question type so one average does not hide a weak group.
Assumptions
All numbers are illustrative.
- 6,500 agreements x 80 clauses = 520,000 passages.
- Evaluation set: 200 answerable (60 exact plus 140 paraphrase) and 30 unanswerable. Baseline: 21 / 60 = 35%, 119 / 140 = 85%, (21 + 119) / 200 = 70%; 22 / 30 = 73.3%. Targets: 54 / 60, 126 / 140 and 180 / 200 = 90%; 3 / 30 = 10%.
- Fusion uses k = 60 from Cormack, Clarke and Büttcher, "Reciprocal Rank Fusion outperforms Condorcet and individual Rank Learning Methods", SIGIR 2009 (read 2026-10-21 from http://cormack.uwaterloo.ca/cormacksigir09-rrf.pdf). The ranks of clauses A, B and C are invented; D to G are invented placeholders so that C sits 7th.
- BM25 defaults are Elasticsearch's, as stated at https://www.elastic.co/docs/reference/elasticsearch/index-settings/similarity and in https://www.elastic.co/blog/practical-bm25-part-2-the-bm25-algorithm-and-its-variables (read 2026-10-22); other engines may differ.
- The BM25 quotation and the 67% figure come from https://www.anthropic.com/news/contextual-retrieval (read 2026-10-21); the 67% is Anthropic's result on its own datasets.
- Top 20 for reranking and the score threshold are illustrative. The firm, agreements and clause are invented. Not legal advice.
Last verified: 2026-10-22