Mรณdulo 17 ยท RAG from Scratch โ Lecciรณn 2 de 4 ยท ~9 min
Chunking
Why not just paste the whole doc?
The obvious idea โ dump every doc into the prompt โ fails for two reasons. First, the context window is finite (module 28): a big repo's docs won't fit. Second, even if they fit, burying the one relevant sentence in thousands of irrelevant ones makes the model's answer worse, not better, and costs more tokens.
So we chunk: cut each document into small passages, and later retrieve only the handful that actually matter. A chunk is just a slice of the text โ a few hundred characters, roughly a paragraph.