Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
World desk4 min

How BM25 Ranks Search Results—and What Its Settings Change

BM25 ranks lexical search results using term frequency, term rarity and document-length normalization. Learn what its score means, how k1 and b affect it, and how it fits alongside vector retrieval and reranking.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

BM25 ranks documents by weighing how often a query term appears, how rare that term is across the collection, and how long the document is. Repeated matches help, but their contribution levels off; a match in a long document is also treated differently from the same count in a short one. The result is a ranking score—not a calibrated probability that a document is relevant.

What BM25 is

BM25, often called Okapi BM25, is a lexical ranking function in the probabilistic relevance framework. “Lexical” means it works with query terms and terms found in documents: it can reward a document for containing the words a person searched for, but it does not by itself establish that two differently worded passages mean the same thing.

As an Amazon Associate I earn from qualifying purchases.

For each query, BM25 supplies a score that a search system can use to order candidate documents. The score is useful for comparing results within a search, but should not be read as a percentage chance of relevance.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How BM25 builds a score

BM25 combines three kinds of evidence. Their effects interact: a query term’s contribution depends both on its frequency in a document and on how that document compares in length with the collection.

Term frequency: matches help, then saturate

Term frequency is the number of times a query term occurs in a document. More occurrences can raise its contribution, but with diminishing returns. The first few occurrences can matter more than many additional repetitions, so simply repeating a keyword does not increase the score without limit.

Inverse document frequency: rare terms can distinguish results

Inverse document frequency reflects how widely a term appears across the document collection. A term found in relatively few documents can provide more distinguishing evidence than a very common term. The collection matters: a word’s rarity, and therefore its usefulness as a discriminator, depends on which documents are indexed.

Length normalization: counts are read in context

BM25 adjusts term-frequency contribution in relation to document length and the collection’s average document length. This helps prevent raw counts from being interpreted identically in a short document and a much longer one. It does not mean long documents are automatically penalized out of the results; it changes how term matches contribute to the score.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What the BM25 settings k1 and b mean

Implementations expose parameters that adjust the scoring behavior. In Elasticsearch’s similarity reference, k1 controls nonlinear term-frequency saturation, while b controls the degree of document-length normalization. That reference lists defaults of k1 = 1.2 and b = 0.75; these are Elasticsearch documentation defaults, not universal constants or evidence that those values are best for every collection.

Changing k1 changes how quickly the benefit from repeated term occurrences levels off. Changing b changes how strongly document length affects the term-frequency contribution. The practical effect depends on the corpus, fields, analyzer, and queries, so parameter changes should be judged against relevance judgments for the intended search task rather than assumed to improve results.

BM25 compared with TF-IDF

Both BM25 and TF-IDF use term frequency and term rarity as signals. BM25’s characteristic treatment includes diminishing returns for repeated occurrences and document-length normalization. That distinction makes BM25 more than a direct count of matching words, but it does not make it a universal replacement for every retrieval method. A useful comparison depends on the implementation and on evaluation against the documents and queries the system actually serves.

Where BM25 fits in a modern search pipeline

BM25 remains useful for full-text retrieval: it can find and rank candidates with matching terms. In Elasticsearch and Lucene, documentation identifies BM25 as the default similarity; Elastic describes its default algorithm as “The algorithm used by default in Elasticsearch and Lucene.” Defaults and available settings should be checked against the version actually deployed.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

BM25 need not be the only retrieval signal. Search systems can combine lexical results with vector-search results in a hybrid approach, then apply a later reranking stage. These stages serve different roles: lexical retrieval rewards term matches, vector retrieval can surface semantic similarity, and reranking can reorder a candidate set. None is established as the winner for all queries or collections; evaluate the full pipeline on the target task.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

How BM25F handles documents with multiple fields

When documents have distinct fields—such as a title and body—a single undifferentiated text representation may not express how much each field should matter. BM25F is a conceptual extension for structured or multi-field documents. It can accumulate term evidence across fields while applying field-specific weights and length normalization. The specific API and implementation details vary, so consult the documentation for the search library in use.

How to decide whether to tune BM25

  1. Define the search task. Identify the queries, documents, and relevance criteria that matter to users; a parameter setting cannot be judged without a target.
  2. Establish a baseline. Record results with the implementation’s current settings and evaluate them on representative queries and relevance judgments.
  3. Change one factor at a time. Test adjustments to term-frequency saturation or length normalization separately, so their effects can be interpreted.
  4. Compare the outcomes. Use a suitable relevance metric and inspect failures as well as aggregate results. A gain on one query type can coincide with a regression on another.
  5. Evaluate the whole pipeline. If hybrid retrieval or reranking is involved, assess those stages together with BM25 rather than attributing every result change to the lexical score alone.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.