Design + build

Zakonnik BY

RAG over Belarusian law · Telegram, StepFun

Zakonnik BY is a retrieval-augmented legal assistant running as a Telegram bot. It answers questions about Belarusian law in plain language and links every answer back to the article it came from.

Zakonnik BY case study cover — AI legal assistant for Belarusian law

Problem

People ask legal questions in everyday language, but the source material is written in legal language and scattered across long codes. A general-purpose chatbot answers confidently and gives no way to check whether the answer came from an actual article of law.

Context

Built for non-lawyers who need a first orientation in Belarusian law — what article applies, roughly what it says, and where to read it in full. It is an orientation tool, not legal advice.

Approach

  • Split the legal corpus into retrievable chunks that stay aligned with article boundaries, so a citation points to something a person can actually open.
  • Put retrieval in front of the model instead of relying on the model's own memory of the law.
  • Constrain the prompt layer so an answer without a supporting source is refused rather than improvised.
  • Ship it inside Telegram, because that is where the audience already is — no new app to install or account to create.

Architecture

  1. 01User question in Telegram
  2. 02Retrieval over the chunked legal corpus
  3. 03Prompt layer: question + retrieved articles + refusal rules
  4. 04Model answer with citation back to the source article

Tools

  • Telegram Bot API
  • StepFun
  • Retrieval / RAG pipeline
  • Prompt + citation layer

What worked

  • Article-aligned chunking: citations stay verifiable because a chunk maps to a real article.
  • Answering in plain language while keeping the legal reference visible next to it.
  • Telegram as the runtime — zero onboarding friction.

What didn't work

  • Naive fixed-size chunking cut across articles and produced citations that pointed at nothing useful.
  • Without explicit refusal rules the model filled gaps with plausible-sounding law.

Result

Retrieval, prompt layer and bot runtime were designed, tested and shipped end to end. It runs as a working Telegram assistant with citation-backed answers.

What I learned

In a legal RAG system the retrieval boundary is the product. How you cut the corpus decides whether a citation is trustworthy — the model choice matters far less.

Links

    More work

    Let's build something real.

    A system built to order, or advice on how to start. Tell me the manual work you want gone.

    Get in touch