BM25 (1994) › The Solution: A Probabilistic Framework

Michael BrenndoerferApril 10, 20254 min read
History of Language AIAll chapters
Part 2 of 9The Statistical Turn
Chapter 24BM25 (1994) › The Solution: A Probabilistic Framework
Reading section 3 of 7 · The Solution: A Probabilistic Framework · 4 minSection 3 of 7 · 4 min

Book contents

Section 3 of 7 · 4 min read

BM25 (1994) › The Solution: A Probabilistic FrameworkOne section · Sections in this chapter3 / 7 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

BM25 addressed these limitations within a probabilistic framework. "BM" stands for "Best Matching," while "25" indicates the 25th iteration of the model developed by Robertson and Spärck Jones.

BM25 follows the probabilistic ranking principle: documents should be ordered by their estimated probability of relevance. Its scoring function approximates this ordering with contributions for term rarity and saturated term frequency, adjusted for document length.

From Heuristics to a Relevance Model

Rather than treating term frequency as an unlimited linear contribution, BM25 derives a ranking function from a probabilistic relevance model. The practical score incorporates term-frequency saturation and document-length normalization.

For a query QQ containing terms q1,q2,…,qnq_1, q_2, \ldots, q_n, the BM25 score for document DD is:

BM25(D,Q)=∑i=1nIDF(qi)⋅f(qi,D)⋅(k1+1)f(qi,D)+k1⋅(1−b+b⋅∣D∣avgdl)\text{BM25}(D,Q) = \sum_{i=1}^{n} \text{IDF}(q_i) \cdot \frac{f(q_i, D) \cdot (k_1 + 1)}{f(q_i, D) + k_1 \cdot (1 - b + b \cdot \frac{|D|}{\text{avgdl}})}

The IDF(qi)\text{IDF}(q_i) term assigns more weight to terms that occur in fewer documents. The fraction containing f(qi,D)f(q_i, D) saturates as term frequency rises, preventing repeated occurrences from increasing the score without bound.

The normalization factor addresses document-length bias. The parameter bb controls its strength: b=0b = 0 applies no length normalization, while b=1b = 1 applies full normalization. The ratio ∣D∣avgdl\frac{|D|}{\text{avgdl}} compares the current document's length with the collection average.

The parameter k1k_1 controls how quickly term frequency saturates. When k1=0k_1 = 0, term frequency does not affect the contribution beyond presence; larger values delay saturation and give repeated occurrences more influence.

The Probabilistic Foundation

BM25 is derived from probabilistic information retrieval theory and extends the binary independence model. Its assumptions connect the scoring terms to a model of relevant and non-relevant documents rather than only to a similarity heuristic.

The probabilistic derivation begins with the assumption that we can model the probability of a document being relevant given a query. Using Bayes' theorem, this probability can be expressed as:

P(relevant∣D,Q)=P(D,Q∣relevant)⋅P(relevant)P(D,Q)P(\text{relevant} | D, Q) = \frac{P(D, Q | \text{relevant}) \cdot P(\text{relevant})}{P(D, Q)}

Computing this probability directly is impractical, so BM25 uses simplifying assumptions to approximate the log-odds of relevance as a sum of term-level contributions. Each contribution reflects how well a term distinguishes relevant from non-relevant documents.

Relevance judgments can be used to tune BM25's parameters for a collection and query distribution. This made the model practical in evaluations and applications where such feedback was available.

Parameter Tuning and Sensitivity

BM25 has two main tuning parameters. The value of k1k_1 controls term-frequency saturation, while bb controls document-length normalization. Both can be selected for a particular collection and query set.

The k1k_1 parameter controls term-frequency saturation and is often set between 1.2 and 2.0. Lower values saturate quickly, reducing the effect of repeated boilerplate or specifications. Higher values give term counts more influence when repeated occurrences correlate with relevance in the target collection.

The bb parameter controls document length normalization, typically ranging from 0.0 to 1.0. When b=0b = 0, the algorithm performs no length normalization, which might be appropriate for collections where document length is a meaningful indicator of comprehensiveness. When b=1b = 1, the algorithm performs full length normalization, which is generally preferred for most applications where users want the most relevant content regardless of document length.

BM25 often performs reasonably across a range of parameter settings. Collection-specific tuning can improve results, but useful baselines are possible without an exhaustive parameter search.

What the Parameters Control

The k1k_1 and bb parameters can be tuned for different collections. News articles may favor settings different from academic papers, while technical documentation may differ from general web content. The same scoring function can therefore be adjusted without changing its basic form.