Bloom-filter–accelerated clustering and set structures in PyTorch (not related to the BLOOM language model).
Project description
bloom-torch
bloom-torch is a small PyTorch library for Bloom filters, Bloom matrices (bitwise set encodings), and BloomKMeans — K-means with Bloom-based candidate pruning when the number of clusters is large.
Note: This package is not related to the BLOOM multilingual language model or other “BLOOM” model names in the Hugging Face ecosystem. The name refers to Bloom filters (probabilistic set membership, 1970).
Install
pip install bloom-torch
(After the first release; for now, from a clone: pip install -e .)
Requirements
- Python ≥ 3.10
- PyTorch ≥ 2.0
Quick start (v0.1)
import torch
from bloom_torch import BloomKMeans
# X: [n, d] float32 — e.g. token or item embeddings (cluster on raw or normalised data as you prefer)
X = torch.randn(10_000, 128, dtype=torch.float32)
km = BloomKMeans(n_clusters=256, topk_cache=16, bm_fp_rate=0.01, routing_fp_rate=0.01, seed=0)
km.fit(X, max_iters=20, use_bm_after=1, allow_bm_assign_small_k=False)
# Optional: build a cluster → element Bloom matrix for routing / masking
routing = km.build_routing_bloom(vocab_size=X.shape[0])
Public API in v0.1: BloomHasher, TorchBloomMatrix, BloomKMeans.
Routing hooks, logits processors, and LLM-specific helpers may be added in later versions or live in application code.
Relationship to research code
This repository was split out from the PyBloomFilter research prototype (torch_bloom package) so the core tensor algorithms can be versioned and published independently.
License
MIT — see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bloom_torch-1.0.0.tar.gz.
File metadata
- Download URL: bloom_torch-1.0.0.tar.gz
- Upload date:
- Size: 17.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
12d97918d1ffaf6242899b364bd5eee6018ebeeb03f0ace4c9602b3b071e9ed4
|
|
| MD5 |
f35cd6e76ff4e0c1bac730a025ba42da
|
|
| BLAKE2b-256 |
d4fe11b674a416eac538654ace3ce98989d32194441a81150ad26b8c0baf35fd
|
Provenance
The following attestation bundles were made for bloom_torch-1.0.0.tar.gz:
Publisher:
publish.yml on BloomTorch/bloom-torch
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bloom_torch-1.0.0.tar.gz -
Subject digest:
12d97918d1ffaf6242899b364bd5eee6018ebeeb03f0ace4c9602b3b071e9ed4 - Sigstore transparency entry: 1508844028
- Sigstore integration time:
-
Permalink:
BloomTorch/bloom-torch@f487ca6021bd7ea8d9404a68e567ed121508a8fe -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/BloomTorch
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f487ca6021bd7ea8d9404a68e567ed121508a8fe -
Trigger Event:
release
-
Statement type:
File details
Details for the file bloom_torch-1.0.0-py3-none-any.whl.
File metadata
- Download URL: bloom_torch-1.0.0-py3-none-any.whl
- Upload date:
- Size: 17.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
403449f8e303a2d14e5e27537e74e67c89407fbbd5e2100b2dc11ffaae0fc802
|
|
| MD5 |
f00df28c702b74c253331ac85c6f980d
|
|
| BLAKE2b-256 |
420ad7d92cb804d2e45df4817c670c30616e2ff24b249de3e4386fcdc7a2c73e
|
Provenance
The following attestation bundles were made for bloom_torch-1.0.0-py3-none-any.whl:
Publisher:
publish.yml on BloomTorch/bloom-torch
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bloom_torch-1.0.0-py3-none-any.whl -
Subject digest:
403449f8e303a2d14e5e27537e74e67c89407fbbd5e2100b2dc11ffaae0fc802 - Sigstore transparency entry: 1508844288
- Sigstore integration time:
-
Permalink:
BloomTorch/bloom-torch@f487ca6021bd7ea8d9404a68e567ed121508a8fe -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/BloomTorch
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f487ca6021bd7ea8d9404a68e567ed121508a8fe -
Trigger Event:
release
-
Statement type: