Chunking Strategies for RAG: Parent-Child vs. Semantic Chunking

In Retrieval-Augmented Generation (RAG) pipelines, the quality of your retrieval is only as good as your chunking strategy. If your chunks are too large, vector embeddings dilute specific facts with surrounding noise. If your chunks are too small, the retriever misses broader context and breaks sentences apart.

To solve this, advanced architectures have moved beyond static character splitting. Two of the most powerful strategies for production systems are Parent-Child (Small-to-Big) Chunking and Semantic Chunking.

1. Parent-Child Chunking (Small-to-Big Retrieval)

Standard chunking forces you to compromise between embedding precision and generation context. Parent-child chunking decouples the embedding search from the context sent to the LLM.

  • Child Chunks: Small, granular segments (e.g., 100-200 tokens) optimized for precise vector cosine similarity matching.
  • Parent Chunks: Large enclosing sections (e.g., 1000-2000 tokens) that contain multiple child chunks.
  • Execution Flow: The vector search matches against child chunks for high precision, but the system feeds the corresponding parent chunk into the LLM context window.

2. Semantic Chunking

Instead of splitting documents at arbitrary token counts or fixed character lengths, semantic chunking splits text based on meaning. It calculates the embedding distance between consecutive sentences, creating a new chunk whenever the semantic variance crosses a specific threshold.

  • Context Preservation: Keeps paragraphs and complete thoughts together regardless of sentence count.
  • Dynamic Boundaries: Adapts automatically to changes in topic, headings, or narrative flow.
  • Reduced Fragmentation: Prevents breaking code blocks or technical explanations mid-sentence.

Parent-Child vs. Semantic Chunking

MetricParent-Child ChunkingSemantic Chunking
Split CriterionHierarchical size (nested chunks)Embedding distance between sentences
Retrieval PrecisionVery high (matches on small granular vectors)High (maintains topical coherence)
Context Window QualityExcellent (provides broad parent context)Variable based on natural topic length
Computational OverheadLow to moderateHigh (requires calculating sentence-level embeddings)

Python Implementation Blueprint

Using LangChain, you can implement a Parent-Child (ParentDocumentRetriever) architecture to combine granular child embeddings with expansive parent context:

Python
Parent-Child retriever setup using LangChain
from langchain.retrievers import ParentDocumentRetriever
from langchain.storage import InMemoryStore
from langchain_chroma import Chroma
from langchain_text_splitters import RecursiveCharacterTextSplitter
from langchain_openai import OpenAIEmbeddings

# Initialize vector store and doc store
embeddings = OpenAIEmbeddings(model="text-embedding-3-small")
vectorstore = Chroma(collection_name="split_parents", embedding_function=embeddings)
store = InMemoryStore()

# Define child and parent splitters
parent_splitter = RecursiveCharacterTextSplitter(chunk_size=2000)
child_splitter = RecursiveCharacterTextSplitter(chunk_size=400)

retriever = ParentDocumentRetriever(
    vectorstore=vectorstore,
    docstore=store,
    child_splitter=child_splitter,
    parent_splitter=parent_splitter,
)

print("Parent-Child retriever initialized successfully.")

Production Best Practices

Choosing between these strategies depends on your corpus structure and hardware constraints:

  • Use Parent-Child for Technical Manuals: Highly structured documents benefit immensely from child chunks matching precise definitions while passing full procedural sections to the LLM.
  • Use Semantic Chunking for Narrative Text: Articles, essays, and unformatted reports work best when split by natural semantic shifts rather than arbitrary character lengths.
  • Combine Strategies: For enterprise-grade RAG, apply semantic splitting at the parent level, then subdivide those semantic blocks into smaller child chunks.