RAG assistant grounded in Saudi legal documents — Al Qanoon
Role · Implemented end-to-end
A retrieval-augmented assistant grounded in Saudi legal documents from the Ministry of Justice, SDAIA, and municipalities — delivered end-to-end as a public-facing assistant.
Problem
Saudi legal information was spread across heterogeneous sources, much of it in Arabic, with no public assistant capable of grounded answers across the corpus.
My responsibility
Implemented the system end-to-end: scraping, normalization, chunking, embeddings, retrieval, answer grounding, UI, and deployment.
Key decisions
Chunk by legal structure (article / clause) rather than fixed token windows to keep citations precise.
Use FAISS for fast local vector search with re-ranking before answer composition.
Embed with a multilingual model that handles Arabic morphology; re-rank with a cross-encoder before the answer is composed.
Ground every answer in cited source passages; refuse when retrieval confidence is low.
Keep the public interface minimal so the retrieval signal dominates the UX.
Architecture
Input
Deterministic
LLM / generative
Data store
Output
Legal sources from the Ministry of Justice, SDAIA, and municipalities are scraped and normalized, chunked along article and clause boundaries, embedded with a multilingual model, and indexed in FAISS. Queries hit FAISS, results are re-ranked by a cross-encoder, and answers are composed with citations or refused when retrieval confidence is low.
Stack
Python
LangChain
Azure OpenAI
FAISS
Multilingual embeddings
Cross-encoder re-ranker
Flask
Outcome
· Delivered as a public-facing RAG assistant over a large Saudi legal corpus.
· Cited answers in Arabic and English from the same retrieval pipeline.
Known limitations
· No longer publicly hosted — corpus freshness and hosting were not maintained beyond the engagement.
· Legal accuracy depends on corpus freshness — informational only, not a substitute for counsel.
· Re-ranking quality is the dominant bottleneck on long ambiguous queries.
Sanitized details available during technical interview.