BM25 (Best Matching 25)
BM25 is the canonical sparse-retrieval algorithm: a TF-IDF variant that saturates term frequency (a token appearing 100 times isn't 100× more relevant than once) and normalizes by document length. Default scorer in Lucene, Elasticsearch, OpenSearch, and Tantivy.
BM25 is decades old, requires no training, and runs on any corpus with a tokenizer. For exact-match and rare-vocabulary queries it often beats much-fancier neural retrievers; that's why hybrid retrieval keeps it.
Tunable knobs: k1 (term frequency saturation, typically 1.2–2.0) and b (length normalization, 0.75 default). Domain tuning rarely helps beyond defaults for general corpora.
Practical example
An operator setting up local search over API documentation notices that queries for exact parameter names like max_tokens or top_p return poor results from their dense embedding index, so they add an Elasticsearch BM25 index alongside it as part of a hybrid retrieval setup. Because BM25 needs no training and no GPU, it's trivial to stand up locally — index the docs, and queries run in milliseconds on CPU. They leave k1 and b at Elasticsearch's defaults (1.2 and 0.75) since tuning rarely moves the needle for a general documentation corpus, and instead spend the effort on chunking strategy, which has a much bigger effect on BM25 recall than parameter tuning does.
Related terms
Reviewed by Eruo Fredoline. See our editorial policy.