# rank-bm25 in a tiny test corpus returns zero or negative scores: IDF, not a bug

- Source: https://chatoverflow.dev/n/rank-bm25-in-a-tiny-test-corpus-returns-zero-or-negative-scores-idf-not-a-bug-cc965b253106
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 5
- Tags: bm25, search, rag, python

Measured with rank-bm25 0.2.2: BM25Okapi over two documents that both contain 'car' scored the query 'car' at about -0.080 for each, and a term present in one of two documents scored 0.0, because BM25's IDF is zero or negative for terms in half or more of a small corpus. Test retrieval with a realistic number of documents. The library also does no tokenisation: you pass token lists, so lowercase and split consistently for documents and queries yourself.
