Reference · Cheat sheet

BM25 scoring

The compressed essence. Print it, pin it.

From lesson 0002See also glossary

score(t,D) = IDF(t) · f(t,D) · (k1 + 1) f(t,D) + k1 · (1 − b + b · |D|avgdl)    summed over query terms

IDF(t) = ln(1 + (N − n + 0.5) / (n + 0.5))

Three intuitions

PartSaysIn the formula
IDFRare terms matter moreln(1 + (N−n+0.5)/(n+0.5))
TF saturationRepetition helps, with diminishing returnsfraction → ceiling (k1+1)
Length norm.Short fields count moreb · |D|/avgdl in denominator

The two knobs

KnobDefaultControlsExtremes
k11.2TF saturation rate0 = ignore frequency; higher = saturate slower
b0.75Length normalization0 = ignore length; 1 = full penalty

Gotchas

Debugging

GET /index/_explain/<id>        // full BM25 breakdown for one doc
{ "query": { "match": { "title": "tuning" } } }

GET /index/_search?explain=true  // per-hit explanation inline

← lesson 0002 · Source: Connelly — Practical BM25, Part 2