BM25
Definition
A classic keyword relevance function that scores documents by term frequency and rarity, adjusted for document length. Still a strong baseline.
In more detail
BM25 is the default ranking in search engines such as Elasticsearch and OpenSearch. It is fast, needs no model, and remains a strong baseline that vector search does not always beat.
BM25 scores a document higher when it contains the query terms, more so for rare terms, with diminishing returns for repeated words and a correction for document length. It does not understand synonyms or paraphrases, which is the gap embeddings fill. That is why most production retrieval combines both, and why contextual retrieval adds context to chunks before indexing them in BM25 as well as in the vector store.
Related terms
Hybrid search
Combining keyword search, such as BM25, with vector search and merging the results into one ranking, often with reciprocal rank fusion.
Reciprocal rank fusion (RRF)
A way to merge ranked result lists into one by scoring each document on its positions in the lists, not their raw scores.
Semantic search
Search that ranks results by how close their meaning is to the query rather than by shared keywords, usually by comparing embeddings.
Read more about BM25
- Embeddings and vector search
Turning text into vectors to find similar items, alone or with keywords.
- Hybrid search
Combining keyword search, such as BM25, with vector search and merging the results into one ranking, often with reciprocal rank fusion.
- Contextual retrieval
Adding a short, model-written note on where each chunk sits in its source document before embedding and indexing the chunk.