BM25
BM25 (Best Match 25) is a classic ranking algorithm widely used in information retrieval, belonging to the probabilistic retrieval model family. It calculates relevance scores between query terms and documents based on factors including term frequency (TF), inverse document frequency (IDF), and document length normalization, and is used to rank search results. BM25 is recognized for its robust keyword matching capability, commonly serves as a baseline algorithm for text retrieval systems, and can be combined with semantic retrieval methods.
Core Facts
混合检索(Hybrid Search)将向量检索与BM25关键词检索的结果通过RRF(倒数排名融合)等算法合并,兼顾语义理解与精确匹配
BM25 (Best Matching 25) is a probabilistic ranking algorithm proposed by Stephen Robertson and others in the 1990s, scoring relevance based on three factors: term frequency, inverse document frequency, and document length normalization.
BM25 is a classic keyword retrieval algorithm based on term frequency statistics, which is complementary to vector retrieval.
Timeline (last 90 days)
Multi-way retrieval combines vector retrieval, keyword retrieval (such as BM25), knowledge graphs and other methods, complementing the blind spots of different retrieval approaches.
The team's testing found that BM25's keyword relevance hit exact-match trade review historical lessons more reliably than fuzzy cosine similarity in high-dimensional embedding space.
Current mainstream retrieval approaches rely on lexical matching (such as BM25) or dense vector similarity, both of which operate in a predefined representation space, and the upper bound of retrieval quality is determined by that space.
The study's retrieval pipeline fused dense vectors, BM25, and cross-encoder reranking, and systematically compared chunk sizes from 128 to 1024 tokens, overlap rates from 0 to 20%, and four retriever configurations.
Keyword matching splits a query into terms and relies on inverted indexes and statistical signals such as TF-IDF or BM25 to judge relevance; semantic matching encodes the entire context into a dense vector and measures semantic closeness with cosine similarity.
BM25 builds on TF-IDF by introducing document length normalization and term frequency saturation, making it more robust for job descriptions of varying length.
In a freeCodeCamp course, Beau Carnes demonstrated combining BM25 keyword search with vector search inside PostgreSQL and merging the two result sets using reciprocal rank fusion (RRF).
The timings in the course show the native full-text search query at about 0.3 milliseconds and the BM25 query at about 9 milliseconds, but the author explicitly states this does not mean which is faster, because the former returns zero rows and the latter returns 10 rows.
pgTextSearch is an open-source extension under the PostgreSQL license that provides BM25 ranking; the query operator is <@>, which returns the negative of the BM25 score, so sorting must be done in ascending order.
BM25 requires global statistics (document frequency, average document length), so it usually needs support from a dedicated index structure, whereas PostgreSQL's built-in ts_rank lacks whole-database document frequency statistics.
40 more timeline events
All Facts (20)
混合检索(Hybrid Search)将向量检索与BM25关键词检索的结果通过RRF(倒数排名融合)等算法合并,兼顾语义理解与精确匹配
90%VerifiedBM25 (Best Matching 25) is a probabilistic ranking algorithm proposed by Stephen Robertson and others in the 1990s, scoring relevance based on three factors: term frequency, inverse document frequency, and document length normalization.
80%VerifiedBM25 is a classic keyword retrieval algorithm based on term frequency statistics, which is complementary to vector retrieval.
80%VerifiedBM25 and TF-IDF are classic representatives of lexical retrieval, based on literal keyword matching and term frequency statistics.
75%VerifiedHybrid retrieval (combining dense vector retrieval with BM25 sparse retrieval) performs better than either method alone on most benchmarks.
75%VerifiedHybrid Search combines Dense Retrieval with sparse retrieval (BM25).
75%VerifiedBM25是一种基于词频统计(TF-IDF改进版)的经典信息检索算法,属于稀疏检索方法
75%VerifiedBM25 remains the default ranking algorithm for mainstream search engines such as Elasticsearch and Lucene.
75%VerifiedThe core mechanism of BM25 is based on three factors: term frequency (TF), inverse document frequency (IDF), and document length normalization, with parameter k1 typically set between 1.2 and 2.0 and b typically set at 0.75.
65%VerifiedBM25 is a bag-of-words model that focuses only on term frequency without understanding word order or semantics, but is more reliable for exact term matching and does not suffer from the semantic drift problem of vector retrieval.
65%VerifiedHybrid Search combines dense vector semantic similarity with BM25 sparse keyword matching, with results from both paths re-ranked by a Re-Ranker model before being injected into the LLM context.
65%Verified重排序(Re-ranking)机制在初步检索后引入交叉编码器(Cross-Encoder)对候选文档重新打分,提升输入大模型的上下文质量
65%VerifiedHybrid retrieval, which fuses BM25 keyword scores with vector similarity scores through weighted combination (typically using the RRF reciprocal rank fusion algorithm), has become the mainstream paradigm for RAG systems.
65%VerifiedHybrid retrieval combines BM25 sparse retrieval with dense vector retrieval, merging ranking results via RRF or linear weighting.
65%VerifiedBM25 is more stable and reliable than vector retrieval in exact lexical matching scenarios (such as product model numbers, proper nouns, and contract clause numbers)
65%VerifiedIn actual production, hybrid retrieval combining both vector similarity and keyword matching is typically used.
65%UnverifiedTraditional search systems mostly rely on statistical algorithms like TF-IDF or BM25 that rank results by term frequency and uniqueness in documents
90%UnverifiedContext Mode使用BM25算法检索相关内容,生成不超过2KB的Session Guide
85%UnverifiedHybrid retrieval combining vector similarity and keyword-based BM25 can significantly improve recall accuracy.
70%UnverifiedBM25 is a probabilistic retrieval model proposed by Robertson et al. in the 1990s and is the core ranking algorithm of search engines such as Elasticsearch.
60%