RAG & Retrieval·Question 33 of 100Intermediate

Your corpus is full of near-duplicates: doc versions, boilerplate, quoted email threads. How do you handle deduplication?

Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.

Model answer: the part to lead with

Duplicates are quietly expensive. Retrieval returns the same content five times, the top-k budget is consumed by one fact, the model sees apparent corroboration and gets overconfident, and genuinely different perspectives never make it into context. This is one of the most common reasons a system with good recall@10 still gives thin answers.

Full worked answer

Duplicates are quietly expensive. Retrieval returns the same content five times, the top-k budget is consumed by one fact, the model sees apparent corroboration and gets overconfident, and genuinely different perspectives never make it into context. This is one of the most common reasons a system with good recall@10 still gives thin answers.

I would deduplicate at three points.

Ingest, exact: content hash after normalization. Catches the same file uploaded twice and re-crawled pages. Free, do it always.

Ingest, near-duplicate: MinHash with LSH, or SimHash, over shingles. This catches the 98%-identical contract with one changed date. Cheap and scalable to large corpora. The important decision is what to do on a hit: usually not delete. Keep the newest, mark the others as superseded, and keep them retrievable behind a filter, because 'what did the old policy say' is a real question.

Boilerplate suppression: legal footers, nav chrome and email signatures repeat across thousands of documents and pollute every embedding. Detect strings that appear in an implausible fraction of documents and strip them at parse time. This one is usually the biggest quality win, and it costs almost nothing.

Query time, diversity: even with clean dedup you get semantically redundant chunks, especially with overlapping windows. Apply MMR after reranking, which trades relevance against novelty via a lambda:

# score = lam * rel(d, q) - (1 - lam) * max(sim(d, s) for s in selected)

Around lambda ~0.5 to 0.7 is a reasonable start. Or dedupe more crudely: cap chunks per source document, which is simpler and captures most of the benefit.

The misconception is that dedup is an ingest-time problem you solve once. Overlapping chunks manufacture redundancy after ingest, so you need the query-time layer regardless.

What a good answer covers

  • Retrieval returns the same content five times, the top-k budget is consumed by one fact, the model sees…
  • This is one of the most common reasons a system with good recall@10 still gives thin answers
  • I would deduplicate at three points
  • Ingest, exact: content hash after normalization
  • Catches the same file uploaded twice and re-crawled pages

Key terms: Ingest, exact · Ingest, near-duplicate · Boilerplate suppression · Query time, diversity

Interviewer follow-ups to expect

  1. How would you pick the MMR lambda without hand-tuning it on vibes?

  2. When is returning duplicate content actually the right behaviour?

Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep