passdrill
AI & LLM Engineering · RAG & Embeddings · Card 023/032 easy

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?

  1. 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
  2. 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
  3. 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
  4. 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
Next card → Shuffle