Adaptive precision
Each query gets a proven overflow bound. Safe queries use the one-byte accumulator; the rest automatically take the higher-precision path.
bm25q 0.0.1 is live
A faster, API-compatible BM25 library for Python. Exact by default; quality-bounded quantization when speed matters.
import bm25q
tokens = bm25q.tokenize(corpus)
engine = bm25q.BM25(
corpus=corpus,
backend="numba",
quantize="adaptive",
)
engine.index(tokens)
docs, scores = engine.retrieve(
bm25q.tokenize(query), k=10
)
Designed for the hot path
bm25q keeps the sparse eager-scoring design and familiar API, then reduces memory traffic where retrieval spends its time.
Each query gets a proven overflow bound. Safe queries use the one-byte accumulator; the rest automatically take the higher-precision path.
Floating-point retrieval remains the default. Quantization is an explicit option, never a hidden behavior change.
Keep the same tokenization, indexing, retrieval, save/load, and
Hugging Face workflows under the bm25q namespace.
Measured, not guessed
Same machine, same index, one thread, every scored query, and
k=1000. Values are relative to the official bm25s
0.3.9 release; the fastest bar fills each group and raw QPS stays
visible at the right.
Local AMD EPYC 7302 full-query run, Python 3.10, one retrieval thread. Relative values are derived from the listed QPS. Hardware and query mix affect absolute throughput.
Official bm25s 0.3.9: repository, 0.3.9 source, Numba implementation, PyPI, and paper.
BM25S-F / BM25S-FQ preview: source snapshot, retrieval implementation, and benchmark definition.
bm25q 0.0.1: release source, adaptive implementation, and full methodology, results, and quality validation.
Ready in minutes
Install the recommended extras, select the adaptive backend, and use the rest of the API as you already do.
import bm25qretriever = bm25q.BM25( backend="numba", quantize="adaptive",)Search at memory speed