Okapi BM25

From HandWiki
Short description: 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

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 [math]\displaystyle{ q_1, ..., q_n }[/math], the BM25 score of a document D is:

[math]\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)} }[/math]

where [math]\displaystyle{ f(q_i, D) }[/math] is the number of times that the keyword [math]\displaystyle{ q_i }[/math] occurs in the document D, [math]\displaystyle{ |D| }[/math] 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. [math]\displaystyle{ k_1 }[/math] and b are free parameters, usually chosen, in absence of an advanced optimization, as [math]\displaystyle{ k_1 \in [1.2,2.0] }[/math] and [math]\displaystyle{ b = 0.75 }[/math].[3] [math]\displaystyle{ \text{IDF}(q_i) }[/math] is the IDF (inverse document frequency) weight of the query term [math]\displaystyle{ q_i }[/math]. It is usually computed as:

[math]\displaystyle{ \text{IDF}(q_i) = \ln \left(\frac{N - n(q_i) + 0.5}{n(q_i) + 0.5}+1\right) }[/math]

where N is the total number of documents in the collection, and [math]\displaystyle{ n(q_i) }[/math] is the number of documents containing [math]\displaystyle{ q_i }[/math].

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

Here is an interpretation from information theory. Suppose a query term [math]\displaystyle{ q }[/math] appears in [math]\displaystyle{ n(q) }[/math] documents. Then a randomly picked document [math]\displaystyle{ D }[/math] will contain the term with probability [math]\displaystyle{ \frac{n(q)}{N} }[/math] (where [math]\displaystyle{ N }[/math] is again the cardinality of the set of documents in the collection). Therefore, the information content of the message "[math]\displaystyle{ D }[/math] contains [math]\displaystyle{ q }[/math]" is:

[math]\displaystyle{ -\log \frac{n(q)}{N} = \log \frac{N}{n(q)}. }[/math]

Now suppose we have two query terms [math]\displaystyle{ q_1 }[/math] and [math]\displaystyle{ q_2 }[/math]. If the two terms occur in documents entirely independently of each other, then the probability of seeing both [math]\displaystyle{ q_1 }[/math] and [math]\displaystyle{ q_2 }[/math] in a randomly picked document [math]\displaystyle{ D }[/math] is:

[math]\displaystyle{ \frac{n(q_1)}{N} \cdot \frac{n(q_2)}{N}, }[/math]

and the information content of such an event is:

[math]\displaystyle{ \sum_{i=1}^{2} \log \frac{N}{n(q_i)}. }[/math]

With a small variation, this is exactly what is expressed by the IDF component of BM25.

Modifications

  • At the extreme values of the coefficient b BM25 turns into ranking functions known as BM11 (for [math]\displaystyle{ b=1 }[/math]) and BM15 (for [math]\displaystyle{ b=0 }[/math]).[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 [math]\displaystyle{ \delta }[/math] (a default value is 1.0 in absence of a training data) as compared with BM25:
[math]\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] }[/math]

References

  1. "OKAPI". https://smcse.city.ac.uk/doc/cisr/web/okapi/okapi.html. 
  2. 2.0 2.1 Stephen Robertson; Hugo Zaragoza (2009). "The Probabilistic Relevance Framework: BM25 and Beyond". Foundations and Trends in Information Retrieval 3 (4): 333–389. doi:10.1561/1500000019. http://dl.acm.org/citation.cfm?id=1704810. 
  3. Christopher D. Manning, Prabhakar Raghavan, Hinrich Schütze. An Introduction to Information Retrieval, Cambridge University Press, 2009, p. 233.
  4. "The BM25 Weighting Scheme". http://xapian.org/docs/bm25.html. 
  5. 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.
  6. 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. https://doi.org/10.1145/1031171.1031181. 
  7. Yuanhua Lv and ChengXiang Zhai. Lower-bounding term frequency normalization. In Proceedings of CIKM'2011, pages 7-16.

General references

External links