BM25 Ranking
In this article
- Explain how the analyzer decides which terms exist, and why a code such as BL-R7 can vanish before ranking starts.
- Name the three things that set one term's share of a BM25 score: how rare the term is, how often it repeats, and how long the chunk is.
- Predict which of two chunks ranks higher for a short query by adding one contribution per query term.
- Say why a BM25 score means nothing outside its own query and index.
- Terms defined here: analyzer, inverse document frequency, term frequency, BM25.
Overview
A customer types "BL-R7 reset" into a support assistant. "Reset" appears in about 200 help-page chunks and the router name in about 40, so a search that only asks "does this chunk contain the word?" returns far too many hits. The assistant shows three. Which three, and in what order?
Brightline, a made-up home-internet provider (its pages and all numbers here are invented), searches about 2,000 chunks of help pages and router manuals in two ways: by meaning and by words. The word side is a lexical search, and it ranks its hits with BM25.
Text goes through an analyzer, which decides what the terms are. For each query term, BM25 asks three questions about a chunk: is the term rare in the collection, how many times does it appear here, and is this chunk long? It turns the answers into one number per term and adds them up. A term the chunk does not contain adds nothing.
Sign in to keep reading
The rest of this article opens with an account. An account also keeps your progress and quiz results on every device, and lets you follow news for up to five topics.
Still to read in this article
- The analyzer decides which terms exist
- Rare terms weigh more
- Repeats add less each time
- Long chunks get a discount
- Adding it up: "BL-R7 reset"
- What a BM25 score cannot tell you
- Common mistakes
- Sources
- Check yourself, 13 questions