Advanced RAG Architecture: Parent-Child Chunking, HyDE, and Multi-Index Retrieval
Basic RAG (chunk → embed → retrieve → generate) works for simple queries but struggles with complex questions. Advanced techniques dramatically improve retrieval quality.
1. Parent-Child Chunking
Document → Large Parent Chunks (2000 tokens)
├── Small Child Chunk 1 (200 tokens) ← Embedded for retrieval
├── Small Child Chunk 2 (200 tokens)
└── Small Child Chunk 3 (200 tokens)
Query matches Child Chunk 2 → Return Parent Chunk (full context)
Small chunks provide precise matching; parent chunks provide complete context to the LLM.
2. Hypothetical Document Embeddings (HyDE)
Instead of embedding the raw query, generate a hypothetical answer first:
async function hydeRetrieval(query: string) {
// Generate hypothetical answer
const hypothetical = await llm.chat(`Write a short paragraph answering: ${query}`);
// Embed the hypothetical answer (closer to document embedding space)
const embedding = await embed(hypothetical);
// Retrieve using hypothetical embedding
return vectorStore.search(embedding, { topK: 5 });
}
HyDE bridges the embedding space gap between short queries and long document passages.
Advanced RAG techniques transform retrieval accuracy from "good enough for demos" to "reliable enough for production enterprise applications."



















