Retrieval and RAG

RAG Chunking and Document Ingestion: Preserve Meaning and Provenance

Build a RAG ingestion pipeline that preserves document structure, source locations, permissions, and version history while producing useful retrieval chunks.

· · 8 min read

Prepared with AI research assistance. Sources are linked throughout; worked examples are illustrative unless stated otherwise. Editorial approach.

RAG chunking determines which pieces of a document can become evidence. If ingestion separates a rule from its exception, loses a table header, or attaches the wrong source location, a good retriever can still deliver misleading context. The useful unit is therefore not simply a string below a token limit. It is a retrievable passage whose meaning and origin remain inspectable.

This guide proposes an illustrative ingestion design for a company policy library. Its records, limits, and examples are hypothetical. The aim is to make design choices explicit enough to test against your own documents.

Parse into a document model before making chunks

Treat extraction, normalization, segmentation, and indexing as distinct stages. Extraction recovers content and layout. Normalization produces a consistent representation. Segmentation groups that representation into retrieval units. Indexing makes those units searchable. Keeping the stages separate lets you inspect where information disappeared.

Docling's document representation can retain text, tables, pictures, section hierarchy, document furniture, layout information, and provenance. This illustrates why a structured intermediate representation is more useful than flattening every input directly to plain text. It does not guarantee perfect parsing of a particular PDF. Docling document model.

In the proposed policy pipeline, an extracted element contains its type, text, source position, and parent section. Preserve the original file independently. Keep a link from normalized text back to the corresponding original span or bounding region, because normalization can change whitespace and character offsets.

A PDF with two columns should not become alternating fragments from unrelated paragraphs. Inspect reading order before adjusting chunk size. If extraction has already interleaved two policies, a more sophisticated chunker will organize corrupted text rather than repair the original meaning.

Choose boundaries around evidence relationships

Start with the smallest unit that can answer an expected question without silently changing its conditions. A standalone definition might work as one paragraph. A procedure may need its prerequisites and several ordered steps. A table row may require column headers, units, and a nearby footnote.

Unstructured separates document partitioning from chunking and generally combines complete elements, splitting an oversized element when necessary. Its title-based strategy uses detected section boundaries, with options governing small-section combination and page behavior. Those options matter: a strategy name alone does not prove that every resulting chunk has the boundary behavior you intended. Unstructured chunking documentation.

For the illustrative library, use this decision policy:

Content Proposed retrieval unit Important accompanying context
Definition Definition paragraph Defined term and section path
Procedure Coherent step group Preconditions and sequence position
Short table Complete table Headers, units, caption, footnotes
Long table Related row group Repeated headers and table identity
Exception Rule plus exception, or linked units Explicit relationship and applicability

This is a starting design, not a universal ranking of chunking methods. Keep the policy configurable by document family. A source-code repository, policy manual, and presentation deck do not have equivalent structural units.

Enforce token limits after adding context

A character count is not a model token count. Measure the exact serialized text that the embedding model will receive, including the document title, section path, repeated headers, and any contextual prefix. Also measure the text eventually supplied to the answer model; those representations may differ.

Docling distinguishes document-aware hierarchical chunking from tokenization-aware refinement in its hybrid chunker. Its documentation also separates raw chunk text from contextualized serialization. This distinction is useful when checking whether metadata enrichment pushes a previously acceptable chunk over the actual embedding limit. Docling chunking concepts.

Suppose the hypothetical pipeline targets 450 tokens of body text and reserves 70 tokens for identifying context. These are experiment settings, not recommended constants. If the actual prefix consumes 110 tokens, the pipeline must reduce the body, use a different representation, or reject the record. It should not rely on an embedding service silently truncating a sentence containing the exception.

For oversized elements, prefer meaningful sub-boundaries before arbitrary windows. Preserve the parent relationship so retrieval can expand from a small matching span to its surrounding procedure when needed. Expansion must still respect the answer context budget and access permissions.

Retain provenance as data rather than decorative citations

An illustrative chunk record might contain:

{
  "document_id": "travel-policy",
  "document_version": "v12",
  "chunk_id": "travel-policy:v12:section-4:part-2",
  "section_path": ["Travel", "Meals", "Exceptions"],
  "source_spans": [{"page": 8, "element_ids": ["e81", "e82"]}],
  "parser_version": "parser-config-3",
  "chunker_version": "policy-chunker-5",
  "embedding_profile": "embedding-profile-2",
  "access_policy_id": "staff-policy",
  "content_hash": "illustrative-normalized-content-hash"
}

