Uzbek Legal RAG Open the chat →

Ask Uzbekistan's laws a question in plain Uzbek.

The assistant searches 24,000 legal acts, answers from the articles it finds, and cites them with links to lex.uz. Ask several questions at once, or follow up on earlier ones.

Try it →
24,201acts in force
124,477searchable chunks
~6 sper answer, in parallel
<$0.002per answer

How it works

Search the law first, then answer only from what was found.

Understand

Split the message into questions, hide personal data, fix spelling (Cyrillic, new 2026 alphabet, apostrophes). Rewrite follow-ups using the chat so far.

Search

bge-m3 embeds all questions in one batch; pgvector finds the 6 closest chunks for each, plus neighbouring text for the best 2.

Answer

An OpenAI model writes each answer in parallel, citing [1], [2], or says the law found doesn't cover it.

Stream

All answers stream back together; sources and follow-up suggestions arrive with them.

Many questions, many users

SplittingUp to 10 questions per message, each answered separately
Micro-batchingQuestions from all users embedded together (20 ms window)
asyncio tasksQuestions run in parallel: 3 take as long as 1
SemaphoreAt most 10 OpenAI answers at once
One SSE streamAll answers stream together, tagged by question
Limits90 s timeout, cancel on page close, 25 questions/user a day

Data

Sourceuzbek-legal-corpus: a June 2026 snapshot of lex.uz, Uzbek Latin, about half of all acts
Size24,267 acts, 54,173 articles or whole acts, ~47M words
Replaced laws removed66 acts that a newer act with the same title replaced, e.g. the 1995 Labour Code (now 2022) and older Tax and Customs Codes. Both Civil Code parts stay.
ChunksShort articles whole; long acts cut at their numbered points, up to 600 words

Search model

1,000 article titles must find their article among 5,000 (RTX 5080).

ModelRecall@10MRR@105,000 articles
bge-m396.70.87212.6 s
bge-m3 + BM2595.80.843
BM25 keyword search91.00.751CPU
granite-311m-r284.00.64311.7 s
Qwen3-Embedding-0.6B83.60.63847.9 s

Recall@10: share of questions whose article is in the top 10. MRR: how high it ranks (1.0 = first). Titles share the articles' wording, so this test is easier than real questions.

Answer model

It only writes from retrieved articles, so a small model is enough. OpenAI prices, November 2026.

ModelInput / 1MOutput / 1MPer 1,000 answers
gpt-6-luna$0.10$0.50~$0.85
gpt-4o-mini$0.15$0.60~$1.20
gpt-4.1$2.00$8.00~$16
gpt-6.1-sol$2.00$10.00~$17

At ~6,000 tokens in and 500 out per answer; follow-up rewriting and suggestions add two small calls.

Key decisions

Limits

  • About half of lex.uz, June 2026 snapshot
  • Laws replaced under another title aren't detected
  • Tested on titles, not yet on real questions
  • Not legal advice: lex.uz is the official source

Stack

  • Python, FastAPI, asyncio, server-sent events
  • bge-m3, Postgres 16 + pgvector (HNSW)
  • OpenAI API, streaming
  • JSON test API (/v1) with verified quotes
  • Docker on Azure (4 vCPU, 16 GB); 66 tests