← Glossary AI

BM25

A classic keyword-matching algorithm. The 'old way' of search that still works great.

Explained simply.

BM25 (short for 'Best Match 25') is a math formula for ranking documents by how well they match your keyword query. It's been around since the 1990s. It handles word frequency, document length, and rare-word bonuses in a clever way. Elasticsearch, OpenSearch, and most classic search engines use it as their core scoring function.

An example.

You search 'refund policy' across 10,000 help articles. BM25 ranks articles that use both 'refund' AND 'policy' frequently, but not too frequently (so it doesn't reward keyword stuffing), and bumps up shorter articles over longer ones (less fluff).

Why it matters.

The best modern RAG systems don't use semantic search alone. They combine BM25 (for exact-term precision) with semantic search (for meaning) - this is called 'hybrid search.' BM25 catches the things semantic search misses, like proper names, codes, and exact phrases.