BM25
Also Okapi BM25 · Best Match 25
BM25 is the tf.idf-style posting score tf* · log2(N / df) whose modified term frequency tf* = tf · (k + 1) / (k · α + tf), α = 1 − b + b · DL / AVDL, saturates in tf and normalizes by document length.
Formula#
The idf factor is the same as in tf.idf; only is replaced by . Rewriting shows that acts as a normalization of :
Parameters:
- controls the length normalization: gives (none), gives (full, “too extreme”); interpolates between the two.
- controls the saturation: as .
- Standard setting: , .
Special cases (lecture):
- : for every (binary: presence only), so the score is the idf.
- , : and , i.e. plain tf.idf. (For general , , a length-normalized tf.)
Properties#
Plausibility argument for (DBIS_VL02 > Plausibility argument): the “simplest” function with
- ,
- increasing in (strictly for ),
- a fixed limit () as (fixes the linearity problem of tf.idf),
for any ; choosing from fixes the length problem.
| Property | tf.idf | BM25 |
|---|---|---|
| tf factor | , unbounded and linear | , saturating |
| Length normalization | none | via (strength ) |
| idf factor | same | |
| Use | simple baseline | standard, outperformed other formulas on benchmarks for many years |
Implementation (DBIS_VL02 > Implementation advice): build the inverted lists with tf scores, compute per document and in the same pass, then make a second pass over the lists and replace each tf by , where is the length of the list.
Vector space view: with BM25 scores as entries of the term-document matrix , the dot product gives exactly the same ranking as the inverted-index ranking (DBIS_VL11 > Variant 1: dot product with BM25 scores); BM25 already accounts for document length, which the plain dot product with tf would not.
Example#
Sources#
- Slides 02, p. 14 (problems of tf.idf), Slides 02, p. 15 (formula), Slides 02, pp. 16–17 (plausibility), Slides 02, p. 18 (implementation)
- Slides 03, p. 5 (ES2 tuning results), Slides 11, p. 11
- DBIS_VL02 > BM25, DBIS_VL03 > Organisation, DBIS_VL11 > Variant 1: dot product with BM25 scores
- Exams: DBIS Exam WS2324-2 (not published) Task 1.1