Retrieval Architecture Stages
1. Multi-Modal Document Parsing & Chunking
Raw documents from connectors are parsed according to their structural syntax:- Code AST Parsing: Source code in Python, TypeScript, Go, Java, and Rust is split along abstract syntax tree boundaries (classes, functions, modules) rather than arbitrary token counts.
- Markdown & HTML Structural Hierarchy: Headers (
#,##,###) are retained as contextual breadcrumbs for every chunk. - Table Normalization: Multi-row tables are formatted as self-contained Markdown blocks with repeated header schemas.
- Parent-Child Chunking: Small child chunks (256 tokens) are used for precise vector matching, while parent passages (1024 tokens) are passed to the model to preserve surrounding context.
2. Dual-Channel Search (Dense + Sparse)
A single search strategy fails on technical queries: dense embeddings miss exact alphanumeric IDs and error codes, while keyword search misses conceptual synonyms. MITHUNAI runs both simultaneously:3. Reciprocal Rank Fusion (RRF) & Cross-Encoder Reranking
Candidates from dense and sparse retrieval are merged using Reciprocal Rank Fusion (RRF): The top 50 fused candidates are then passed through a deep cross-encoder reranking model (Cohere Rerank v3 or BGE-reranker-large). Unlike bi-encoder embeddings, the cross-encoder jointly computes attention across the entire query-passage pair, evaluating logical relevance with high precision.4. Cryptographic Prompt Fencing
To defeat indirect prompt injection attacks hidden in untrusted documentation or user files, MITHUNAI encloses all retrieved context inside cryptographic fences containing per-request unpredictable nonces:Context Fence Example
5. Grounding Verification & Honest Abstention
Before tokens are emitted to the client, the grounding engine calculates an evidentiary support score:- Direct Citation: Every factual claim in the response must correspond to an explicit quotation or factual statement in the retrieved passages.
- Abstention Threshold: If no retrieved passage exceeds the relevance threshold (), or if the model’s response would require ungrounded speculation, the assistant explicitly declines:
“The connected documentation does not contain information on configuring webhook retry intervals for v1 endpoints. Please consult your administrator or submit a ticket.”Abstentions are logged to the Analytics Console so documentation teams can immediately identify and fill content gaps.