--- id: bm25s version: "0.3.10" license: unclear license_treatment: permissive maintenance: active --- # bm25s — An ultra-fast implementation of BM25 based on sparse matrices. License: permissive · Maintenance: active · Downloads: 1.9M/mo ## 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 above — verify before relying. BM25S implements the BM25 ranking algorithm in pure Python with Numpy, enabling fast document retrieval and ranking based on text queries. 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 pip install bm25s uv add bm25s poetry add bm25s ## Installing bm25s 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: not declared (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 1.9M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags BM25 ranking implementation, document retrieval and scoring, text search ranking, sparse matrix search, lexical search library, information retrieval, query-based document ranking, information-retrieval, search-ranking, sparse-matrices [View on SkillFed](https://skillfed.io/packages/bm25s) · [View on PyPI](https://pypi.org/project/bm25s/)