bb25 (Bayesian BM25)
bb25 is a fast, self-contained BM25 + Bayesian calibration implementation with a minimal Python API. It also includes a small reference corpus and experiment suite so you can validate the expected numerical properties.
- PyPI package name:
bayesian_bm25_rs - Python import name:
bb25
Install
pip install bayesian_bm25_rs
Quick start
Use the built-in corpus and queries
import bb25 as bb
corpus = bb.build_default_corpus()
docs = corpus.documents()
queries = bb.build_default_queries()
bm25 = bb.BM25Scorer(corpus, 1.2, 0.75)
score = bm25.score(queries[0].terms, docs[0])
print("score0", score)
Build your own corpus
import bb25 as bb
corpus = bb.Corpus()
corpus.add_document("d1", "neural networks for ranking", [0.1] * 8)
corpus.add_document("d2", "bm25 is a strong baseline", [0.2] * 8)
corpus.build_index() # must be called before creating scorers
bm25 = bb.BM25Scorer(corpus, 1.2, 0.75)
print(bm25.idf("bm25"))
Bayesian calibration + hybrid fusion
import bb25 as bb
corpus = bb.build_default_corpus()
docs = corpus.documents()
queries = bb.build_default_queries()
bm25 = bb.BM25Scorer(corpus, 1.2, 0.75)
bayes = bb.BayesianBM25Scorer(bm25, 1.0, 0.5)
vector = bb.VectorScorer()
hybrid = bb.HybridScorer(bayes, vector)
q = queries[0]
prob_or = hybrid.score_or(q.terms, q.embedding, docs[0])
prob_and = hybrid.score_and(q.terms, q.embedding, docs[0])
print("OR", prob_or, "AND", prob_and)
Run the experiments
import bb25 as bb
results = bb.run_experiments()
print(all(r.passed for r in results))
Build from source (Rust)
make build
PyPI publishing
Build a wheel with maturin:
python -m pip install maturin
maturin build --release
For Pyodide builds, see docs/pyodide.md.
Metadata
Release files for bayesian_bm25_rs 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bayesian_bm25_rs-0.1.1.tar.gz | 17.0 kB | Without provenance | Details for bayesian_bm25_rs-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bayesian_bm25_rs-0.1.1-cp312-cp312-macosx_11_0_arm64.whl | CPython 3.12 | CPython 3.12 | macOS 11.0+ ARM64 | Details for bayesian_bm25_rs-0.1.1-cp312-cp312-macosx_11_0_arm64.whl |
Total release size: 407.7 kB
Release files / bayesian_bm25_rs-0.1.1.tar.gz
| Download URL | bayesian_bm25_rs-0.1.1.tar.gz |
|---|---|
| Size | 17.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fa8f583458db3433968ca805c35062c643f1998a7f457408fb4b433b12959377
|
|
BLAKE2b-256 checksum How to use checksums |
f23133a503223c4c723f3f6234eddd2520b8a80f189b7ad9176ff0b77929dafb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.14
|
Release files / bayesian_bm25_rs-0.1.1-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | bayesian_bm25_rs-0.1.1-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 390.7 kB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
d4cc3ae490e496106759063f4851f7b950f1b75927e255426ec3c6daa950fdff
|
|
BLAKE2b-256 checksum How to use checksums |
094d3c8aa6ee85de62cbe9c18cf671d0ea1e7e7eae9feee07ff9097c93dac703
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.14
|
Security for bayesian_bm25_rs 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.