Skip to main content

EntropyHash: near document duplicate detection algorithm

Project description

Entropy Hash

Entropy Hash is a high-performance algorithm for near-duplicate detection in text. It serves as a fast and more accurate alternative to SimHash.

  • 23% more accurate than SimHash
  • 6.6× faster on synthetic benchmarks
  • 🚀 Built on PyTorch for maximum speed and flexibility

Installation

You can install Entropy Hash using:

pip install entropy-hash

If installing locally from source:

git clone https://github.com/saeeddhqan/entropy_hash.git
cd entropy_hash
pip install -e .

Usage

Here's a quick example to get started:

from entropy_hash.pipeline.pipeline import EntropyHash

# Initialize the model
entropy_hash = EntropyHash(device="cuda", num_bits=64)

# Example input
docs = [
    "Deep learning is a subset of machine learning.",
    "Machine learning includes deep learning.",
    "Quantum computing is a different field."
]

# Get hashed vectors (PyTorch tensors)
vectors = entropy_hash.batch(docs, binarization=False)

# Example: compute cosine similarity
import torch.nn.functional as F

similarity = F.cosine_similarity(vectors[0], vectors[1], dim=0)
print("Similarity:", similarity.item())

Reproduce results

git clone https://github.com/saeeddhqan/entropy_hash
cd entropy_hash
apt install libssl-dev
gcc -shared -o entropy_hash/simhash/simhash/libsimhash_parallel.so -fPIC -fopenmp entropy_hash/simhash/simhash/simhash_parallel.c -lcrypto
pip install -r requirements.txt
python -m entropy_hash.benchmark.synthetic_bench

License

This project is licensed under the Apache License 2.0. See the LICENSE file for details.


Citation

If you use this library in your research, please cite it as:

@misc{entropyhash2025,
  title={EntropyHash: near duplicate detection algorithm},
  author={Saeed Dehqan},
  year={2025},
  howpublished={\url{https://github.com/saeeddhqan/entropy_hash}},
}

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

entropy_hash-0.1.1.tar.gz (17.3 kB view details)

Uploaded Source

Built Distribution

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

entropy_hash-0.1.1-py3-none-any.whl (18.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: entropy_hash-0.1.1.tar.gz
  • Upload date:
  • Size: 17.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.3

File hashes

Hashes for entropy_hash-0.1.1.tar.gz
Algorithm Hash digest
SHA256 5f1670e4ab8a914c7ecdb3e21f1688076beae40f6b9540fa411024ee8fa3d8ca
MD5 5f2c19aea6688037830c25e9608ac591
BLAKE2b-256 ab953a71621e8a1a9a4137d5d47cbbaebaa84e0b69ba86f3ed34c913f96b7773

See more details on using hashes here.

File details

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

File metadata

  • Download URL: entropy_hash-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 18.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.3

File hashes

Hashes for entropy_hash-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 dd2f8820a0aa2a2d638511faad257b4c2ff63992afa36aac131195cebfec3a9a
MD5 b9c2dd213e95823f8d7986e73ea16340
BLAKE2b-256 4e4a89f5128ba4db4c74301003f2c7254495e834e56e8cd7d6c45577d1d959e5

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