Mid

How do you choose a chunking strategy for RAG?

How to answer it in an AI engineer interview: what is being tested, a step-by-step framework, a sample answer and the mistakes to avoid.

$19.99 on Gumroad, instant download40% off with code EARLYBF until Nov 3, 11:59 PM PTEARLYBF: 40% off until Nov 3

Smaller start: Score your answers against 50 rubrics, $9. 50 AI engineer questions, one rubric each, PDF on Gumroad.

Practiced one out loud? Paste your answer into the free self-check and get a score in 30 seconds

What the interviewer is testing

Whether you choose chunking from the documents and the questions rather than defaults, and whether you can explain the size trade-off and how to measure it.

Answer framework

  1. Follow structure: split on headings, sections, paragraphs, code blocks and table rows rather than fixed character counts.
  2. Pick a size range: typically a few hundred tokens with modest overlap, then tune.
  3. Know the trade-off: small chunks match precisely but lose context; large chunks keep context but dilute similarity and cost more tokens.
  4. Use parent retrieval when needed: retrieve small chunks, then pass their parent section to the model.
  5. Decide by measurement: compare recall@k on real questions for each strategy.

Sample answer

I start from the documents. Policies, manuals and wikis have headings and paragraphs, so I split along that structure and keep the heading path as metadata, for example 'Billing > Refunds > Annual plans'. Code is split by function or class, and tables by row with the header repeated, so each chunk still makes sense when read alone.

Then I choose a size, usually a few hundred tokens with a small overlap. Small chunks give sharper matches because the embedding represents one idea, but the model may not get enough context to answer. Large chunks carry more context but blur the embedding and use more of the prompt. A common compromise is small-to-parent retrieval: match on small chunks, then send the enclosing section to the model.

I do not settle this by intuition. I build a set of real questions with the passages that answer them, index the corpus with two or three strategies, and compare recall@k and final answer quality. The winner is often different for different document types.

Likely follow-ups

What goes wrong with fixed-size chunking? It cuts sentences, tables and code mid-way and separates headings from their content, so chunks lose meaning and retrieve poorly.

Common mistakes

The PlaybookWant the full method?

The 0 to 1 AI Engineer Interview Playbook covers the answer frameworks, system-design walkthroughs and an 8-week plan.

Get the playbook 40% off with code EARLYBF until Nov 3, 11:59 PM PTEARLYBF: 40% off until Nov 3

Smaller start: Score your answers against 50 rubrics, $9. 50 AI engineer questions, one rubric each, PDF on Gumroad.

Interviewing for PM or TPM? See the full PM package, $59 on Gumroad: a resume system, a PM, TPM and PGM interview handbook, a 1:1 cheat sheet and a PM playbook. PM and TPM content, not AI engineer prep.

Related questions

Based on question #27, #94 in the full question bank.