TECHNOLOGY

SimHash text deduplication: weighted features and Hamming distance

In this article
THE QUICK TAKE

A small SimHash distance describes selected lexical features; it does not certify identical meaning or interchangeable records.

Features determine what can be similar

The Python simhash implementation accepts text or explicit features. Its text path lowercases content, selects characters using a regular expression and builds sliding character features. Passing weighted features follows a different construction path. These inputs should not be described as interchangeable document encodings.

For technical corpora, inspect what punctuation removal and case folding discard. An identifier or mathematical expression can change meaning while the default text preprocessing suppresses that difference. Supply explicit features when the intended comparison requires information that the default representation removes.

Weights influence the fingerprint

SimHash combines feature hashes with weights into a compact bit fingerprint. Changing feature extraction, weights or the underlying hash function can change the output even for the same source document. The project’s tests demonstrate distinct results for weighted features and default text processing.

Persist the construction settings with the fingerprint. A vocabulary or weighting revision creates a new comparison population; mixing fingerprints across that revision can make distances uninterpretable. Equal bit lengths alone are not enough to establish that both sides used the same representation.

Hamming distance counts bit differences

The implementation computes distance between compatible fingerprint widths. This is a bitwise measure, not the fraction of words shared by two documents. A threshold therefore needs interpretation against the corpus and the precise feature pipeline that produced the fingerprints.

Avoid transferring a threshold from a web-crawling study directly to short code comments or multilingual questions. A collection’s length distribution and repeated templates can change which pairs cluster together. The original crawling research provides methodological context, not a universal acceptance certificate for every later dataset.

Index matches still need document inspection

A near-duplicate index accelerates discovery of fingerprints within its configured distance. The returned identifier points back to a document that may contain important differences. Keep the original content and provenance available for the final retention decision.

A proposed review can compare boilerplate-heavy pages, lightly edited copies and related but distinct technical instructions. Record false merges separately from missed copies. No threshold performance is asserted here; the purpose is to specify what a local evaluation would have to measure.

Version a comparison policy with its output

Keep feature extraction, weighting, hash configuration, fingerprint width and acceptance distance together. Store the representative choice and cluster membership so an incorrect merge can be investigated without reconstructing the entire crawl from memory.

If the policy changes, rebuild affected fingerprints and compare retained populations. A reduced document count can reflect more aggressive grouping rather than better information quality. SimHash is useful when its lexical comparison contract remains visible throughout that decision.

Primary references

Python simhash implementation.

Python simhash tests.

Near-duplicate crawling research.

Related explanations: Duplicates and memorization; Preprocessing memory.

Earn rental income from GPUs

Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.

Explore GPU hosting
← All articles