---
title: "Chunking"
type: "glossary term"
url: "https://aifordevs.org/glossary#chunking"
markdown: "https://aifordevs.org/glossary/chunking.md"
publisher: "AI for Devs"
license: "https://aifordevs.org/reuse"
attribution: "Credit AI for Devs and link to https://aifordevs.org/glossary#chunking"
---

# Chunking

Chunking is splitting documents into smaller passages before you embed and index them for retrieval. Chunk size sets how much text a single retrieved passage can bring into the prompt.

Small chunks match queries closely but lose surrounding context, and large chunks keep context but blur the embedding. Overlapping neighbors keeps a sentence from being cut at a boundary. Anthropic's Contextual Retrieval post says RAG systems usually chunk to no more than a few hundred tokens, and that size, boundaries, and overlap all affect retrieval.

## Example

A 10,000-token document split into 500-token chunks with 50 tokens of overlap produces 23 chunks, because each new chunk starts 450 tokens after the last.

## Source

[Anthropic, Introducing Contextual Retrieval (2024)](https://www.anthropic.com/research/contextual-retrieval)

## Related terms

- [RAG](https://aifordevs.org/glossary#rag)
- [Embedding](https://aifordevs.org/glossary#embedding)
- [Vector database](https://aifordevs.org/glossary#vector-database)
- [Reranking](https://aifordevs.org/glossary#reranking)
- [Hybrid search](https://aifordevs.org/glossary#hybrid-search)

## Read the article

[What is a vector database? HNSW, IVF, and when to skip one](https://aifordevs.org/articles/what-is-a-vector-database)

## Cite this term

AI for Devs. "Chunking." https://aifordevs.org/glossary#chunking

- Page: https://aifordevs.org/glossary#chunking
- Markdown: https://aifordevs.org/glossary/chunking.md
- Reuse: Quote or summarize with a link to this page. Terms: https://aifordevs.org/reuse
- Publisher: AI for Devs
