Skip to main content

bm25-mojo

A drop-in faster replacement for the rank_bm25 package, powered by a clean-room Mojo kernel — with a vendored pure-Python fallback for platforms without a native build (including Windows — tested there in CI: windows-fallback).

from bm25_mojo import BM25Okapi  # same API as rank_bm25.BM25Okapi

bm25 = BM25Okapi(tokenized_corpus)
scores = bm25.get_scores(tokenized_query)        # np.ndarray, float64
top = bm25.get_top_n(tokenized_query, documents, n=5)
panel = bm25.get_scores_batch(list_of_queries)   # batch API: bit-identical rows
  • Same results: scores match rank_bm25 element-wise (last-ulp level; the differential suite asserts agreement within 1e-8 on both the native and fallback backends). BM25Okapi, BM25L, and BM25Plus are provided.
  • Much faster scoring: the kernel walks postings lists with the idf-weighted scores baked in at index time — 149x-13,137x faster get_scores than rank_bm25, and 1.1x-1.95x faster than bm25s 0.3.11 (numba, its recommended config) across the whole 1k-100k doc grid (Apple M4 Max; full method and numbers in the repository README and benchmarks/AUTOPSY-bm25s.md).
  • No toolchain needed: per-platform wheels ship the compiled kernel. Everywhere else the package transparently uses its pure-Python fallback.
  • Force the fallback with BM25_MOJO_DISABLE_NATIVE=1; inspect the active backend with bm25_mojo.backend_info().

Source, benchmarks, and development: https://github.com/thyn-ai/mojo-kernels

License: Apache-2.0, © 2026 Algenta

Metadata

Release files for bm25-mojo 0.2.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for bm25-mojo 0.2.4
File Interpreter ABI Platform
bm25_mojo-0.2.4-py3-none-manylinux_2_35_x86_64.whl Python 3 none Linux glibc 2.35+ x86-64 Details
bm25_mojo-0.2.4-py3-none-macosx_14_0_arm64.whl Python 3 none macOS 14.0+ ARM64 Details

Total release size: 2.0 MB

Release files / bm25_mojo-0.2.4-py3-none-manylinux_2_35_x86_64.whl

Download URL bm25_mojo-0.2.4-py3-none-manylinux_2_35_x86_64.whl
Size 840.5 kB
Tags Linux glibc 2.35+ x86-64 Python 3
SHA-256 checksum
How to use checksums
26c05b86b18791fcc04b72b2343edee87397f1f2606ad1c621f70eb75b3ec42c
BLAKE2b-256 checksum
How to use checksums
7b3125e4771b3699febd506fa7f299c124ae6c43f7afe78e05ad31d0683b6332
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / bm25_mojo-0.2.4-py3-none-macosx_14_0_arm64.whl

Download URL bm25_mojo-0.2.4-py3-none-macosx_14_0_arm64.whl
Size 1.1 MB
Tags Python 3 macOS 14.0+ ARM64
SHA-256 checksum
How to use checksums
2fdfdb0464defe22ac13e2effeb50dff6e9a4c5ece0910e4a088837fd9bd5b30
BLAKE2b-256 checksum
How to use checksums
9c0ff3924d1e1b49b62b2dd6ec3720efd6f31ac8d0971ad1ff80e4dd9b5e16d9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

0.2.4 This release

2 release files

0.2.3

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.7

2 release files

0.1.5

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page