Skip to content
← The journal

Retrieval & graphs / Insight

Document chunking for RAG: preserve context and source citations

Choose document boundaries around evidence, preserve headings and qualifiers, and evaluate splitting choices against the questions your agent must answer.

Overlapping curved metal panels catching soft light.
Photography by Tobias Keller / Unsplash

The short answer

A useful chunk contains enough context to support a claim and enough identity to find its source.

Choose document boundaries around evidence, preserve headings and qualifiers, and evaluate splitting choices against the questions your agent must answer.

Preserve enough context to answer the question

A chunk is the portion of a document a retrieval system selects as one unit. Splitting makes it possible to select relevant material, but the boundary matters. Cut between a rule and its exception, or a number and its label, and the retrieved text can mislead.

Start with the evidence needed for a question. For "what is the cancellation period?", the number alone is inadequate if the next paragraph limits it to a particular service tier.

Inspect boundaries that carry meaning

Document elementWhat to preserveTypical failure
Heading and paragraphSection title and the paragraph's scope.A generic sentence loses its subject.
Table rowColumn labels and row identity.A number is retrieved without its unit.
Rule and exceptionThe qualification needed to interpret the rule.The answer states the default as universal.
Decision and amendmentSource identity and relationship.The original commitment appears current.

Use these questions to choose boundaries for your documents. They do not prescribe one way to split every file. LangChain's splitter documentation describes length-based and document-structure approaches. Test a strategy against your own material before tuning it.

Use a boundary test with a visible exception

Create a short synthetic policy: standard support covers weekdays. A second sentence excludes public holidays. Ask whether support is available on a holiday. If retrieval only supplies the first sentence, the agent cannot properly interpret the rule.

Compare a paragraph-preserving split with a smaller fixed split. Keep the model, question and source revision constant. Save the retrieved text, not just the final answer. This is an evaluation exercise, not a result for either strategy.

Carry source identity into each retrieved unit

Each unit should lead back to an original document and a stable location or passage. Preserve section headings where they establish scope. Record the document revision or capture date where changes matter.

Overlap can keep adjacent context together, but it also creates repeated text. Avoid interpreting three overlapping passages as three independent sources. Deduplicate evidence when writing a final answer and keep the original source as the authority.

Adjust chunk size using failed queries

If relevant passages are absent, examine import coverage and retrieval before concluding that every chunk is too large. If the answer mixes unrelated sections, a narrower unit or better source metadata may help. If qualifiers disappear, preserve the surrounding structure.

There is no single word count that makes every document searchable. Build a test set with prose, tables, short notes and changed facts. Compare relevant retrieval, supported answers and context sent to the agent. Compare each change with a simple split, and keep it only if the results justify the extra work.

Evaluate your import workflow

The retrieval evaluation kit shows how to keep questions, relevance decisions and results separate. Its arithmetic example is synthetic and does not benchmark Gigabrain.

For Gigabrain, use the supported import/index workflow rather than editing internal retrieval files to match a generic tutorial. Inspect the product mechanism and setup guide. Compare plans after verifying that the system fits your sources.

Compare two splits of one source

Consider this fictional sentence: "Weekday support covers the inspection team, except on public holidays." A split after "team" separates the offer from its exception.

SplitRetrieved textRisk
At a fixed positionWeekday support covers the inspection teamThe holiday exception is absent.
Preserve the sentenceWeekday support covers the inspection team, except on public holidays.The condition remains visible.

This is a constructed boundary example, not a measured retrieval improvement. Both text variants come from the same supplied sentence.

The boundary worksheet includes the source, two candidate splits and questions for a repeatable review. Test actual retrieval separately before choosing a chunking configuration.

Retain the location as well as the words

The connected-source experiment returns a document identity, quotation and location. Those fields let a reviewer inspect the underlying source instead of relying on the chunk alone.

See the citation walkthrough for the changed-source failure. A convenient chunk boundary does not remove the need for source verification.

Method note: Gigabrain Labs prepared this material with AI assistance. Fictional teaching examples and executed results are labelled separately.

About this publication

Gigabrain Labs publishes practical guidance for people using file-capable AI agents. Our guides explain the product and link to supporting tests. We label practice exercises separately from recorded results.

About Gigabrain ↗
One complete system

Get Gigabrain.

Give your AI agent persistent, source-linked knowledge from the files you already own.

Gigabrain System
Complete core system

$79 once

The complete knowledge and memory system for your AI agent.

Try Gigabrain
7-day money-back guaranteeNot satisfied? Request a full System refund within seven days of delivery.
  • Persistent, source-linked memory
  • Semantic and lexical retrieval
  • Connected knowledge graph
  • Guided agent setup
  • Tools for building your own workflows
  • Twelve months of core updates

One-time purchase · No coding required · Knowledge stored locally · Model accounts and usage fees are separate

Gigabrain

Gigabrain System 1.1.0

Your context, ready for the next conversation.Keep your files, decisions and previous work ready for your AI.

7-day money-back guarantee

Not satisfied? Request a full System refund within seven days of delivery.

  • Keep every conversation connectedYour AI starts with the decisions and work already done.
  • Set up with a guided walkthroughStart your first project with clear, practical steps.
  • 12 months of core updatesKeep your system current as your work develops.
  • Your licence and download linkSet up on your computer. Keep your files local.

One payment. Yours to keep. No subscription.

Your AI agent and model usage fees are separate.

Secure checkout

Stripe handles your payment details. Your final total, including any tax, appears in the payment form before you pay.

Preparing secure checkout.