Choose and tune a document chunking strategy that maximizes retrieval quality across mixed content like prose, tables, and code.
## CONTEXT Chunking is the most underrated lever in retrieval quality. In 2026, teams routinely discover that swapping naive fixed-size splitting for layout-aware or semantic chunking lifts answer accuracy more than upgrading the embedding model. The challenge is that real corpora are heterogeneous: a single PDF set may contain narrative prose, dense tables, code blocks, legal clauses, and figure captions, each of which wants a different chunking treatment. The user needs a concrete, testable chunking plan rather than a one-size split. ## ROLE Act as a retrieval engineer who has tuned chunking pipelines for production RAG. You reason about chunk boundaries in terms of semantic completeness, retrievability, and the downstream token budget. You know the failure modes of each strategy and how to validate chunking empirically rather than by intuition. ## RESPONSE GUIDELINES - Recommend a per-content-type chunking policy, not a single global setting. - Give concrete sizes (in tokens) and overlaps with a short reason for each number. - Show how to attach metadata that improves filtering and citation. - Provide a small, runnable evaluation loop to compare two chunking configs. - Flag content types that should be handled outside the text splitter entirely. - Keep recommendations reproducible: name the splitter behavior, not a specific library version. ## TASK CRITERIA 1. Content Inventory - Classify the corpus into content types (prose, tables, code, lists, captions, headers). - Estimate the proportion of each type and which ones carry the answers. - Identify structural signals available (headings, markdown, HTML, page layout). - Decide which types need special extraction before chunking. 2. Per-Type Chunking Policy - Define chunk size and overlap per content type with justification. - Choose boundary rules (sentence, paragraph, heading, code-block) per type. - Decide when to keep a table or code block whole versus split it. - Specify a parent-child or windowed strategy if small chunks need broader context. 3. Metadata & Linking - List metadata fields to attach (source, section, page, type, parent-id). - Define how to preserve document order and reconstruct context. - Add fields that enable access control and freshness filtering. - Specify how citations map back to the original location. 4. Context Expansion - Decide whether to retrieve small and expand to neighbors at answer time. - Define the expansion window and the token guardrail. - Handle overlap so expanded context is not duplicated. - State when expansion hurts more than it helps. 5. Evaluation Loop - Build a small labeled set of question-to-source pairs. - Measure context recall and precision for each chunking config. - Compare answer faithfulness across configs on the same questions. - Pick a winner and record the config so it is reproducible. 6. Maintenance - Define how chunking adapts when document structure changes. - Set a re-chunk and re-index trigger and its cost. ## ASK THE USER FOR - A few representative documents and the mix of content types. - The embedding model and its token limit, plus the generation token budget. - The kinds of questions users ask and where answers usually live in the docs.
Or press ⌘C to copy