Skip to content
BENIBIX Learn

Okapi BM25

Also known as BM25, Best Matching 25

The standard way to rank pages in keyword search.

Think of it like

Think of it like a judge. A word wins points, but each time it shows up again, it wins less.

Example

Two pages mention 'solar panel'. One uses it 3 times in 200 words, the other 30 times in 20,000 words. BM25 ranks the short, focused page higher.

Why it matters

It scores most keyword search. It is also the keyword half of most hybrid search.

Definition

Okapi BM25 is the standard formula for ranking documents in keyword search. It gives a page more points when it uses a query word, but each extra use adds less than the one before. Rare words count for more than common ones. Long pages are scaled down, so they do not win just by being long. It dates from the 1990s and is still the default in most search engines.
The first few uses of a word add a lot. After that, each extra use adds very little.

Common mistake

Assuming more mentions always mean a better match. BM25 caps the gain, which is why stuffing a page with a word does little.

Key takeaways

  1. 1
    Rare words count more. Common words count less.
  2. 2
    Repeats add less. The gain flattens out.
  3. 3
    Length is evened out. Long pages get no free win.