Home Knowledge Base BM25 (Best Match 25)

BM25 (Best Match 25) is the probabilistic keyword ranking algorithm that scores document relevance by combining term frequency saturation with inverse document frequency and document length normalization — serving as the universal baseline for information retrieval since the 1990s and remaining the mandatory first-stage retrieval component in hybrid search and RAG pipelines today.

What Is BM25?

Why BM25 Matters

BM25 vs. TF-IDF

TF-IDF Problems BM25 Solves:

Problem 1 — Term Frequency Saturation:

Problem 2 — Document Length Bias:

BM25 Scoring Formula

Score(D, Q) = Σ IDF(qi) × [f(qi, D) × (k1 + 1)] / [f(qi, D) + k1 × (1 - b + b × |D|/avgdl)]

Where:

Key Parameters

k1 (Term Frequency Saturation):

b (Length Normalization):

Variants: BM25+ and BM25L

Sparse vs. Dense Retrieval Comparison

PropertyBM25 (Sparse)Dense (Bi-Encoder)
Training requiredNoYes (large corpus)
Handles synonymsNoYes
Exact term matchExcellentVariable
Out-of-vocabulary termsHandles gracefullyPoor (OOV embeddings)
Inference speedSub-10ms30–100ms
GPU requiredNoYes (for encoding)
InterpretabilityFullOpaque
MultilingualPer-language indexSingle multilingual model

Production Usage

BM25 is the 30-year-old algorithm that continues to outperform pure neural retrieval on keyword-heavy queries and remains indispensable in every serious production search and RAG pipeline — its combination of zero training requirements, sub-millisecond speed, and excellent exact-match precision makes it the irreplaceable keyword foundation of modern hybrid retrieval systems.

bm25tfidfsparse

Explore 500+ Semiconductor & AI Topics

From EUV lithography to CUDA optimization — search the full knowledge base or chat with our AI assistant.