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.
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.
Chunk overlap means neighboring chunks share some text at their edges, so the end of one chunk repeats as the start of the next.
With 500-token chunks and 50 tokens of overlap, you move forward 450 tokens each time instead of 500.
The reason is boundary loss. A hard cut can split a definition from its example, or leave a pronoun with nothing to refer to.
Overlap gives an idea that sits on a cut a second chance to land whole inside one chunk.
A common starting point is 10 to 20 percent of the chunk size.
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 reasonSaying 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 saferOverlapped 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 resultsNeighboring 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 contextOverlap 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.