BM25
The standard keyword-search ranking formula: it scores documents by how often query words appear, weighting rare words more.

BM25 is the standard ranking formula for keyword search: it scores documents by how often the query words appear in them, weighting rare words more and correcting for document length. It needs no AI model, runs on ordinary servers and remains the baseline that newer search methods are measured against.
BM25 dates from the 1990s and is still the default ranking in engines such as Elasticsearch and OpenSearch. It rewards rare terms, dampens repeated ones and corrects for document length. Two parameters control this, k1 for how fast repeated words stop adding score and b for length normalization (Elasticsearch defaults: 1.2 and 0.75). It needs no model and no GPU, and it is exact on product codes, names and numbers, where embeddings are weak.
It does not understand synonyms, which is why hybrid search combines it with vector search. Anthropic’s Contextual Retrieval setup adds BM25 next to embeddings for exactly this reason. Before paying for semantic search, run BM25 on a golden dataset of real queries and see how far it already gets.
Sources
- Elastic: Similarity settings elastic.co
- Anthropic: Contextual retrieval in AI systems anthropic.com
Related terms
- Hybrid search: Combining keyword search (such as BM25) with vector search, so results match both exact terms and meaning.
- Semantic search: Search that matches by meaning instead of exact words, by comparing embeddings of the query and the documents.
- Embeddings: Vectors of numbers that place texts with similar meaning close together.
- RAG (retrieval-augmented generation): Finding relevant documents first and putting them into the prompt, so the model answers from them.
- Golden dataset: A fixed set of real inputs with expected answers or checks, used to test an AI feature after every prompt or model change.
- MRR and nDCG: Ranking metrics for search: MRR scores how high the first relevant result appears, nDCG scores the order of the whole result list.
- Inverted index: A map from each word to the list of documents that contain it; the structure behind keyword search engines and BM25.
