Skip to main content

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


Download files

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

Source Distribution

bloom_torch-1.0.0.tar.gz (17.2 kB view details)

Uploaded Source

Built Distribution

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

bloom_torch-1.0.0-py3-none-any.whl (17.9 kB view details)

Uploaded Python 3

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

Hashes for bloom_torch-1.0.0.tar.gz
Algorithm Hash digest
SHA256 12d97918d1ffaf6242899b364bd5eee6018ebeeb03f0ace4c9602b3b071e9ed4
MD5 f35cd6e76ff4e0c1bac730a025ba42da
BLAKE2b-256 d4fe11b674a416eac538654ace3ce98989d32194441a81150ad26b8c0baf35fd

See more details on using hashes here.

Provenance

The following attestation bundles were made for bloom_torch-1.0.0.tar.gz:

Publisher: publish.yml on BloomTorch/bloom-torch

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for bloom_torch-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 403449f8e303a2d14e5e27537e74e67c89407fbbd5e2100b2dc11ffaae0fc802
MD5 f00df28c702b74c253331ac85c6f980d
BLAKE2b-256 420ad7d92cb804d2e45df4817c670c30616e2ff24b249de3e4386fcdc7a2c73e

See more details on using hashes here.

Provenance

The following attestation bundles were made for bloom_torch-1.0.0-py3-none-any.whl:

Publisher: publish.yml on BloomTorch/bloom-torch

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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