RAG Architecture

RAG-DiReCT: Hierarchical Semantic Search

Optimizing retrieval precision for massive datasets through parent-child chunking and context re-ranking.

Rehan Tariq
April 20, 20268 min read
Enterprise Grade

98%

Retrieval Accuracy

450ms

Latency (p95)

10M+

Dataset Size

2.5x

Re-ranking Boost

Standard RAG often fails when dealing with long, technical documents. Information gets lost in "generic" chunks. RAG-DiReCT solves this by maintaining hierarchical relationships between data points.

The Challenge: "Information Dilution"#

When you chunk a 50-page manual into 500-token pieces, you lose the overarching context. The engine needs to know that a specific technical spec belongs to a specific product model mentioned 10 pages earlier.

Hierarchical Architecture#

Our approach uses a multi-layered retrieval strategy: Parent chunks for context, Child chunks for precise detail.

RAG-DiReCT ArchitectureHierarchical Retrieval Augmented GenerationUser QueryNatural Language InputSemantic RouterIntent ClassificationHierarchical RetrievalSupabase · pgvectorContext Re-rankerPrecision OptimizationLLM GeneratorContext-Aware Synthesis🚀 Hierarchical Semantic Search OptimizedInput layerProcessingStorageGeneration

The Technical Stack#

Vector Storage

Supabase with pgvector for high-concurrency similarity search.

Embedding Models

Custom fine-tuned BGE embeddings for domain-specific terminology.

Re-ranking

Cohere Rerank layer to filter top 100 results down to top 5.

Orchestration

LangChain optimized for low-latency asynchronous retrieval.

Measured Impact#

In head-to-head evals against naive RAG, RAG-DiReCT demonstrated a 40% improvement in "Faithfulness" and a 30% reduction in "Hallucination" rates on complex technical queries.

Explore the source code

Dive into the implementation details of hierarchical chunking and semantic routing.