Kanun AI
Legal document retrieval for Nepal: a RAG API combining dense embeddings, TF-IDF and a reranker for semantic search over Nepali Acts, with a chat-style React frontend.
- Role
- Full-stack developer - retrieval pipeline, FastAPI service, evaluation tooling, and the React frontend.
- Engagement
- Own product
01/Overview
Kanun AI ('kanun' means law in Nepali) is a legal-document assistant for Nepal. A React app lets you upload documents or search English translations of Nepali Acts and returns semantic matches, summaries and context-aware answers, backed by a FastAPI retrieval service.
Technical highlight
Hybrid dense + TF-IDF retrieval with a reranker stage, plus reproducible indexing and MRR/MAP evaluation endpoints, so retrieval quality is measured instead of assumed.
02/The problem
Legal research in Nepal means long Acts where the same concept appears under many phrasings, so keyword search misses relevant sections. Researchers need section-level answers with citations they can check, not a list of whole documents.
03/The solution
A hybrid retrieval pipeline: documents are parsed with PyMuPDF and pypdf, chunked at section level with metadata, embedded with sentence-transformers and indexed in Qdrant. At query time, dense vector search is combined with classical TF-IDF, then a reranker reorders the top results for precision. FastAPI exposes search, summaries and evaluation endpoints with OpenAPI docs; the React frontend wraps it in a chat UI with upload, a file browser and snippet panels.
04/The result
A working prototype covering English translations of Nepali Acts, with a public demo and an API built for integration into other apps. Corpus coverage is deliberately narrow today; the pipeline is built to widen it.
05/Key features
- 01Hybrid semantic search combining dense embeddings with TF-IDF and a reranker.
- 02Section-level chunking with metadata for precise, citable results.
- 03Evaluation endpoints computing MRR and MAP for retrieval quality.
- 04Chat-style React UI with document upload, file browser, snippet panels and summaries.
06/Tech stack
