Okapi BM25

The ranking function that extended the Binary Independence Model with term frequency saturation and document length normalization, and has remained the standard lexical baseline for three decades. Built up step by step from the RSJ weight, with the saturation and length curves plotted, a fully worked score for a Cranfield query, and an interactive demo of k1 and b.

Okapi BM25 scores a document as $\sum_{t \in q} \mathrm{IDF}(t) \cdot \mathrm{tf}_{t,d}\,(k_1 + 1)/(\mathrm{tf}_{t,d} + K)$, with $K = k_1 (1 - b + b\, L_d / L_{\mathrm{avg}})$. The term frequency part rises from 0 toward $k_1 + 1$, and in a document of average length it reaches half of that at $\mathrm{tf} = k_1$. The parameter $b$ moves length normalization between none ($b = 0$) and full ($b = 1$). The saturating curve takes the 2-Poisson model's shape but is a design choice, not a derivation from it, and with $k_1 = 0$ the function reduces to the Binary Independence Model. On Cranfield query 185, with Lucene's IDF, $k_1 = 1.2$ and $b = 0.75$, it breaks the BIM's ties and raises average precision from 0.659 to 0.784. Over all 225 queries its MAP of 0.307 is the highest of the classical models compared; the BM25L and BM25+ variants reach 0.289 and 0.283.

Cranfield query 185 asks for experimental studies on panel flutter. Abstract 856 uses panel 16 times, and abstract 390 uses it five times. To the Binary Independence Model the two are equal on that term, because the BIM sees only whether a term is present. Its top 20 places hold all nine relevant abstracts and eleven others, in large groups of tied scores. The 2-Poisson model showed that counts do carry evidence, and that the evidence levels off by the second or third occurrence. How can that shape, together with a correction for document length, become a scoring function simple enough to run on every query?

Okapi BM25 ("Best Match 25") is that function. It scores a document by summing a weight over the query terms the document contains. Each weight combines three things:

  • how rare the term is in the collection;
  • how often it occurs in the document;
  • how long the document is relative to the average.

Stephen Robertson, Steve Walker and colleagues developed it for the Okapi system at City University London. It reached its standard form at TREC-3 in 1994 (Robertson and colleagues, 1995). It is the default similarity in Lucene, and therefore in Elasticsearch, OpenSearch and Solr. Thirty years later it is still the baseline that new retrieval methods are measured against. On the BEIR benchmark of 18 datasets from domains the neural models were not trained on, its authors found BM25 "a robust baseline" that dense and sparse neural retrievers often failed to match (Thakur and colleagues, 2021).

Here is the route. First we build the formula in four steps from the BIM's weight, each step fixing one problem. Then we take its parts one at a time: term frequency saturation, length normalization, the IDF, and query term frequency. Next we score query 185 by hand and watch the ties break, with a demo for the two parameters. Finally we cover tuning, variants and common misreadings. The article assumes the BIM and its Robertson–Spärck Jones weight.

From BIM to BM25

The BIM derives a principled term weight, but it sees only whether a term is present. Two things it ignores matter a great deal:

  • Term frequency. Abstract 856, which uses flutter 11 times, is more likely to be about flutter than an abstract that uses it once.
  • Document length. A long document contains more terms simply because it is long, so raw counts favor it unfairly.

The obvious fix, multiplying the weight by raw term frequency, overcorrects. The eleventh occurrence of a word is not eleven times as informative as the first. In the 2-Poisson model, documents are either elite for a term, actually about its concept, or not, and the term's counts follow a different Poisson distribution in each group. For flutter, the 2-Poisson fit put the probability that a document is elite at 0.164 after one occurrence and 0.996 after two. Further occurrences barely move it. The full 2-Poisson model has too many hidden parameters to estimate for every term. So Robertson and Walker (1994) designed a simple function with the same shape: it starts at zero, rises with term frequency, and levels off. That function is the heart of BM25.

Building the formula in four steps

Here is the plan of the derivation. Start from the BIM's weight. Make it grow with the count but level off. Let long documents need more occurrences for the same credit. Then rescale, so that one occurrence keeps the weight the BIM gave it. Robertson and Zaragoza (2009, §3.4.4 to §3.4.5) present the construction in this sequence of small steps. Following it makes every part of the final formula explicit.

