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 raw vectors (PyTorch tensors). Set binarization to True to receive hashed vectors.
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.2.tar.gz (17.4 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.2-py3-none-any.whl (18.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: entropy_hash-0.1.2.tar.gz
  • Upload date:
  • Size: 17.4 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.2.tar.gz
Algorithm Hash digest
SHA256 5d00f1c1225e1cab0ec9c68b1c3cef6be24520d9061e7d211adcdbda2a80f9d1
MD5 ab4d10ba14e69f82cd0bf019dbe6fdb3
BLAKE2b-256 f31dc151099eb830ac955cd58243e1bddaf31a924fb7a3193d12984cfdef4552

See more details on using hashes here.

File details

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

File metadata

  • Download URL: entropy_hash-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 18.7 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 95a00e3deeecfbf584d952b3eb292286f4c0e6f50329a437969d66694620c438
MD5 bd08490649349502ce0e0e019c5583ef
BLAKE2b-256 725afa25149ba2ea95635d1caeb024a39b0457832cc0d377bf596f9bffe75d80

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