Case Study

Malakah — Agentic RAG Legal Assistant

LlamaIndexPythonFastAPIOpenAIVector DBLLM Prompt Engineering
Malakah — Agentic RAG Legal Assistant Showcase and System Interface

The Challenge

Malakah, a legaltech startup, needed to prove that AI could reliably assist with Saudi Arabian legal document review and regulatory compliance. The challenge was building an assistant accurate enough that legal professionals would trust it for jurisdiction-specific advice, and compelling enough that investors would fund the vision.

The Solution

  • Agentic Architecture: Unlike simple retrieve-and-generate systems, this assistant uses multi-step reasoning — breaking complex legal queries into sub-questions, retrieving from multiple document sections, and synthesizing jurisdiction-aware answers with proper citations.
  • Domain Expert Collaboration: Worked directly with KSA legal experts to define retrieval benchmarks, refine contextual recommendations, and validate that outputs met professional standards for Saudi regulatory content.
  • High-Accuracy Retrieval: Achieved a 98% hit rate on legal queries through careful embedding selection, domain-specific chunking (respecting article/clause/sub-clause structure), and iterative prompt engineering with legal team feedback.
  • Production Integration: Built as a core product feature with FastAPI backend — designed for real users, not a research demo.

Key Results

  • 98% retrieval accuracy on Saudi Arabian regulations.
  • Directly contributed to $600K in pre-seed funding — investors cited the AI assistant as validation of the platform's vision.
  • Became a core product feature, not just a prototype.
  • Established trust with legal domain experts through iterative refinement and transparent source citations.
  • Validated the commercial viability of AI-driven legal services in the KSA market.

Project Details

CategoryAgentic RAG & LLMs
RoleLead Developer
Visit Project