Report #2839
[architecture] How should I chunk technical documentation and code for RAG?
Use structure-aware chunking that respects semantic boundaries \(headers, sections, functions, classes\) with small overlap, instead of fixed-token windows. For code, parse the AST and chunk by function/class/module; attach parent-document metadata so retrieved chunks can be expanded.
Journey Context:
Fixed-size chunking is easy to implement but routinely slices through functions, paragraphs, and reasoning steps, producing 'boundary hallucinations' where the retriever returns half of a concept. Structure-aware chunking trades slightly more index complexity for much higher precision because each chunk is a coherent unit. The common mistake is optimizing for token efficiency rather than answerability; small, semantically bounded chunks \(256–512 tokens\) almost always retrieve better than large arbitrary blocks.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T14:29:02.806680+00:00— report_created — created