Tag: ChromaDB

  • DivinityAI – Islamic Grounded RAG: The Hallucination-Free Quran and Hadith Search System

    DivinityAI – Islamic Grounded RAG: The Hallucination-Free Quran and Hadith Search System

    Key Takeaways:

    • DivinityAI ensures zero hallucination by grounding every answer in authenticated Quran and Hadith texts.
    • Features include intent routing, HyDE expansion, hybrid search, and deterministic citation verification.
    • Built with Django ASGI, React 19, ChromaDB, and advanced AI models like BGE-M3 and Llama 3.3 70B.
    • Real-world applications include scholarly research, academic study, and high-stakes domain-specific RAG architectures.
    Live Project Access: https://muslim.nevatal.tech

    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 synthesizing inaccurate Islamic jurisprudence (Fiqh) fatwas. 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 answer is grounded in authenticated Quran and Hadith texts.

    Core Architecture & Technical Stack Deep-Dive

    DivinityAI is built as a modular application with a Django backend serving a React SPA, deploying local embeddings and remote LLM orchestrators. The tech stack includes:

    • Frontend: React 19 single-page application styled using Tailwind CSS v4, optimized for Right-to-Left Arabic typography.
    • Backend: Django web service with Django REST Framework (DRF) for REST endpoints.
    • Vector Database: ChromaDB server for storing Quran and Hadith embeddings.
    • Sparse Index: BM25 sparse search for exact-token matches.
    • Embedding Model: BGE-M3 embeddings for semantic search.
    • LLM Engine: OpenRouter for text generation and Groq for high-speed validation tasks.

    Key Features Breakdown & Practical Benefits

    Strict Corpus-Lock Policy

    DivinityAI refuses to answer queries that cannot be verified from authenticated Quran and Hadith texts, ensuring zero hallucination.

    Five-Path Intent Router

    Every user query is classified into one of five intents: Quran verse, Hadith, Fiqh, Calculation, or Off-Domain, with specialized retrieval strategies for each.

    Hybrid Search

    Combines BM25 sparse matching with BGE-M3 dense embeddings for comprehensive retrieval.

    Deterministic Citation Verification

    Validates citations through a 4-tier verification chain, ensuring every reference is accurate.

    Pre- and Post-Generation Checks

    Pre-generation evidence sufficiency checks and post-generation fatwa boundary/hallucination detectors ensure the integrity of responses.

    Real-World Use Cases & Applications

    DivinityAI is designed for:

    • Scholarly research and authenticated Quran/Hadith reference discovery.
    • 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 query execution pipeline includes:

    1. Intent Classification: Routes the query to the appropriate intent.
    2. Scope Enforcement: Rejects off-domain queries.
    3. Query Rewriting: Expands and decomposes complex queries.
    4. Hybrid Retrieval: Combines BM25 and BGE-M3 searches.
    5. Citation Verification: Validates references through a 4-tier chain.
    6. Grounded Generation: Synthesizes answers strictly from verified sources.
    7. Safety Layer: Detects hallucinations and ensures compliance with fatwa boundaries.

    Comparison: DivinityAI – Islamic Grounded RAG vs Traditional Approaches

    Feature DivinityAI Traditional Approaches
    Hallucination Risk Zero High
    Citation Accuracy 95%+ Variable
    Intent Routing Five-path classification None
    Hybrid Search BM25 + BGE-M3 Single method

    Frequently Asked Questions (FAQ)

    What is DivinityAI?

    DivinityAI is a Retrieval-Augmented Generation system designed to provide hallucination-free Quran and Hadith search results with deterministic citation verification.

    How does DivinityAI ensure accuracy?

    DivinityAI implements a strict corpus-lock policy, hybrid search, and a 4-tier citation verification chain.

    What languages does DivinityAI support?

    DivinityAI supports Arabic, English, and Malay inputs.

    Can DivinityAI issue fatwas?

    No, DivinityAI displays source materials and scholarly positions without generating new religious rulings.

    Is DivinityAI free to use?

    Yes, DivinityAI operates on a 100% free-tier model.

    Conclusion & Next Steps

    DivinityAI – Islamic Grounded RAG sets a new standard for hallucination-free Quran and Hadith search systems. Its strict corpus-lock policy, advanced intent routing, and deterministic citation verification ensure unparalleled accuracy. Explore the live project at https://muslim.nevatal.tech to experience its capabilities firsthand.

  • Advanced RAG Architecture Portfolio: Inside Nevatal’s Defense-in-Depth AI Systems Suite

    Advanced RAG Architecture Portfolio: Inside Nevatal’s Defense-in-Depth AI Systems Suite

    Key Takeaways:

    • Five production-ready AI systems demonstrating defense-in-depth RAG architectures
    • Hybrid retrieval combining dense vectors, sparse BM25, and cross-encoder reranking
    • Multi-stage verification workflows to combat hallucinations in high-stakes domains
    • Open-source stack with ChromaDB, Celery, Redis, and OpenRouter integration
    • Cross-platform deployment from web to desktop via React/Electron

    The Challenge: Why Nevatal Defense-in-Depth AI Systems Suite Was Built

    Modern retrieval-augmented generation (RAG) systems face critical reliability challenges – from hallucinated references in DivinityAI’s religious domain to incomplete multi-hop reasoning in CRAG MultiHop. Traditional approaches often fail when:

    • Questions require connecting information across multiple documents (multi-hop reasoning)
    • Retrieved documents contain ambiguous or incorrect information
    • Responses need verifiable citations in high-stakes domains
    • Optimal retrieval/generation combinations vary by document set

    Core Architecture & Technical Stack Deep-Dive

    Unified Backend Infrastructure

    The suite shares a common technical foundation:

    Python (Django ASGI/FastAPI) → Redis/Celery → ChromaDB/PostgreSQL → OpenRouter

    Advanced Retrieval Pipelines

    Each application implements a customized version of this hybrid retrieval workflow:

    1. Query intent classification and HyDE-based query expansion
    2. Parallel dense vector (ChromaDB) and sparse BM25 searches
    3. Reciprocal Rank Fusion (RRF) to combine results
    4. Jina Reranker v3 cross-encoder for final relevance scoring

    Key Features Breakdown & Practical Benefits

    Deterministic Verification (DivinityAI)

    For religious texts requiring absolute accuracy, DivinityAI implements:

    • Corpus-locked domain enforcement
    • String-matching citation verification
    • Fatwa boundary monitoring

    Multi-Hop Reasoning (CRAG MultiHop)

    This unique pipeline:

    • Decomposes complex questions into 3 sequential sub-queries
    • Self-grades retrieved chunks with corrective RAG workflow
    • Falls back to live web search when needed
    Feature Traditional RAG Nevatal Suite
    Hallucination Prevention Basic prompt engineering Multi-stage verification workflows
    Complex Queries Single-hop retrieval 3-hop decomposition + correction
    Evaluation Manual testing Automated 3×3 consensus benchmarking

    Frequently Asked Questions (FAQ)

    How does the suite handle different document types?

    RagReader’s benchmarking system tests and scores various retrieval/generation combinations against your specific document set to determine optimal configurations.

    What makes the verification system “deterministic”?

    DivinityAI uses exact string matching against locked corpora rather than semantic similarity, ensuring absolute citation accuracy for religious texts.

    Conclusion & Next Steps

    Nevatal’s Defense-in-Depth AI Systems Suite demonstrates how modern RAG architectures can achieve enterprise-grade reliability through multi-stage verification, hybrid retrieval, and systematic evaluation. Explore the live applications:

  • Advanced RAG Architecture Portfolio: Defense-in-Depth AI Systems Suite

    Advanced RAG Architecture Portfolio: Defense-in-Depth AI Systems Suite

    In the rapidly evolving landscape of artificial intelligence, Retrieval-Augmented Generation (RAG) systems have emerged as a cornerstone for building reliable, context-aware AI applications. However, as these systems grow in complexity, so do the challenges of ensuring accuracy, reducing hallucinations, and maintaining robust performance across diverse use cases. The Nevatal Defense-in-Depth AI Systems Suite addresses these challenges head-on with a comprehensive portfolio of five advanced AI applications, each designed to tackle specific aspects of RAG, multi-LLM consensus, and semantic search routing.

    Key Takeaways

    • Comprehensive suite of five AI applications addressing critical RAG challenges
    • Defense-in-depth architectural paradigm for agentic and RAG systems
    • Multi-stage intent routing, HyDE, BM25, and dense vector embeddings
    • Automated benchmarking, 3×3 consensus evaluation, and RRF pooling
    • Cross-platform distribution across desktop and web

    The Challenge: Why Nevatal Defense-in-Depth AI Systems Suite Was Built

    The limitations of traditional RAG systems are well-documented: they often struggle with complex queries requiring multi-hop reasoning, fail to properly verify citations, and can produce hallucinated responses when dealing with specialized domains. The Nevatal Defense-in-Depth AI Systems Suite was developed to overcome these limitations through a systematic, layered approach to AI system design.

    Addressing the Trust Problem in RAG

    Projects like DivinityAI and Recommendica specifically target the trustworthiness of AI-generated responses. DivinityAI implements a strict “corpus-lock” design for Islamic texts, while Recommendica employs an active relevance agent loop to ensure research paper recommendations remain grounded in actual content.

    Solving Complex Query Processing

    The CRAG MultiHop App and RagReader focus on handling complex information needs. CRAG MultiHop breaks down questions requiring connections across multiple documents into sequential sub-queries, while RagReader provides a benchmarking environment to test and optimize combinations of search algorithms and language models.

    Core Architecture & Technical Stack Deep-Dive

    The suite’s technical foundation represents a carefully curated selection of modern technologies designed for performance, scalability, and reliability.

    Backend Orchestration

    Python-based services form the backbone of the system, utilizing Django (with ASGI for WebSocket streaming) or FastAPI for API endpoints. High-performance asynchronous tasks are managed through Celery with Redis as a message broker, ensuring responsive user experiences even during intensive operations.

    # Example of a typical Celery task setup
    from celery import Celery
    
    app = Celery('tasks', broker='redis://localhost:6379/0')
    
    @app.task
    def process_rag_query(query):
        # RAG processing logic here
        return results
    

    Database Layer

    The architecture employs a polyglot persistence approach:

    • ChromaDB: Primary vector database for semantic index storage
    • PostgreSQL/SQLite: Relational databases for user accounts, thread histories, metadata tracking
    • Redis: Caching and message brokering

    Embedding and LLM Layer

    The suite leverages multiple approaches to model access:

    • OpenRouter API: For scalable access to leading closed-source models
    • Groq: Used for fast-inference validation calls
    • Ollama: Local instances for offline vector embeddings

    Key Features Breakdown & Practical Benefits

    The Nevatal suite introduces several innovative features that collectively address the most pressing challenges in modern AI system development.

    Unified Defense-in-Depth Architectural Paradigm

    This multi-layered approach ensures that potential failure points in traditional RAG systems are mitigated through successive verification stages:

    1. Intent routing to filter inappropriate or off-domain queries
    2. HyDE (Hypothetical Document Embeddings) for query rewriting
    3. Deterministic citation verification through string comparison
    4. Evidence sufficiency checking
    5. Boundary monitoring for specialized domains

    Multi-Model Consensus & Verification

    By employing multiple LLMs and comparing their outputs (3×3 consensus evaluation), the system significantly reduces the likelihood of hallucinations or incorrect responses slipping through.

    Real-World Use Cases & Applications

    The Nevatal Defense-in-Depth AI Systems Suite has been designed with practical applications in mind:

    • Technical Portfolio Showcase: Demonstrates modern AI engineering practices for developers and architects
    • Enterprise RAG Pipelines: Provides an architectural reference for building robust, verifiable systems in corporate environments
    • Research Assistance: Recommendica serves as a powerful tool for academic researchers needing accurate paper recommendations
    • Religious Studies: DivinityAI offers a trustworthy resource for Islamic scholarship

    Comparison: Nevatal Defense-in-Depth AI Systems Suite vs Traditional Approaches

    Feature Traditional RAG Nevatal Suite
    Query Processing Single-pass retrieval Multi-hop reasoning with corrective retrieval
    Verification Limited or none Deterministic citation verification and hallucination guards
    Evaluation Manual or basic metrics Automated benchmarking with 3×3 consensus evaluation
    Retrieval Methods Single method (usually dense vectors) Hybrid retrieval with RRF pooling

    Frequently Asked Questions (FAQ)

    What makes the Nevatal suite different from other RAG implementations?

    The Nevatal suite implements a defense-in-depth approach, layering multiple verification and validation steps throughout the RAG pipeline to ensure higher accuracy and reliability compared to standard implementations.

    How does the system handle complex multi-hop questions?

    Through the CRAG MultiHop application, questions are decomposed into sequential sub-queries (up to 3 hops), with a corrective RAG workflow that self-grades chunks and falls back to web search when necessary.

    What are the system requirements for running these applications?

    The applications are designed to run across multiple platforms, from web browsers to desktop applications (via Electron). The backend can be deployed using Docker Compose, with typical requirements including Python 3.9+ and moderate hardware specifications.

    How does the suite prevent hallucinations in specialized domains?

    DivinityAI demonstrates this capability with its “corpus-lock” design for Islamic texts, rejecting off-domain questions and strictly verifying references through deterministic string comparison before including them in responses.

    Conclusion & Next Steps

    The Nevatal Defense-in-Depth AI Systems Suite represents a significant advancement in the development of reliable, production-ready RAG systems. By addressing critical challenges through a combination of innovative architectural patterns and rigorous verification processes, the suite provides both a practical solution for current needs and a blueprint for future AI system development.

    To explore these applications firsthand, visit the live demo portal and experience the next generation of defense-in-depth AI systems.

  • CRAG MultiHop Reasoning Engine: Self-Grading RAG with Query Decomposition

    CRAG MultiHop Reasoning Engine: Self-Grading RAG with Query Decomposition

    Key Takeaways

    • Multi-hop reasoning decomposes complex questions into logical sub-queries (up to 3 hops)
    • Self-grading retrieval classifies context as correct/ambiguous/incorrect with automated fallback
    • Hybrid search pipeline merges dense vectors (ChromaDB) + sparse BM25 with Jina reranker
    • WebSocket UI visualizes real-time pipeline progress from retrieval to generation
    • Graceful degradation maintains functionality when components fail (e.g., falls back to BM25 if vector search fails)

    The Challenge: Why CRAG MultiHop Reasoning Engine Was Built

    Traditional Retrieval-Augmented Generation (RAG) systems face two critical limitations:

    1. The Multi-Hop Problem: Complex research questions often require chaining multiple information retrieval steps. A single query cannot directly answer “What were the economic impacts of the 2021 Suez Canal obstruction on European manufacturing?”—it needs sequential searches about the obstruction timeline, affected shipping routes, then regional economic data.
    2. Garbage-In, Garbage-Out Retrieval: Standard retrievers frequently return noisy or irrelevant chunks. When LLMs generate answers from these weak contexts, hallucinations and inaccuracies propagate.

    CRAG MultiHop Reasoning Engine addresses both through its query decomposition and self-correcting retrieval architecture.

    Core Architecture & Technical Stack Deep-Dive

    System Topology

    The containerized deployment runs:

    • Frontend: React + Vite with WebSocket event streaming
    • Backend: Django ASGI (Daphne) handling HTTP/WS routes
    • Workers: Celery + Redis for async document ingestion
    • Datastores: ChromaDB (vectors), PostgreSQL (metadata), BM25 (sparse)
    • Models: Hybrid local/cloud execution (Jina reranker + OpenRouter LLMs)

    Pipeline Models

    Role Model Execution Purpose
    Embeddings Multilingual-E5 Local CPU Chunk vectorization
    Reranker Jina-Reranker-v3 Local CPU Hybrid result ordering
    CRAG Evaluator Multilingual-E5 Local CPU Retrieval self-grading
    Generator Qwen-30B Cloud (OpenRouter) Answer synthesis

    Key Features Breakdown & Practical Benefits

    1. Query Decomposition Engine

    For multi-hop questions like “How did Tesla’s 2023 price cuts affect BYD’s Q2 sales in Germany?”, the system:

    1. Identifies required sub-queries (Tesla’s price cuts → BYD’s Germany market share → Q2 sales reports)
    2. Executes retrievals sequentially, feeding prior results into subsequent hops
    3. Merges evidence chains for final generation

    2. Self-Grading Retrieval (CRAG)

    Before passing chunks to the LLM, the pipeline evaluates their relevance:

    • Correct: High similarity to query → Proceeds to reranking
    • Ambiguous: Moderate match → Triggers query expansion with atomic terms
    • Incorrect: Low relevance → Fallback to external web search

    Real-World Use Cases & Applications

    • Cross-Document Intelligence: Investigative research connecting disparate sources
    • Technical Documentation QA: Precise answers from API docs, RFCs, or manuals
    • Academic Literature Reviews: Synthesizing findings across multiple papers

    How It Works: Step-by-Step Workflow

    1. User Query: Submits complex question via WebSocket
    2. Multi-Hop Split: Qwen-30B decomposes into sub-queries
    3. Hybrid Retrieval: Concurrent BM25 + vector search
    4. CRAG Grading: E5 model scores chunk relevance
    5. Reranking: Jina model orders top candidates
    6. Generation: Qwen-30B synthesizes final answer

    Comparison: CRAG vs Traditional RAG

    Feature Traditional RAG CRAG MultiHop
    Query Handling Single-step retrieval Multi-hop decomposition
    Retrieval QA No self-assessment Grades as correct/ambiguous/incorrect
    Fallback None External search on weak retrievals
    Pipeline Visibility Black box Real-time WebSocket events

    Frequently Asked Questions (FAQ)

    How many hops can CRAG process?

    Default maximum of 3 hops to balance depth and latency. Configurable via UI settings.

    What file formats are supported for uploads?

    PDF, plain text (TXT), and web URLs with automated background parsing.

    Does it work without GPU acceleration?

    Yes—Jina reranker and E5 evaluator run efficiently on CPU-only environments.

    How is this different from LangChain agents?

    CRAG specializes in self-grading retrieval with corrective actions, whereas LangChain offers broader agent tooling without built-in retrieval QA.

    Conclusion & Next Steps

    CRAG MultiHop Reasoning Engine sets a new standard for reliable, multi-step question answering. Its self-correcting architecture and real-time pipeline transparency make it ideal for research-intensive domains.

    Ready to test it? Experience the live demo at crag.nevatal.tech or explore the architecture diagrams for implementation insights.

  • CRAG MultiHop Reasoning Engine: Self-Grading RAG with Query Decomposition

    CRAG MultiHop Reasoning Engine: Self-Grading RAG with Query Decomposition

    Key Takeaways:

    • Automatically decomposes complex questions into logical sub-queries (up to 3 hops)
    • Self-grading retrieval system evaluates context quality before generation
    • Hybrid dense/sparse search with local Jina reranker for precision
    • Real-time WebSocket streaming shows pipeline progress visually
    • Graceful degradation maintains functionality during partial failures

    The Challenge: Why CRAG MultiHop Reasoning Engine Was Built

    Traditional Retrieval-Augmented Generation (RAG) systems face two critical limitations:

    • Multi-Hop Questions: Complex queries requiring intermediate reasoning steps often fail because standard RAG performs single-step retrieval.
    • Noisy Contexts: Weak or irrelevant retrieved documents lead to hallucinated answers when fed to LLMs.

    The CRAG MultiHop Reasoning Engine addresses these through a novel pipeline combining:

    1. Sequential Question Decomposition
    2. Self-Grading Retrieval (Corrective RAG)
    3. Hybrid Dense+Sparse Search with Local Reranking
    4. Real-Time Pipeline Visualization

    Core Architecture & Technical Stack

    Containerized Microservices

    • Frontend: React + Vite with WebSocket event streaming
    • Backend: Django ASGI (Daphne) with Celery task queues
    • Vector DB: ChromaDB for dense retrieval
    • Search: BM25 sparse retrieval + Jina Reranker v3
    • LLM: OpenRouter with Qwen 30B for generation

    Model Pipeline

    Component Model Execution
    Embeddings multilingual-e5-small Local CPU
    Reranker jina-reranker-v3 Local CPU
    Generator Qwen 30B Cloud (OpenRouter)

    Key Features Breakdown

    1. Multi-Hop Query Decomposition

    Breaks complex questions like “What were the economic impacts of the 2021 Suez Canal obstruction on European manufacturing?” into sequenced sub-queries:

    1. Identify key events during 2021 Suez Canal obstruction
    2. Find European manufacturing sectors dependent on Suez routes
    3. Cross-reference economic reports from impacted industries

    2. Self-Grading Corrective RAG

    Uses multilingual-e5-small to classify retrieved chunks as:

    • Correct: Directly relevant (proceeds to generation)
    • Ambiguous: Triggers query refinement
    • Incorrect: Falls back to external web search

    Real-World Use Cases

    • Investigative Research: Connect facts across legal documents or medical studies
    • Technical Support: Diagnose issues requiring multi-step manual lookups
    • Academic Literature Reviews: Synthesize findings from disparate papers

    How It Works: Step-by-Step Workflow

    1. User submits query via WebSocket connection
    2. System decomposes into sub-queries (if multi-hop enabled)
    3. Executes hybrid dense/sparse retrieval against ChromaDB
    4. Grades results using CRAG evaluator
    5. Reranks merged results with Jina Cross-Encoder
    6. Generates answer with Qwen 30B
    7. Streams verification scores back to UI

    Comparison: CRAG vs Traditional RAG

    Feature Traditional RAG CRAG MultiHop
    Query Complexity Single-step Multi-hop (3+ steps)
    Retrieval QA Passes all results to LLM Self-grades context quality
    Fallback None External web search

    Frequently Asked Questions

    How does multi-hop differ from chain-of-thought prompting?

    Multi-hop performs sequential retrievals with each step’s results modifying subsequent queries, while CoT maintains a single context window.

    What hardware requirements does the system have?

    Designed for 4GB+ RAM VPS environments with CPU-only support for local models (jina-reranker-v3, multilingual-e5).

    Can I customize the retrieval pipeline?

    Yes – the UI allows toggling hybrid search, multi-hop depth, CRAG grading, and reranking per query.

    Conclusion & Next Steps

    The CRAG MultiHop Reasoning Engine represents a significant evolution in RAG architectures by combining self-assessment with sequential reasoning. For developers building complex QA systems, it provides:

    • A reference implementation for agentic RAG workflows
    • Production-ready Django/React codebase patterns
    • Configurable pipeline components

    Try the Live Demo

  • DivinityAI – Islamic Grounded RAG: A Hallucination-Free Quran & Hadith Search System

    Key Takeaways

    • Strict corpus-lock ensures answers are only sourced from authenticated Quran and Hadith collections
    • Five-path intent routing with confidence gating prevents off-topic responses
    • Hybrid search combining BM25 sparse and BGE-M3 dense embeddings for precise results
    • Deterministic citation verification with 4-tier validation chain
    • Pre-generation evidence checks and post-generation hallucination detectors

    The Challenge: Why DivinityAI – Islamic Grounded RAG Was Built

    General-purpose large language models (LLMs) frequently hallucinate religious texts, fabricating Quranic surah and ayah numbers, misattributing Hadith narrations, and synthesizing inaccurate Fiqh positions. In a domain where textual accuracy is paramount, these hallucinations pose serious risks to users seeking authentic Islamic knowledge.

    Core Architecture & Technical Stack Deep-Dive

    System Components

    The system is built as a modular application with:

    • Frontend: React 19 SPA with Tailwind CSS v4 and specialized RTL Arabic typography
    • Backend: Django ASGI with Django REST Framework
    • Vector Database: ChromaDB with separate collections for Quran and Hadith
    • Embeddings: BGE-M3 for dense vector search
    • Sparse Search: BM25 on normalized Arabic text
    • LLM Orchestration: OpenRouter (Gemini 2.5 Flash) and Groq (Llama 3.3 70B)

    Arabic NLP Pipeline

    The system implements a rigorous preprocessing normalization stage:

    • NFKD Unicode normalization
    • Diacritic stripping (tashkeel removal)
    • Alef form normalization
    • Tatweel (kashida) removal

    Key Features Breakdown & Practical Benefits

    Strict Corpus-Lock Policy

    The system refuses to answer any query that cannot be verified from its locked database of authenticated sources, ensuring zero hallucination of religious texts.

    Five-Path Intent Router

    Automatically classifies queries into one of five categories with confidence gating:

    • Quran verse search
    • Hadith research
    • Fiqh analysis
    • Islamic calculations
    • Off-domain queries

    Deterministic Citation Verification

    Implements a 4-tier validation chain:

    1. Exact string matching
    2. Normalized text comparison
    3. Levenshtein distance fuzzy matching
    4. Semantic LLM fallback verification

    Real-World Use Cases & Applications

    • Scholarly research with guaranteed authentic references
    • Comparative analysis across canonical Hadith collections
    • Reference architecture for high-stakes domain-specific RAG systems
    • Academic study of classical Arabic religious texts

    How It Works: Step-by-Step Workflow

    1. User query enters the intent classification system
    2. Scope guard checks for domain appropriateness
    3. Query undergoes HyDE expansion and sub-query decomposition
    4. Hybrid retrieval with BM25 and BGE-M3 embeddings
    5. Reciprocal Rank Fusion blends results
    6. Deterministic citation verification
    7. Evidence sufficiency check
    8. Grounded generation with safety layers

    Comparison: DivinityAI vs Traditional Approaches

    Feature DivinityAI Traditional LLMs
    Hallucination Rate 0% (corpus-locked) High (5-20% for religious texts)
    Citation Accuracy >95% verified Unverified
    Domain Control Strict Islamic corpus only General knowledge
    Technical Approach RAG with verification layers Pure generative

    Frequently Asked Questions (FAQ)

    Does DivinityAI issue fatwas?

    No. The system displays authenticated source materials and existing scholarly positions without generating new religious rulings. Users are always advised to consult qualified scholars for definitive rulings.

    What languages does it support?

    The system fully supports Arabic (with optimized RTL rendering), English, and Malay inputs and outputs.

    How does it prevent hallucinations?

    Through multiple safeguards: strict corpus-locking, pre-generation evidence checks, post-generation hallucination detectors, and deterministic citation verification.

    Conclusion & Next Steps

    DivinityAI represents a significant advancement in domain-specific RAG systems, particularly for high-stakes applications where accuracy is non-negotiable. Its architectural patterns serve as a valuable reference for implementing similar systems in other specialized domains.

    Experience DivinityAI today at https://muslim.nevatal.tech

  • DivinityAI – Islamic Grounded RAG: Hallucination-Free Quran & Hadith Search

    DivinityAI – Islamic Grounded RAG: Hallucination-Free Quran & Hadith Search

    Key Takeaways:

    • Zero hallucination guarantee for Quran and Hadith references
    • Strict corpus-lock policy enforcing answers grounded in authenticated sources
    • Hybrid search combining BM25 sparse matching with BGE-M3 dense embeddings
    • Deterministic 4-tier citation verification ensuring textual accuracy
    • Specialized intent routing for Quran verses, Hadith, Fiqh, and calculations

    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 or misattributing Hadith narrations. This poses significant risks for scholars, students, and anyone seeking accurate Islamic references. DivinityAI addresses this critical gap with a Retrieval-Augmented Generation (RAG) system built around a locked, authenticated corpus of Al-Quran and canonical Hadith compilations.

    Core Architecture & Technical Stack Deep-Dive

    DivinityAI’s architecture combines modern AI techniques with specialized Islamic text processing:

    Frontend & Backend Infrastructure

    • Frontend: React 19 SPA with Tailwind CSS v4, optimized for Right-to-Left (RTL) Arabic typography and Uthmani script rendering
    • Backend: Django ASGI with Django REST Framework (DRF) for API endpoints

    Retrieval & Search Components

    • Vector Database: ChromaDB for storing Quran and Hadith embeddings
    • Embeddings: BGE-M3 for dense semantic search
    • Sparse Search: BM25 for exact token matching on normalized Arabic text
    • Rank Fusion: Reciprocal Rank Fusion (RRF) to combine sparse and dense results

    LLM Orchestration

    • Generation: OpenRouter (Gemini 2.5 Flash) for response synthesis
    • Validation: Groq (Llama 3.3 70B) for high-speed verification tasks

    Key Features Breakdown & Practical Benefits

    Strict Corpus-Lock Policy

    DivinityAI implements an uncompromising policy: if a fact or claim cannot be verified from retrieved sources, the system refuses to answer. This ensures zero hallucination of religious texts.

    Five-Path Intent Router

    Queries are intelligently classified into:

    • Quran verse search
    • Hadith research
    • Fiqh (jurisprudence) analysis
    • Islamic calculations (Zakat, inheritance)
    • Off-domain queries (automatically rejected)

    Deterministic Citation Verification

    A 4-tier validation chain ensures reference accuracy:

    1. Exact string matching against canonical sources
    2. Normalized matching (stripped diacritics)
    3. Fuzzy Levenshtein distance for near-identical texts
    4. Semantic LLM fallback for paraphrased content

    Real-World Use Cases & Applications

    • Scholarly Research: Authenticated Quran/Hadith reference discovery without hallucination risks
    • Academic Study: Comparative analysis of classical Arabic religious texts
    • Technical Reference: Design pattern for high-stakes zero-hallucination RAG architectures

    How It Works: Step-by-Step Workflow

    1. User submits query through React interface
    2. Intent classification via Gemini 2.5 Flash
    3. Scope enforcement (rejects off-domain queries)
    4. Query rewriting using HyDE and sub-query decomposition
    5. Hybrid retrieval (BM25 + BGE-M3 embeddings)
    6. Reciprocal Rank Fusion to combine results
    7. 4-tier citation verification
    8. Evidence sufficiency check
    9. Grounded generation with safety layers
    10. Final output with verified citations

    Comparison: DivinityAI vs Traditional Approaches

    Feature DivinityAI Traditional LLMs
    Hallucination Prevention Strict corpus-lock with verification High risk of fabrication
    Citation Accuracy 95%+ verified Unverified, often incorrect
    Query Understanding Specialized intent routing Generic interpretation
    Arabic Text Handling Advanced normalization pipeline Basic tokenization

    Frequently Asked Questions (FAQ)

    How does DivinityAI prevent hallucinations?

    Through a strict corpus-lock policy that refuses answers not grounded in authenticated sources, combined with pre-generation evidence checks and post-generation verification layers.

    What Islamic texts are included in the corpus?

    The King Fahd Uthmani Quran and the six main Hadith books (Sahih Bukhari, Sahih Muslim, etc.).

    Can DivinityAI issue fatwas?

    No, it displays source materials and scholarly positions without generating new religious rulings. For definitive rulings, consultation with qualified scholars is recommended.

    What languages are supported?

    Full support for Arabic (including RTL formatting) and English queries.

    Conclusion & Next Steps

    DivinityAI represents a significant advancement in reliable Islamic text retrieval, combining modern AI techniques with rigorous verification processes. For scholars, students, and developers alike, it offers a trustworthy solution for Quran and Hadith research free from hallucination risks.

    Explore the live system at https://muslim.nevatal.tech to experience corpus-locked Islamic RAG in action.