Sistava

What is BM25?

Also called Okapi BM25.

BM25 is a ranking function that scores how well a document matches a keyword query, based on how often query terms appear in the document, how rare those terms are across the collection, and how long the document is. Developed from probabilistic retrieval research in the 1990s, it remains the default lexical baseline in search engines and retrieval benchmarks.

Three ingredients drive the score. Term frequency rewards documents that mention a query term repeatedly, but with saturation, so the tenth mention adds far less than the second. Inverse document frequency rewards rare terms, so a match on an unusual word counts for much more than a match on a common one. Length normalization prevents long documents from scoring highly simply because they contain more words.

Two tunable constants control this behavior. One sets how quickly term frequency saturates, and the other sets how strongly document length is penalized. Defaults around 1.2 and 0.75 work well across many collections, which is part of why BM25 is treated as a strong out-of-the-box baseline that needs no training data and no model inference at query time.

BM25 remains competitive because it is cheap, transparent, and hard to beat on queries dominated by specific terms. Retrieval papers routinely report it alongside neural systems, and it is common for a well tuned lexical baseline to outperform an off-the-shelf embedding model on domains full of technical identifiers. Its scores are unbounded and collection dependent, so they cannot be compared across indexes without normalization.

In modern pipelines BM25 usually serves as one branch of a hybrid retriever. Its ranked list is merged with an embedding based list, often through reciprocal rank fusion, which sidesteps the incompatible score scales by combining ranks instead of raw scores. Many search engines and vector databases now ship BM25 scoring built in for exactly this purpose.

Key points

In practice

A query for quarterly revenue recognition policy is scored against a filing archive. A short accounting note that mentions recognition four times outranks a two-hundred-page annual report that mentions it twelve times, because length normalization discounts the long document and term frequency saturation limits the reward for repetition. The common word policy contributes little, since nearly every document contains it.

Related terms

Back to the AI Glossary