Managing Duplicate and Near-Duplicate Documents for RAG

GT

GigaRAG team

Retrieval11 min read
On this page
Illustration for the GigaRAG article on duplicate and near-duplicate documents poisoning results in RAG pipelines.

Managing Duplicate and Near-Duplicate Documents for RAG

When several stored documents cover the same operational topic, teams need a way to compare them without losing source, version, or ownership context. This guide outlines a version-aware process for reviewing exact-match candidates, near-match candidates, and related records in an AI knowledge base.

Treat similarity findings as prompts to examine related records, not as an automatic decision to designate a canonical record, change availability, or delete content. Preserve the original source and its version context while reviewers determine the appropriate relationship and handling.

The sections below cover policy terms, ingestion records, chunk-level evaluation, and governance decisions so teams can document how related records are handled.

Quick answer

Use similarity checks to organize related-document candidates. Keep source and version context available, review the group, and test the retrieval behavior you intend to support.

  • Separate identical-content candidates from related documents with meaningful differences.
  • Review candidate groups before changing how records are stored or served.
  • Test retrieval against the version developers expect.

Reviewing duplicate and near-duplicate documents for RAG

Set documented comparison rules before reviewing related records. Specify the representation and comparison unit, the criteria for exact-match and near-match candidate groups, and the governance decision that the comparison is intended to inform.

Duplicate vs. near-duplicate: the practical distinction

Use terms consistently within your knowledge-base policy. For example, reserve exact duplicate for records that match under a defined comparison rule, use near duplicate for closely related candidates, and use duplicative for material that repeats information across records. These labels organize review; they do not determine disposition.

Review retrieval results at the chunk level

Evaluate duplicate handling against the units your retrieval system returns. Include chunk-level results in the test set when your system retrieves chunks rather than whole documents.

For each tested result, inspect the source, revision, status, and relationship metadata alongside the returned text. Record the result and the metadata reviewed for each test query.

Similar wording can serve different records

Use the context fields required by your governance model when reviewing related records. For example, a team may include release, locale, audience, approval, or historical-status fields before deciding whether records should be grouped, retained, or handled differently in retrieval.

A match or similarity score is only one input to a handling decision. Reviewers still need to determine the records' relationship, applicability, and disposition under the governance rules that apply to the content.

Exact duplicates vs. near duplicates

FactorExact duplicateNear duplicate
Content relationshipMatches under the selected comparison ruleClosely related content with recorded differences
Detection questionDoes the selected representation match?Which differences matter for this use case?
Review focusCompare provenance and record contextCompare applicability, version, and meaning in context
HandlingGroup for review under documented rulesReview and document the relationship or separate handling
Quick answer infographic for GigaRAG

Governing ingestion sources and repeated records

Set ingestion rules for every source that feeds the knowledge base. The rules should identify the source, record the revision where available, and specify how the pipeline handles a record that has already been ingested.

Four failure modes caused by duplicate documents in RAG retrieval, from the GigaRAG guide.

Inventory ingestion inputs and record handling

Maintain an inventory of ingestion inputs, such as repositories, ticket systems, wikis, exports, generated pages, and scheduled jobs. For each input, document the source identifier, path or URL, owner, and ingest time used by your workflow.

Define how each ingestion handles an existing source identifier and revision. Keep a history of ingest events and make the replacement, retention, and review behavior explicit in the pipeline.

Apply one documented record schema across the sources available to agents so reviewers can compare source identifiers, revisions, and ingest history consistently. Teams connecting agents through GigaRAG can use its central Hive Mind through MCP or the API while maintaining those source records in their own governance workflow.

Chunk-level duplication versus document-level duplication

Review documents and chunks as separate comparison units. Record whether a candidate relationship was identified at the document level, the chunk level, or both, and retain the surrounding source context for reviewers.

Document your chunking and overlap settings as part of the retrieval configuration. Include representative chunk outputs in testing so reviewers can assess what the system returns for a source.

For release-specific material, include the applicable release in the record context and in the review criteria. This keeps version-specific handling explicit when records are compared.

If your retrieval stack uses embedding-based search, include it in the evaluation plan. Test a defined query set and capture the returned records, chunks, scores, and metadata for review.

When a test returns multiple records from the same candidate group, record that grouping alongside the results. Use the review outcome and the documented retrieval expectation to decide whether grouping or retrieval configuration needs adjustment.

Step-by-step: Review similar documents without losing version context

  1. Normalize documents consistently while retaining the original files, source identifiers, and provenance.
  2. Apply the comparison rules your team has defined to produce exact-match and near-match candidate groups.
  3. Review each group for provenance, version, applicability, ownership, and meaningful differences.
  4. Record the chosen relationship and keep source and version metadata with every grouped record.
  5. Test representative retrieval queries, including queries that name a specific reviewed version.
  6. Update grouping or retrieval configuration when test results do not match the documented expectation.

Other methods for finding near-duplicate documents

Choose comparison methods that match the question you need to answer, and record the representation, thresholds, and review rules used by the pipeline. Broder's 2000 work is titled "Identifying and Filtering Near-Duplicate Documents"; use it as background reading rather than as a substitute for your own governance rules.

[!note] Andrei Z. Broder's 2000 CPM paper addresses identifying and filtering near-duplicate documents. Use documented comparison rules and a review process suited to the records your team manages.

File-level comparison

A file-level comparison can be useful when your policy needs to distinguish matching stored files from other related records. Define the file representation, matching rule, and the action that follows a match, and retain the original record for review.

Text representation comparison

A text-based comparison requires a documented extraction and normalization process. Keep both the original record and the derived comparison representation so reviewers can see what was included or excluded.

