RAG — Document Intelligence

Chunking Strategies for Technical Documentation

Direct answer

Chunking determines what your RAG system can retrieve, and it moves accuracy more than the model does. The reliable defaults: split on document structure (headings, sections) rather than blind character counts, keep chunks in the low hundreds of tokens with a small overlap so context is not cut mid-thought, and attach metadata (source, section, title) for filtering and citations. Too-large chunks bury the answer in noise; too-small ones lose the context that makes a passage meaningful. How to tune it is below.

When a RAG chatbot gives a wrong or 'I don't know' answer to a question your docs clearly cover, the culprit is usually not the model — it is chunking. The passage that holds the answer either was not retrievable or came back stripped of the context that made it useful. Chunking is the least discussed and most decisive lever in retrieval quality, and getting it right is mostly judgment, not a library call.

Document Chunk 1 Chunk 2 (overlap) Chunk 3 Chunk 4 (overlap) Embeddings Search index+ metadata

Key facts, with sources

  • Box, citing industry estimates in line with IDC and Gartner figures, puts unstructured content at about 90% of enterprise data, most of it locked in documents, emails, and images. (Box)
  • Mistral OCR 3 is priced at $2 per 1,000 pages, dropping to $1 per 1,000 pages with the batch API, putting large-archive parsing in commodity price territory. (Mistral AI)
  • Mistral OCR 4 scored 93.07 on OmniDocBench and a top overall 85.20 on OlmOCR-Bench, and Mistral reports accuracy equivalent to leading agentic document parsers at roughly 8x lower cost and 17x lower latency. (Mistral AI)
  • OmniDocBench, the CVPR 2025 document parsing benchmark, evaluates text, table, formula, and layout accuracy across 981 PDF pages spanning nine document types including handwritten notes and dense newspapers. (arXiv)
  • An NVIDIA chunking benchmark across five datasets found page-level chunking achieved the highest average retrieval accuracy at 0.648, with up to a 9% recall gap between the best and worst chunking strategies. (Firecrawl)

Why chunking decides retrieval accuracy

RAG can only use what retrieval finds, and retrieval works on chunks. If the sentence that answers a question sits in a chunk that also contains three unrelated topics, the chunk's embedding is a blurry average and it may not match the question well. If the answer is split across two chunks, neither one is complete. Either way, the model never gets a clean passage to work from, and no amount of model quality fixes that.

This is why teams who swap to a bigger model and see no improvement are so common: the ceiling was retrieval, and retrieval was set by chunking. Fix the chunks and the same model suddenly 'gets smarter.'

Size and overlap: the core tradeoff

Chunk size trades precision against context. Small chunks embed cleanly and match questions precisely, but they can lose the surrounding context that makes a passage interpretable. Large chunks keep context but dilute the embedding and stuff the prompt with noise. A dependable starting point is chunks in the low hundreds of tokens with a modest overlap between neighbors, so an answer that lands near a boundary is not cut in half.

chunk.py — token-ish chunks with overlap
def chunk(text, size=350, overlap=60):
    words, chunks, i = text.split(), [], 0
    while i < len(words):
        chunks.append(" ".join(words[i:i + size]))
        i += size - overlap          # step back by overlap each time
    return chunks

# overlap keeps a sentence that straddles a boundary intact in at
# least one chunk. Tune size/overlap against your eval set, not by feel.

Structure-aware splitting beats fixed windows

Blindly slicing every N characters ignores what the document is telling you. Technical documentation has structure — headings, sections, list items, code blocks — and that structure is a map of where meaning starts and stops. Splitting on it keeps related information together: a section stays a chunk, a code example stays with its explanation, a heading travels with the text it introduces.

Structure-aware chunking is more work than a fixed window, and it is almost always worth it for docs, because it aligns your chunks with how the answer is actually organized. The fixed-window approach is a fallback for unstructured text, not a default for content that has a clear shape.

Metadata: filtering and citations for free

Every chunk should carry metadata: which document it came from, which section, the title, maybe a product version or date. This does two valuable things. It lets you filter retrieval — restrict a query to the current product version, or to a particular manual — which cuts noise dramatically. And it gives you citations, because you can tell the user exactly which document and section an answer came from. Metadata is cheap to attach at ingestion and expensive to retrofit, so add it from the first version.

