# Chunking

> Chunking splits a document into pieces that retrieval can store and return.

Splitting documents into pieces that retrieval can store and return.

Track: Retrieval & Grounding
Access: free
Card: https://buildsparkai.com/chunking
Plain text: https://buildsparkai.com/chunking.md
Last checked: 2026-10-17

## What it is

Chunking splits a document into pieces small enough to store and return. LangChain's text splitter guide says those pieces should be retrievable on their own and fit in a context window. OpenAI's retrieval guide says a file added to a vector store is chunked, embedded, and indexed. Gemini's File Search guide says an imported file is broken into chunks, then embedded.

## Why it matters

**Cost.** Each stored piece can be embedded and kept. Overlap repeats text across pieces, so the same sentence can be stored more than once. OpenAI's retrieval guide documents a default of 800-token chunks with 400 tokens of overlap, and a chunk size from 100 to 4096 tokens. Those are that API's settings, not a universal size.

**Quality.** LangChain's text splitter guide says splitters break large documents into smaller chunks that can be retrieved on their own and that fit in a context window. A piece that starts mid-sentence can be returned without the heading it needed.

**Risk.** OpenAI's retrieval guide says files added to a vector store are chunked automatically unless you set a chunking strategy. A default cut can separate a fact from the name it refers to. Gemini's File Search guide also chunks on import, and documents a config for a maximum number of tokens per chunk and an overlap.

## Try today

Take one page you would search. Mark the cuts so each piece still names the thing it is about. If a sentence uses "it" or "the company," keep the name in that piece.

## Common mistake

Cutting on a fixed length so a heading, a sentence, or a table row is split, then retrieving the half that does not say what it refers to.

## Self-check

A sentence says "It closes at 18:00." The heading "Warehouse hours" is in the previous piece. What is wrong with that cut?

The piece that says "it" can be returned without the heading

## Practice and deep

Coming soon. One page you already search, cut so each piece still names its subject.

Coming soon. How OpenAI and Gemini document chunk size and overlap, and how a framework splitter differs.

## Sources

- [OpenAI, Retrieval guide: chunking](https://developers.openai.com/api/docs/guides/retrieval)
- [Gemini, File Search: chunking](https://ai.google.dev/gemini-api/docs/file-search)
- [LangChain, Text splitters](https://docs.langchain.com/oss/python/integrations/splitters)

Opened 2026-10-17. Each page is a vendor or framework doc. The card does not add a rate or a usage count.