The construction is a design guided by a model, not a derivation from it, and each step below says which it is. What the 2-Poisson model proves is that a term's weight is zero when the term is absent, rises with each occurrence, and is bounded. The particular curve, the weight it is multiplied by, and the form of the length correction are the authors' choices; the 2-Poisson article lists them against the 1994 paper.

The formal version.

  1. Start from the binary weight. The BIM gives each matching term a weight $w^{\mathrm{RSJ}}_t$, the Robertson–Spärck Jones weight. Without relevance information it is an IDF. In the 2-Poisson model a term's weight approaches a maximum as its count grows, and that maximum is approximately the log odds ratio of eliteness (exactly so if an elite document can never lack the term). That maximum cannot be estimated, because eliteness is hidden, and the RSJ weight of term presence is used in its place. This is a substitution of one quantity for another, not a consequence of the model (Robertson and Zaragoza, 2009, call it "an approximation to the asymptotic maximum").
  2. Saturate. Multiply by a function of term frequency that is 0 at $\mathit{tf} = 0$, increases, and approaches 1. The one-parameter function chosen was $\mathit{tf}/(\mathit{tf} + k_1)$, fitted to the shape of the model's weight and not derived from it. It gives the early form $\frac{\mathit{tf}}{k_1 + \mathit{tf}}\, w^{\mathrm{RSJ}}_t$ (their eq. 3.11), which approaches the binary weight from below as $\mathit{tf}$ grows.
  3. Normalize length before saturating. Divide the raw count by a length factor $B = (1 - b) + b \, L_d / L_{\mathrm{avg}}$ to get $\mathit{tf}' = \mathit{tf} / B$, and saturate that instead. Here $L_d$ is the document's length, $L_{\mathrm{avg}}$ the average length, and $b$ a parameter between 0 and 1. Substituting and multiplying top and bottom by $B$: $$\frac{\mathit{tf}'}{k_1 + \mathit{tf}'} = \frac{\mathit{tf} / B}{k_1 + \mathit{tf}/B} = \frac{\mathit{tf}}{\mathit{tf} + k_1 B}.$$ Length enters only as a rescaling of $k_1$. A long document ($B > 1$) needs more occurrences to reach the same fraction of the maximum (their eqs. 3.12 to 3.15). The form of $B$ comes from two hypotheses about why documents differ in length (Robertson and Walker, 1994, §5.1; the reading of each hypothesis as one end of $b$ is Robertson and Zaragoza's, 2009, §3.4.5). Under the verbosity hypothesis a long document says the same thing in more words. Its Poisson rates are then higher in proportion to its length, and the count comparable with an average document's is $\mathit{tf} \cdot L_{\mathrm{avg}} / L_d$: this is $B = L_d / L_{\mathrm{avg}}$, the case $b = 1$. Under the scope hypothesis a long document covers more ground, its counts are real evidence, and no correction is due: this is $B = 1$, the case $b = 0$. The factor $B = (1 - b) \cdot 1 + b \cdot L_d / L_{\mathrm{avg}}$ is the weighted average of the two, a "soft normalisation" in Robertson and Zaragoza's words for collections where both effects are present. The two ends are motivated by the model. The linear mixture and the value of $b$ are empirical.
  4. Rescale so one occurrence keeps the binary weight. Multiplying by the constant $k_1 + 1$ makes the factor exactly 1 when $\mathit{tf} = 1$ and $L_d = L_{\mathrm{avg}}$. A single occurrence in an average document then scores what the BIM would give it, and the maximum becomes $k_1 + 1$ times that. The constant is the same for every term and document, so it changes no ranking. It only keeps scores on a familiar scale.

The scoring function

For a query $q$ and document $d$:

$$\mathrm{BM25}(d, q) = \sum_{t \in q} \mathrm{IDF}(t) \cdot \frac{\mathrm{tf}_{t,d} \, (k_1 + 1)}{\mathrm{tf}_{t,d} + k_1 \left(1 - b + b \, \frac{L_d}{L_{\mathrm{avg}}}\right)}$$

Symbol Meaning
$\mathrm{tf}_{t,d}$ Number of times term $t$ occurs in document $d$
$L_d$, $L_{\mathrm{avg}}$ Length of $d$ and the average document length, in tokens
$\mathrm{IDF}(t)$ Rarity of $t$ in the collection, discussed below
$k_1$ Controls how quickly term frequency saturates, typically 1.2 to 2.0
$b$ Controls the strength of length normalization, from 0 to 1, typically 0.75

Terms absent from the document have $\mathrm{tf} = 0$ and contribute nothing. So, as with the BIM, the score can be accumulated directly from the postings lists of an inverted index. Because each term's contribution is bounded, by $(k_1 + 1)\,\mathrm{IDF}(t)$ or more tightly by the largest value in its list, an engine can skip documents that cannot reach the current top $k$ without changing the results; Dynamic Pruning with MaxScore and WAND proves this and measures the savings.

The formula has three moving parts: the saturation curve, the length factor and the IDF. Each deserves a closer look before we use them on query 185.

Term frequency saturation

Write $K = k_1 \left(1 - b + b \, L_d / L_{\mathrm{avg}}\right)$. The term frequency component is then $\frac{\mathrm{tf}\,(k_1 + 1)}{\mathrm{tf} + K}$. It is zero when $\mathrm{tf} = 0$ and increases with every additional occurrence. As $\mathrm{tf}$ grows without bound, it approaches $k_1 + 1$. The factor $(k_1 + 1)$ in the numerator is a normalization: for a document of average length, a single occurrence scores exactly 1. With $k_1 = 1.2$ and an average-length document:

tf 1 2 3 5 10 20 limit
Component 1.00 1.38 1.57 1.77 1.96 2.08 2.20

The second occurrence adds 0.38, and the tenth adds very little. This diminishing return makes the score hard to inflate by repeating a keyword. The parameter $k_1$ sets the curve's shape. At $k_1 = 0$ the component is 1 for any $\mathrm{tf} > 0$, which recovers the binary model. As $k_1$ grows, the curve approaches raw term frequency.

The term frequency component for an average-length document against the number of occurrences, for five values of k1, with raw term frequency dotted for comparison. Notice that every curve passes through 1 at tf = 1. At k1 = 0 the component is flat, which is the binary model; at k1 = 5 it still climbs steeply at tf = 10. Each curve levels off toward k1 + 1.
The term frequency component for an average-length document against the number of occurrences, for five values of k1, with raw term frequency dotted for comparison. Notice that every curve passes through 1 at tf = 1. At k1 = 0 the component is flat, which is the binary model; at k1 = 5 it still climbs steeply at tf = 10. Each curve levels off toward k1 + 1.

Example (what $k_1$ measures). In a document of average length, with $k_1 = 1.2$, a term earns half of its maximum possible weight at $\mathrm{tf} = 1.2$, that is, at $\mathrm{tf} = K$. The component is $\mathrm{tf}\,(k_1 + 1)/(\mathrm{tf} + K)$, and its limit is $k_1 + 1$, so it is half the limit exactly when $\mathrm{tf}/(\mathrm{tf} + K) = \tfrac12$, which is $\mathrm{tf} = K$. This gives $k_1$ a direct reading: for an average-length document, it is the number of occurrences at which a term earns half its possible weight. With the default 1.2, a term mentioned once or twice in a typical document has already earned most of what it ever will.

Saturation treats every document as if it were of average length. Real documents are not, which is the job of the second part.

Document length normalization

The factor $1 - b + b \, L_d / L_{\mathrm{avg}}$ is 1 for a document of average length. It is greater than 1 for longer documents and less than 1 for shorter ones. It enters the denominator, so a long document needs more occurrences of a term to reach the same score. The parameter $b$ interpolates between no normalization ($b = 0$) and full normalization by length ($b = 1$). For three occurrences of a term with $k_1 = 1.2$ and $b = 0.75$:

Document length Half the average Average Twice the average
Component for tf = 3 1.76 1.57 1.29
The component for three occurrences of a term (k1 = 1.2) against document length relative to the average, for five values of b. Notice that all curves cross at the average length, where the normalization factor is 1. At b = 0 length is ignored; the steeper the curve, the more a long document is discounted. The marked points are the table's 1.76, 1.57 and 1.29 at b = 0.75.
The component for three occurrences of a term (k1 = 1.2) against document length relative to the average, for five values of b. Notice that all curves cross at the average length, where the normalization factor is 1. At b = 0 length is ignored; the steeper the curve, the more a long document is discounted. The marked points are the table's 1.76, 1.57 and 1.29 at b = 0.75.

Why not always normalize fully? Long documents are long for two different reasons:

  • Some are verbose. They say the same thing at greater length, and they should be normalized.
  • Others have broader scope. They cover more topics, and in them a high term count is real evidence.

Partial normalization is the compromise between the two. Robertson and Zaragoza (2009, §3.5) report that experiments suggest values of $b$ between 0.5 and 0.8 are "reasonably good in many circumstances". If all the length variation in a collection were verbosity, $b = 1$ would be the right setting, and if all of it were scope, $b = 0$.

The IDF component

BM25 inherits its IDF from the BIM's weight in the case with no relevance information:

$$\mathrm{IDF}(t) = \log \frac{N - \mathrm{df}_t + 0.5}{\mathrm{df}_t + 0.5}$$

where $N$ is the number of documents and $\mathrm{df}_t$ the number containing $t$. As in the BIM, this is negative for terms in more than half of the collection. Adding a common word to a query can then lower the score of the documents that contain it, and the formula then fails the formal constraints examined in constraints on term weighting. Lucene avoids this by adding 1 inside the logarithm:

$$\mathrm{IDF}_{\text{Lucene}}(t) = \log \left(1 + \frac{N - \mathrm{df}_t + 0.5}{\mathrm{df}_t + 0.5}\right)$$

In a collection of 1,000 documents, a term in 600 of them gets $-0.41$ under the first form and $0.51$ under Lucene's. For rare terms the two are nearly identical (4.55 and 4.56 for a term in 10 documents). The BIM article plots the forms side by side. When relevance judgments are available, the IDF can be replaced by the full Robertson–Spärck Jones weight from the BIM. That is how BM25 incorporates relevance feedback.

Long queries

The original formulation also saturates term frequency in the query, with a third parameter $k_3$:

$$\frac{(k_3 + 1)\,\mathrm{tf}_{t,q}}{k_3 + \mathrm{tf}_{t,q}}$$

For short keyword queries, where each term appears once, this factor is 1 and is usually omitted. It matters when the "query" is a paragraph or a whole document, as in finding similar documents. Even there, Robertson and Walker (1994) found that a very large $k_3$ worked best, which makes the factor linear in query term frequency. Robertson and Zaragoza (2009) summarize the experiments as showing that saturation in the query is unimportant. Many implementations therefore simply count a repeated query term again.

A worked score: Cranfield query 185

Back to query 185 and its tied abstracts. BM25 breaks the ties with term counts and lengths. The numbers below come from tools/experiments/cranfield/bm25_example.py. They use Lucene's IDF in natural logs, $k_1 = 1.2$, $b = 0.75$, and lengths counted in tokens after stopping. The 1,400 abstracts average $L_{\mathrm{avg}} = 111.65$ tokens.

Term $\mathrm{df}_t$ $\mathrm{IDF}(t) = \ln\left(1 + \frac{1400 - \mathrm{df}_t + 0.5}{\mathrm{df}_t + 0.5}\right)$
experiment 339 1.4175
studi 240 1.7622
panel 45 3.4272
flutter 56 3.2107

The six highest-scoring abstracts, with the length factor of each:

Rank Abstract Judged Length $L_d$ $L_d / L_{\mathrm{avg}}$ $K = 1.2\,(0.25 + 0.75\, L_d / L_{\mathrm{avg}})$
1 856 relevant 172 1.541 1.6865
2 857 relevant 175 1.567 1.7107
3 766 relevant 192 1.720 1.8477
4 390 not relevant 90 0.806 1.0255
5 858 relevant 149 1.335 1.5011
6 1008 relevant 58 0.519 0.7675

Each term's contribution is $\mathrm{IDF}(t) \times \frac{2.2\, \mathrm{tf}}{\mathrm{tf} + K}$, shown as "tf: contribution":

Abstract experiment studi panel flutter Score
856 4: 2.194 5: 2.899 16: 6.821 11: 6.125 18.038
857 3: 1.986 2: 2.090 16: 6.812 7: 5.676 16.564
766 4: 2.133 0: 0 14: 6.661 10: 5.962 14.756
390 0: 0 2: 2.563 5: 6.257 5: 5.861 14.681
858 3: 2.079 0: 0 11: 6.635 7: 5.816 14.529
1008 1: 1.764 0: 0 6: 6.685 4: 5.926 14.375

One row by hand, for abstract 1008, the shortest: $K = 1.2 \times (0.25 + 0.75 \times 58 / 111.65) = 0.7675$.

  • For panel, $\frac{2.2 \times 6}{6 + 0.7675} = 1.9505$, times 3.4272 gives 6.685.
  • For flutter, $\frac{2.2 \times 4}{4 + 0.7675} = 1.8458$, times 3.2107 gives 5.926.
  • For experiment, $\frac{2.2 \times 1}{1 + 0.7675} = 1.2447$, times 1.4175 gives 1.764.

The sum is 14.375.

Example (six occurrences against fourteen). Abstract 1008 (58 tokens) contains panel 6 times, and abstract 766 (192 tokens) contains it 14 times. The two get almost exactly the same score from panel: 6.685 for abstract 1008 and 6.661 for abstract 766, with the short abstract slightly ahead. Saturation and length normalization both work against the long abstract's extra occurrences. The table shows each mechanism at work.

  • Saturation flattens the rare terms. Panel contributes between 6.26 and 6.82 to every one of these abstracts, whether it occurs 5 times or 16. Its maximum possible contribution is $2.2 \times 3.4272 = 7.54$, and all six are close to it. Once the rare terms are saturated, the common terms experiment and studi decide the ranking among these abstracts. That was also true in the BIM, but now their contributions are graded.
  • Length normalization rescues short documents. Abstract 1008, at half the average length, reaches 1.95 of a possible 2.2 for panel from six occurrences. Abstract 766, at 1.7 times the average, needs fourteen occurrences for 1.94.
  • Lexical evidence has limits. Abstract 390, some panel-flutter studies using piston theory, ranks fourth. It is a theoretical study, so it is not relevant to a request for experiments. But it uses three of the four query words at a short length. No weighting of terms can see that it lacks what experimental asked for, beyond the absence of one word.

Across all 542 abstracts that contain a query term, the nine relevant ones land at ranks 1, 2, 3, 5, 6, 9, 12, 14, and 15. That is an average precision of 0.784, against 0.659 for the BIM without judgments. Setting $k_1 = 0$ turns BM25 back into the BIM with Lucene's IDF, and the average precision returns to exactly 0.659.

The parameters, interactively

The demo scores the same 542 abstracts. Moving $k_1$ reshapes the term frequency curve, and moving $b$ separates the curves for short and long documents. The table shows how the top ten respond.

BM25 on Cranfield query 185. The sliders set k1 and b. The chart shows the term frequency component for documents of half, average, and twice the average length; the table lists the ten highest-scoring abstracts, with R marking the judged relevant ones and the last column showing how far each has moved since the defaults.

Three settings show the two mechanisms:

  • Binary flattens the curve to the BIM's step. The ranking collapses into ties broken by document number.
  • No length norm. merges the three curves. The short abstracts 1008 and 864 drop (from 6th to 8th and from 8th to 13th), and the long relevant abstract 859 rises from 9th to 7th.
  • Raising $k_1$ toward 3 lets abstracts with many occurrences pull ahead.

For this one query, the average precision moves between 0.659 (at $k_1 = 0$) and 0.829 (near $k_1 = 2.5$, $b = 0.7$) over the slider range. A single query is far too little to tune on. Comparing ranking models tunes the two parameters properly over held-out queries.

Tuning

So what values should $k_1$ and $b$ take? Manning, Raghavan, and Schütze suggest $k_1$ (and $k_3$) between 1.2 and 2 and $b = 0.75$ when there is no data to tune on. Lucene's defaults are $k_1 = 1.2$ and $b = 0.75$. With a set of queries and relevance judgments, both parameters can be fitted by grid search against a measure such as MAP or nDCG. The best values depend on the collection: Robertson and Zaragoza (2009, §3.5) give $0.5 < b < 0.8$ and $1.2 < k_1 < 2$ as reasonably good in many circumstances, and add that optimal values depend on the type of documents and queries. One dependence follows from the formula alone. If every document has nearly the average length, then $L_d / L_{\mathrm{avg}}$ is close to 1 for all of them, $B$ is close to 1 whatever $b$ is, and $b$ has little effect on any score. On Cranfield, tuning on half the queries gave $k_1 = 1.5$ (comparing ranking models).

Variants

  • BM25F handles documents with fields such as title, body, and anchor text. It combines weighted term frequencies across fields first and saturates once, instead of adding separate per-field scores.
  • BM25L and BM25+ (Lv and Zhai, 2011a, 2011b) address a bias against very long documents. With strong length normalization, a term in a long document can contribute almost nothing. A long relevant document may then score below a short one that lacks the term. Both variants change the term frequency part, which is all that the comparison below changes. As published they also use an IDF that cannot be negative, close to Lucene's (Kamphuis and colleagues, 2020). This page's experiment keeps Lucene's IDF for all three functions, so that only the term frequency part differs; that is the page's choice, not the authors'. Write $c = \mathrm{tf}/B$ for the length-normalized count, with $B = 1 - b + b\, L_d/L_{\mathrm{avg}}$, so that BM25's part is $\frac{(k_1 + 1)\, c}{k_1 + c}$. For a term that occurs at least once, $$\text{BM25L:}\quad \frac{(k_1 + 1)\,(c + \delta)}{k_1 + c + \delta}, \qquad\qquad \text{BM25+:}\quad \frac{(k_1 + 1)\, c}{k_1 + c} + \delta,$$ and both are 0 for an absent term. For BM25L the authors report $\delta = 0.5$ as the most effective value (Kamphuis and colleagues, 2020); for BM25+ Lv and Zhai (2011b, §7.2) found that a fixed $\delta = 1$ worked well across their collections and proposed it as the default, and it is the value used here. BM25L shifts the normalized count before saturating, and BM25+ adds a constant after. Either way a term that occurs at all contributes at least a fixed positive amount, however long the document.

Example (one occurrence in a very long document). As a document grows, one occurrence of a term is worth less and less under BM25, and the two variants stop the decline. With $k_1 = 1.2$ and $b = 0.75$:

Length, in average lengths 1 2 5 20 100 Limit
BM25 1.000 0.710 0.379 0.114 0.024 0
BM25L, $\delta = 0.5$ 1.222 1.038 0.846 0.705 0.659 0.647
BM25+, $\delta = 1$ 2.000 1.710 1.379 1.114 1.024 1

The limits are read from the formulas with $c \to 0$: 0 for BM25, $\frac{(k_1 + 1)\,\delta}{k_1 + \delta} = \frac{2.2 \times 0.5}{1.7} = 0.647$ for BM25L, and $\delta$ for BM25+. On Cranfield the correction has little to act on, since the longest abstract is 414 tokens, 3.7 times the average. For panel in query 185, BM25L changes abstract 766's part from 1.9435 to 1.9554 and abstract 1008's from 1.9505 to 1.9617. Over all 225 queries with the same IDF, the script measures a mean average precision of 0.307 for BM25, 0.289 for BM25L and 0.283 for BM25+. On this collection of short abstracts the variants rank slightly worse. That is one small collection without the very long documents the variants were designed for, and it says nothing about the collections where Lv and Zhai report gains.

Common misreadings

  • "$k_1$ is the maximum contribution." The maximum of the term frequency component is $k_1 + 1$, and the term's maximum contribution is $(k_1 + 1)\,\mathrm{IDF}(t)$. $k_1$ is better read as the count at which a term in an average-length document earns half of that.
  • "$b = 1$ divides by length." Full normalization divides the count by the relative length before saturating, so a document twice as long needs twice the occurrences for the same score. It does not divide the score by length.
  • "BM25 scores are probabilities." The derivation dropped every constant that would make them so, as the BIM's did. Scores order documents for one query and are not comparable across queries.

Worked problems

The course text sets no exercise on BM25, so these problems are posed on query 185 and on the formula itself, one for each part of the function. The script recomputes every number.

Problem 1. Abstract 390 has 90 tokens and contains studi twice, panel five times and flutter five times, and it lacks experiment. Compute its BM25 score for query 185 with $k_1 = 1.2$, $b = 0.75$ and the IDF values of the table above.

The length factor is $K = 1.2 \times (0.25 + 0.75 \times 90/111.65) = 1.2 \times 0.8546 = 1.0255$. Each present term contributes its IDF times $\frac{2.2\,\mathrm{tf}}{\mathrm{tf} + K}$.

  • studi: $\frac{2.2 \times 2}{2 + 1.0255} = 1.4543$, times 1.7622 gives 2.563.
  • panel: $\frac{2.2 \times 5}{5 + 1.0255} = 1.8256$, times 3.4272 gives 6.257.
  • flutter: the same 1.8256, times 3.2107 gives 5.861.
  • experiment: absent, so 0.

The score is $2.563 + 6.257 + 5.861 = 14.681$, the fourth highest for the query. The abstract is shorter than average, so $K < k_1$ and each count is worth more than it would be at average length.

Problem 2. With $k_1 = 1.2$, how many occurrences does a document of twice the average length need in order to earn the same credit as three occurrences in a document of average length, for $b = 0.75$ and for $b = 1$?

The credit is $\frac{(k_1 + 1)\,\mathrm{tf}}{\mathrm{tf} + K}$, which depends on $\mathrm{tf}$ and $K$ only through the ratio $\mathrm{tf}/K$. Equal credit therefore means equal $\mathrm{tf}/K$. At average length $K = 1.2$, and three occurrences give $\mathrm{tf}/K = 2.5$ and a credit of $2.2 \times 3/4.2 = 1.571$. At twice the average length with $b = 0.75$, $B = 0.25 + 0.75 \times 2 = 1.75$ and $K = 2.1$, so the count needed is $2.5 \times 2.1 = 5.25$. With $b = 1$, $B = 2$ and $K = 2.4$, and the count needed is $2.5 \times 2.4 = 6$, exactly double. In general the count needed is multiplied by $B$: full normalization asks for occurrences in proportion to length, and $b = 0.75$ asks for three quarters of the way there.

Problem 3. In a collection of 1,000 documents a term occurs in 600. Find its weight under the RSJ form of the IDF and under Lucene's, and the contribution of three occurrences in a document of average length under each.

The RSJ form is $\ln \frac{1000 - 600 + 0.5}{600 + 0.5} = \ln 0.6669 = -0.405$. Lucene's is $\ln(1 + 0.6669) = 0.511$. Three occurrences at average length have term frequency part 1.571 (Problem 2), so the contributions are $-0.405 \times 1.571 = -0.637$ and $0.511 \times 1.571 = 0.803$. Under the RSJ form, a document that contains this query term three times scores 0.637 less than one that lacks it, and more occurrences cost more, up to $2.2 \times 0.405 = 0.891$. Lucene's form keeps the contribution positive for every term.

Problem 4. Show that BM25 with $k_1 = 0$ is the binary model, and that with $b = 0$ the term frequency part approaches the raw count as $k_1$ grows.

With $k_1 = 0$, $K = 0$ and the part is $\frac{\mathrm{tf} \times 1}{\mathrm{tf} + 0} = 1$ for every $\mathrm{tf} \ge 1$, and 0 for $\mathrm{tf} = 0$. The score is then the sum of the IDF weights of the query terms present, which is the BIM's retrieval status value with that IDF; on query 185 it gives the BIM's average precision of 0.659 again. With $b = 0$, $K = k_1$ and the part is

$$\frac{\mathrm{tf}\,(k_1 + 1)}{\mathrm{tf} + k_1} = \mathrm{tf} \cdot \frac{1 + 1/k_1}{1 + \mathrm{tf}/k_1} \longrightarrow \mathrm{tf} \quad \text{as } k_1 \to \infty,$$

since both $1/k_1$ and $\mathrm{tf}/k_1$ go to 0 for a fixed count. For five occurrences the part is 4.81 at $k_1 = 100$ and 4.998 at $k_1 = 10{,}000$. So $k_1$ moves the function between the BIM at one end and an unnormalized $\mathrm{tf} \times \mathrm{IDF}$ at the other.

Why it still matters

BM25 has no learned parameters beyond $k_1$ and $b$. It needs no training data, indexes quickly, and explains its scores term by term. On the Cranfield collection, with default parameters, it reaches the highest mean average precision of the classical models compared in comparing ranking models. Implementing BM25 gives a tested implementation.

Neural retrievers outperform it on the collections they were trained on. But the BEIR benchmark (Thakur and colleagues, 2021) tested a varied set of unseen domains. Its authors report that BM25 is a robust baseline there, that re-ranking and late-interaction models achieve the best average results at high computational cost, and that dense and sparse retrievers "often underperform other approaches". Limits of single-vector retrieval gives the paper's table and the conditions under which BM25 wins. Production systems therefore commonly combine the two. BM25 retrieves a candidate set cheaply and a neural model re-ranks it, or the two rankings are fused in hybrid search (rank fusion covers the fusion step). Retrieval-augmented generation systems use the same pattern to find passages for a language model. Learned sparse retrieval keeps BM25's inverted index but lets a trained model set the term weights and add related terms; on Cranfield a pretrained SPLADE model reaches an nDCG@10 of 0.390 against BM25's 0.368, a difference on the edge of what 225 queries can detect ($p = 0.052$).

BM25 also embodies the gap the Probability Ranking Principle leaves open. Its scores are not probabilities. But they track the probability of relevance closely enough, across enough collections, that the ordering they produce is very hard to beat without training data.

What we have learned

BM25 keeps the BIM's weight as the most a term can earn, and earns it gradually. The curve $\mathrm{tf}/(\mathrm{tf} + K)$ takes the 2-Poisson model's shape without its hidden parameters, and the length factor makes a long document need more occurrences for the same credit. On query 185 these changes break the BIM's ties and raise average precision from 0.659 to 0.784.

BM25 treats a document as one bag of words, yet a word in a title is stronger evidence than the same word in the body. Adding a BM25 score per field undoes the saturation we just built. BM25F shows why, and how to combine fields before saturating.

References

  • Kamphuis, C., de Vries, A. P., Boytsov, L., and Lin, J. (2020). Which BM25 do you mean? A large-scale reproducibility study of scoring variants. In Advances in Information Retrieval (ECIR 2020), Lecture Notes in Computer Science 12036, 28–34. record · 2 pages
  • Lv, Y., and Zhai, C. (2011a). When documents are very long, BM25 fails! In Proceedings of SIGIR 2011, 1103–1104. record
  • Lv, Y., and Zhai, C. (2011b). Lower-bounding term frequency normalization. In Proceedings of CIKM 2011, 7–16. record
  • Manning, C. D., Raghavan, P., and Schütze, H. (2008). Introduction to Information Retrieval, section 11.4.3. Cambridge University Press. record · 102 pages
  • Robertson, S. E., and Walker, S. (1994). Some simple effective approximations to the 2-Poisson model for probabilistic weighted retrieval. In Proceedings of SIGIR 1994, 232–241. record · 4 pages
  • Robertson, S. E., Walker, S., Jones, S., Hancock-Beaulieu, M., and Gatford, M. (1995). Okapi at TREC-3. In Overview of the Third Text REtrieval Conference (TREC-3), NIST Special Publication 500-225, 109–126. record · 3 pages
  • Robertson, S., and Zaragoza, H. (2009). The probabilistic relevance framework: BM25 and beyond. Foundations and Trends in Information Retrieval, 3(4), 333–389. record · 8 pages
  • Thakur, N., Reimers, N., Rücklé, A., Srivastava, A., and Gurevych, I. (2021). BEIR: A heterogeneous benchmark for zero-shot evaluation of information retrieval models. In Proceedings of the NeurIPS 2021 Datasets and Benchmarks Track. record · 8 pages

Reviewed: verified, 16 Nov 2026 · citations checked, 16 Nov 2026 · editorial review, 23 Nov 2026 · 14 revisions