A team builds the keyword-matching stage of a hybrid RAG pipeline using BM25 rather than a plain raw term-count match against a query like 'database backup schedule.' Beyond simply counting how many times each query term appears in a candidate document, BM25's score is shaped by two additional factors. What are those two factors, and what problem does each one correct for?
- It multiplies the raw term count by the number of images embedded in the document and divides by the file's total byte size, correcting for documents that pad their length with non-text media
- It replaces the term counts with a cosine similarity between a dense embedding of the query and a dense embedding of the document, correcting for exact keyword matching having no notion of semantic relatedness
- It gives more weight to a query term the rarer that term is across the whole document collection, so a distinctive word contributes more than a generic one, and it dampens the raw term-frequency contribution as a document's length grows past the collection's average, so a document cannot win purely by being long; the first corrects for common terms being uninformative, and the second corrects for a length-driven bias
- It only scores a query term if it appears inside the document's title field, correcting for body text carrying a less reliable signal than titles
Why C? And why not the others?
Correct answer: C. It gives more weight to a query term the rarer that term is across the whole document collection, so a distinctive word contributes more than a generic one, and it dampens the raw term-frequency contribution as a document's length grows past the collection's average, so a document cannot win purely by being long; the first corrects for common terms being uninformative, and the second corrects for a length-driven bias
BM25 scores a query term's contribution using an inverse-document-frequency weight, so a term that appears in only a few documents across the whole collection counts for more than a term that appears almost everywhere, which corrects for common, uninformative terms otherwise inflating scores just as much as distinctive ones. It also saturates the raw term-frequency contribution using a length-normalization parameter (commonly denoted b) that compares a document's length to the collection's average length, so a document cannot rack up an artificially high score purely by being long and repeating terms more often. The option about image counts and byte size is wrong because BM25 operates purely on term statistics within text, with no notion of embedded media. The option describing a dense-embedding cosine similarity is wrong because that describes a semantic retrieval method entirely separate from BM25, which stays lexical and never computes embeddings. The option restricting scoring to the title field is wrong because BM25 scores terms wherever they appear in the indexed text field, not only within a title.
Source: Robertson & Zaragoza, 'The Probabilistic Relevance Framework: BM25 and Beyond' (2009); mechanics corroborated via the Okapi BM25 reference entry (Wikipedia, cross-checked against the original paper's term-frequency saturation and IDF formulation)