bm25s
An ultra-fast implementation of BM25 based on sparse matrices.
Decision gist · record as of 2026-08-14
Yes. BM25S is actively maintained, has no security vulnerabilities, installs with minimal friction, and is licensed permissively. It solves a real problem—fast lexical search—with a simple, dependency-light design. Install it if you need to rank documents by text relevance in Python without external services.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Installation is straightforward with low friction—the package is a pure Python wheel with only Numpy as a required dependency.
- The project is actively maintained with a recent release and steady commit activity.
License · maintenance · safety
permissive license (permissive) — Licensed under MIT (permissive), so you can use, modify, and distribute the package freely in commercial and private projects without restriction.
last release 2026-07-22 (23 days) · last repo commit 2026-07-22 · 1,763 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 1,923,766 downloads/mo, #3,428 on PyPI
Alternatives
Verify before relying
pip install bm25s
import bm25s
corpus = ["a cat is a feline", "a dog is friendly"]
corpus_tokens = bm25s.tokenize(corpus, stopwords="en")
retriever = bm25s.BM25()
retriever.index(corpus_tokens)
query_tokens = bm25s.tokenize("cat")
results, scores = retriever.retrieve(query_tokens, k=2)- Whether optional dependencies (PyStemmer, numba) are truly optional or recommended for typical use cases
- Performance comparison claims against Elasticsearch and rank-bm25 (benchmarks cited but not included in fact sheet)
What it is and what it does
BM25S is a pure-Python implementation of the BM25 ranking algorithm, a widely-used text retrieval function that scores how relevant documents are to a query. It uses sparse matrices to precompute and store token scores, enabling very fast retrieval at query time. The package is designed for simplicity—it requires only Numpy and can be installed and used within minutes, with no Java or PyTorch dependencies.
You tokenize a corpus of documents, index them with the BM25 model, then query against the index to retrieve ranked results. The library supports optional stemming via PyStemmer and optional JIT compilation via Numba for additional speedup on larger datasets. It also provides a command-line interface for indexing and searching without writing Python code, and a high-level API for quick file-based indexing.
Use it for
- Build a search engine over a local document collection (CSV, JSON, JSONL, or text files) without external infrastructure
- Rank documents by relevance to user queries in a Python application or web service
- Prototype information retrieval systems before scaling to Elasticsearch or similar production systems
- Index and search large corpora (millions of documents) with fast query-time performance
- Combine BM25 ranking with other retrieval methods in a hybrid search pipeline
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
BM25S is actively maintained, has no security vulnerabilities, installs with minimal friction, and is licensed permissively. It solves a real problem—fast lexical search—with a simple, dependency-light design. Install it if you need to rank documents by text relevance in Python without external services.
Install
bm25s on PyPI
Before you install
Installation is straightforward with low friction—the package is a pure Python wheel with only Numpy as a required dependency. The project is actively maintained with a recent release and steady commit activity.
License in practice
Licensed under MIT (permissive), so you can use, modify, and distribute the package freely in commercial and private projects without restriction.
Quickstart
pip install bm25s
import bm25s
corpus = ["a cat is a feline", "a dog is friendly"]
corpus_tokens = bm25s.tokenize(corpus, stopwords="en")
retriever = bm25s.BM25()
retriever.index(corpus_tokens)
query_tokens = bm25s.tokenize("cat")
results, scores = retriever.retrieve(query_tokens, k=2)
Verify before relying
- Whether optional dependencies (PyStemmer, numba) are truly optional or recommended for typical use cases
- Performance comparison claims against Elasticsearch and rank-bm25 (benchmarks cited but not included in fact sheet)
Package facts
| License | permissive license permissive |
| Python support | Supports the current Python release >=3.8 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 1 packagenumpy |
| Maintenance | Actively maintained 23 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,923,766 / month, #3,428 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | License :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3 |
Evidence: bm25s-0.3.10-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “text search ranking”
- bm25sBM25S implements the BM25 ranking algorithm in pure Python with…
- rank-bm25Implements BM25 ranking algorithms (Okapi BM25, BM25L, BM25+) to…
- colbert-aiColBERT is a BERT-based retrieval model that encodes passages and…
Give your agent the search over MCP, or paste the wish link into any chat.
More Text Processing packages
A drop-in replacement for Python's standard `re` module that adds advanced regex features like nested sets, fuzzy matching, lookaround in conditionals, and full Unicode case-folding while maintaining backward compatibility.
pyparsing provides a library for building text parsers directly in Python code using composable grammar classes, handling quoted strings, whitespace variation, and embedded comments without regex or lex/yacc.
Install it if you need to parse text or define grammars programmatically.
fonttools manipulates font files in multiple formats (TrueType, OpenType, AFM, Type 1, Mac-specific) and includes TTX, a tool to convert fonts to and from XML text format.
Install it if you need to read, write, or manipulate fonts programmatically or via the TTX command-line tool.
Docutils converts plaintext documentation in reStructuredText format into multiple output formats including HTML, XML, and LaTeX using a modular processing system.
RapidFuzz provides fast fuzzy string matching using Levenshtein Distance and related metrics, implemented mostly in C++ with Python bindings for rapid similarity scoring and approximate string matching.
Install it if you need fuzzy string matching; it's a solid replacement for FuzzyWuzzy with better licensing and performance.
tinycss2 parses CSS strings into token and block objects, and generates CSS strings from those objects, following the CSS Syntax Level 3 specification without enforcing specific properties or values.
Install it if your project requires CSS tokenization or syntax manipulation.
See also rank-bm25 · sqlite-fts4 · llama-index-retrievers-bm25 · pinecone-text · colbert-ai · Whoosh · milvus-lite · langchain-graph-retriever · graph-retriever · py-rust-stemmers