Back to journal
AI & Automation

Inside law-search.impetik.com: The Architecture of a Production Legal RAG

We built a legal search engine that returns grounded, citable answers across 40 years of Somali law. Here's the retrieval architecture, the embedding strategy, and the lesson we learned about hallucinations the hard way.

D
dhaqaner
Principal Engineer
30 April 2026 12 min read

law-search.impetik.com lets a lawyer ask a natural-language question and get back an answer grounded in actual statutes — with citations, paragraph numbers, and links to the source document. Building it taught us more about retrieval engineering than any of the prior AI projects we've shipped.

Retrieval beats reasoning

We spent two months tuning the LLM. We spent six months tuning the retriever. The biggest accuracy gains came from hybrid search — sparse plus dense, with a learned re-ranker on top. The model on the end of the pipeline matters less than the chunks you feed it.

Hallucinations and how we killed them

Citations as a hard constraint. The system refuses to answer unless every claim in the response can be traced back to a retrieved chunk above a confidence threshold. The cost is occasionally saying 'I don't know' when a softer system would guess. In legal work, that's the right tradeoff.

Tagged
#h #tgsetrgv
D
Written by
dhaqaner
Principal Engineer · Impetik
Get in touch