Interactive companion

The BM25 Evidence Lab

BM25 treats matching words as weighted clues and adds their contributions into a graded score. This laboratory lets you change one source of evidence at a time and watch the ranking respond.

Step 1 of 6

You can skip the prediction, but guessing first is what builds the intuition.

Query & collection

No stemming, no stop-word removal, no phrase or field weighting — plain word matching, so you can see exactly what BM25 itself contributes.

Query terms (the legend)

    Click a term to switch its evidence off. The bar next to each term shows how unusual it is in this collection.

    The collection (6 records)

    Ranked results

    3

    Watch Record D's delulu segment. The first repetitions matter; the twentieth barely registers.

    0

    This adds no matching words at all. Only the document's length changes.

    Why did this score?

    Show the BM25 machinery
    Σ IDF(q) f(q,D) × (k₁ + 1) f(q,D) + k₁ × (1 − b + b × |D| ÷ avgdl)

    What each part means

    f(q,D)How many times the term occurs in this document
    IDF(q)How unusual the term is across the collection
    |D| ÷ avgdlThis document's length relative to the average
    k₁How quickly repetition stops helping
    bHow strongly document length matters

    Advanced parameters

    1.20
    0.75

    Defaults are k₁ = 1.2 and b = 0.75. Nothing in the guided tour depends on changing them. Set b to 0 to switch document-length normalisation off entirely.

    This lab uses the Lucene inverse-document-frequency form, ln(1 + (N − df + 0.5) ÷ (df + 0.5)), which stays positive. Other implementations use variants that can go negative for very common terms, so two systems both described as “using BM25” can rank differently.

    Where this sits in a real search product

    BM25 lexical score — everything in this lab
    +
    field, phrase and proximity boosts
    +
    recency, citations and other static signals
    +
    possible machine-learning reranking
    =
    production search ranking

    Changing k₁ and b here does not reproduce Primo, Scopus or PubMed. Those systems wrap lexical evidence of this kind inside considerably richer pipelines.

    Companion to “How Search Decides What You See”. The collection is deliberately tiny and fully visible so that every number on this page can be checked by hand.