Logo Lanfrica

kecir-mohamed/qanuni

Domain:

natural language processing

Record type:

software
Creator:
kec
Host:
Multi-agent Arabic RAG assistant for Algerian law — dialect questions, article-level citations, amendment tracking # ⚖️ Qanuni — قانوني ### An Arabic Multi-Agent RAG Assistant for Algerian Law *Ask a legal question in Algerian dialect — get a verified answer grounded in the official texts, with article-level citations and amendment tracking.* -orange) --- **Qanuni** ingests the complete corpus of Algerian legislation published by the Ministry of Justice — **131 official PDFs, ~2,100 pages, 15,848 legal articles** — and turns it into a five-agent RAG system that ordinary Algerians can question in their own dialect: > **س:** واش يصرا إذا سرقلي واحد الهاتف تاعي؟ > > **ج:** عقوبة السرقة هي الحبس من سنة إلى خمس سنوات وبغرامة من 500 إلى 20000 دينار *(قانون العقوبات، المادة 250)* ... Every claim is cited to a specific article, checked against later amendments, and audited by a verification agent before it reaches the user. The entire stack — OCR, embeddings, vector search, and four LLM agents — runs on **$0 of infrastructure**. A dialect question answered with article-level citations and the retrieved sources. ## Why this is a hard problem | Challenge | What went wrong with the naive approach | Solution | |---|---|---| | **Scanned gazettes** | 50 of 131 PDFs are pure image scans — no text layer at all | Benchmark-driven OCR: three engines compared word-by-word against the real Civil Code before choosing `mistral-ocr` | | **Corrupted text layers** | The other 81 PDFs store Arabic in *reversed visual order* with ligature presentation forms — extraction yields gibberish (`الجريدة` → `ةديرﳉا`) | OCR everything for one uniform, faithful pipeline | | **OCR hallucination** | Chat-vision models *invent plausible legal text* where the scan is hard to read — unacceptable for law | Column-split rendering + "never guess, mark `[غير مقروء]`" prompting + engine benchmarking | | **Dialect gap** | Users ask in Darija ("شحال العقوبة تاع السرقة؟"); laws are written in formal legal Arabic | A router agent rewrites questions into legal terminology before retrieval | | **Laws change** | A …