BM25 is a popular and highly efficient ranking function used by many information retrieval systems, including search engines. Its main task is to sort sets of documents (web pages) by their relevance to a specific search query submitted by the user.

The BM25 algorithm is based on a probabilistic model and calculates the degree of match between the query and each document, taking into account several key factors. These include the frequency of occurrence of the query words in the document (Term Frequency – TF) and the Inverse Document Frequency – IDF, which estimates how rare a given word is in the entire collection of documents.

It is important to note that in its standard implementation, the BM25 function does not take into account the relative position of the query words within the document, nor their proximity. That is, regardless of whether the words are scattered throughout the text or grouped together (as a phrase), BM25 treats them as separate terms when assessing relevance. This makes the algorithm fast and efficient, although less sensitive to phrase matches than some more complex models.