DivinityAI – Islamic Grounded RAG: Architecture & Performance Benchmark
- DivinityAI ensures zero hallucinations in Quranic verses and Hadith citations.
- It uses a strict corpus-lock policy grounded in authentic Quran and Hadith texts.
- The system employs advanced techniques like HyDE expansion, hybrid search, and deterministic citation verification.
The Challenge: Why DivinityAI – Islamic Grounded RAG Was Built
General-purpose large language models (LLMs) often hallucinate religious texts, fabricating Quranic surah and ayah numbers, attributing narrations to the wrong companions, and merging distinct prophetic sayings. In a domain where textual accuracy is critical, these hallucinations are unreliable and potentially misleading. DivinityAI addresses this challenge by implementing a strict corpus-lock policy, ensuring every response is grounded in authentic Quran and Hadith texts.
Core Architecture & Technical Stack Deep-Dive
DivinityAI is built using a modular architecture with a Django backend serving a React SPA. The system leverages ChromaDB for vector storage, BGE-M3 embeddings, BM25 sparse search, and Reciprocal Rank Fusion for hybrid search. The LLM engine uses OpenRouter (Gemini 2.5 Flash) and Groq (Llama 3.3 70B) for text generation and validation tasks.
System Components & Interface Boundaries
The architecture includes:
- Frontend: React 19 single-page application styled with Tailwind CSS v4.
- Backend: Django web service exposing REST endpoints via Django REST Framework (DRF).
- Vector Database: ChromaDB server deployed locally on port 8040.
- Sparse Index: rank_bm25 indexes saved on disk for fast exact-token matches.
- Embedding Model: A local Ollama service serving embeddinggemma.
- LLM Engine: OpenRouter handles text generation, while Groq performs high-speed validation tasks.
Key Features Breakdown & Practical Benefits
DivinityAI’s key features include:
- Strict corpus-lock policy refusing answers not grounded in authentic Quran and Hadith texts.
- Five-path Intent Router with confidence gating.
- HyDE expansion and sub-query decomposition for nuanced queries.
- Hybrid BM25 sparse matching combined with BGE-M3 dense embeddings.
- Deterministic 4-tier citation verification chain.
- Pre-generation evidence sufficiency checks and post-generation fatwa boundary / hallucination detectors.
Real-World Use Cases & Applications
DivinityAI is ideal for:
- Scholarly research and authenticated Quran/Hadith reference discovery.
- Academic study of classical Arabic religious texts.
- Reference design pattern for high-stakes zero-hallucination domain-specific RAG architectures.
How It Works: Step-by-Step Workflow
The query execution pipeline includes:
- Intent Classification: Categorizes the query using Gemini 2.5 Flash.
- Scope Enforcement: Checks classification confidence and rejects off-domain queries.
- Expansion: Executes HyDE and splits Fiqh questions into sub-queries.
- Retrieval: Runs hybrid searches using BM25 and BGE-M3 embeddings.
- RRF & Verification: Melds retrieval lists and validates citations.
- Sufficiency Check: Determines if retrieved chunks contain sufficient evidence.
- Synthesis: Compiles the final response using Gemini 2.5 Flash.
- Audit: Audits the response text and appends appropriate disclaimers.
Comparison: DivinityAI – Islamic Grounded RAG vs Traditional Approaches
| Feature | DivinityAI | Traditional Approaches |
|---|---|---|
| Hallucination Risk | Zero | High |
| Citation Verification | Deterministic | None |
| Query Intent Routing | Five-path Intent Router | None |
| Search Technique | Hybrid BM25 + BGE-M3 | Single Method |
Frequently Asked Questions (FAQ)
What is DivinityAI?
DivinityAI is a Retrieval-Augmented Generation (RAG) system built around a locked, authenticated corpus of Al-Quran and canonical Hadith compilations, ensuring zero hallucinations.
How does DivinityAI verify citations?
DivinityAI uses a deterministic 4-tier citation verification chain, including exact string matching, normalized matching, fuzzy Levenshtein distance, and semantic LLM fallback.
Can DivinityAI issue fatwas?
No, DivinityAI displays source materials and scholarly positions without generating new religious rulings.
What languages does DivinityAI support?
DivinityAI supports multilingual inputs in Arabic, English, and Malay.
Conclusion & Next Steps
DivinityAI sets a new standard for domain-specific RAG systems, ensuring zero hallucinations and deterministic citation verification in Islamic texts. Explore the live project at https://muslim.nevatal.tech.
Leave a Reply