menu move to sidebar hide Navigation Main page Contents Current events Random article About Wikipedia Contact us Contribute Help Learn to edit Community portal Recent changes Upload file Special pages Search Search Appearance Donate Create account Log in Personal tools Donate Create account Log in Contents move to sidebar hide (Top) 1 The ranking function 2 IDF information theoretic interpretation 3 Modifications 4 References 5 General references 6 External links Toggle the table of contents Okapi BM25 9 languages Español فارسی Français 日本語 Polski Русский Українська Tiếng Việt 粵語 Edit links Article Talk English Read Edit View history Tools Tools move to sidebar hide Actions Read Edit View history General What links here Related changes Upload file Permanent link Page information Cite this page Get shortened URL Switch to legacy parser Print/export Download as PDF Printable version In other projects Wikidata item Appearance move to sidebar hide From Wikipedia, the free encyclopedia Ranking function used by search engines In information retrieval, Okapi BM25 (BM is an abbreviation of best matching) is a ranking function used by search engines to estimate the relevance of documents to a given search query. It is based on the probabilistic retrieval framework developed in the 1970s and 1980s by Stephen E. Robertson, Karen Spärck Jones, and others. The name of the actual ranking function is BM25. The fuller name, Okapi BM25, includes the name of the first system to use it, which was the Okapi information retrieval system, implemented at London's City University[1] in the 1980s and 1990s. BM25 and its newer variants, e.g. BM25F (a version of BM25 that can take document structure and anchor text into account), represent TF-IDF-like retrieval functions used in document retrieval.[2] The ranking function [edit] BM25 is a bag-of-words retrieval function that ranks a set of documents based on the query terms appearing in each document, regardless of their proximity within the document. It is a family of scoring functions with slightly different components and parameters. One of the most prominent instantiations of the function is as follows. Given a query Q, containing keywords q 1 , . . . , q n {\displaystyle q_{1},...,q_{n}} , the BM25 score of a document D is: score ( D , Q ) = ∑ i = 1 n IDF ( q i ) ⋅ f ( q i , D ) ⋅ ( k 1 + 1 ) f ( q i , D ) + k 1 ⋅ ( 1 − b + b ⋅ | D | avgdl ) {\displaystyle {\text{score}}(D,Q)=\sum _{i=1}^{n}{\text{IDF}}(q_{i})\cdot {\frac {f(q_{i},D)\cdot (k_{1}+1)}{f(q_{i},D)+k_{1}\cdot \left(1-b+b\cdot {\frac {|D|}{\text{avgdl}}}\right)}}} where f ( q i , D ) {\displaystyle f(q_{i},D)} is the number of times that the keyword q i {\displaystyle q_{i}} occurs in the document D, | D | {\displaystyle |D|} is the length of the document D in words, and avgdl is the average document length in the text collection from which documents are drawn. k 1 {\displaystyle k_{1}} and b are free parameters, usually chosen, in absence of an advanced optimization, as k 1 ∈ [ 1.2 , 2.0 ] {\displaystyle k_{1}\in [1.2,2.0]} and b = 0.75 {\displaystyle b=0.75} .[3] IDF ( q i ) {\displaystyle {\text{IDF}}(q_{i})} is the IDF (inverse document frequency) weight of the query term q i {\displaystyle q_{i}} . It is usually computed as: IDF ( q i ) = ln ( N − n ( q i ) + 0.5 n ( q i ) + 0.5 + 1 ) {\displaystyle {\text{IDF}}(q_{i})=\ln \left({\frac {N-n(q_{i})+0.5}{n(q_{i})+0.5}}+1\right)} where N is the total number of documents in the collection, and n ( q i ) {\displaystyle n(q_{i})} is the number of documents containing q i {\displaystyle q_{i}} . There are several interpretations for IDF and slight variations on its formula. In the original BM25 derivation, the IDF component is derived from the Binary Independence Model. IDF information theoretic interpretation [edit] Here is an interpretation from information theory. Suppose a query term q {\displaystyle q} appears in n ( q ) {\displaystyle n(q)} documents. Then a randomly picked document D {\displaystyle D} will contain the term with probability n ( q ) N {\displaystyle {\frac {n(q)}{N}}} (where N {\displaystyle N} is again the cardinality of the set of documents in the collection). Therefore, the information content of the message " D {\displaystyle D} contains q {\displaystyle q} " is: − log n ( q ) N = log N n ( q ) . {\displaystyle -\log {\frac {n(q)}{N}}=\log {\frac {N}{n(q)}}.} Now suppose we have two query terms q 1 {\displaystyle q_{1}} and q 2 {\displaystyle q_{2}} . If the two terms occur in documents entirely independently of each other, then the probability of seeing both q 1 {\displaystyle q_{1}} and q 2 {\displaystyle q_{2}} in a randomly picked document D {\displaystyle D} is: n ( q 1 ) N ⋅ n ( q 2 ) N , {\displaystyle {\frac {n(q_{1})}{N}}\cdot {\frac {n(q_{2})}{N}},} and the information content of such an event is: ∑ i = 1 2 log N n ( q i ) . {\displaystyle \sum _{i=1}^{2}\log {\frac {N}{n(q_{i})}}.} With a small variation, this is exactly what is expressed by the IDF component of BM25. Modifications [edit] At the extreme values of the coefficient b BM25 turns into ranking functions known as BM11 (for b = 1 {\displaystyle b=1} ) and BM15 (for b = 0 {\displaystyle b=0} ).[4] BM25F[5][2] (or the BM25 model with Extension to Multiple Weighted Fields[6]) is a modification of BM25 in which the document is considered to be composed from several fields (such as headlines, main text, anchor text) with possibly different degrees of importance, term relevance saturation and length normalization. BM25F defines each type of field as a stream, applying a per-stream weighting to scale each stream against the calculated score. BM25+[7] is an extension of BM25. BM25+ was developed to address one deficiency of the standard BM25 in which the component of term frequency normalization by document length is not properly lower-bounded; as a result of this deficiency, long documents which do match the query term can often be scored unfairly by BM25 as having a similar relevancy to shorter documents that do not contain the query term at all. The scoring formula of BM25+ only has one additional free parameter δ {\displaystyle \delta } (a default value is 1.0 in absence of a training data) as compared with BM25: score ( D , Q ) = ∑ i = 1 n IDF ( q i ) ⋅ [ f ( q i , D ) ⋅ ( k 1 + 1 ) f ( q i , D ) + k 1 ⋅ ( 1 − b + b ⋅ | D | avgdl ) + δ ] {\displaystyle {\text{score}}(D,Q)=\sum _{i=1}^{n}{\text{IDF}}(q_{i})\cdot \left[{\frac {f(q_{i},D)\cdot (k_{1}+1)}{f(q_{i},D)+k_{1}\cdot \left(1-b+b\cdot {\frac {|D|}{\text{avgdl}}}\right)}}+\delta \right]} References [edit] ↑ "OKAPI". smcse.city.ac.uk. Archived from the original on 2023-12-07. Retrieved 2023-10-16. 1 2 Stephen Robertson & Hugo Zaragoza (2009). "The Probabilistic Relevance Framework: BM25 and Beyond". Foundations and Trends in Information Retrieval. 3 (4): 333–389. CiteSeerX 10.1.1.156.5282. doi:10.1561/1500000019. S2CID 207178704. ↑ Christopher D. Manning, Prabhakar Raghavan, Hinrich Schütze. An Introduction to Information Retrieval, Cambridge University Press, 2009, p. 233. ↑ "The BM25 Weighting Scheme". ↑ Hugo Zaragoza, Nick Craswell, Michael Taylor, Suchi Saria, and Stephen Robertson. Microsoft Cambridge at TREC-13: Web and HARD tracks. In Proceedings of TREC-2004. ↑ Robertson, Stephen; Zaragoza, Hugo; Taylor, Michael (2004-11-13). "Simple BM25 extension to multiple weighted fields". Proceedings of the thirteenth ACM international conference on Information and knowledge management. CIKM '04. New York, NY, USA: Association for Computing Machinery. pp. 42–49. doi:10.1145/1031171.1031181. ISBN 978-1-58113-874-0. S2CID 16628332. ↑ Yuanhua Lv and ChengXiang Zhai. Lower-bounding term frequency normalization. In Proceedings of CIKM'2011, pages 7-16. General references [edit] Stephen E. Robertson; Steve Walker; Susan Jones; Micheline Hancock-Beaulieu & Mike Gatford (November 1994). Okapi at TREC-3. Proceedings of the Third Text REtrieval Conference (TREC 1994). Gaithersburg, USA. Stephen E. Robertson; Steve Walker & Micheline Hancock-Beaulieu (November 1998). Okapi at TREC-7. Proceedings of the Seventh Text REtrieval Conference. Gaithersburg, USA. Spärck Jones, K.; Walker, S.; Robertson, S. E. (2000). "A probabilistic model of information retrieval: Development and comparative experiments: Part 1". Information Processing & Management. 36 (6): 779–808. CiteSeerX 10.1.1.134.6108. doi:10.1016/S0306-4573(00)00015-7. Spärck Jones, K.; Walker, S.; Robertson, S. E. (2000). "A probabilistic model of information retrieval: Development and comparative experiments: Part 2". Information Processing & Management. 36 (6): 809–840. doi:10.1016/S0306-4573(00)00016-9. Stephen Robertson & Hugo Zaragoza (2009). "The Probabilistic Relevance Framework: BM25 and Beyond". Foundations and Trends in Information Retrieval. 3 (4): 333–389. CiteSeerX 10.1.1.156.5282. doi:10.1561/1500000019. S2CID 207178704. External links [edit] "},"url":{"wt":"https://www.staff.city.ac.uk/~sbrp622/papers/foundations_bm25_review.pdf"},"author1-link":{"wt":"Stephen Robertson (computer scientist)"}},"i":0}}]}'/>Robertson, Stephen; Zaragoza, Hugo (2009). The Probabilistic Relevance Framework: BM25 and Beyond (PDF). NOW Publishers, Inc. ISBN 978-1-60198-308-4. Retrieved from "https://en.wikipedia.org/w/index.php?title=Okapi_BM25&oldid=1356130773" Category: Ranking functions Hidden categories: Articles with short description Short description matches Wikidata This page was last edited on 25 May 2026, at 22:33 (UTC). Page was rendered with Parsoid. Text is available under the Creative Commons Attribution-ShareAlike 4.0 License; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy. Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc., a non-profit organization. Privacy policy About Wikipedia Disclaimers Contact Wikipedia Legal & safety contacts Code of Conduct Developers Statistics Cookie statement Mobile view Search Search Toggle the table of contents Okapi BM25 9 languages Add topic