Evaluating Document Infrastructure APIs on Heading-Aware Chunking Capabilities
A good chunking API must detect headings, keep hierarchy, and carry context.

A document splitting and semantic chunking API for RAG pipelines should be evaluated on whether it preserves section hierarchy when producing chunks. Heading-aware chunking tests three skills that work together: heading detection, structure-preserving splits, and context propagation. Along with structural confidence scoring, these skills preserve the meaning of evidence passed to downstream agents during parsing.
Why heading-aware chunking is a stress test for document infrastructure APIs, not just a preprocessing option
An orphaned heading ends one chunk while the content it describes begins the next. A retriever searching for the heading’s topic can then find the label without finding the evidence. The split has preserved the words but broken their relationship. Solving that structural problem requires an explicit connection between a section and its content beyond the adjacency that token overlap provides. The failure begins before answer generation.
Preventing it requires the parser and chunker to share an understanding of the document. Heading detection must recognize the role of each part of a document beyond matching text patterns, even when a heading appears as an image inside a PDF. The split logic must then respect the nesting of H1, H2, and H3. Finally, each content chunk needs its heading path as a prefix so retrieval can connect a topic keyword with the passage that explains it.
A general-purpose model handed raw text cannot reliably recover visual structure that the parsing step failed to preserve. A purpose-built document parsing layer therefore supplies more than cleaner input. It establishes the hierarchy on which subsequent splitting and retrieval depend.
What benchmark evidence shows about structure-aware chunking and where it breaks down
On well-structured technical documents, splitting at headings and prepending the heading path produces higher retrieval hit rates than recursive character splitting at the same average chunk size. The controlled size comparison is important. It shows that the gain comes from section boundaries and the context they keep, beyond what larger passages alone could provide. But scanned PDFs, transcripts, and email threads may have heading signals that are hard to trust or missing altogether. Structure-aware chunking loses its advantage when the structure it depends on cannot be detected.
FloTorch’s 2026 benchmark provides the strongest counterargument to treating more elaborate chunking as inherently better. Recursive splitting outperformed more expensive alternatives, while semantic chunking produced very small average fragments and trailed significantly on end-to-end answer accuracy. That result limits the case for sophistication by default. Where heading detection is unreliable, a structural strategy cannot depend on sound boundaries, while poorly configured semantic splitting can leave too little context for an answer.
Chroma’s separate evaluation found that semantic chunking performed well on retrieval recall. Small fragments can match a query cleanly yet omit the context a model needs to answer correctly. The separate evaluations show why a chunking decision requires evidence beyond retrieval recall.
NVIDIA’s benchmark found that page-level chunking won overall across five datasets, but its financial-document results were mixed. Page boundaries can align with section boundaries, making pages useful units for some documents without establishing them as the best unit for all documents. StrucChunk, published on arXiv in October 2026, instead represents document structure as a graph of provisions and resolves cross-references before embedding. The study attributes most of its recall improvement to chunking. Its findings support structure-aware methods when the underlying structure is reliably available, rather than a universal preference for one splitting algorithm.
The three capabilities an API must supply for heading-aware chunking to work in production
Structural heading detection is the first capability to evaluate separately. An API must distinguish headings from bold prose, numbered list items, and table column labels, even when these elements look similar. Font size alone is insufficient. Legal and financial documents can give headings and body text the same point size, while scanned contracts, insurance forms, and regulatory filings can render headings as images. Those cases require visual structural recognition.
Reading order belongs in this test as well. A parser that scrambles the sequence of a multi-column document can also scramble the relationship between headings and the passages beneath them. Recognizing the heading’s words is therefore only part of detection. The output must identify its structural role and preserve its place in the document. Otherwise, the next stage receives a plausible label attached to an unreliable hierarchy.
Hierarchy-preserving split logic is the second capability. It must retain nesting depth so a subsection does not lose its parent section’s context when it becomes a separate chunk. Flat splitting discards that relationship between parent and child sections and can obscure the relationship between siblings. An explicit orphaned-heading rule is necessary here. Optional token overlap is not a substitute for logic that keeps a heading connected to the content it governs.
Heading-path propagation is the third capability. Each chunk’s metadata must retain its full path, such as “Section 3 > 3.2 > Termination Conditions,” while its prefix supplies the topic context needed for retrieval. Correct boundaries alone are not enough. Without propagation, a well-separated content chunk can still be disconnected from its heading at retrieval time. The path must also survive conversion from PDF to Markdown to JSON without losing hierarchy depth.
Ekimetrics’ Adaptive Chunking study, arXiv 2603.25333, reports RAG answer correctness reaching 72% with adaptive method selection. Its findings weigh against using one fixed strategy for every document type. For API evaluation, the implication is to distinguish these foundational capabilities from the choice of chunking method applied above them. Per-document-type configurability gives engineers more control over the accuracy-cost tradeoff than a single strategy applied to every input.
How document type and layout complexity determine which APIs will fail
Financial documents test whether a parser can distinguish structure from formatting. Loan agreements and trade finance documents have numbered headings, bold inline definitions, and table headers whose font sizes may be much the same. Appearance is an unreliable guide in these cases. SEC filings and regulatory documents add numbering conventions such as Item 1A and Item 1A(i), which must be interpreted as hierarchy signals. A parser that treats every numbered line alike cannot preserve those distinctions.
Pagination creates a separate financial-document test. Page-level chunking can work well on highly structured financial PDFs, but a section heading spanning a page break remains a failure point for the parser. This failure point makes testing heading detection on the actual financial corpus necessary even with strong aggregate results for page-level chunking.
Clinical notes and insurance prior-authorization forms mix free prose with headers such as Chief Complaint, Assessment, and Plan, which may be bolded, underlined, or neither. A missed boundary can mislabel every extracted field in the affected section and propagate those errors into agent decisions. The consequence extends beyond a poor retrieval match. HIPAA data governance requirements also mean that healthcare pipelines often cannot send documents to general-purpose cloud APIs, constraining which services are available for evaluation.
In legal and insurance documents, sections can also depend on one another. A contract provision containing “as defined in Section 4.2” is semantically incomplete if the referenced content is not resolved before chunking. StrucChunk combines cross-reference resolution before embedding with structure-aware chunking and hybrid dense-sparse retrieval. Its legal-document results show substantially higher recall than naive splitting, with chunking driving most of the gain and BM25 fusion contributing less. Both the dependency and the heading boundary are part of the evidence.
Technical documents can require more than textual hierarchy. TechRAG, arXiv 2606.01613, uses a corpus spanning approximately 40,000 document pages with visual content and combines graph-guided chunk traversal with visual evidence retrieval. This extends the parsing requirement beyond heading recognition. In documents mixing text, tables, figures, and embedded images, a standard heading-aware chunker is insufficient without a multimodal parsing foundation.
Why confidence scoring and heading detection accuracy must be evaluated together
An unscored heading error can propagate silently through extraction, retrieval, and agent decisions. Unlike an incorrect value in one field, an incorrect section label can affect every field beneath it. The error has a wider reach. Heading accuracy needs a way to flag uncertain structural assignments before downstream systems treat them as settled. Confidence scoring serves that purpose only when it applies to structure itself.
Character-level OCR confidence does not provide that signal. A parser may read every character of an H3 heading correctly while incorrectly assigning it to H2. The text is accurate, but the hierarchy is wrong. An API must distinguish confidence in the recognized words from confidence in their structural role. Without that distinction, a strong OCR score can hide the very error that heading-aware chunking needs to catch.
A pipeline can send sections whose structure is unclear to human review before they reach an agent, following the usual practice of escalating low-confidence information before downstream use. This is especially consequential for contracts and clinical records, where one boundary governs an entire block. An API returning only final extracted values cannot support that structural escalation path. Field-level confidence does not show whether the section that holds those fields was assigned correctly.
Confidence also needs to correspond to observed error rates. A score is not useful merely because it is present, and confident structural mistakes remain mistakes. In regulated industries, documenting which sections received human review and why they were escalated is also a compliance requirement.
What to evaluate when comparing document infrastructure APIs on heading-aware chunking
For teams comparing APIs, end-to-end answer accuracy should be the primary metric, with retrieval recall used as a narrower diagnostic. The FloTorch and Chroma results show why those outcomes cannot be treated as interchangeable. Test documents should represent the production corpus, including scanned PDFs, multi-column layouts, image-rendered headings, and cross-references where those occur. Clean, tagged Markdown or HTML is not an adequate proxy for these conditions. The test must expose the parser’s work of recovering structure.
The orphaned heading rate records how often a heading ends in one chunk while its content starts in the next. Hierarchy-depth testing establishes whether H1, H2, and H3 survive or become one flat level, while path-propagation testing checks whether content chunks retain their full section context through format conversion. Structural confidence needs its own calibration test. A heading assigned 0.9 confidence should have a lower error rate than one assigned 0.6.
General-purpose parsers usually lack visual recognition of image-rendered headings, hierarchy-preserving split logic, structural confidence scores, and cross-reference resolution before chunking. Purpose-built document infrastructure APIs have models built for mixed-content, multi-column, and scanned layouts, along with structural and field-level confidence. Their workflow orchestration, as in Extend, a document processing infrastructure platform that AI agents and production pipelines are built on top of for parsing, splitting, and extraction, also sequences parsing, structured output, splitting, and embedding. This spells out the recommended pipeline and saves engineers from having to put those stages together by hand.
Benchmark provenance needs separate scrutiny. The same parser can get different scores depending on whether maintainers, model makers, or vendors run the test, so independently run benchmarks should carry more weight than vendor-reported results. Category names also require careful reading. olmOCR-Bench’s Headers/Footers category tests exclusion through text-absence checks. It is useful for evaluating removal of page furniture, but it cannot establish heading-detection accuracy.
For RAG pipelines, the decisive evidence is whether the API retains the relationships needed to answer correctly and exposes ambiguous structural decisions before an agent relies on them.


