Flashcard: what does chunking mean in RAG, and why do we chunk at all?
Chunking splits long documents into 200 to 800 token pieces before embedding so retrieval is precise, prompts stay cheap, and citations land on specific paragraphs.
Imagine you are studying for an open book test and someone hands you a 50-page textbook. If you only know how to grab whole books from the shelf, every search drops the entire book on your desk. Useful pages and useless pages all together. Chunking is the opposite habit: before the test, you tear the book into single-page handouts, label each one, and shelve them separately. Now when you ask a question, you can fetch only the two or three pages you actually need. The book did not change; the way you sliced it did. In RAG, every document gets sliced into small pieces called chunks before anything is stored away. The retriever then finds the right chunk, not the right book. That precision is why chunking is one of the most consequential decisions in a RAG system.
Detailed answer & concept explanation~7 min readEverything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
3 min: define chunking as the indexing-time split, name the three motivations (precision, context budget, citation granularity), quote the 200 to 800 token band, and call out that changing chunking is a reindex.
Real products, models, and research that use this idea.
- LangChain's RecursiveCharacterTextSplitter splitting Markdown documents along headers then paragraphs, the default in many production RAG stacks.
- LlamaIndex's SemanticSplitterNodeParser using embedding similarity to merge sentences into coherent chunks instead of fixed-size windows.
- Anthropic's contextual retrieval adding short context summaries to each chunk to fight the precision loss of small windows.
- Chunk-by-function splitters in Cody, Cursor, and GitHub Copilot's code-RAG paths, preserving complete function and class units.
What an interviewer would ask next. Try answering before peeking at the approach.
QHow would you choose a chunk size for a mixed corpus of Markdown docs, PDFs, and source code?
QWhat is contextual retrieval and what problem with small chunks does it solve?
Don't say thisRed flags and common mistakes that signal junior thinking. Click to expand.
Red flags and common mistakes that signal junior thinking. Click to expand.
Embedding entire documents as single vectors. The vector becomes a blurry average of every topic the doc covers, retrieval loses precision, and the prompt has to carry the whole document just to answer one question.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.
Same topic, related formats. Practice these next.