skillfed

llama-index-retrievers-bm25

llama-index retrievers bm25 integration

llama-index-retrievers-bm25 v0.7.1 326.3K downloads/30d#7,578 on PyPI
Permissive license MIT Active released

What it is and what it does

This package provides a BM25-based retriever for LlamaIndex, a framework for building retrieval-augmented generation (RAG) applications. BM25 is a probabilistic ranking function that scores documents based on keyword relevance, making it useful for traditional full-text search within LlamaIndex pipelines. The retriever accepts a collection of documents, builds an index using the bm25s library, and returns ranked results for text queries.

It sits between your document collection and LlamaIndex's query pipeline, handling the retrieval step without requiring external search infrastructure. The package depends on bm25s for the core ranking algorithm, llama-index-core for integration hooks, and pystemmer for linguistic preprocessing. It's designed for developers who want keyword-based retrieval as part of a larger LlamaIndex application, particularly when semantic or hybrid search isn't the primary need.

Use it for:

  • Build a RAG pipeline where keyword matching is the primary retrieval strategy before passing results to an LLM.
  • Add full-text search to a document Q&A system without setting up a separate search engine.
  • Combine BM25 retrieval with other LlamaIndex retrievers in a hybrid or ensemble approach.
  • Index and retrieve from domain-specific documents where exact keyword matches are important.
  • Prototype or test retrieval logic quickly without infrastructure overhead.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Integrates BM25 full-text search retrieval into LlamaIndex applications, enabling keyword-based document ranking and retrieval without external dependencies.

Yes, if you're building a LlamaIndex application and need straightforward keyword-based retrieval. The low install friction, active maintenance, MIT license, and zero known vulnerabilities make it a safe choice. Install only if BM25 ranking fits your retrieval needs; for semantic or dense vector search, you'd want a different retriever.

Install

llama-index-retrievers-bm25 on PyPI

pip

pip install llama-index-retrievers-bm25

uv

uv add llama-index-retrievers-bm25

poetry

poetry add llama-index-retrievers-bm25

Installing llama-index-retrievers-bm25

Before you install

Low install friction with a pure-Python wheel and only three runtime dependencies. Actively maintained as of March 2026, with no known security vulnerabilities.

License in practice

MIT license permits unrestricted use, modification, and distribution in both open-source and commercial projects, with only attribution required.

Quickstart

pip install llama-index-retrievers-bm25

from llama_index.retrievers.bm25 import BM25Retriever

retriever = BM25Retriever.from_documents(documents)
results = retriever.retrieve(query_str)

Requires Python 3.10 or later (supports current versions up to <4.0).

Verify before relying

  • Whether BM25Retriever integrates seamlessly with other LlamaIndex components beyond core retrieval.
  • Performance characteristics when indexing or querying large document collections.
  • How pystemmer is used internally and whether stemming behavior is configurable.

Package facts

License MIT (permissive)
Python support supports the current Python release (<4.0,>=3.10)
Install friction low — pure-Python wheel
Runtime dependencies 3 — bm25s, llama-index-core, pystemmer
Maintenance actively maintained — 154 days since the last release
First released
Downloads 326,294/month — #7,578 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: llama_index_retrievers_bm25-0.7.1-py3-none-any.whl

Tags

bm25 retrieval llama indexkeyword search document rankingfull-text search integrationbm25 ranking algorithmllama index retriever plugintext-based document retrievalinformation retrieval bm25
retrieval-augmented-generationinformation-retrievalllama-index-integration

More Artificial Intelligence packages

litellm

LiteLLM provides a unified Python interface to…

permissive · top 100 on PyPI

huggingface-hub

Client library and CLI tool for downloading,…

permissive · top 100 on PyPI

langchain

LangChain provides a framework for building…

permissive · top 1,000 on PyPI

hf-xet

hf-xet provides chunk-based deduplication and…

permissive · top 1,000 on PyPI

tokenizers

Tokenizers converts raw text into token…

permissive · top 1,000 on PyPI

transformers

Transformers provides a unified framework for…

permissive · top 1,000 on PyPI

llama-index-vector-stores-qdrant

Integrates Qdrant vector database with…

permissive · top 15,000 on PyPI

llama-index-vector-stores-chroma

Integrates Chroma vector database with…

permissive · top 15,000 on PyPI

llama-index-vector-stores-faiss

Integrates FAISS vector storage with LlamaIndex…

permissive · top 15,000 on PyPI

llama-index-embeddings-openai

Integrates OpenAI's embedding models with…

permissive · top 5,000 on PyPI

rank-bm25

Implements BM25 ranking algorithms (Okapi BM25,…

permissive · top 5,000 on PyPI

llama-index-embeddings-langchain

Integrates Langchain embedding models with…

permissive · top 15,000 on PyPI

bm25s

BM25S implements the BM25 ranking algorithm in…

permissive · top 5,000 on PyPI

llama-index-vector-stores-postgres

Integrates PostgreSQL with pgvector extension…

permissive · top 15,000 on PyPI

llama-index-vector-stores-redis

Integrates Redis as a vector store backend for…

permissive · top 15,000 on PyPI

llama-index-indices-managed-llama-cloud

Provides deprecated integration for creating…

permissive · top 1,000 on PyPI

Further reading