BM25 and RAG: An Engineering Review by an AI Architect
This article examines the use of BM25 in production: fast retrieval of precise data, its dependence on collection statistics, and rules for combining it with neural search.

BM25 precomputes word weights for documents, so during search, it is sufficient to select the necessary coordinates of the sparse matrix and sum them. However, its score is not a probability and is not comparable across collections or different points in time.
Adding or removing documents alters global metrics, including the average document length, which requires the index to be recalculated or allows for statistical drift. In a distributed system, local scores across shards may also differ. Fixed thresholds for scores are unreliable: the score increases with query length, so the author recommends relative normalization.
In the EntityQuestions test, BM25 found the correct answer in 72% of cases, compared to 49.7% for neural search, excelling particularly with surnames, case numbers, and other exact identifiers. For a hybrid system, a weighted sum of scores is preferable, though after fine-tuning the neural network, weights must be recalibrated.
Practical results depend more on tokenization, morphology, and document segmentation than on choosing between BM25L or BM25+ variants. Scores from different libraries are also not directly comparable: formulas and parameters vary.





