Engineering
How we build legal AI
Most of legal AI does not show its work. These are the internals of ours: what our citation verifier actually checks, how retrieval survives a pin cite to a subsection, how we write native Word tracked changes, and the infrastructure underneath. Written by the people who ship it, and specific enough to argue with.
We Made Our Database Deliberately Lose All Its Data
Why we run a production database UNLOGGED on purpose: for a derived, reproducible dataset, durability is a cost, not a virtue, and the recovery path is the refresh path.
Priyansh Khodiyar · 12 min readReadCutting a BM25 Index Build From Four Hours to Ninety Minutes
How we cut a BM25 index build from four hours to ninety minutes: index build time scales with the bytes of text you hand the tokenizer, not the row count.
Priyansh Khodiyar · 14 min readReadWho in Legal AI Actually Shows Their Work?
Who in legal AI actually publishes real engineering content? A survey of the sector's transparency, and why showing your work is a costly signal a small team can send.
Priyansh Khodiyar · 12 min readReadHow We Think About Hallucination in Legal AI
A seven-type taxonomy of legal AI hallucination mapped to a four-layer defense: retrieval grounding, prevention, detection, and honest uncertainty.
Priyansh Khodiyar · 16 min readReadHow to Write Real Word Tracked Changes in Python
How to emit native Word tracked changes (w:ins and w:del) from Python with lxml, including the delText gotcha that silently breaks Reject.
Priyansh Khodiyar · 15 min readReadThe Deterministic Layer Under the LLM
Where we deliberately do not use a model: deterministic, testable backstops at the boundaries where correctness is non-negotiable.
Priyansh Khodiyar · 12 min readReadHow We Keep a Legal-AI Product From Regressing
Layered evaluation for a legal AI product: a deterministic routing sweep plus a live end-to-end harness, diffed before every rollout.
Priyansh Khodiyar · 14 min readReadWe Ran 1,341 Prompts Through Our Router to Find Out What Misroutes
We ran 1,341 prompts through our router and published the results, including the severe false-whole-doc misroute metric.
Priyansh Khodiyar · 18 min readReadHow to Verify an AI's Citations in Code, Not With Another Model
Deterministic citation verification in code: range-check, substring-verify, drop-and-downgrade, then a gated model call.
Priyansh Khodiyar · 14 min readReadOne Retriever Is Not Enough
Multi-query, corrective RAG, self-RAG, multi-hop, and HyDE as our code actually runs them, including which ones fire by default.
Priyansh Khodiyar · 14 min readReadResearch a Hard Question the Way a Lawyer Would: In Pieces, Then Synthesized
Decompose a multi-issue legal question into dimensions, research each in parallel, and render a cited Word memo verbatim.
Priyansh Khodiyar · 13 min readReadKnowing When You Do Not Know
Multi-sample consistency, sentence-level groundedness, and calibration that discounts overconfidence: how a legal AI knows when it does not know.
Priyansh Khodiyar · 12 min readReadTeaching the Reviewer How Your Firm Negotiates
The playbook data model behind an AI reviewer: standard position, fallback ladder, deal-breaker floor, and a deterministic structure linter.
Priyansh Khodiyar · 14 min readReadDraft the Fix, But Earn It
An agentic per-clause repair loop that plans, diagnoses, drafts, validates, and critiques, and knows when to abstain.
Priyansh Khodiyar · 14 min readReadCall US Law From Your Own Code: The Statutes and Regulations API
Call US law from your own code: the statutes and regulations API over USC, CFR, state codes, and court rules, with official-source links.
Priyansh Khodiyar · 10 min readReadA Spreadsheet Where Every Cell Is a Cited, Verified Extraction
A document matrix where every cell is a cited, verified extraction: per-cell retrieval, a strict two-outcome schema, and literal-substring verification.
Priyansh Khodiyar · 13 min readReadThe Tracked Changes a Document Is Hiding
Deterministic OOXML detection of the tracked changes, moves, and hidden text a document is hiding behind its rendered view.
Priyansh Khodiyar · 11 min readReadReal Word Redlines, Not a Diff View
Native OOXML tracked changes a lawyer can Accept or Reject in Word, plus the grounding and sign-off gates behind them.
Priyansh Khodiyar · 11 min readReadThe Law Is Not Clean Data
Defensive modeling for messy US statutes: alphanumeric title numbers, an amendment-year sanitizer, and the guards that keep dirty data honest.
Priyansh Khodiyar · 13 min readReadExtract Once, Read Many: The Shared Evidence Spine Behind a Matter Workspace
One extraction spine behind Facts and Summary: extract once, read many, and stay consistent by construction rather than by reconciliation.
Priyansh Khodiyar · 12 min readReadSending 'Rewrite This Transcript, NOT a Summary' to the Right Engine
Why an LLM classifier alone misroutes 'rewrite this, NOT a summary', and how deterministic regex guards backstop it.
Priyansh Khodiyar · 14 min readReadCatching a Fabricated [N] Before It Reaches the Lawyer
A deterministic, zero-false-positive gate that strips fabricated citation markers before they reach the lawyer, distinct from after-the-fact verification.
Priyansh Khodiyar · 11 min readReadWhat Our Citation Verifier Actually Checks
What a legal AI citation verifier actually checks: a two-phase verifier, why the denominator matters, and six prompts to test any vendor's verifier.
Priyansh Khodiyar · 15 min readReadHybrid Retrieval for Law, and the Citation-to-a-Subsection Problem
Why semantic search is blind to exact identifiers like a pin cite to a subsection, and how dense plus BM25 plus reranking fixes it.
Priyansh Khodiyar · 11 min readReadReview contracts, draft policies, and ship faster, with cited authority.
Every answer shows its source. Your data stays yours, we never train on it. 7-day free trial.