Source: Hao Hoang's LinkedIn post, 2026-11-21, part of his AI Agent Engineering Interview Questions series. Framed as an interview question; useful as a debugging order for any team whose RAG returns "sort-of-relevant" results.
The scenario
A RAG system returns chunks that are loosely on-topic. One engineer wants smaller chunks (100 tokens instead of 500), another wants bigger ones (1,500). The post's point is that both proposals trade one failure for another, and that size should be tuned last.
Too small: a chunk loses its subject. Phrases like "the policy" or "this quarter" no longer say which policy or quarter, so the embedding has too little to match on.
Too large: one vector averages several topics, so it matches many queries weakly. That is exactly the loosely-relevant symptom.
The recommended order
Measure retrieval on its own. Label real queries with the passages that answer them and track recall@k (how often the right passage is in the top k). Without this, every change is a guess, and end-to-end answer quality mixes retrieval errors with generation errors.
Fix boundaries before size. Split on document structure (headings, paragraphs, sentences) with roughly 10-20% overlap so no chunk starts mid-thought.
Put the missing context back. Contextual retrieval prepends a short model-written note about where the chunk sits in its document before embedding it. Cost: one model call per chunk at index time.
Search small, send big. Match on small chunks, then hand the model the parent section. Cost: more prompt tokens per answer.
Only then tune size, against the retrieval eval from step 1.
The summary claim: most chunk-size debates are really missing-context problems.
Tradeoffs
| Technique | Helps with | Costs |
|---|---|---|
| Structure-aware splitting | chunks that start or end mid-thought | per-format parsers; messy sources (PDFs, chat logs) have weak structure |
| Overlap | answers split across a boundary | index size, near-duplicate hits |
| Contextual notes | chunks that lost their subject | one model call per chunk; re-index when the prompt or model changes |
| Small-to-big | precise matching plus enough context to answer | prompt tokens; parent sections can be long |
Failure modes to watch
An eval set built from synthetic questions that mirror chunk wording overstates recall; use real user queries.
Contextual notes that hallucinate or repeat the document title on every chunk, which makes all chunks look alike to the embedder.
Parent sections that blow the context budget when several hits come from long sections.
Fixing retrieval when the problem is ranking. If the right passage is in the top 50 but not the top 5, add a reranker before re-chunking.
Re-chunking without re-running the eval, so a regression on one query type goes unnoticed.
Review checklist
Is there a labelled retrieval eval (real queries, gold passages, recall@k) separate from answer quality?
Are chunk boundaries aligned with document structure?
Does each chunk carry enough context to be understood alone (title, section path, or a generated note)?
Is what you match on separated from what you send to the model?
Is chunk size tuned against the eval rather than argued about?
Is a reranker considered before re-chunking?
Teaching notes
Good as a whiteboard exercise: give students one document and two queries, chunk it at three sizes, and have them find which queries fail at each size and why. Then add contextual notes and show the failures change without changing size.
Related entries
R010 PageIndex: reasoning-based retrieval over a section tree instead of chunk-and-embed.
R127 GraphRAG Zero: graph-guided retrieval with no model calls at index time.
R183 Policy-filtered retrieval with lineage to every source chunk.
R087 Stanford CS329Z course map (same author).