Skip to main content

A fast and minimal minhashing based similarity checking library.

Project description

Minhashlib

This is a minimal implementation of MinHashing as described in Jeffrey Ullman's book Mining Massive Datasets.

Current Benchmark Claim

Based on the benchmark outputs in this repository:

  • On recent multi-seed CPU synthetic runs (seeds 42-46), minhashlib builds signatures about ~6x faster than datasketch.
  • Accuracy is comparable in magnitude (similar MAE scale and matching threshold-based metrics in these runs), though datasketch is slightly better on MAE in most synthetic scenarios.
  • Memory results are workload-dependent, so this project does not claim universal memory superiority.

In short: this implementation is minimal and fast, with accuracy that is broadly comparable to datasketch, but outcomes vary depending on dataset and configuration.

Benchmark Suite

Use benchmarks/benchmark_claims_suite.py to run comprehensive, reproducible benchmarks:

  • Multiple datasets (synthetic, 20newsgroups, wikipedia, ag_news, local)
  • Multiple seeds with mean/std/95% CI
  • Metrics: MAE(Mean Average Error), Precision/Recall/F1 at threshold, Precision@K/Recall@K
  • Speed: build/pair-eval/retrieval latency and throughput
  • Memory: peak allocation and bytes/signature
  • Optional scaling sweeps over docs/number of hashes/doc length

Example (full):

python3 benchmarks/benchmark_claims_suite.py
  --datasets synthetic,20newsgroups,wikipedia
  --wiki-dump-path data/simplewiki-latest-pages-articles.xml.bz2
  --seeds 42,43,44
  --p-values 2147483647,3037000493
  --max-docs 2000
  --random-pairs 3000
  --num-queries 200
  --include-scaling

Example (offline/local corpus only):

python3 benchmarks/benchmark_claims_suite.py
  --datasets synthetic,local
  --local-docs /path/to/docs.jsonl
  --seeds 42,43,44

Outputs are written to benchmark_outputs/ by default:

  • raw_runs.json / raw_runs.csv
  • summary_stats.json / summary_stats.csv
  • run_metadata.json
  • skipped_runs.json

Benchmark data setup

Pull required benchmark datasets into local project paths:

python3 scripts/setup_benchmark_data.py

This prepares:

  • data/simplewiki-latest-pages-articles.xml.bz2 (for Wikipedia benchmarks)
  • .cache/scikit_learn_data (for 20newsgroups benchmarks)

Optional flags:

python3 scripts/setup_benchmark_data.py --force
python3 scripts/setup_benchmark_data.py --skip-wikipedia
python3 scripts/setup_benchmark_data.py --skip-20newsgroups

Individual Benchmarks

You can run individual benchmarks instead of the full suite:

# Accuracy-only
python3 benchmarks/benchmark_claims_accuracy.py --datasets synthetic,20newsgroups,wikipedia

# Performance-only
python3 benchmarks/benchmark_claims_performance.py --datasets synthetic,20newsgroups,wikipedia

# Memory-only
python3 benchmarks/benchmark_claims_memory.py --datasets synthetic,20newsgroups,wikipedia

# Scaling-only (synthetic sweeps)
python3 benchmarks/benchmark_claims_scaling.py --datasets synthetic

Each individual benchmark writes outputs under benchmark_outputs/<test_name>/.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

minhashlib-0.1.1.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

minhashlib-0.1.1-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file minhashlib-0.1.1.tar.gz.

File metadata

  • Download URL: minhashlib-0.1.1.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for minhashlib-0.1.1.tar.gz
Algorithm Hash digest
SHA256 fdecff5c1317cf4628b4ddbce87cdd7eb55f7560c18eec2da4644af83492d224
MD5 b608d227cc6ece4fe943121750fc0850
BLAKE2b-256 d934339ab284872977797dce747cabf569d00f4258fe8508445b662daf2de706

See more details on using hashes here.

File details

Details for the file minhashlib-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: minhashlib-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for minhashlib-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ee829d8dde15dda616a5c83f4bb744a6e42598febab68dd17054824435faf95b
MD5 5b10bbe96ca45991d07a04586a2af5f7
BLAKE2b-256 a5ce813e23a4e6ae0eec187d2215b9eb5f82150e7891d87eaa2d89e95670de46

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page