Data & databases

BM25

AI-assisted editorial review:

BM25 is a lexical retrieval scoring method that ranks documents using query-term matches, term rarity, term-frequency saturation, and document-length normalization. Parameters k1 and b control saturation and length normalization respectively.[1] It can complement vector retrieval in a hybrid search system.[3]

What does BM25 mean in simple terms?

Repeated search words can help a document rank, but repeating them does not increase the score without limit. Length adjustment also helps avoid rewarding a long document merely because it contains more words.

How can BM25 be explained with an analogy?

A librarian counts matching words, discounts endless repetition, and takes the book’s length into account.

Where is BM25 used?

Case 1

Elasticsearch — A documented default

Elastic states that Elasticsearch switched its default similarity to BM25 in version 5.0.[2] Lucene 6.0.0 documents k1=1.2 and b=0.75 as defaults.[1] Treat these as implementation settings, not universally optimal values.

Case 2

Anthropic — Contextual retrieval experiment

Anthropic’s 2024 experiment added context to chunks and combined contextual embeddings with contextual BM25. For its top-20 evaluation and selected embedding configuration, retrieval failure fell from 5.7% to 2.9%, a 49% relative reduction.[3] This is an experimental result, not a promised gain for every corpus.

Case 3

BEIR — A useful baseline

The 2021 paper evaluated 18 datasets and identified BM25 as a robust baseline. Reranking and late-interaction approaches performed best on average in that evaluation, with higher computational costs.[4] Compare relevance and cost on your own domain.

Case 4

NAVER Place — Hybrid backoffice search

The team’s November 2025 account describes a backoffice agent using lexical and dense retrieval, including BM25-based sparse vectors in Milvus, with OpenSearch storing raw documents and logs.[5] The article reports whole-system improvements; they should not be attributed to BM25 alone.

Try it today

  1. Choose permitted documents and representative user questions.
  2. Inspect whether relevant documents appear near the top.
  3. Compare lexical and vector results, especially exact names and synonyms.
  4. Change one parameter at a time and record relevance and latency.
  5. Evaluate a hybrid or reranked system against the same questions.

Limits and direction

Lexical matching depends on analyzed terms. Tokenization, language, synonyms, and query construction matter. Do not infer that the surrounding search engine cannot support phrase or proximity queries merely because BM25 is its scorer.[1]

Hybrid retrieval is one option, not a universal requirement. Microsoft documents BM25 defaults for newer Azure AI Search services and separate behavior for older services.[6] Verify the actual product and index configuration, then measure quality, computation, and cost.

Which sources explain BM25?

  1. Apache Lucene6.0.0 — BM25Similarity — https://lucene.apache.org/core/6_0_0/core/org/apache/lucene/search/similarities/BM25Similarity.html
  2. Elastic — Practical BM25 Part1 — https://www.elastic.co/blog/practical-bm25-part-1-how-shards-affect-relevance-scoring-in-elasticsearch
  3. Anthropic — Contextual Retrieval — https://www.anthropic.com/engineering/contextual-retrieval
  4. Thakur et al. — BEIR — https://arxiv.org/abs/2104.08663
  5. NAVER Place development blog — Backoffice AI Agent — https://medium.com/@mjsk0583/backoffice-ai-agent-구축기-rag-mcp-기반-플레이스ai-특화-지식-검색-시스템-9a66b4afa1aa
  6. Microsoft — Configure BM25 relevance scoring — https://learn.microsoft.com/en-us/azure/search/index-ranking-similarity