Choosing a Chunking Granularity Strategy When Documents Mix Headings Tables and Prose
Match chunk granularity to headings, tables, and prose to keep answers grounded.

For RAG pipelines that mix headings, tables, and prose, the right chunking granularity depends on how each region encodes meaning. Preserve section hierarchy with parent-child chunks, split tables into rows with headers and captions, and split prose recursively at paragraph and sentence boundaries. A document splitting and semantic chunking API should be judged by whether its pipeline preserves those relationships.
Why a single chunking granularity silently breaks retrieval on mixed-content documents
A retrieved table row contains the right value but not the header that identifies its units. The answer looks plausible, yet its interpretation is unsupported. Fixed token windows are a simple way to split text into chunks with a size limit, which makes them useful as a fallback when stronger boundaries are missing. Their limitation is specific, however. A token count does not identify the relationship between a value and its header, or between a policy statement and the heading that limits its scope.
A demo built from clean paragraphs may never show this production problem, but mixed-content documents can produce chunks with half of one policy and half of another. An embedding model cannot bring back a missing relationship just by finding a better match for the fragment. Generation then gets context that is missing parts or is misleading, even when retrieval seems to have worked.
Three Sides of Retrieval: Factorial Evidence for Document-Side, Query-Side, and Answer-Side Complementarity in RAG describes chunking as destroying heading hierarchies, section boundaries, and cross-references, framing the failure as architectural. Before changing the embedding model, engineers should check whether the retrieval units still have the information needed to make sense of the answer.
What makes mixed-content documents structurally different from plain prose
Heading-organized sections encode meaning through hierarchy. A heading supplies the interpretive frame for the body beneath it, so a sentence retrieved without that frame can lose its scope. The body may remain grammatically complete and still be decontextualized. This distinguishes a section boundary from an arbitrary break between adjacent paragraphs.
Tables encode meaning through relationships: a cell depends on its column header and row label, while the caption identifies what the table measures. Units, dates, and entity scope can determine how a value should be read. Prose works differently again. Its meaning develops across sentences and paragraphs, where a qualifying condition may precede or follow the claim it constrains.
A larger window may include a missing qualification but also combine unrelated sections, while a smaller window may isolate a table value from its label. Lists, code blocks, and multi-column layouts have their own structural units too. FreeChunker: A Cross-Granularity Chunking Framework identifies fragmentation and redundancy as consequences of inappropriate chunking.
Detecting content-type boundaries before splitting begins
The first engineering step is to identify document and region types before applying any splitter. MIME type and content heuristics can distinguish code, Markdown, prose, tabular content, and PDF inputs for initial routing. Document-level classification is only the starting point. A PDF can contain all three principal zones, so the pipeline also needs a map of heading-structured regions, tables, and flowing prose.
For complex formats, that map depends on layout analysis. Font size, font weight, spacing, and indentation provide signals from which structural boundaries can be inferred without native bookmarks or LLM calls. The ToC study reconstructed a hierarchical table of contents from typographic cues across all eight documents in its corpus, including documents without PDF bookmark metadata. That result supports visual structure detection within the tested corpus. It does not make every visually inferred boundary reliable.
Parsing quality therefore constrains every downstream choice. If a parser strips heading levels or collapses table cells into comma-separated text, the chunker receives a representation in which the relevant relationships are already missing. The practical requirement is to preserve heading hierarchy, cell boundaries, layout metadata, and reading order upstream. Only then can the zone map route each region to a splitter suited to its structure.
Chunking heading-organized sections with a hierarchical parent-child pattern
For heading-organized content, use the document hierarchy as the primary boundary. Each section becomes a candidate chunk, and oversized sections recurse along their subheadings. Every child retains a reference to its parent section. Prepend the heading path, such as “Section 3 > 3.2 > Eligibility Criteria,” so that a child retrieved alone retains its organizational context.
Small child chunks help find precise matches, and the parent section gives generation the broader passage it needs to answer the question. This works for technical manuals, regulatory documents, multi-section knowledge bases, and policy documents whose headings set the scope. If a section exceeds the embedding model’s effective context window, split along subheadings first. Use sentence boundaries when there are no subheadings, and turn to fixed token windows only as the last fallback.
The ToC study tested heading-aware retrieval in a production enterprise RAG system that serves HR, procurement, and travel-policy documents. It reported a significant main effect on answer quality of d = +0.41, with the largest gains in completeness and usefulness. The study tested heading embeddings to retrieve full page sections, but it did not test every detail of the parent-child recipe. The evidence shows that section identity can help retrieval find more than passage matching alone can.
Chunking tables by row with headers prepended to every chunk
Extract each row and keep its row label and cell relationships. Prepend the column headers, then prepend the table caption if one is present. Treat the resulting caption, headers, and row as one chunk. The chunk must keep the values, units, dates, and nearby labels needed to make sense of it on its own.
This recipe addresses a failure that overlap cannot reliably repair. A token window may happen to include a header, but it does not guarantee that every row retains the correct header relationship. The caption is a separate dependency. Without it, a row can preserve its columns yet lose the measurement context, including the date range or entity scope. Row-wise splitting is useful because it preserves these relationships deliberately.
Correct extraction must come before that recipe. Simple tables with clear headers and no merged cells are more tractable for multimodal parsing, while merged cells and nested headers require specialized extraction. A flat string is not an adequate substitute. Once row and column relationships have been discarded, prepending labels to text fragments does not establish that those labels belong to the extracted values. Ambiguous table structure requires review before malformed row chunks enter the index.
Chunking prose with structure-aware recursive splitting
For prose zones, use recursive splitting that prefers paragraphs, then sentences, and resorts to fixed tokens only when necessary. These boundaries keep the text’s own organization without the need for embedding-based boundary detection. A size limit still constrains the output. It should trigger a search for a smaller natural boundary.
Semantic chunking is not automatically the stronger choice. The benchmark evidence described in the notes supports recursive and sentence-based approaches as competitive alternatives, rather than treating semantic boundary detection as a prerequisite for accurate retrieval. FreeChunker provides a concrete example. It treats sentences as atomic units, avoids the computational overhead of semantic boundary detection, and reports retrieval and time-efficiency advantages on LongBench V2. That finding gives a reason to test simpler methods before taking on the extra computational cost.
A prose chunk containing “the API,” “the customer,” or a figure cited from an earlier section may still require appended context from its surrounding section. Enrichment should address that missing referent. Overlap serves a different purpose and should be introduced only when evaluation demonstrates a boundary problem, because near-duplicate passages enlarge the index without reliably restoring the relationship that was lost.
How should a RAG pipeline split PDFs and long documents without losing hierarchy?

