DEV Community

Discussion on: How Does a Text Splitter Actually Chunk Your Documents?

Collapse
 
recallrundev profile image
RecallRun •

The point about configured overlap vs real overlap is the one most tutorials skip. Once the splitter cuts on separators first, the overlap you set is a ceiling, not what you get.

One thing worth a section in a follow-up: what goes in front of each chunk. On the FastAPI docs I tested, prefixing each chunk with its heading path (page > section > subsection) moved hit@1 from 0.389 to 0.785, a bigger change than any chunk_size or overlap setting I tried. The splitter decides where the cut lands; the heading path tells the embedding what the chunk is about.

Collapse
 
jishnusaha89 profile image
Jishnu Saha •

Thanks a lot for this. Honestly, I didn't think about it before.

You're right. The splitter only decides where the cut happens. But a chunk from the middle of a section often doesn't say what it's about. So its vector is weak and it gets missed in search. Adding the heading path gives every chunk that context, not just the first one.

0.389 to 0.785 is a big jump. Great tip, thanks for sharing.