LearnThatStack Ace your next interview
RAG (Retrieval-Augmented Generation) · question
Question 6 of 56

What is chunk overlap, and why is it commonly used?

beginner
← All RAG (Retrieval-Augmented Generation) questions
Re-explain
Visual ↓

Chunk overlap means neighboring chunks share some text at their edges. A 500-token chunk with 50-token overlap repeats the last 50 tokens of one chunk as the start of the next.

The reason is boundary loss. A hard cut can split a definition from its example, or leave a pronoun with nothing to point at. Overlap gives each idea a second chance to sit whole inside some chunk.

step = chunk_size - overlap
chunks = [tokens[i:i + chunk_size] for i in range(0, len(tokens), step)]

Typical overlap is 10 to 20 percent of chunk size. The cost is duplication: the index grows, and retrieval can return near-copies, so dedupe neighboring chunks before building the prompt.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

The diagram below the answer is the concept . Jump to it ↓

Tailored explanation · switch back to · ·
What should the new diagram focus on?
Guided practice for RAG (Retrieval-Augmented Generation) One question at a time. Answer out loud, get graded, see what you missed.
See it - interactive diagram
Chunk overlap with 500-token chunks every 450 tokens
chunk_size = 500
overlap = 50
step = chunk_size - overlap
chunks = []
n = len(tokens)
for i in range(0, n, step):
end = i + chunk_size
chunk = tokens[i:end]
chunks.append(chunk)
Tokenseach cell = 50 tokens
050...400450500550...900950
Variables
chunk_size500
overlap50
step450
1step

Each chunk holds 500 tokens, but the loop moves ahead only 450. So neighboring chunks share 50 tokens, a 10 percent overlap.

1 / 7

Chunks of 500 tokens start every 450, so neighbors share 50 tokens, and a split idea that starts inside those 50 lands whole in the next chunk.

© LearnThatStack - diagrams may not be republished without permission.

Other questions have diagrams like this too. Sign in to ask for one where it's missing - it's free.

Create a free account
How well did you know this?
AI:

Saved in this browser - sign in to keep your review list.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Interview lens How interviewers actually use this question

Likely follow-ups

  • How would you pick the overlap size for a new corpus? Start near 10 to 20 percent of chunk size, then compare a few settings on real queries with a retrieval metric like recall@k instead of guessing.
  • Why not just make chunks bigger instead of overlapping them? Bigger chunks blur the embedding across several ideas and cost more prompt tokens. The boundary problem stays, it just happens at fewer cuts.
  • Two neighboring chunks both land in your top-k. What do you do before building the prompt? Spot adjacent chunk ids or heavy text overlap, merge them into one span or drop the copy, and spend the saved tokens on other results.
  • Overlap only fixes local cuts. How would you fix a chunk that has lost its document-level context? Prepend context such as the document title, section name or a short generated summary to each chunk before embedding. Name it as contextual retrieval.

What you can say

  1. Chunk overlap means neighboring chunks share some text at their edges, so the end of one chunk repeats as the start of the next.
  2. With 500-token chunks and 50 tokens of overlap, you move forward 450 tokens each time instead of 500.
  3. The reason is boundary loss. A hard cut can split a definition from its example, or leave a pronoun with nothing to refer to.
  4. Overlap gives an idea that sits on a cut a second chance to land whole inside one chunk.
  5. A common starting point is 10 to 20 percent of the chunk size.
  6. The cost is duplication. The index grows and retrieval can return near-copies, so I dedupe neighboring chunks before building the prompt.

Weak answers to avoid

  • Gives the definition with no reason Saying chunks share text is half the answer. Explain boundary loss, where a cut splits a definition from its example, and how overlap lets that idea land whole.
  • Treats more overlap as always safer Overlapped text gets stored and embedded twice. At 50 percent overlap the chunk count roughly doubles. Start around 10 to 20 percent and measure.
  • Never mentions near-duplicate results Neighboring chunks often come back together, so the prompt repeats the same text and wastes tokens. Say you dedupe or merge them before building the prompt.
  • Claims overlap fixes all lost context Overlap only helps when an idea crosses a cut by less than the overlap. A pronoun pointing back three pages still breaks. Mention structure-aware splits or added context.
Interview lens

Likely follow-ups, what you can say, and the weak answers to avoid.

Sign in free to open it Free account - the lens opens as soon as you're back.

Want a quick review of the fundamentals? See the RAG (Retrieval-Augmented Generation) cheatsheet.

← Back to all RAG (Retrieval-Augmented Generation) questions
Pro · $10/mo

50 of 56 RAG (Retrieval-Augmented Generation) answers are in Pro.

Full answers, code samples, and AI explanations that go simpler or deeper. Cancel anytime.

  • Full answers + code
  • AI explanations, simpler or deeper
  • 1,000 AI credits / month
  • Cancel anytime