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 →How it works
Search the law first, then answer only from what was found.
Split the message into questions, hide personal data, fix spelling (Cyrillic, new 2026 alphabet, apostrophes). Rewrite follow-ups using the chat so far.
bge-m3 embeds all questions in one batch; pgvector finds the 6 closest chunks for each, plus neighbouring text for the best 2.
An OpenAI model writes each answer in parallel, citing [1], [2], or says the law found doesn't cover it.
All answers stream back together; sources and follow-up suggestions arrive with them.
Many questions, many users
| Splitting | Up to 10 questions per message, each answered separately |
|---|---|
| Micro-batching | Questions from all users embedded together (20 ms window) |
| asyncio tasks | Questions run in parallel: 3 take as long as 1 |
| Semaphore | At most 10 OpenAI answers at once |
| One SSE stream | All answers stream together, tagged by question |
| Limits | 90 s timeout, cancel on page close, 25 questions/user a day |
Data
| Source | uzbek-legal-corpus: a June 2026 snapshot of lex.uz, Uzbek Latin, about half of all acts |
|---|---|
| Size | 24,267 acts, 54,173 articles or whole acts, ~47M words |
| Replaced laws removed | 66 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. |
| Chunks | Short 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).
| Model | Recall@10 | MRR@10 | 5,000 articles |
|---|---|---|---|
| bge-m3 | 96.7 | 0.872 | 12.6 s |
| bge-m3 + BM25 | 95.8 | 0.843 | |
| BM25 keyword search | 91.0 | 0.751 | CPU |
| granite-311m-r2 | 84.0 | 0.643 | 11.7 s |
| Qwen3-Embedding-0.6B | 83.6 | 0.638 | 47.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.
| Model | Input / 1M | Output / 1M | Per 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
- Tested on our own data. No Uzbek embedding benchmark exists, so models were compared on the legal corpus.
- bge-m3 over Qwen3. Qwen3 was the first pick from general rankings; on Uzbek law it scored 83.6 against 96.7.
- Vector search only. Adding keyword search helped weak models but slightly lowered bge-m3.
- 600-word chunks at numbered points. 400-word chunks overflowed the token limit 9% of the time and ignored the law's structure.
- Replaced laws removed. The first real answer cited the 1995 Labour Code, still marked "in force" in the dataset.
- GPU only for indexing. 24 minutes on an RTX 5080; questions are embedded on the CPU.
- Chats stay in the browser. No accounts; the last 4 questions and answers give follow-ups their context.
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