The three strategies connect through a shared document map. After parsing and zone detection, each region passes through its assigned chunker, and the outputs merge into a single content index. Every chunk needs zone-type, section-path, source-page, and position metadata, with parent references for hierarchical chunks. That metadata preserves the connection between a local retrieval unit and the document that gives it meaning.
The retriever can then apply query-specific logic. A question about numbers can favor table chunks, while a question about policy can favor heading-structured content. Section paths and positions keep the outputs coherent when different chunk types contribute to the same answer. Context enrichment comes after parsing and structure-aware splitting to finish preparing the chunks for retrieval.
A parallel heading index gives retrieval another way to find content. The ToC study matched queries against heading embeddings through cosine similarity, loaded the corresponding page sections, and merged those results with content retrieval. This allows section-level and passage-level matches to contribute different evidence. Whether that additional channel is warranted depends on the document family and its query distribution, rather than a global preference for more elaborate retrieval.
Where structure-first chunking breaks down and what to do about it
Structure-first chunking depends on recoverable structure. Scanned PDFs and low-quality document images require OCR before structural detection, and parsing errors can propagate into every later boundary decision. Inconsistent formatting creates a related problem even when the text itself is readable. Low-confidence structural inferences should be flagged before indexing, rather than treated as equivalent to clear section or table boundaries.
When headings are absent, fall back to paragraph-first recursive splitting with section-level metadata inferred from document position. Continue to sentence boundaries when paragraphs are too large, and use fixed token windows only as a last resort. For ambiguous tables, the response is different. Merged cells, multi-row headers, and transposed layouts require review when the parser cannot establish reliable relationships. Prose fallback cannot bring back missing table structure.
FreeChunker offers a partial alternative when static boundaries are unreliable, because its sentence-level units support flexible combinations at retrieval time. It does not remove the need to detect extraction errors. Every fallback decision should be logged and surfaced in evaluation, so an apparently successful indexing run does not conceal a loss of structure. Confidence scores show which inferences are uncertain, and retrieval evaluation is needed to find failures that would otherwise go unnoticed.
Evaluating chunking strategy before and after deployment
Chunking requires controlled evaluation against the document families and queries the system will serve. Visual inspection can reveal malformed chunks, but it cannot establish retrieval quality. Measure retrieval metrics separately from end-to-end answer accuracy. Larger units may improve top-k recall but bring in enough irrelevant context to lower answer accuracy, so neither measure can stand in for the other.
Evaluation should also separate heading-heavy policy documents, tabular financial reports, and mixed-content contracts. A global aggregate can hide a concentrated failure. Establish a measurable baseline with recursive paragraph splitting for prose and row-wise chunking for tables, then add structural routing where a document family demonstrates the need.
After deployment, chunk-level confidence and retrieval scores show where to look for problems. Persistently weak results on in-domain queries warrant examination of boundaries and routing. The ToC study’s sensitivity analysis across 480 conditions found defaults near-optimal, illustrating how evaluation can establish stable operating parameters. The objective is accountable operation.
Extend is one option for the upstream layer, using specialized vision models to preserve heading hierarchy, table structure, and reading order in complex layouts. Its built-in evals and confidence scoring support the operational loop needed to surface degradation before it reaches users. The governing discipline is to measure retrieval quality as a pipeline property.


