DivinityAI – Islamic Grounded RAG: Architecture & Performance Benchmark
- DivinityAI enforces a strict corpus-lock policy to prevent hallucinations in Quran and Hadith searches.
- It uses a hybrid retrieval system combining BM25 sparse search and BGE-M3 dense embeddings for accurate results.
- The system includes deterministic citation verification and post-generation hallucination checks.
The Challenge: Why DivinityAI – Islamic Grounded RAG Was Built
General-purpose large language models (LLMs) frequently hallucinate religious texts, fabricating Quranic verses and Hadith narrations. In a domain where textual accuracy is critical, these hallucinations can be misleading and harmful. DivinityAI was built to address this challenge by providing a Retrieval-Augmented Generation (RAG) system that is strictly grounded in authenticated Quran and Hadith sources.
Core Architecture & Technical Stack Deep-Dive
System Components & Interface Boundaries
DivinityAI is built as a modular application with a Django backend serving a React SPA, deploying local embeddings and remote LLM orchestrators:
┌──────────────────────┐
│ React 19 / Vite │
└──────────┬───────────┘
│
│ HTTP (POST /api/v1/query)
▼
┌──────────────────────┐
│ Django / DRF │
└──────────┬───────────┘
│
┌──────────┼───────────┐
▼ ▼ ▼
┌─────────────────────┐┌───────────────┐┌───────────────────┐
│ ChromaDB (8040) ││ rank_bm25 ││ Ollama (11434) │
│ Quran & Hadith ││ (Local Disk) ││ embeddinggemma │
└─────────────────────┘└───────────────┘└───────────────────┘
Query Execution Pipeline
A query execution runs through a series of sequential services:
- Intent Classification: Classifies queries into Quran, Hadith, Fiqh, Calculation, or Off-Domain.
- Scope Enforcement: Rejects off-domain queries or those with low confidence.
- Expansion: Uses HyDE and sub-query decomposition for complex queries.
- Retrieval: Combines BM25 sparse search and BGE-M3 dense embeddings.
- RRF & Verification: Blends results via Reciprocal Rank Fusion and verifies citations.
- Sufficiency Check: Ensures retrieved chunks contain sufficient evidence.
- Synthesis: Generates the final response using Gemini 2.5 Flash.
- Audit: Runs post-generation hallucination and boundary checks.
Key Features Breakdown & Practical Benefits
Strict Corpus-Lock Policy
DivinityAI refuses to answer queries that cannot be grounded in authenticated Quran and Hadith sources, ensuring zero hallucinations.
Hybrid Retrieval System
The system combines BM25 sparse search for exact keyword matches and BGE-M3 dense embeddings for semantic understanding, providing comprehensive and accurate results.
Deterministic Citation Verification
Citations are verified through a 4-tier chain: exact match, normalized match, Levenshtein distance, and semantic check.
Real-World Use Cases & Applications
- Scholarly research and authenticated Quran/Hadith reference discovery without hallucination risks.
- Academic study of classical Arabic religious texts and cross-source comparative analysis.
- Reference design pattern for high-stakes zero-hallucination domain-specific RAG architectures.
How It Works: Step-by-Step Workflow
The workflow begins with user query classification and proceeds through retrieval, verification, and generation, ensuring grounded and accurate responses.
Comparison: DivinityAI – Islamic Grounded RAG vs Traditional Approaches
| Feature | DivinityAI | Traditional LLMs |
|---|---|---|
| Hallucination Rate | 0% (corpus-locked) | High (fabricates texts) |
| Citation Accuracy | 95%+ (deterministic checks) | Low (no verification) |
| Query Routing | Five-path intent router | Single-path |
Frequently Asked Questions (FAQ)
How does DivinityAI prevent hallucinations?
DivinityAI enforces a strict corpus-lock policy and uses deterministic citation verification to ensure all answers are grounded in authenticated sources.
What languages does DivinityAI support?
DivinityAI supports multilingual inputs, including Arabic, English, and Malay.
Can DivinityAI issue fatwas?
No, DivinityAI is not a fatwa-issuing machine. It displays source materials and scholarly positions without generating new religious rulings.
How fast is DivinityAI?
End-to-end responses are designed to return in less than 8 seconds.
Conclusion & Next Steps
DivinityAI represents a significant advancement in grounded RAG systems, particularly for high-stakes domains like religious texts. Its architecture ensures zero hallucinations and deterministic citation accuracy, making it a reliable tool for scholars and researchers. Explore the live project at https://muslim.nevatal.tech.
Leave a Reply