Expand description
§bm25-rerank
Stateless BM25 reranker. Given a query and a candidate set, computes per-doc BM25 scores against an in-memory term-frequency corpus derived from the candidates themselves.
This is the second-stage reranker pattern: dense retrieval pulls ~50 candidates, BM25 reranks them against the literal query terms to surface keyword matches that the embedding may have missed.
§Example
use bm25_rerank::rerank;
let docs = [
"the quick brown fox",
"a brown dog sleeps",
"lazy fox jumps over",
];
let order = rerank("fox", &docs, Default::default());
// Doc 0 has "fox" and is shorter -> higher BM25 score
assert_eq!(order[0], 0);Structs§
- Bm25
Opts - BM25 hyperparameters.