How do you chunk documents for RAG?
hardAnswer
- Bad chunking = bad retrieval.
- Strategies: (1) Fixed-size (512 tokens) with overlap (50-100) — simple.
- (2) Recursive character split by markdown/code structure.
- (3) Semantic chunking: embed sentences + split at similarity drops.
- (4) Layout-aware for PDFs (page + section).
- (5) Small-to-Big: embed small chunk, retrieve, feed parent doc to LLM.
- (6) Multi-vector: multiple embeddings per doc (summary + chunks).
- Test with your queries; no single best strategy.
- Modern: Contextual retrieval (Anthropic) prepends chunk context.
Check yourself — multiple choice
- Any way
- Fixed-size + overlap / recursive markdown / semantic (similarity drops) / layout-aware PDF / small-to-big (embed chunk retrieve doc) / multi-vector (summary+chunks); test with queries; Anthropic contextual retrieval prepends context
- Random
- Not real
Chunking: fixed / recursive / semantic / layout / small-to-big / multi-vector.
#llmops
Practise MLOps & Data Quality
215 interview questions in this topic.