Vector Text Chunking
Embedding models cannot read unlimited text, and one vector for a whole book would blur every idea together. Chunking splits long documents into smaller pieces before embedding. Good chunks lead to precise search results. Poor chunks lead to confusing answers.
The Textbook Analogy
A student looking for the definition of photosynthesis does not carry the entire biology textbook to the teacher. The student points to one paragraph. Chunking lets your database work the same way: it hands back the exact paragraph instead of the whole book.
Why Chunking Matters
WITHOUT CHUNKING
Entire 50-page manual -> one vector
Question: "How do I reset the device?"
Result: vague match, long irrelevant text
WITH CHUNKING
Manual -> 120 chunks -> 120 vectors
Question: "How do I reset the device?"
Result: chunk 87 "Resetting the device" (precise)
- Precision: Each vector represents one focused idea.
- Model limits: Every embedding model accepts a maximum input length.
- Answer quality: AI assistants receive only relevant text, which reduces confusion.
- Cost: Smaller prompts cost less to process.
Chunk Size
Chunk size balances two risks. Tiny chunks lose context. Huge chunks mix several topics.
| Chunk Size | Benefit | Risk |
|---|---|---|
| Small (100 to 200 words) | Very precise matches | Missing surrounding context |
| Medium (200 to 400 words) | Balanced precision and context | Occasional topic mixing |
| Large (500+ words) | Rich context | Blurry, less targeted vectors |
Start with a medium size and adjust after testing real questions.
Chunk Overlap
Overlap repeats a few sentences at the edge of neighboring chunks. A sentence cut in half loses its meaning, and overlap protects against that loss.
TEXT: S1 S2 S3 S4 S5 S6 S7 S8 S9 S10
NO OVERLAP
Chunk A: S1 S2 S3 S4
Chunk B: S5 S6 S7 S8
Chunk C: S9 S10
WITH OVERLAP OF 1 SENTENCE
Chunk A: S1 S2 S3 S4
Chunk B: S4 S5 S6 S7
Chunk C: S7 S8 S9 S10
A common starting overlap equals 10 to 20 percent of the chunk size.
Chunking Strategies
Fixed-Size Chunking
The splitter cuts text after a set number of characters or words. It runs fast and stays predictable, but it can slice through sentences.
Sentence-Based Chunking
The splitter groups whole sentences until it reaches the size limit. Every chunk begins and ends cleanly.
Paragraph or Section Chunking
The splitter follows the natural structure of the document, using headings and paragraph breaks. This approach suits articles, manuals, and reports.
Recursive Chunking
The splitter tries large separators first, such as section breaks, then falls back to paragraphs, sentences, and finally words. It adapts to messy text.
Semantic Chunking
The splitter compares neighboring sentence embeddings and starts a new chunk when the topic shifts. It produces coherent chunks but costs more processing time.
Attach Metadata to Every Chunk
CHUNK RECORD
text: "To reset the device, hold the power button..."
vector: [0.21, -0.44, 0.67, ...]
metadata: {
"source": "device-manual.pdf",
"page": 14,
"section": "Troubleshooting",
"chunk_number": 87
}
Metadata lets users trace an answer back to its source and lets you filter by document or section.
Tips for Better Chunks
- Add the section title to the front of each chunk for extra context.
- Keep tables and code blocks intact instead of splitting them.
- Remove page numbers, headers, and footers before chunking.
- Test several sizes against 30 real questions and compare results.
- Store the chunk number so you can fetch neighboring chunks when needed.
Chunking quietly decides the quality of most search and AI assistant systems. Spend time here, and every later step benefits.
