Fine-tuned Arabic legal AI assistant trained on Qatari laws, delivering accurate, citation-rich answers for professional legal workflows.

Fine-tuned LLM for Qatar court case law

Law
5 min read
July 1, 2025
HTML
Javascript
view live site

Client & The Problem


A legal AI development team in Qatar needed to build a fine-tuned Arabic language legal assistant that could understand Qatari laws and court decisions, reason through complex legal scenarios, and provide answers with precise legal citations in Modern Standard Arabic. Existing base models lacked jurisdiction-specific legal accuracy and citation handling, limiting their usability for professional legal workflows.

Solution


We designed and fine-tuned a 70B-parameter DeepSeek LLM using Low-Rank Adaptation (LoRA) techniques on a 60K Q&A dataset of Qatari legal content. The AI was trained to interpret laws, match queries with accurate legal provisions, and provide structured outputs including verbatim citations, law numbers, and multi-step reasoning. The system was benchmarked against DeepSeek R1 and achieved superior legal accuracy, coherence, and citation fidelity.

Results


The fine-tuned model demonstrated over 85% legal accuracy on a stratified test set spanning contract, corporate, and labor law. Human validation by a panel of lawyers confirmed high-quality responses with correct legal basis. The system met a <3s inference latency requirement and is now deployable as an API, ready to be scaled across other MENA jurisdictions using the same methodology.

Stack

  • Base Model: DeepSeek-V2 (70B), quantized (4-bit QLoRA)

  • Training Framework: PyTorch + Transformers + LoRA (via PEFT)

  • Data: 60K curated Q&A pairs from Qatari legal corpus

  • Training Infra: AWS SageMaker p5.48xlarge / 8×H100 on RunPod

  • NLP Tools: LangChain, FlashAttention, Hugging Face Transformers

  • Deployment: Dockerized APIs on GPU inference servers (T4/A10G)

  • Monitoring: Weights & Biases, FastAPI logs, latency dashboards

  • Security/Compliance: GDPR-compliant, citation traceability

Timeframe

2 months