BM25
BM25 is the classic lexical retrieval algorithm — a tuned TF-IDF variant that scores documents by query-term frequency and inverse document frequency, still essential as part of [[hybrid-search]] in 2026.
In more detail
What it means
BM25 (Best Matching 25) scores documents by how often query terms appear in them, weighted by global term rarity and adjusted for document length. It's purely lexical — no semantics — so it misses synonyms and paraphrases that vector embeddings catch. But it dominates on exact-match queries (product codes, names, error messages, technical terms) where embeddings often fail. Modern 2026 RAG pipelines hybrid-search: BM25 + vector retrieval combined via reciprocal rank fusion ([[rrf]]) before reranking. Implementations: Postgres `tsvector`, Elasticsearch / OpenSearch, Tantivy, Qdrant + sparse vectors, MeiliSearch.
Part 1 of 2
When to use it, and when not
Use it for
- Exact-match queries (codes, names, error strings).
- Hybrid search alongside vector retrieval.
Part 2 of 2
Common mistakes
- Skipping BM25 — vector-only retrieval misses exact-match queries.
- Using BM25 alone for semantic queries — synonyms / paraphrases get missed.
FAQ
Questions readers ask.
What is bm25?
BM25 is the classic lexical retrieval algorithm — a tuned TF-IDF variant that scores documents by query-term frequency and inverse document frequency, still essential as part of [[hybrid-search]] in 2026.
When should you use bm25?
Exact-match queries (codes, names, error strings). Hybrid search alongside vector retrieval.
What are the common mistakes with bm25?
Skipping BM25 — vector-only retrieval misses exact-match queries. Using BM25 alone for semantic queries — synonyms / paraphrases get missed.
Last updated: 2026-06-01. Raw markdown: https://promtable.com/glossary/bm25.md. Found a mistake? Tell us.