RAG / Legal AI · Independent project

Law Agent: Multilingual Legal RAG Application

Author: Dmitri Derevjanko · Tallinn, Estonia · 2025-11 · updated 2026-08

Dmitri Derevjanko built Law Agent, a multilingual legal RAG application that answers questions about Estonian law with source citations.

This is one of 10+ independent public projects by Dmitri Derevjanko. 100+ additional workflows were delivered professionally, mostly under confidentiality, and are not documented here.

Law Agent dashboard showing a source-backed legal answer with citations
Law Agent — live system built by Dmitri Derevjanko.

Open live demo Back to portfolio

Problem

Generic chat models can sound fluent on legal questions while citing the wrong statute, mixing versions of the law, or inventing provisions. People looking up Estonian law need answers tied to the text in force, not a plausible summary.

Solution

Law Agent is a source-grounded legal assistant. It retrieves statutory chunks from a maintained Estonian law corpus, answers in Estonian, English, or Russian, and shows the provisions used. Weak evidence makes the system more conservative instead of more confident.

What Dmitri Derevjanko built

Dmitri designed and implemented the full product: Riigi Teataja ingestion, chunking, embeddings, version-aware retrieval, confidence and strict-mode behaviour, the ET/EN/RU interface, citation inspection, benchmark pages, and 24/7 deployment with Docker, TLS, rate limits, and scheduled corpus sync.

Architecture

  1. Ingest Estonian statutes from Riigi Teataja, normalize structure, and split them into searchable legal chunks.
  2. Store embeddings in PostgreSQL with pgvector and refresh the corpus on a schedule instead of one-off reindexing.
  3. Retrieve by semantic match plus the law in force on the requested date, including current-law filtering.
  4. Generate answers that prefer quoted excerpts and direct citations; downgrade certainty when support is thin.
  5. Expose the product through a multilingual UI with citation inspection, corpus stats, and a public benchmark against a generic GPT baseline.
  6. Run behind Nginx with Docker, GitHub Actions, Redis, structured logging, backups, and smoke checks.

Technologies

Result

A public legal RAG demo with 181k chunks over 16k+ legal records, automatic corpus updates, citation-first answers, and a benchmark that compares grounded replies with generic model output.

Limitations

Live demo and source

Live demo: https://counsel.dmitriderevjanko.com/

GitHub: source is not public. The live demo is the public artifact for this project.

Portfolio case study: https://dmitriderevjanko.com/projects/law-agent/

Other independent projects by Dmitri Derevjanko