The Parent-Child RAG Strategy
This is the absolute gold standard for Enterprise AI Architecture. When designing a RAG pipeline, you face a dilemma: Small chunks (200 chars) are mathematically highly specific, making them perfect for Vector Database searching. However, they provide terrible context to the LLM (it gets the answer, but doesn't know the surrounding context). Conversely, large chunks (2000 chars) give the LLM great context, but their vectors are "diluted", making them hard for the database to find.
Parent-Child Retrieval solves this. The document is split into massive "Parent" blocks (e.g. 1500 chars). Then, those Parents are split into smaller "Child" blocks (e.g. 200 chars). Only the Children are embedded into the Vector DB. If a user's question mathematically matches a Child vector, the database uses a foreign key to retrieve the ENTIRE Parent block and feed it to the LLM. You get surgical search accuracy with flawless context.
The "Lost in the Middle" Phenomenon
Why not just feed a 100,000 token book to an LLM like Claude 3 or GPT-4-Turbo? Research from Stanford proved the "Lost in the Middle" phenomenon. LLMs have perfect recall for information at the very beginning of a prompt, and the very end of a prompt. But their ability to extract facts from the exact middle of a massive context window degrades exponentially.
Because of this, RAG is still required even for LLMs with infinite context windows. Curating specific, highly relevant chunks and placing them at the end of the prompt guarantees the LLM will actually utilize the information.
Sub-Word Tokenization (BPE)
LLMs do not read words; they read "Tokens". Modern LLMs use Byte-Pair Encoding (BPE). BPE statistically merges common character combinations. A common word like "Apple" might be 1 token, while an uncommon word like "Antigravity" might be split into 3 tokens: "Anti" + "grav" + "ity".
This is precisely why LLMs are historically terrible at math, spelling backwards, or counting the letter 'r' in strawberry. The LLM literally cannot "see" the letters; it only sees the integer ID representing the merged chunk of letters. Use our Tokenizer Visualizer tab to see how text is broken down into sub-word chunks.
Why Chunk Overlap Prevents Context Loss
If you split a document strictly at exactly 1000 characters with 0 overlap, you run a massive risk of context destruction. Imagine the algorithm makes a hard cut right in the middle of a sentence:
Chunk 1 ends with: "...the CEO of the company is John"
Chunk 2 begins with: "Smith, and he stated that revenue will double."
If a user asks "Who is the CEO?", the vector database will struggle to find the answer because the semantic relationship between "CEO" and "John Smith" was severed across two different mathematical vectors. By introducing a Chunk Overlap (e.g., 200 characters), we ensure that the end of Chunk 1 is duplicated at the beginning of Chunk 2, guaranteeing that "John Smith" is preserved as a complete entity.
Vector DB RAM Economics
Overlap creates data redundancy. If you have a 1,000,000 character document, a high overlap means generating exponentially more chunks. Every single chunk is converted into a high-dimensional vector array (e.g., 1536 dimensions for OpenAI).
Vector Databases (Pinecone, Qdrant, Milvus) must store these arrays in physical RAM (memory) for fast similarity search. Because each dimension is a 32-bit float (4 bytes), a single 1536-dimensional chunk consumes ~6.14 KB of RAM. If excessive chunk overlap causes your pipeline to generate 100,000 extra chunks, you are burning over 600 MB of premium Vector DB RAM.
Cosine Similarity Explained
Once chunks are converted into vectors, how does the Vector Database find the right one? It uses Cosine Similarity. When you ask a question, the LLM converts your question into a vector. The database then calculates the mathematical angle between your question's vector and every chunk's vector in the database.
Vectors that point in the same direction (an angle of 0, yielding a cosine of 1) are semantically identical. If your chunks are too large, the specific answer gets diluted by unrelated text, altering the angle of the vector and causing the database to miss it.