Blog Case Studies

Case Study: Document Intelligence for a Lagos Law Firm

How we built a RAG-powered document intelligence system that reduced research time by 70% for a 40-attorney firm in Lagos.

Rex Kelly
Rex Kelly
Engineer
· 07 June 2026 · 4 min read

The client

A full-service commercial law firm in Victoria Island, Lagos — 40 attorneys, specialising in corporate transactions, infrastructure finance, and regulatory compliance. The firm handles a mix of Nigerian law matters and cross-border transactions governed by English law.

We are not naming the firm at their request, but the results in this case study are accurate.

The problem

Legal research is time-intensive and expensive. Associates at Nigerian law firms routinely spend 3–6 hours researching the precedents and regulations relevant to a single transaction opinion. Much of this research involves searching through:

  • Internal precedent files (thousands of prior transaction documents, opinions, and memos)
  • Regulatory circulars from the Central Bank of Nigeria, the SEC, and sector regulators
  • Legislation and statutory instruments from the National Assembly
  • Annotated case law databases

The internal precedent files were the biggest pain point. They lived in a shared drive organised loosely by transaction type, with inconsistent naming conventions accumulated over 15 years. Experienced partners knew where to look. Junior associates did not.

The solution: a hybrid retrieval system

We built a document intelligence system using a hybrid retrieval architecture — combining vector similarity search (for semantic relevance) with BM25 keyword search (for precise legal terminology). This hybrid approach outperforms either method alone on legal content, where both conceptual similarity and exact term matching matter.

Document processing pipeline

We ingested approximately 12,000 documents from the precedent library and regulatory archive. The processing pipeline:

  • PDF extraction with layout preservation (tables, footnotes, numbered clauses)
  • Document chunking at clause boundaries, not arbitrary token counts
  • Metadata extraction: document type, transaction type, jurisdiction, date, parties
  • Dual embedding: dense embeddings for semantic search, sparse for keyword search

Chunking at clause boundaries was one of the most important decisions. Legal documents derive meaning from clause structure. A chunk that cuts across clause boundaries creates context-free fragments that retrieve poorly and confuse the model when used as context.

The retrieval interface

We built a chat interface where attorneys can ask questions in natural language — "what are typical representations and warranties in an LNG offtake agreement under Nigerian law?" — and receive an answer grounded in the firm's own precedents, with citations to the specific documents and clauses retrieved.

Every answer includes the sources used. Attorneys can click through to the original document. Trust in the system depends entirely on this transparency — if the answer is wrong, the attorney needs to know where the wrong information came from.

Access controls

Not all documents are accessible to all staff. Partner memos and client-confidential opinions are restricted. We implemented role-based access controls at the retrieval layer, so the vector search query only scans documents the user is permitted to see. This was a non-negotiable requirement before the system could go live.

The results

After a 60-day pilot with 12 associates:

  • Research time per opinion: down from an average of 4.2 hours to 1.3 hours — a 69% reduction
  • Precedent reuse rate: up from approximately 30% (estimated by partners) to over 70% — associates are now building on the firm's own work rather than starting from scratch
  • Associate satisfaction: 9.1/10 on the pilot survey — the system was described as "the single most useful tool we have added in five years"
  • Partner review time per associate memo: reduced by approximately 40%, because the memos now cite firm precedent more consistently

What we learned

The quality of the document collection matters more than the model. We ran the same queries against GPT-4o and Claude Sonnet and found minimal difference in answer quality. The dominant factor was retrieval quality — whether the right chunks made it into the context window.

Domain vocabulary is an unsolved problem in standard embeddings. Nigerian legal terminology (CAMA 2020 provisions, CBN prudential guidelines, specific regulatory frameworks) is underrepresented in general-purpose embedding models. We fine-tuned a custom embedding model on a corpus of Nigerian legal text to improve retrieval precision by about 18% on domain-specific queries.

Change management takes longer than the build. We spent roughly equal time on technical implementation and on embedding the system in attorney workflows. The partners who championed the tool internally were more important to adoption than any feature we built.

What is next

The firm is now expanding the system to include real-time monitoring of CBN and SEC regulatory circulars, with automatic summarisation of new circulars and relevance tagging against the firm's active practice areas. The groundwork for this was laid in the initial architecture — adding new document sources to an existing retrieval system is incremental work once the pipeline is running.

Tags #rag #case-study #legal-ai #document-intelligence #africa
Rex Kelly