BM25
The conceptWhy searching 'the platypus' ignores the word 'the'
BM25 is a rule that ranks documents for a keyword search. Each query word adds to a document's score: more if the word appears, more if it is rare, less if the document is very long.
Rare words count most. Almost every page has 'the', so it adds almost nothing; few have 'platypus', so it adds a lot. This rarity weight is called IDF (inverse document frequency).
What it’s forScores how well one document D matches a search query, so results can be sorted.
score(D) = Σ IDF(q) · f·(k₁+1) / (f + k₁·(1 − b + b·|D|/avgdl))
- IDF(q)
- how rare query word q is across all documents; rare words weigh more
- f
- how many times q appears in document D
- k₁, b
- tuning knobs, typically k₁ ≈ 1.2 (how fast repeats stop helping) and b = 0.75 (how much length counts)
- |D|/avgdl
- this document's length divided by the average document length
What it givesOne number per document; higher means a better match, and results are shown in that order.
- Take k₁ = 1 and b = 0, so the word part is f·2/(f+1).
- f = 1 gives 2/2 = 1; f = 3 gives 6/4 = 1.5.
- f = 9 gives 18/10 = 1.8: nine mentions score less than twice one mention.