Every time you type a query into a search engine, the engine must decide in milliseconds which of millions of documents is most relevant. The simplest idea — count how many times your query words appear in each document — turns out to be surprisingly wrong.
BM25 (Best Match 25) is the probabilistic ranking function that fixed those problems. Proposed by Stephen Robertson and colleagues at City University London around 1994 and refined through the TREC evaluation campaigns, it remained the gold-standard retrieval formula for two decades and is still the default scorer in Elasticsearch, Apache Lucene, and Apache Solr today.
Two ideas do most of the work:
- Term frequency saturation. The first few times a query word appears in a document, it is strong evidence of relevance. The hundredth time adds almost nothing. BM25 squashes diminishing returns with a curve controlled by a parameter (typically 1.2 to 2.0).
- Length normalization. A long document naturally contains more words, so it will mention your query term more often by chance. BM25 divides the raw count by the document length (relative to the corpus average), controlled by a parameter (typically 0.75).
These two corrections transform a naive word-count into a ranking function that matches human relevance judgments far better — and the math behind them traces back to a probabilistic model of how humans actually decide what is relevant.
Comments
Loading comments...