Chunking means splitting a large document into smaller pieces before creating embeddings for RAG.

Each piece is called a chunk.

Why is chunking needed?

Suppose a 50-page employee handbook contains:

If the whole handbook becomes one embedding, its meaning is too broad. A question about remote work may retrieve the entire handbook instead of the relevant paragraph.

Chunking creates focused pieces:

Large handbook
    ↓
Leave-policy chunk
Remote-work chunk
Salary-policy chunk
Security chunk

Chunk size trade-off

Chunks that are too large

Chunks that are too small

The correct size depends on the content. Test it using real user questions rather than memorizing one universal number.

Example

Original text:

Remote Work Policy

Employees may work remotely during severe-weather alerts.
They must inform their manager before the shift begins.

Annual Leave Policy

Annual leave requires manager approval.

Good chunks:

Chunk 1:
Remote Work Policy
Employees may work remotely during severe-weather alerts.
They must inform their manager before the shift begins.

Chunk 2:
Annual Leave Policy
Annual leave requires manager approval.

Do not split a sentence or separate an important rule from its heading.

Chunk overlap

Sometimes a small amount of text is repeated between neighbouring chunks so that information near a boundary is not lost.

Chunk 1: paragraphs 1–3
Chunk 2: paragraphs 3–5

Too much overlap creates duplicates, increases storage, and may return the same information repeatedly.

Useful chunking strategies

Structure-aware chunking is usually better than blindly cutting after every fixed number of characters.

Store metadata with every chunk

{
  "text": "Employees may work remotely...",
  "documentId": 10,
  "section": "Remote Work Policy",
  "page": 8,
  "updatedAt": "2026-08-01"
}

Metadata helps with permissions, filtering, source links, and updates.

How do you know chunking is good?

Test sample questions and check:

Good chunking creates pieces that are small enough to retrieve accurately but large enough to keep their meaning.