BM25

BM25 (Best Matching 25) is a probabilistic information retrieval algorithm that scores the relevance between a query and documents by taking into account the term frequency within documents and document length.
As an Evolution of TF-IDF
BM25 is a ranking function that extends the concept of TF-IDF, and has long served as the default algorithm for major full-text search engines such as Elasticsearch and Apache Solr. Its defining characteristic is the use of a saturation function to correct the intuition that "the more frequently a term appears in a document, the more relevant it is." Even as term frequency increases, the score does not rise without bound—it plateaus at a certain point.
There are two primary parameters. k1 controls the saturation rate of term frequency, while b adjusts the strength of normalization based on document length. The default values (k1=1.2, b=0.75) are often used as-is, though tuning them can improve retrieval accuracy for domain-specific corpora.
Role in RAG Pipelines
Even amid the growing attention on vector search (semantic search), BM25 remains strong for exact keyword matching and retrieval of technical terminology. In practice, a hybrid search approach—combining BM25 with vector search and merging scores using RRF (Reciprocal Rank Fusion)—has become the standard pattern.
For queries where "string matching" matters more than "meaning," such as those involving proper nouns or model numbers, a hybrid configuration that includes BM25 delivers more consistent results than vector search alone.
Articles covering this term
- 10 RAG Implementation Failure Patterns and How to Avoid Them — Preventing Production Issues Before They Happen10 common RAG failures before & after production: chunk design errors, retrieval accuracy drops, hallucination fixes & more. Learn key avoidance strategies before you build.
- What is a Vector Database? A Complete Guide to How It Works, Top Product Comparisons, and RAG ApplicationsFrom basic vector database concepts to comparing top products like Pinecone, Weaviate, and pgvector, plus RAG system integration—a clear guide for AI implementation managers.
- What is Hybrid Search? How It Works and Implementation to Improve RAG Accuracy with Vector Search × Full-Text SearchExplains hybrid search using vector search, BM25, and RRF. Practical design patterns and implementation tips to improve RAG system retrieval accuracy.
- What is Adaptive RAG? How to Balance Cost and Accuracy with Query-Driven Dynamic RetrievalLearn how Adaptive RAG eliminates inefficiencies of traditional RAG by selectively retrieving only when needed—covering mechanisms, implementation patterns, and B2B use cases.
Related Terms

RRF
RRF (Reciprocal Rank Fusion) is a scoring method that integrates ranking results returned by multipl

Agentic RAG
Agentic RAG is an architecture in which an LLM autonomously and iteratively generates search queries

Embedding
Embedding is a technique that transforms unstructured data such as text, images, and audio into fixe

GraphRAG
A next-generation RAG architecture that combines knowledge graphs and vector search, leveraging rela



