Skip to main content

YaBM25 - Python BM25 Search Engine

PyPI version Python Versions Downloads License

Fast, scalable BM25 search engine implementation in Python with both in-memory and disk-based indexing. Perfect for RAG (Retrieval Augmented Generation), information retrieval, and search applications.

Key Features

  • 🚀 High Performance: Optimized implementation with vectorized operations
  • 💾 Memory Efficient: Optional disk-based indexing for large datasets
  • 🔄 rank_bm25 Compatible: Drop-in replacement for rank_bm25 with extended features
  • 📊 Multiple Variants: Supports BM25, BM25L, BM25Adpt
  • 🛠 Production Ready: Thread-safe with proper resource management
  • 📦 Easy Integration: Works with LangChain, LlamaIndex, and other RAG frameworks

Benchmarks

Dataset Size Memory Usage Index Time Query Time
x y z qt

Installation

pip install yabm25

Quick Start

Simple In-Memory Usage

from yabm25 import BM25Indexer

# Initialize with corpus
corpus = [
    "Hello there good man!",
    "It is quite windy in London",
    "How is the weather today?"
]
tokenized_corpus = [doc.split(" ") for doc in corpus]
bm25 = BM25Indexer(tokenized_corpus)

# Search
query = "windy London"
doc_scores = bm25.get_scores(query.split(" "))
print(doc_scores)  # array([0., 0.93729472, 0.])

# Get top document
top_docs = bm25.get_top_n(query.split(" "), corpus, n=1)
print(top_docs)  # ['It is quite windy in London']

Large-Scale Usage

from yabm25 import BM25Indexer, BM25Config

# Configure disk-based index
config = BM25Config(
    index_dir="my_index",
    doc_chunk_size=500_000,
    compression="ZSTD"
)

# Build index
indexer = BM25Indexer(config)
indexer.build_index(large_corpus)

# Search
results = indexer.query(["term1", "term2"])

Documentation

Use Cases

  • 🤖 RAG Applications: Enhance LLM responses with relevant context
  • 🔍 Search Systems: Build powerful document search engines
  • 📚 Information Retrieval: Academic and research applications
  • 📊 Text Analysis: Document similarity and ranking

Comparison with Alternatives

Feature YaBM25 rank_bm25 Elasticsearch
Memory Efficient ✅ ❌ ✅
Disk-based ✅ ❌ ✅
Easy Setup ✅ ✅ ❌
Python Native ✅ ✅ ❌
RAG Optimized ✅ ❌ ❌

Citation

@software{yabm25,
  title = {YaBM25: Yet Another BM25 Implementation},
  author = {Muhammad, Ali},
  year = {2025},
  url = {https://github.com/alimuhammadofficial/yabm25}
}

Contributing

Contributions welcome! See CONTRIBUTING.md for guidelines.

License

MIT License. See LICENSE for details.

Metadata

Release files for yabm25 0.1.1

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

Source distribution (sdist)

Source distribution for yabm25 0.1.1
File Size Uploaded Provenance Actions
yabm25-0.1.1.tar.gz 13.9 kB Without provenance Details for yabm25-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for yabm25 0.1.1
File Interpreter ABI Platform Actions
yabm25-0.1.1-py3-none-any.whl Python 3 none any Details for yabm25-0.1.1-py3-none-any.whl

Total release size: 28.3 kB

Release files / yabm25-0.1.1.tar.gz

Download URL yabm25-0.1.1.tar.gz
Size 13.9 kB
Tags Source
SHA-256 checksum
How to use checksums
04352a2fee6cf0e2ba53c6782ed9c6a63f9540c686bbf4dad510bdacab8323ed
BLAKE2b-256 checksum
How to use checksums
204aa76cd8da938d51231f0e48f0a52133d53631943e17c045cb9341435fa328
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.4

Release files / yabm25-0.1.1-py3-none-any.whl

Download URL yabm25-0.1.1-py3-none-any.whl
Size 14.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fd2a5be891a87896d76e1cede905b2bcab5f8db68424149b729a36fb6481440f
BLAKE2b-256 checksum
How to use checksums
a8c86bad88886e52ab8c21e3b4a2d0dc5ccefd3f6a9c1c155b964ea7f23aca47
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.4

Security for yabm25 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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

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