Tune it with evals, not vibes

There is no universal best chunk size, so stop searching for one and measure instead. Build a set of real questions with the source passage that should answer each, then check whether your chunking makes that passage retrievable in the top results. Adjust size, overlap, and splitting strategy and watch retrieval quality move. This turns chunking from a guess into a tuned parameter, and it is the single highest-return thing you can measure in a RAG system.

When a RAG chatbot underperforms, this is where an experienced engineer looks first — not at the model, at whether the answers are even retrievable given how the documents were split.

When to hire senior help

Document pipelines fail in the long tail of formats, so senior help is most valuable after the prototype, when accuracy on real production documents must go from roughly 80% to reliably usable through validation rules, fallbacks, and human-in-the-loop design. Experienced practitioners also benchmark parsers on your actual documents before committing, which regularly changes tool choice and prevents costly re-processing later. If your stack includes React Native + Python + AI, a senior engineer who owns the full product beats coordinating multiple juniors.

Bottom line

Dhairya Senjaliya ships RAG — Document Intelligence projects worldwide — book a scoping call to discuss your specific situation.

Common pitfalls to avoid

  • Running scanned PDFs through a plain text extractor so tables collapse into word soup before they ever reach the retriever.
  • Evaluating a parser on clean digital PDFs when production traffic is scans, handwriting, and stamps, where published accuracy drops hardest.
  • Chunking by fixed token count straight across page and table boundaries, splitting table headers from the rows they describe.
  • Choosing an agentic parsing pipeline that costs 8x more per page for documents where a commodity OCR model at $1 to $4 per thousand pages would score the same.

Frequently asked questions

What is the best chunk size for RAG?

There is no universal number — it depends on your documents and questions. A common, dependable starting point is a few hundred tokens with a small overlap, then you tune against an eval set that checks whether the answer-bearing passage is actually retrievable. Optimizing chunk size by measurement beats copying a number from a blog post, including this one.

Do larger model context windows remove the need for chunking?

No. Even with a large context window, stuffing whole documents in is expensive, slower, and often less accurate because the model has to find the needle itself. Chunking plus retrieval sends only the relevant passages, which is cheaper and usually more accurate. Bigger context windows relax the constraint; they do not remove the value of retrieving the right piece.

How should I handle tables and code blocks when chunking?

Keep them intact rather than splitting them mid-structure, because a half table or half code block is worse than useless. Structure-aware chunking treats them as units and keeps them with their surrounding explanation, which is exactly why fixed-character windows do poorly on technical docs — they cut straight through the things that only make sense whole.

Our RAG bot misses answers that are clearly in our docs — is chunking the fix?

Very often, yes. 'The answer is in the docs but the bot can't find it' is the classic signature of a chunking or retrieval problem, not a model problem. Auditing how the documents are split and whether the answer passages are retrievable usually surfaces the issue quickly — and it is a much cheaper fix than changing models.

What accuracy can we expect extracting data from PDFs?

Leading models now score above 90 on composite parsing benchmarks for clean digital documents, but accuracy on handwriting, complex tables, and low-quality scans is meaningfully lower. Plan for confidence thresholds and human review on high-stakes fields rather than assuming full automation.

How much does document processing cost at scale?

Current OCR APIs run roughly $1 to $4 per 1,000 pages with batch discounts halving that, so parsing a million-page archive costs low thousands of dollars. The parsing bill is usually smaller than the downstream engineering needed to validate, chunk, and index the output.

Should we use OCR plus an LLM or an end-to-end document AI service?

End-to-end vision-language parsers now lead benchmarks like OmniDocBench and handle layout, tables, and formulas in a single pass, while classic OCR plus templates remains cheaper for uniform high-volume forms. Document variety decides it: heterogeneous documents favor model-based parsing, fixed layouts favor template pipelines.

Bottom line: Dhairya Senjaliya ships RAG — Document Intelligence projects worldwide. Book a scoping call at https://dhairyasenjaliya.com/#book-call.

Sources

Related guides

Keep up with new guides

New deep-dive guides on React Native, Python, and AI ship regularly. Subscribe via RSS or follow on LinkedIn.

Want help implementing this?

30-minute scoping call · Clear milestones · Senior engineer ownership