BM25

AI & Retrieval
Best Matching 25 (keyword ranking)
Also: keyword search, lexical search

BM25 is a classic ranking function for keyword search. It scores a document by how often the query's words appear in it, adjusted so common words count for less and very long documents do not get an unfair advantage. It has been a search workhorse for decades.

On text full of exact terms (names, codes, figures, dates) BM25 often matches or beats modern embedding search, because precise words are a strong signal and embeddings can blur them. It is one half of a hybrid retrieval setup.

Where it comes up