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}},
}
Metadata
Release files for entropy-hash 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| entropy_hash-0.1.3.tar.gz | 17.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| entropy_hash-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 36.1 kB
Release files / entropy_hash-0.1.3.tar.gz
| Download URL | entropy_hash-0.1.3.tar.gz |
|---|---|
| Size | 17.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1354be124a1b7e9cd1402417a8452db434e47a9899212eece281668fcdd093af
|
|
BLAKE2b-256 checksum How to use checksums |
8e9a0e40d0f53437b2dbebbe947c1d85c90f322c958be7acaf2302063318ba2b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.3
|
Release files / entropy_hash-0.1.3-py3-none-any.whl
| Download URL | entropy_hash-0.1.3-py3-none-any.whl |
|---|---|
| Size | 18.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
68370facc82ed6a919d0794678c35219e42fa5f5d61115edefb491b71f2f3566
|
|
BLAKE2b-256 checksum How to use checksums |
763cb9038660abd54559c7810660ddfed23fd251ee245b501db801d64424c31e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.3
|