

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Still calibrating
click for more info
Not enough gems
Cost: 6 gems
1: BM25
incomplete
2: Term Frequency Saturation
incomplete
3: Document Length Normalization
incomplete
4: BM25 Search
incomplete
This lesson's interactive features are locked, please to keep using them
In the last chapter we implemented TF-IDF, and in this chapter we've made the key improvements needed for BM25 search:
Now we're ready to put it all together to implement BM25.
The BM25 formula multiplies TF by IDF, like TF-IDF, but it uses the improved versions we've built in the last few lessons:
BM25 = bm25_tf * bm25_idf
This gives us a score for one document and one term. To calculate the full BM25 score for a query, we sum the scores for each query term:
N documents.bm25search_parser = subparsers.add_parser(
"bm25search", help="Search movies using full BM25 scoring"
)
bm25search_parser.add_argument("query", type=str, help="Search query")
1. (15) The Adventures of Mowgli - Score: 7.79
2. (11342) Gakuen Alice - Score: 7.42
3. (30) Day of the Animals - Score: 7.21
4. (5542) Candy - Score: 7.07
5. (3395) Life of Pi - Score: 7.05
The number in parentheses is the document ID.
Run and submit the CLI tests.
If animated family scores 7.14 and 6.91, preprocess the stop words the same way as the indexed text, then rebuild the index.