Skip to main content
Memvid automatically prevents duplicate content from bloating your memory files using two complementary techniques: content hashing for exact duplicates and SimHash for near-duplicates.

How Deduplication Works

When you add content to a memory, Memvid performs two checks: Both checks happen automatically during put operations with no configuration required.

Exact Deduplication

Every frame stores a BLAKE3 content hash. When you add new content:
  1. Hash is computed for the new content
  2. Hash is checked against existing frames
  3. If match found, the existing frame ID is returned
  4. No duplicate frame is created

SimHash (Near-Duplicate Detection)

SimHash is a locality-sensitive hashing algorithm that detects near-duplicate content - documents that are almost identical but have minor differences like:
  • Whitespace changes
  • Punctuation variations
  • Minor edits or typos
  • Reformatted text

How SimHash Works

  1. Tokenize: Break content into word n-grams (shingles)
  2. Hash shingles: Each shingle gets a 64-bit hash
  3. Combine: Weighted combination produces final 64-bit fingerprint
  4. Compare: Hamming distance measures similarity
Two documents are considered near-duplicates if their SimHash fingerprints differ by fewer than 32 bits (out of 64).

Hamming Distance Thresholds

Example: Near-Duplicate Detection


Sketch Track (Fast Pre-filtering)

For large memories (10k+ frames), Memvid uses sketch tracks to accelerate duplicate detection. Sketches are compact fingerprints that enable sub-millisecond candidate filtering.

Sketch Variants

Building Sketches

Output:
Without sketches:
  1. Compare query against all 45,230 frames
  2. Full SimHash comparison for each
  3. ~450ms total
With sketches:
  1. Compare query sketch against sketch index
  2. Get ~100 candidates in 0.3ms
  3. Full comparison only on candidates
  4. ~5ms total (90x faster)

Deduplication Statistics

Check deduplication stats for your memory:

When Duplicates Are Allowed

Some use cases require keeping duplicates:

Audit Trails

When you need to track every submission regardless of content:

Versioning

Track document versions explicitly:

Disabling Deduplication

For specific use cases where you want all content stored:
Disabling deduplication can significantly increase storage usage. Only disable when you have a specific need to store duplicate content.

Deduplication Across Memories

Deduplication only works within a single .mv2 file. The same content in different memory files will be stored separately.

Performance Impact

The overhead is minimal and the storage savings are typically significant - especially for:
  • Chat logs with repeated messages
  • Documentation with boilerplate sections
  • Logs with repeated patterns
  • Meeting notes with agenda templates

Best Practices

For Most Use Cases

Let deduplication work automatically:

For Large Collections

Build sketch indices for faster dedup checking:

For Audit Requirements

Use unique identifiers when duplicates matter:

Troubleshooting

”Why isn’t my duplicate being detected?”

  1. Content differs slightly: Check for hidden whitespace, encoding differences
  2. Different metadata: URI or timestamp makes entries unique
  3. Sketch not built: For large memories, build sketch index

”Why was my unique content marked as duplicate?”

SimHash can have false positives for very short content or content with similar structure:
Solution: Add distinguishing context or use unique URIs.

Next Steps

Adaptive Retrieval

Automatically determine optimal result counts

Indices & Tracks

Understand how content is indexed