How would you chunk a mixed corpus of policy PDFs with tables, wiki pages, chat threads and code? What do you trade off when picking chunk size and overlap?
Theme reported publicly: Cohere
Answer
Model answer, written in a candidate's voice
In short
- Split by structure: headings/sections for PDFs and wikis, functions/classes for code, turns/threads for chat; keep tables intact or render as text with repeated headers.
- Small chunks retrieve precisely but lose context; large chunks add context but dilute embeddings and cost tokens; overlap protects boundaries but duplicates storage.
- Attach metadata (title, section path, date, ACL, URL) and prepend document/section context before embedding.
- Use parent-child retrieval: match small units, return the enclosing section/parent.
- Tune chunk size and overlap empirically on a labelled query set using recall@k and downstream answer quality.
In full
I would treat chunking as a per-source, structure-aware problem rather than a fixed window: split policy PDFs and wiki pages on headings/sections, code on functions/classes, and chat on threads/turns, while keeping tables intact or converting them to text with headers repeated so a row is not orphaned. The trade-off is that small chunks retrieve precisely but lose surrounding context, while large chunks preserve context but dilute embeddings and spend more tokens; overlap helps at boundaries but duplicates storage and can create near-duplicate hits. I would attach metadata such as title, section path, date, ACL and URL, and prepend document/section context to each chunk before embedding so the vector represents the passage in its place. For retrieval I would use parent-child/small-to-big: match the small unit, then return the enclosing section or parent for the model. Finally I would tune sizes and overlap empirically on a labelled query set with recall@k and downstream answer quality, checking per source type, because the right setting for code is not the right setting for policy prose.
What a strong answer covers
- Structure-aware splitting (headings, sections, functions, threads) over fixed windows; keep tables intact or convert to text with headers repeated
- Small chunks retrieve precisely but lose context; large chunks dilute embeddings and cost tokens; overlap protects boundaries at storage cost
- Attach metadata (title, section path, date, ACL, URL) and prepend document/section context to each chunk before embedding
- Parent–child (“small-to-big”) retrieval: match small units, return the enclosing section
- Tunes sizes empirically on a labelled query set (recall@k)
Common mistakes
- One chunk size for every document type, chosen without measurement
- stripping titles/metadata so chunks lose meaning