Chunking and Retrieval Units
In this article
- Say when a document must be cut to fit an embedding model's input limit, and when it should be cut so that a search can match one question.
- Spot items that should stay whole, such as a short page on one topic or a database row that is read live.
- Name the document, embedding, retrieval and context units for a document, and explain why they need not be the same piece of text.
- Terms defined here: chunking, embedding unit, retrieval unit, context unit.
Overview
A support colleague asks: "Who can approve a fee waiver above $50?" The answer is one paragraph in a 120-page staff handbook. If the search behind your assistant treats that handbook as a single item, it can only say "the handbook is relevant", which is no help at all.
Search needs smaller pieces, and cutting documents into them has a name: chunking. Cutting is not always right, though. Some items are too large to process whole, some are fine as they are, and some should never be put in a search at all.
By the end you can decide, for any item in a collection, whether to cut it, and you can name the four different pieces of text involved, from the stored document to the text the model finally reads.
Brightline's search, piece by piece
Take a made-up home-internet provider, Brightline. Its support assistant answers from about 400 help pages, most under 500 tokens and each on one topic; 12 router manuals; and a 120-page staff handbook of about 60,000 tokens, in 40 chapters of about 1,500 tokens each. A token is a piece of text, often part of a word, that a model counts as one unit; a tokenizer is the code that does the cutting and the counting.
Before any question arrives, those documents are cut into chunks, short pieces of a document that a search can find and hand to a model. Each chunk gets an embedding, a list of numbers (a vector) standing for the meaning of its text, chosen so that texts with similar meaning get vectors that lie close together, and goes into Brightline's search index, a store built so a program can search it quickly; it holds about 2,000 chunks. When a question comes in, vector search embeds it with the same model and returns the top 3, the three chunks whose vectors lie nearest to the question's vector.
The assistant then pastes the text of those 3 chunks into the prompt (the text sent to the language model) next to the question. The model answers from that pasted text.
The embedding model is real: OpenAI's text-embedding-3-small. It accepts at most 8,191 tokens in one input, counted with its cl100k_base tokenizer. [1] That limit is measured in tokens, not in characters or words, so you check it with the tokenizer, not with len(). [1]
The first reason: the input limit
The handbook is about 60,000 tokens. That is more than seven times the 8,191-token limit, so one call cannot embed it. Send it anyway and the API rejects the request with a 400 error that says the input exceeds the model's maximum length. [1] Chunking is the general fix: break a document into pieces of a suitable size, each holding text that belongs together. [2]
OpenAI's cookbook names two ways to deal with text that is over the limit. You can truncate it yourself before the call, tokenizing it and keeping only the first 8,191 tokens, or you can cut it into chunks and embed each one on its own. [1] Truncation throws away everything after the cut, and that text may hold the answer. [1] For the handbook it would keep roughly the first eighth and drop every chapter after it, "Fee waivers" included.
So for the handbook there is no choice: it must be cut. The limit tells you that much. It says nothing about how small the pieces should be, and that is where the second reason comes in.
The second reason: one question, one rule
Now take one chapter, "Fee waivers". It is about 1,500 tokens, well under 8,191, so text-embedding-3-small can embed it whole. Is one vector for the chapter a good search unit? Look at what the chapter holds (sizes in tokens; contents made up):
| paragraph | about | tokens |
|---|---|---|
| 1 | which fees can be waived | 400 |
| 2 | what a support-staff member may waive alone | 350 |
| 3 | waivers above $50 and who approves them | 250 |
| 4 | how a waiver is recorded | 300 |
| 5 | when a waiver is refused | 200 |
The question "Who can approve a fee waiver above $50?" needs paragraph 3, about 250 of the 1,500 tokens. Before reading on, guess: which of the five paragraphs is one vector for the whole chapter about? None of them. It has to stand for all five rules at once, so think of it as a blend of five topics in which the $50 rule is about one fifth. "Blend" simplifies how the numbers are formed, but it predicts the effect. The question's vector points at one rule, so its match with the chapter is weaker than with paragraph 3 alone, and a nearby chapter that also talks about approvals above $50, such as one on refund approval, can come closer than it should.
Even when the chapter vector does win, the hit is 1,500 tokens where 250 matter. The model then reads four paragraphs it did not need, and passing text that has nothing to do with the question can lead to inaccurate or off-topic answers. [2] Sending whole documents or oversized chunks also costs more and does not give the best results. [2]
So fitting under the limit answers "can I embed this?", not "can a search find one rule in it?". A chapter with five rules that people ask about separately should be cut, even though it fits.
When to leave an item whole
Cutting has its own failure. A piece that is too small to carry enough context gives poor results, and meaning that is spread over several pieces may not be captured by any of them. [2] Cut "Fee waivers" into 30-token scraps and one of them might read "These need a second sign-off." Which waivers? Whose sign-off? The words that answer that sit in the scrap before it. A good chunk is small enough to be about one thing and large enough to make sense on its own.
That is why a typical Brightline help page stays whole. A page with separate sections, such as help-refunds (how to ask; the time limits), is cut at its sections, which is where help-refunds#1 and help-refunds#2 come from. It is under 500 tokens and covers one topic, so the page already is the unit a question wants. Cutting it would only add index entries that each know less than the page does.
An order record is the other case. It is one row in Brightline's order database: an order number, a status, a delivery date, a few dozen tokens. There is nothing to cut, and it should not go into the search index at all. Its status changes during the day, and an index copy is only as fresh as the last rebuild, so the assistant could tell a customer "not yet shipped" about an order that left this morning. A row like that is read live, by its order number, at the moment the question is asked.
Four units, four choices
The handbook shows that "the chunk" is several choices that happen to fall on similar-looking pieces of text. Brightline makes four of them.
The source document is the handbook itself, the item you store and keep as the original. Between the document and the chunks sits a parsing step that turns the file into headings and paragraphs; it is a preparation step, not one of the four units. The embedding unit is the piece sent to the embedding model for one vector: a chunk of a few hundred tokens, far under the 8,191 limit. The retrieval unit is what one search hit stands for: here the same chunk, so each of the top 3 hits is one chunk. The context unit is the text that ends up in the model's request for each hit: here, the text of those three chunks.
In Brightline's index the embedding unit and the retrieval unit are the same chunk, yet each answers its own question. The embedding unit must fit the model's input limit; the retrieval unit must be specific enough to match one question. The whole "Fee waivers" chapter passed the first test and failed the second. The context unit is a separate choice again, and it may be larger than the retrieval unit, for example the whole section around a small hit.
:::note In practice (Nov 2026) LangChain describes its text splitters as tools that break large documents into smaller chunks that can be retrieved one by one and fit within a model's context window limit. [3] Microsoft's Azure guidance calls the chunking approach a semipermanent design choice, because changing it later can affect much of what comes after it in the pipeline. [2] :::
Choosing the unit
The rule Brightline applies: pick the retrieval unit that keeps enough local meaning to match a question, then decide separately how much text to give the model. Here is that rule on the four items, with the failure each choice prevents.
| item | cut? | why | failure it prevents |
|---|---|---|---|
| help page, under 500 tokens, one topic | no | already one topic | needless entries that each know less |
| staff handbook, about 60,000 tokens | yes | over 8,191 | 400 error, or truncation that drops chapters |
| "Fee waivers" chapter, 1,500 tokens | yes | five rules asked about apart | a one-rule question gets a blurred match |
| order record, one row | never | changes during the day | a stale status from the index |
:::note In an interview Asked why you would chunk a document that fits the embedding limit, say: the limit decides what can be embedded, and the questions decide what should be. A model like text-embedding-3-small takes up to 8,191 tokens. [1] But one vector for a multi-topic text matches the topic in general, not the rule someone asked about. :::
Sources
- OpenAI Cookbook: Embedding texts longer than the model's maximum context length. OpenAI. Checked 24 Oct 2026.
- Develop a RAG Solution on Azure - Chunking Phase. Microsoft (Azure Architecture Center). Checked 24 Oct 2026.
- Text splitter integrations (LangChain docs). LangChain. Checked 25 Oct 2026.
Check yourself
Check yourself
Question 1 of 13
You need a search to match one question to one rule inside a long guide. What do you do?
Your first check counts towards your result.