liveBook · Manning

BM25

As explained in Generative AI in Action

BM25 is a probabilistic ranking function that estimates document relevance to a query using term frequency, inverse document frequency, document length, and term-frequency saturation.

BM25 ranks documents by estimating query relevance from term frequency, inverse document frequency, document length, and term-frequency saturation. It is a sparse retrieval option for retrieval-augmented generation when queries closely match document wording and speed matters. section 7.4

Choose BM25 by balancing retrieval behavior and operational constraints:

  • Prefer sparse retrieval when computational efficiency is important or query terms are expected to match document text closely. section 7.4
  • Contrast BM25 with TF-IDF, which lacks BM25’s additional treatment of document length and term-frequency saturation. section 7.4
  • Consider dense retrieval such as DPR when semantic matching and nuanced language understanding outweigh computational cost. section 7.4

How Generative AI in Action covers it

How deep it goes
Defines ranking inputs and contrasts alternatives but stops short of mathematical derivation or implementation details.
Examples
Uses query-term frequency, inverse document frequency, document length, and term-frequency saturation as ranking signals.
What you can do after
Evaluate/understand retriever choices using lexical matching, semantic understanding, computational efficiency, and resource availability.
How it connects
Connects BM25 with sparse retrieval, TF-IDF, dense retrieval, DPR, and retrieval-augmented generation.

Also explained in

Compare how 5 books explain BM25 →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Generative AI in Action. The section links point to the parts of the book it draws on.