4 min read
How LexAI was built: what a lawyer learned by writing code
Why general AI tools get legal references wrong, how LexAI loads provisions from the official source, and what I learned building a tool for Latvian legal language.
LexAI started with one observation: general-purpose AI tools write legal text with confidence, yet they fail exactly where a mistake costs the most, namely in references to legal provisions.
The problem is not language but the source
A large language model does not know the current wording of a statutory provision. It knows what provisions usually look like. So it can produce a section that sounds right but does not exist, or quote a version that is no longer in force. For a lawyer that is worse than no answer at all, because such an error is hard to spot.
The provision from the source, not from memory
That is why LexAI rests on a simple principle: every provision a document refers to is loaded from the official source. Latvian legislation comes from likumi.lv, European Union law from EUR-Lex. The document is drafted on the basis of that text, and after drafting every reference is compared against the loaded provision. If a section cannot be loaded, the document says so plainly instead of silently leaving it out.
The second level is an automated check: the document is tested for invented sections, outdated provisions and internal contradictions. When a question is high-risk or outside the areas the tool is built for, LexAI says so and recommends seeing a lawyer.
What I learned by writing code
- Latvian is also a technical problem. Long vowels, softened consonants and declensions break PDF export, text offsets and page breaks more often than you would think. Each of them had to be solved separately.
- An empty field matters as much as a filled one. A document must never invent facts that are not there. So the system has explicit logic: what can be inferred, what must be asked, and what stays visibly unfilled.
- A prompt is like a contract. The more precisely the obligations are described, the fewer surprises later. A well-written prompt is as structured as a good contract draft.
- Honesty is a feature. A tool that says "I am not sure here" is worth more than a tool that always answers.
Where LexAI is today
Today LexAI prepares legal opinions with references to the law, legal documents and contract risk reviews, and helps with procedures that have statutory deadlines. Services cost from €6.99 each, with no subscription. The next module I am working on covers appeals and cassation complaints.
Behind the tool there is a lawyer, not just an algorithm. The algorithm loads provisions and drafts the document, but which sources may be used and where the tool must stop is decided by a person who answers for the result.