# BM25

- **Canonical URL:** https://getaimath.com/dictionary/bm25/
- **Topics:** [Context, Memory & Retrieval](https://getaimath.com/dictionary/category/context-memory-and-retrieval/)
- **Last updated:** 2026-11-25

## What is BM25?

**In one sentence:** BM25 is a classic keyword-based ranking formula that scores documents by how often and how importantly query words appear.

It gives more weight to rare words and does not over-reward documents that repeat a word many times. It has powered search engines for decades and is still very strong.

![Context Window vs. Memory: Your Desk vs. The Filing Cabinet — Simple cartoon comparing the AI Context Window (a small desk that can only fit a few pages right now) with External Memory & Search (a big filing cabinet where a librarian grabs just the 3 pages you need).](https://getaimath.com/diagrams/context-memory-and-retrieval.png)
*Napkin Diagram (Context, Memory & Retrieval): The context window is the small desk the AI can see right now; search grabs the right pages from the filing cabinet.*

## What is an example of BM25?

For "purple elephant," BM25 ranks pages that mention the rare word "elephant" higher than ones that just say "purple."

## Why does BM25 matter?

BM25 is a reliable baseline and a key part of hybrid search.

## Related Concepts

- [Dense Retrieval](https://getaimath.com/dictionary/dense-retrieval/): Dense retrieval finds documents by comparing embeddings, where every number in the vector has a value.
- [Sparse Retrieval](https://getaimath.com/dictionary/sparse-retrieval/): Sparse retrieval finds documents by matching words, using long lists that are mostly zeros except for the words present.
- [Hybrid Search](https://getaimath.com/dictionary/hybrid-search/): Hybrid search combines keyword search and semantic vector search to get better results than either alone.
- [Relevance Score](https://getaimath.com/dictionary/relevance-score/): A relevance score is a number showing how well a result matches a search query.
- [Reranking](https://getaimath.com/dictionary/reranking/): Reranking reorders search results with a more careful model so the most relevant ones end up on top.
- [Chunk Overlap](https://getaimath.com/dictionary/chunk-overlap/): Chunk overlap repeats a little text between neighboring chunks so ideas split at the edges are not lost.

---
Source: The AI Math Dictionary (https://getaimath.com/dictionary/bm25/)
