← Charlie Yan

retrievalkit

2026 — Python · PyPI · BM25 · HNSW · BEIR

Repository ↗ PyPI ↗

An inverted index and BM25, HNSW with the diversity heuristic, and the metrics, all written out. On top of them a sentence-transformer embedder, a cross-encoder reranker, and contrastive fine-tuning. The point is that they’re measured as one ladder on the same benchmark, so each stage’s contribution is visible rather than claimed.

What’s tested

BM25 scores, idf and length normalisation against hand values. The posting/length invariant. Porter against the examples in the 1980 paper. HNSW against an exact oracle. Every metric against a hand value.

And in CI, the BM25 row against BEIR’s published FiQA number, on both nDCG@10 and Recall@100. That’s the check that matters: a retrieval stack that scores well against its own implementation of a metric has proved nothing.

The one rule

Every number in the README is produced by retrievalkit bench on the machine it names, and --check regenerates and diffs it in CI.

pip install retrievalkit