# Okapi BM25

> The standard way to rank pages in keyword search.

**Field:** Artificial Intelligence  
**Category:** Retrieval & Search  
**Also known as:** BM25, Best Matching 25

## Think of it like

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

## 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.

## 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.

## 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.

## Three principles

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

## Related terms

- [Keyword Search](https://learn.benibix.com/term/ai/keyword-search)
- [Term Frequency-Inverse Document Frequency (TF-IDF)](https://learn.benibix.com/term/ai/tf-idf)
- [Hybrid Search](https://learn.benibix.com/term/ai/hybrid-search)
- [Inverted Index](https://learn.benibix.com/term/ai/inverted-index)
- [Sparse Vector](https://learn.benibix.com/term/ai/sparse-vector)

![A curve of score against how many times a word appears in a page. It rises fast at first, then flattens out, so the tenth use adds far less than the first.](https://learn.benibix.com/diagrams/rt-bm25.svg)

---

Source: https://learn.benibix.com/term/ai/okapi-bm25
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-18
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
