Project Overview and Business Context
The client was a UK commercial law firm with 35 fee earners. Their legal research process relied primarily on Westlaw and LexisNexis subscriptions, which are comprehensive but require skilled query formulation and significant time to synthesise results across multiple cases. Junior associates spent a disproportionate share of their time on research tasks that had limited learning value once the basic skill was developed, and the firm was losing money on research hours charged at junior rates. The brief was to build a tool that ingests the firm's own corpus of case summaries, annotated precedents, and matter notes alongside public case law, and allows solicitors to ask natural language questions and receive multi-source answers with citations. The tool needed to surface: the current legal position on a specific issue (what courts have held), divergent judicial approaches where case law is unsettled, relevant statutory provisions and how they have been interpreted, and any recent developments in the preceding 24 months that might affect the position. The SRA's developing guidance on AI in legal practice was a consideration: the tool needed to present citations in a format that allowed solicitors to verify sources independently, rather than presenting synthesised summaries without traceability. Invented or hallucinated citations are a significant professional risk in legal research.
Technical Architecture and Stack Decisions
The architecture is built around a multi-source vector search and generation pipeline. The corpus ingestion layer processes three data sources: the firm's internal case summaries and matter notes (exported from their practice management system as Word documents), a public case law corpus covering UK Supreme Court, Court of Appeal, and High Court decisions in the firm's practice areas (processed from BAILII exports), and statutory provisions and explanatory notes from legislation.gov.uk. All three sources are chunked, embedded using OpenAI text-embedding-3-large, and indexed in Weaviate with metadata: source type (internal/public case law/statute), jurisdiction, date, case name or statute title, and practice area tags. The retrieval layer uses LangChain to orchestrate a hybrid retrieval strategy: vector similarity search for semantic relevance plus keyword filter for jurisdiction and date range. Retrieved chunks are ranked, deduplicated, and selected for the generation context using a maximum marginal relevance algorithm that balances relevance and diversity. GPT-4o receives the retrieved chunks with a system prompt instructing it to synthesise a research response, cite every claim with the source document reference, flag where the law is unsettled across different judgments, and note any 2023-2026 developments that might affect the current position. The Next.js frontend presents the response with inline citations that link to source document excerpts. Solicitors can click any citation to see the relevant paragraph from the source document, verifying the AI's use of the source material.
Key AI and ML Components
GPT-4o handles synthesis and generation. The system prompt is designed for legal research: it instructs the model to distinguish between binding precedent and persuasive authority, to note the court level and jurisdiction for each cited case, to flag where a holding has been distinguished or overruled in later cases, and to identify when a question of law is unsettled. The prompt includes explicit instructions against synthesising holdings in ways that misrepresent the source material, with a fallback instruction to note uncertainty rather than extrapolate beyond what the sources directly support. LangChain orchestrates the multi-step retrieval and generation pipeline, including the hybrid search coordination, context window management for large retrieval sets, and the fallback logic when retrieved sources are insufficient to answer the query. The system includes a source sufficiency check: if the retrieved chunks have low average relevance scores for the query, the response includes a flag that the corpus may not have adequate coverage for this specific issue, prompting the solicitor to supplement with a Westlaw or LexisNexis search. Weaviate was chosen as the vector database because of its hybrid search capability (vector plus BM25 keyword search) and its ability to handle metadata filtering at query time, which is essential for restricting searches to relevant jurisdictions and date ranges.
Challenges Solved and How
Citation hallucination is the most serious failure mode in legal AI tools. The architecture addresses this through strict grounding: the system prompt instructs GPT-4o to cite only from the retrieved chunks provided in the context, and the response parser validates that every cited source reference appears in the retrieval metadata. If a citation does not match a retrieved source, the response is flagged for review rather than displayed. This does not eliminate all hallucination risk but catches the most obvious failure mode where the model invents a case name or misattributes a holding. Legal text is dense and requires different chunking strategies from general text. Case judgments have a specific structure: headnote, introduction, analysis, ratio decidendi, disposition. The chunking pipeline preserves this structure and tags each chunk with its document section, so the retrieval layer can weight ratio decidendi chunks more heavily for questions about the legal holding. The firm's internal documents required a separate handling approach due to confidentiality. Internal case summaries are indexed in a separate Weaviate collection with access restricted to the authenticated user and their matter team, and are never mixed with public case law in responses without an explicit indication that the source is internal.
Outcome and Measurable Results
The client deployed the tool to all 35 fee earners with a structured onboarding session covering how to formulate research queries and how to verify AI-generated citations. In the first eight weeks, the tool processed 2,340 research queries across the firm. Solicitor time spent on initial research scoping (the first-pass task of identifying relevant case law and statutory provisions) fell by an average of 65% based on time recording data. Seven solicitors reported using the tool to check their own initial legal analysis rather than delegating initial research to juniors, which they attributed to the speed of verification. Associate feedback highlighted citation verification as the most-used feature: 78% of users said they clicked through to source material on at least some queries. One senior partner credited the tool with identifying a 2024 Court of Appeal decision that overturned a 2019 High Court judgment they had been citing in standard client advice, a development that had not propagated through the firm's knowledge management system.
Lessons for Similar Projects
Source grounding is not optional in legal AI. Any tool that presents case law summaries without traceable citations to verifiable sources is a professional liability risk for the firm using it. Build the citation validation layer before the generation layer, not after. Invest in corpus quality over corpus size. A well-curated corpus of 5,000 case summaries in the firm's practice areas outperforms a poorly structured corpus of 50,000 general law documents for targeted legal research. Corpus curation, including duplicate removal, date stamping, and jurisdiction tagging, is often the largest component of the build effort and should be scoped accurately. Legal text requires legal-aware chunking. Preserve document structure in your chunks and tag section types. A chunk that contains only the headnote and not the ratio decidendi will produce misleading retrieval results. Design for hybrid search from the start. Pure vector search misses precise case name and citation lookups that solicitors frequently perform. Keyword search handles precision queries; vector search handles conceptual queries. Both are needed.