The identifiers are fictional. In a real implementation, distinguish the source file version from the parser version and the chunker configuration. Reprocessing unchanged bytes with a different parser can change reading order and chunk boundaries even though the source file hash remains identical.

Location metadata can also come from managed ingestion systems. Microsoft's Content Understanding integration describes chunks with Markdown content and page or polygon locations; its semantic chunking and generated image descriptions are marked preview in the consulted documentation. Treat generated descriptions as derived content rather than silently equating them with original source text. Azure Content Understanding ingestion.

Store original text, normalized text, and generated enrichment as distinguishable fields. A citation should let a reviewer determine which claim came from which representation. A document URL alone cannot explain an extraction error on page eight.

Walk through a policy exception that crosses a page

Imagine a fictional policy saying that ordinary meal expenses have a daily cap. The next page contains an exception for approved overnight travel, followed by a table of currencies. A fixed window ends immediately after the ordinary cap; another begins with “This limit does not apply...” without identifying the limit.

A naive ingestion pipeline produces two plausible but incomplete answers. The first chunk suggests the cap is universal. The second retrieves an exception without the rule it modifies. More overlap may sometimes include both, but relying on accidental overlap makes correctness sensitive to unrelated edits earlier in the file.

In the proposed design, parsing attaches both paragraphs to the same section and records the page break separately. The segmenter either keeps the short rule and exception together or creates linked child chunks with a shared parent evidence unit. The currency table remains associated with its caption and units.

At retrieval time, matching the exception triggers bounded expansion to the rule and its conditions. The answer generator receives source spans for both pages. If the table's column structure is uncertain, the pipeline flags that element rather than embedding a confident but incorrect serialization. This example demonstrates an acceptance condition: the evidence supplied for a cap question must preserve the relevant exception, not merely contain the word “cap.”

Make updates and indexing explicit

A new document version should not silently coexist with obsolete chunks as equally current evidence. Build a manifest describing the complete intended chunk set for a version. Validate parsing, permissions, chunk counts, and required metadata before making that version eligible for retrieval.

For this illustrative system, publish a validated version by changing an authoritative active-version reference. Retire the old version's search records according to the index's update model. If vector and keyword indexes update separately, track their completion rather than assuming one successful write means both are current. See RAG freshness and index consistency for the full lifecycle problem.

Content hashes can help avoid unnecessary embedding, but they are insufficient as authorization identities. Two tenants may upload identical text under different access rules. Deduplicating storage must not accidentally merge their permission boundaries. Likewise, removing a source requires addressing derived chunks, cached evidence, and stored summaries, not only the original file.

Evaluate evidence preservation before answer fluency

Create a fixture set with multi-column pages, repeated headers, scanned text, long tables, cross-page conditions, and documents with identical titles but different versions. Record expected source elements and relationships. These fixtures test ingestion behavior independently of whichever model drafts the final response.

Then evaluate retrieval with queries requiring exact identifiers, exceptions, multiple passages, and explicit abstention. Compare chunking configurations under a similar supplied-context budget, not merely the same number of chunks. Otherwise a large-chunk strategy may receive far more source text than its comparator.

Research does not establish one universally best semantic splitter. A study of academic theses found that its cluster-based chunking configuration did not outperform simpler approaches and identified sensitivity to document formatting and evaluation questions. That is evidence about the tested setup, rather than a reason to reject semantic methods generally. Evaluating chunking strategies on academic texts.

For the proposed pipeline, track source-span accuracy, missing conditions, table reconstruction failures, retrieval of required evidence, context size, and ingestion cost. Inspect where reranking and context selection discard a needed exception even after ingestion preserved it. Successful parsing and successful answering are separate outcomes.

Frequently asked questions

Is a fixed-size splitter always inadequate?

No. It is a useful baseline for relatively uniform text and can be easier to reason about. Evaluate whether it preserves the evidence relationships your questions require before adding structural or model-based complexity.

How much overlap should every chunk use?

There is no universal amount. Overlap can rescue boundary context but also consumes index space and repeats evidence. Test it on boundary-sensitive questions, and retain explicit parent or neighboring-element references where those relationships matter.

Should generated summaries replace the source chunks?

Usually keep them separate in this design. A summary can help discovery, but it can omit a condition or introduce an interpretation. Retrieve or verify the original evidence before using the summary to support a consequential factual claim.

Source reference list

RAG
Document Ingestion
Chunking
Retrieval Engineering