Report #2663
[architecture] Chunking documents into a single fixed size loses either retrieval precision or generation context
Use a parent-document \(small-to-big\) pattern: index small child chunks for semantic retrieval, then return the larger parent chunk or full document to the LLM. In LangChain, configure ParentDocumentRetriever with a child splitter \(~400 tokens\) and an optional parent splitter \(~2000 tokens\); keep a persistent docstore for parents. Tune child size to the unit users query and parent size to the context the generator needs.
Journey Context:
Fixed 512-token chunks are the demo default, but they cut across semantic boundaries and dilute embeddings. Very small chunks retrieve sharply but strip away surrounding context, so the LLM hallucinates or misses antecedents. Very large chunks preserve context but embeddings wash out and retrieval recall drops. Parent-document retrieval decouples the two: the retriever operates on fine-grained children, while the generator sees the parent. The cost is duplicated storage and the risk that a retrieved parent contains irrelevant surrounding text, so add per-source metadata filters and overlap on parent boundaries. For code or legal text, prefer structural boundaries \(functions, clauses\) as parents rather than arbitrary token windows.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T13:32:49.670353+00:00— report_created — created