Home » Near-Duplicate Documents in RAG: Keep the Evidence, Remove the Copies

Near-Duplicate Documents in RAG: Keep the Evidence, Remove the Copies

Several mirrored manuals converge on one representative while a changed revision follows a separate path.

Near-duplicate documents can fill a retrieval shortlist with copies of the same evidence. Group clearly equivalent copies, preserve their provenance and leave material revisions available for retrieval. The aim is a more useful context, which requires keeping exceptions that differ by only a few words.

Which copy gets the second slot?

A reader asks which gasket fits the revised housing on a fictional Lumen pump. Four candidates share the title “Lumen service bulletin.” In retrieval order they are STAFF-R1 (a restricted mirror), BUL-1 (the public original), PORTAL-R1 (a public mirror of BUL-1) and BUL-2 (the public revision). BUL-1 and its mirrors say G14 fits the original housing. BUL-2 says G27 fits the revised housing.

The reader can see public documents and has room for two passages. First remove STAFF-R1. Try the following grouping rules on the remaining candidates, keeping the first eligible representative in retrieval order.

What fits in two slots for a public reader
Rule Passage IDs retained Answer for the revised housing
Take the first two BUL-1, PORTAL-R1 Withhold the part number. Both cover the original housing.
Group identical bodies BUL-1, BUL-2 G27, from BUL-2.
Group by title alone BUL-1 Withhold the part number. The shared title hides the revision.
Group identical bodies with BUL-2 unavailable BUL-1 Withhold the part number. No eligible passage supplies it.

Keep PORTAL-R1 as an alias of BUL-1 so an editor can trace the mirror. Keep BUL-2 separately so a reader with either housing can reach the right instruction. A changed part number is enough to justify a separate record here. The exercise uses literal text equality and a fixed order. It measures neither fuzzy matching nor retrieval quality.

Exact equality is a useful starting point. Remove known transport differences such as repeated page headers before computing a normalized fingerprint. Keep the original identity and revision. A near-duplicate detector can surface the remaining same-text or lightly changed documents for review. Detecting near-duplicates for web crawling describes fingerprint-based detection for web crawling. It is a method for finding candidates, not an estimate of how well a particular policy corpus can be merged.

Separate mirrors from revisions

Two refund policies might differ only in a line specifying the eligibility window. A high similarity score would be expected. A material difference can appear in a numeric value, a negation, a section heading or a jurisdiction statement. Keep candidates distinct when such changes affect interpretation. Use canonical document IDs, effective dates and an explicit version relation where you have them.

For a stable set of equivalent copies, choose a representative with a durable link and an authoritative owner. Preserve the aliases and the evidence used to classify them. Recheck equivalence when a source revision changes. The RAG index freshness guide explains how to keep versions and deletions reflected in the index. Duplicate groups add a separate decision about how many equivalent versions occupy a retrieval result.

Avoid crossing the permission boundary

A private copy and a public copy may have identical text. Treat access as a property of each source, including its URL and provenance. If they are grouped, the selected citation and any linked metadata still need to be accessible to the requesting reader. Select representatives within the authorized result set. Do not let an inaccessible canonical item turn an otherwise permitted answer into a disclosure.

Evaluate with an exception set

Build questions for known mirrors, old revisions, near-identical but conflicting documents, and distinct documents that share a boilerplate template. Compare unique evidence in top-k before and after grouping. Record false merges separately because losing the one authoritative exception hurts more than showing an occasional duplicate. Fix the normalization or threshold against those failures. Keeping a reversible group membership record lets the team recover a mistaken merge without waiting for a full re-ingestion.

You may also like