Lexical comparison methods

Lexical comparison methods can be configured around the text representation and overlap rules your team selects. Document the tokenization, thresholds, and candidate-group criteria so results can be reproduced and reviewed.

Evaluate lexical results against examples from your own corpus, including records whose wording differs but whose relationship still requires review.

Embedding-based candidate review

If your stack produces vector-similarity candidates, retain the score, model and configuration details, source metadata, and reviewer decision with the candidate group. Use those records to make the review process auditable.

A practical layered detection order

Arrange comparison stages to fit your corpus, operational constraints, and review capacity. At every stage, preserve source metadata and route ambiguous or high-impact groups through the review process your team has defined.

A version-aware workflow from ingestion to retrieval testing

The following workflow separates comparison, review, record relationships, and retrieval evaluation into documented steps. Use it as a structure for recording decisions about related records.

[!tip] For runbooks, include queries that name the service and the expected version in retrieval tests. Check whether the returned result preserves the source and version context developers need.

Example: duplicated deployment runbooks across a repository and wiki

For example, a repository may contain deploy-prod.md, a wiki may contain a page titled "Production deployment," and an earlier export may also be stored. Begin by recording the source, revision, owner, and applicable release for each record.

Preserve the records while the group is under review.

Normalize and fingerprint without losing the original source

Extract a comparison representation while retaining the raw file or page, source URL, repository path, commit or page revision, ingest time, and owner. Store any fingerprints or comparison outputs as metadata rather than replacing the original record.

This gives reviewers a traceable record of the comparison.

Group candidates and route ambiguous matches to review

Place records that meet your documented criteria into a candidate group. Route edited exports, conflicting instructions, and other ambiguous cases to the designated record owner or reviewer, and record the outcome.

Similarity results identify records to review; they do not by themselves determine the relationship or handling decision for the group.

Mark canonical, superseded, localized, and release-specific versions

Use status and relationship fields that fit your governance model, such as canonical, superseded, localized_variant_of, or applies_to_release. Record the reviewer, decision date, and rationale, especially where related records remain available for different releases or audiences.

Make the selected status and relationship fields available wherever reviewers and retrieval administrators need to apply the governance model. In GigaRAG, access controls can manage what each agent can use, so teams can align agent access with the records made available under that model.

Include current and historical records in retrieval tests when both remain in scope. Document which record and version each query is expected to return or include.

Test retrieval with queries that previously surfaced stale copies

Run queries such as "deploy production" and "rollback release 4.2." Record which sources appear, whether the expected reviewed runbook is present, and whether a release-specific query returns the intended release context.

Governance decisions beyond similarity

Similarity output is one input to a record review. Keep approval, ownership, release, audience, and retention decisions in the governance process that applies to your content.

Comparison of exact hash, SimHash, MinHash/LSH, and embedding methods for RAG deduplication.

Use similarity as review input

Create a review queue from candidate matches and give reviewers the source material, comparison output, metadata, and decision options they need. Record the chosen relationship and the reason for it.

Decide record availability using the applicable release, locale, audience, approval, and retention requirements. When related documents remain available, make their relationship and scope visible in metadata.

Don't flatten that context.

Minimum operating rules for a duplicate-controlled knowledge base

Assign an owner for each designated canonical record and define review thresholds for candidate groups. Retain source URLs, revision details, ingest dates, and relationship metadata such as supersedes or applies_to_release when those fields are part of your governance model.

For teams using GigaRAG as shared memory for AI agents, maintain the source, version, and status metadata that their governance model requires across the project knowledge made available to agents.

Include active-release and historical-use cases in your retrieval test suite where they matter to your team. Re-run the suite after ingestion or configuration changes and use the results to refine documented handling rules.

Frequently asked questions

What is a duplicate document?

For a documented comparison workflow, a duplicate document is a record that matches another record under the team's selected comparison rule. Compare provenance and record context before treating stored files as interchangeable.

What is the difference between duplicative and duplicate?

Use duplicate for a match under a defined comparison rule. Use duplicative for material that repeats information across records, whether or not those records meet that rule.

These labels help organize review; document the handling decision separately.

How should teams evaluate repeated documents in RAG retrieval?

Build a representative query set, record the expected source and version for each query, and inspect the returned records and metadata. Use the results to evaluate whether the current configuration meets your team's retrieval expectations.

How should teams define near-match comparison rules?

Define the representation being compared, the comparison unit, the thresholds or criteria for candidate groups, and the review decision the comparison supports. Document those rules with the pipeline so reviewers can apply them consistently.

When should a team use exact hashes instead of semantic similarity?

Choose the method that fits the comparison question and your documented pipeline. For example, a file-level identity check and a related-content candidate review are different tasks and should have different review criteria.

Can embedding similarity safely identify documents to delete?

Do not make a deletion decision from a similarity result alone. Route the candidate through the review process that covers provenance, version context, ownership, approval, and applicable retention requirements.

Should near-duplicate documents always be removed from an AI knowledge base?

No. Decide how to handle each candidate group through the governance process that applies to its source, version, audience, and retention context. Document whether records are retained, grouped, suppressed for a use case, or otherwise handled.

How can teams preserve source and version context after grouping duplicate documents?

Keep source identifiers, revision details, status, and recorded relationships with grouped records. Include those fields in retrieval tests so the returned results can be checked against the intended source and version.

About GigaRAG

GigaRAG is a shared memory platform for AI agents that helps developers and teams keep project knowledge available across sessions and tools.

Connect agents to a central Hive Mind through MCP or the API, with access controls to manage what each agent can use.

All posts