Glossary

Chunking

Splitting documents into smaller passages so they can be embedded, indexed and retrieved as context for a language model.

Chunking is the step in a retrieval pipeline that splits documents into smaller passages, called chunks, before they are embedded and indexed. A retriever then returns individual chunks instead of whole documents, so the model receives the few paragraphs that relate to a question rather than a 200-page PDF. Each chunk is the unit that gets matched, ranked and placed in the prompt, so its size and boundaries decide what the model can see.

Why documents are chunked

Most retrieval-augmented generation systems chunk for three reasons. An embedding model has an input limit and produces one vector per input, so a long document embedded whole becomes a blurred average of many topics. Search precision improves when each indexed unit covers one idea. And the context window is finite and paid for per token, so sending only relevant passages keeps requests smaller, as your LLM bill is a retrieval problem sets out.

Common chunking strategies

Strategy

How it splits

Good for

Watch out for

Fixed-size

Every N tokens or characters

Baselines and uniform text

Cuts sentences and tables part-way

Recursive

Paragraphs, then sentences, then words, until under a size limit

Most prose and documentation

Ignores meaning across paragraphs

Semantic

Where similarity between neighbouring sentences drops

Long documents that change topic

Slower indexing and uneven sizes

Structure-aware

By headings, sections, pages or table rows

Manuals, contracts, Markdown

Needs clean parsing of the layout

Time-based

By time ranges or scenes

Audio and video transcripts

Speech that runs across boundaries

Fixed-size chunking is the usual starting point, often with chunk overlap of 10 to 20 percent so a sentence cut at a boundary appears whole in one of the neighbours. Recursive chunking with a text splitter that respects separators is the default in most RAG frameworks. Semantic chunking starts a new chunk where the topic shifts, and fixed vs semantic chunking compares the two. Structure-aware splitting depends on PDF parsing and layout analysis that recover headings, reading order and tables.

Choosing a chunk size

Small chunks of around 100 to 250 tokens match precise questions well but lose surrounding context, so a retrieved sentence may lack the subject it refers to. Large chunks of 800 tokens or more keep context but dilute the embedding and add noise to the prompt. Many pipelines settle between 256 and 512 tokens and then tune against their own questions with retrieval evaluation metrics such as recall at k. No single setting suits every document type, which is why tuning chunk size rarely fixes poor answers on its own.

Several techniques soften the trade-off. Parent document retrieval matches small chunks and returns their larger parent section. Sentence window retrieval returns the matched sentence with its neighbours. Contextual retrieval prepends a short description of the surrounding document to each chunk before embedding, and late chunking embeds the whole document first and splits the token embeddings afterwards, so each chunk keeps document-level context.

Chunking in Exabase

Exabase handles chunking at write time, so there is no chunking logic to build or tune. Content stored as Resources is extracted and indexed when it is created, and Deep Search returns the matching passage with a page number for documents or a timestamp range for audio and video, an approach described under sub-document retrieval and in how sub-document retrieval works. A precision setting from 0 to 1 controls how many loosely related matches come back, which covers much of what teams otherwise try to adjust through chunk size.

When you need the chunks themselves, Extract returns text split into ordered chunks, each with a sequence number and a page number or start and end timestamps. The chunks endpoint pages through them, and the free PDF to chunks tool shows the output for a single file. Video is split into timestamped chunks that carry both transcript and visual content. Parsers that produce chunks are compared in best PDF parser for LLMs and Exabase vs Unstructured. RAG accuracy covers why retrieval quality decides whether an answer contains the fact, and RAG pipelines shows the setup end to end.

FAQs

What is chunking in AI?

Chunking is splitting documents into smaller passages before embedding and indexing them, so retrieval can return the relevant part of a document instead of the whole file.

What is the best chunk size for RAG?

There is no universal best size. Between 256 and 512 tokens with some overlap is a common starting point, tuned against your own queries.

What is chunk overlap?

Overlap repeats a few sentences from the end of one chunk at the start of the next, so information cut at a boundary still appears whole in one chunk.

What is the difference between fixed and semantic chunking?

Fixed chunking splits at a set length, while semantic chunking splits where the topic changes. Semantic vs recursive chunking compares another common pairing.

Does chunking affect hallucinations?

It can. Chunks that separate a fact from its context, or that bring in unrelated text, make it more likely the model fills the gap with a guess, as hallucination explains.

Is chunking still needed with long context models?

For large corpora, usually yes. Long-context models read more per request, but sending everything costs more and accuracy falls on long inputs, as RAG vs long context covers.

How do you chunk tables and images?

Keep each table whole or split it by rows with the header repeated, and convert images to text with OCR or captions first. Table extraction covers the parsing side, and multimodal RAG covers other approaches.

Related pages: Chunk overlap, Semantic chunking, Recursive chunking, Late chunking, Fixed vs semantic chunking, Contextual retrieval, Sub-document retrieval, Deep Search, RAG accuracy, Chunking is a workaround, not a design, Data pipeline, Contextual embeddings, Re-indexing.

Cut your token spend and give your agent precise context.

Get started in minutes.

Cut your token spend and give your agent precise context.

Get started in minutes.