We built AILegal — a legal assistant for people who can't afford a lawyer — around a single rule: never state a legal fact we haven't verified against the official source. This post is about the engineering that makes the rule enforceable, and about what still doesn't work.
The failure that started it
Early versions used the usual approach: a careful prompt, a corpus in the context window, "answer only from these sources". It failed in ways that are easy to miss if you don't check:
- it cited 18 U.S.C. § 301 in a form that doesn't exist;
- it quoted Consumer Credit Act 1974 s. 157 — a real section, but about something else entirely.
Neither answer looked wrong. That's the dangerous part: a plausible citation is worse than an obvious refusal.
Verification as a data structure, not a prompt
Every norm in the corpus is a record, not a paragraph in a prompt:
Norm(
id="us-cares-4024c",
code="15 U.S.C. § 9058(c)",
jurisdiction="us",
summary="...", # plain-language, human-reviewed
source_url="https://...", # official text
source_hash="...", # hash of the checked version
checked_at="2026-10-18",
verified=True, # human review passed
)
The corpus currently has 53 norms: 11 Russian, 26 US, 9 UK, 7 Canadian.
A scheduled job runs every three days. It fetches every official source, requires that the numbers and terms from our summary actually appear in the fetched text, and stores a hash of the version it checked. If the hash changes, the norm is flagged for a human re-check.
verified is deliberately not set by the machine. The script proves "the text says what we claim"; a human decides "this norm is usable for a deadline". Those are different claims, and conflating them is how legal AI ends up inventing law.
The gate
At answer time the rule is boring on purpose: if a norm isn't verified, the assistant does not name deadlines or article numbers derived from it. It says what it can't confirm and asks for the missing fact.
We also measured a "soft" classifier that catches paraphrases by word-stem similarity. The exact stage resolved 12 of 31 test paraphrases; the soft stage added hints for 14 more, of which 8 were correct — roughly 57% precision. That is nowhere near enough to answer a legal question: every other hint would be about a different problem. So the soft stage only asks a clarifying question. It never produces a verdict.
What still doesn't work
Synonyms. "вычисли" vs "посчитай", "списали" vs "удержали" — different words, same meaning. Without a source of synonymy, similarity scoring can't tell them apart. We tried local embedding models (nomic-embed-text, qwen3-embedding) on a canonical paraphrase; the results were top-3/top-4 with cosine gaps of 0.001–0.03 — noise. The real fix is not a better model but a semantic representation of the norms themselves: everyday search phrasings, written and reviewed per norm. That's legal work, not a prompt tweak.
Why this matters
If you ask a legal assistant "what's the deadline?" and it answers confidently, you can't tell a verified answer from a hallucinated one. The gate makes the failure mode boring: "I can't confirm this from the official text." Boring is what you want when the cost of a wrong answer is a missed court deadline.
Try to break it: ailegal.legal — take any norm, compare it with the source it links to, and try to make the assistant state something the source doesn't.
Not legal advice. Legal content is RU/EN; the interface speaks more languages.
Top comments (0)