learning-it by example

Back to the video

Chunking Strategies Compared on One Document

Chunking decides what your RAG app can find. I cut one document five ways and scored each against ten questions.

Video #40 ยท RAG and vector search

Steps in the video

  1. 0:00 How you cut decides what you find
  2. 0:22 What a chunker is
  3. 1:09 Setup
  4. 1:26 Three chunkers
  5. 1:45 The golden set
  6. 2:03 The scorer
  7. 2:54 Where it cut
  8. 3:20 Why overlap helps
  9. 3:41 What this does not show
  10. 4:15 Mistakes to avoid
  11. 4:38 My take and next steps
  12. 4:59 Recap

Files

  • chunkers.py (17 lines)
  • compare.py (44 lines)
  • cut.py (13 lines)
  • golden.py (13 lines)
  • handbook.md (28 lines)

Download the code (zip)

Tested with

Python 3.12.15 | ollama==0.6.3

What this does not show

One made-up 586 word handbook and ten questions I wrote, so one question is a ten percent swing: a method, not a ranking. Clean headings favour the heading split. One small embedding model. No semantic chunking tried.

Sources

Learning IT by Example.