Inspiration

I have always been fascinated by jurimetrics—the idea that law, despite its human complexity, contains patterns that can be analysed, measured, and understood computationally. As both a data protection professional and a software builder, I have spent years thinking about how AI can support legal decision-making without replacing human judgment. That curiosity ultimately led to LEXI.

My long-term goal is simple but ambitious: to automate justice ethically. Not by allowing AI to make legal decisions, but by building systems that help lawyers and regulators work more consistently, transparently, and with greater confidence in the information before them.For this project, I chose the Solicitors Disciplinary Tribunal because it presents exactly the kind of high-stakes environment where factual accuracy matters. If an AI invents a case citation or misquotes a judgment, the consequences can be serious. That became the central design challenge: not making the model sound intelligent, but making it demonstrably trustworthy.

How I Built It

LEXI is a verification-first multi-agent system, and bringing it to life started from the ground up. I built a custom scraper to extract a corpus of more than 2,100 Solicitors Disciplinary Tribunal judgments. Once the data was extracted, I relied exclusively on Qwen for all the embeddings. Remarkably, the entire development process—from scraping the raw data to testing the multi-agent reasoning steps, and even performing complete re-embeddings of the corpus during iteration—was accomplished entirely within my $40 cloud voucher. Rather than relying on a single LLM call, specialised agents perform distinct responsibilities throughout the pipeline. Cases are deterministically resolved before semantic retrieval begins, relevant authorities are retrieved from the corpus, quotations are verified against the underlying judgment text, and unsupported claims trigger automatic regeneration before an answer is returned. To demonstrate that the architecture genuinely improves reliability, I built a benchmarking harness that compares the complete multi-agent pipeline against a single-agent baseline using the same legal research prompts. The evaluation measures fabricated case citations, unverified quotations, and the system's ability to reject intentionally fake case numbers using deterministic scoring rather than another LLM as the judge.

Challenges

The most difficult part of the project was not building the interface—it was building confidence in the underlying data and reasoning pipeline while operating under strict resource constraints. The first major challenge was extracting a usable legal corpus. Scraping and converting thousands of tribunal judgments into structured, searchable text required extensive OCR processing, cleaning, and validation to preserve the accuracy of the original decisions. Semantic retrieval required extensive refinement, which meant I had to re-embed the corpus multiple times. Doing this while strictly managing my $40 voucher budget forced me to be highly efficient with my Qwen API calls. Small improvements in ranking and retrieval quality produced disproportionately large improvements in the quality and reliability of the final answers, making retrieval accuracy just as important as the language model itself. Another significant challenge was eliminating hallucinations. Legal AI cannot afford to invent authorities or quotations, so I designed multiple verification stages that compare generated answers against retrieved source material and force regeneration whenever unsupported claims are detected. I also had to debug the compliance scanner so that it consistently distinguished between genuine regulatory risks and unsupported assertions without overwhelming users with false positives.

Finally, managing latency became an engineering challenge. Verification, quotation checking, retrieval, and regeneration all improve reliability but add computational cost. A significant part of the work involved balancing responsiveness with the level of verification required for high-stakes legal research.What I LearnedThe biggest lesson from this project is that the quality of an AI system depends far more on its architecture than on the language model alone.Reliable AI is built through careful retrieval, structured verification, measurable evaluation, and clear human oversight—not simply by writing better prompts. Furthermore, building this entire pipeline within a strict $40 budget taught me the immense value of efficient system design and deterministic preprocessing.

Working on LEXI reinforced my belief that AI has an important role to play in the legal profession, provided it is designed around transparency, accountability, and evidence. Those principles have guided every engineering decision in this project and continue to shape my broader goal of building systems that help automate justice ethically while keeping human decision-makers firmly in control.

Built With

Share this project:

Updates