Why deduplicate retrieved chunks before stuffing them into context?
Top-k similarity has no opinion about redundancy, so copy-pasted paragraphs can fill every slot with one fact; dedupe at assembly frees slots for actually different content and cuts cost.
Imagine you ask five friends for movie recommendations and four of them are reading off the same blog post. You only learned one movie, and you wasted four phone calls. Retrieval works exactly the same way. A vector index returns the five chunks most similar to your query, and if your knowledge base has the same paragraph copy-pasted across five documents, all five chunks are the same paragraph. You paid for five chunks but you only got one fact. Deduping checks before you assemble the context: are any of these chunks the same as each other? If so, keep one and replace the others with the next-best different chunks. Now you get five different facts for the same price.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Retrieved context is a scarce resource. Five chunk slots in a context block can carry five distinct facts or one fact repeated five times. Which outcome you get depends on a single design choice, whether the assembly pipeline checks the candidates against each other before writing them into the context.
This card walks through why top-k similarity produces redundancy by construction, what dedupe actually buys, and where it sits in a production retrieval pipeline.
Top-k has no objective term for diversity
A vector store's top-k operation is a sort. For each candidate chunk it computes a similarity score against the query, and returns the k highest scorers. The score function is unary, it only sees one chunk at a time. There is no pairwise term that says 'this chunk is too similar to that one'.
That shape is fine when the corpus is clean and each chunk is a distinct piece of evidence. It breaks the moment the corpus has near-duplicates. Five copies of the same paragraph, scattered across five documents, will all score similarly against any query that targets the paragraph's topic. All five will end up in the top-5.
Why this is not a vector-store bug
The vector store is doing exactly what it advertises. The retrieval problem is a query to chunk problem; redundancy is a chunk to chunk problem. The two live at different layers. Dedupe is the layer that closes the gap.
Situations where this technique stops working.
2–4 min · Everything important, quickly.
Real products, models, and research that use this idea.
- LlamaIndex 2026 ships a node deduplication post-processor that hashes node ids and content before assembly.
- LangChain's contextual compression retriever combines dedupe with relevance filtering as a single post-retrieval pass.
What an interviewer would ask next. Try answering before peeking at the approach.
QWhere should dedupe sit in a pipeline that also includes reranking?
Retrieve wide, dedupe, rerank, trim. Dedupe before rerank so the cross-encoder does not spend inferences on duplicate pairs.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Trusting the vector store's top-k to handle redundancy. Top-k optimizes only for similarity to the query, it has no mechanism that penalizes near-identical chunks.
60 second bullets to scan on the way to the call.
State why top-k similarity does not penalize candidate redundancy
Name two corpus shapes that produce many near-duplicate retrievals
Primary sources. Browse if you want the original framing.
Same topic, related formats. Practice these next.