How to evaluate rerankers

Evaluation · ~8 min read ·

Public BEIR scores are a starting point, not a verdict. A reranker that wins on English news may flop on your support tickets. You need a small labelled set of real queries and two metrics: NDCG@k (ranking quality) and MRR (is the best answer near the top?).

Does a Chinese support knowledge base benefit from reranking?

We wrote 12 short Chinese support passages and eight queries, each with one labelled answer. A character-bigram BM25 baseline retrieved five passages. BGE reranked exactly those five. The first answer was correct for 5/8 queries before reranking and 6/8 afterwards. MRR@5 rose from 0.681 to 0.813. This is a worked example with invented tickets and a lexical baseline.

QueryBM25 rankRank after BGE
发票抬头开错了怎么办11
以后别再每个月从我卡里扣钱了42
同一笔订单付了两次怎么退一笔51
手机不见了收不到登录验证码11
E42911
下载团队成员名单11
怎样让新员工进工作区——
去哪里拿电子票据的 PDF11

The refund answer rose from fifth to first. The cancellation query improved but still surfaced a refund first. The invitation passage never entered the pool (—). BM25 used document order to break ties, including zero-score ties, so some candidates entered by chance. Five queries already had the right first answer; none fell in this run.

On an AMD EPYC 9V74 CPU with two inference threads, the median added time was 70.3 ms across eight queries after one warm-up. Timing includes tokenizing five pairs, ONNX inference and sorting. Retrieval and model loading are excluded. Local inference incurred no API fee; CPU time still has a cost. Use your own traffic, hardware rate and throughput in the cost calculator.

To repeat the run, use the script with passages, labels and setup instructions and the pinned BGE ONNX conversion. For a deployment decision, replace the examples with real queries and your current retriever. Check missed candidates first, then weigh recovered answers against added latency.

Build a labelled query set

Pull 30–100 real queries from logs (anonymised). For each query, mark which document IDs are relevant (binary is enough to start). Store as JSON:

{
  "q-001": {
    "query": "How do I reset my API key?",
    "relevant": ["doc-42", "doc-108"]
  }
}

Thirty queries with one gold document each is enough to see whether reranking beats retrieval-only — you’re measuring relative lift, not publishing a leaderboard.

Metrics that matter

MetricWhat it tells youTypical k
NDCG@kRewards putting highly relevant docs at the top; graded relevance if you have it5 or 10
MRRHow high the first relevant doc ranks — great for single-answer RAG—
Recall@kIs the right doc in the shortlist at all? Diagnoses retrieval, not reranker50–100

Run metrics before and after reranking on the same retrieved candidates. If NDCG@5 jumps but Recall@50 is low, your problem is retrieval — reranking can’t invent missing chunks.

Want a number without installing anything? The NDCG and MRR calculator takes the labels before and after reranking and works out NDCG@k, MRR and Hit@1 in your browser.

Evaluation protocol

  1. Fix a retrieval pipeline (vector-only or hybrid) and log top-50 candidates per query.
  2. Score baseline: order as retrieved (or bi-encoder scores).
  3. Apply reranker A, measure NDCG@5 and MRR.
  4. Swap reranker B (different model or hosted API), repeat.
  5. Track latency p50/p95 alongside quality — a 2-point NDCG gain may not justify 400 ms.

Python with ranx

from ranx import Qrels, Run, evaluate

qrels = Qrels.from_file("qrels.json")      # ground truth
run_before = Run.from_file("retrieve.json")
run_after = Run.from_file("rerank.json")

for name, run in [("retrieve", run_before), ("rerank", run_after)]:
    print(name, evaluate(qrels, run, ["ndcg@5", "mrr@10"]))

ir-measures and BEIR’s evaluator work too. The important part is consistent qrels and the same candidate pool — not which library you pick.

Comparing rerankers

Use the model comparison table for ballpark BEIR numbers, then validate on your labelled set. Hosted APIs (Cohere, Jina, Voyage) are fastest to A/B; open models (bge, mxbai) need GPU for fair latency comparison.

Regression tests: check eval metrics into CI. When you change chunk size, embedding model, or reranker version, re-run the same JSON qrels — quality drops should block deploys.

Build intuition before you benchmark

Use the live demo to see how a cross-encoder reorders a hand-picked shortlist — then scale up with labelled queries.

Try the demo →

Keep reading