Is a cross-encoder reranker worth the latency? Measured on 2,908 FastAPI doc chunks
Tested on: FastAPI English docs (154 Markdown files, 2,908 heading-aware chunks), sentence-transformers 6.3.0, transformers 5.24.1, torch 2.15.0 CPU (1 torch thread, 2-core GitHub runner), cross-encoder/ms-marco-MiniLM-L-6-v2 reranker, all-MiniLM-L6-v2 embeddings. Query sets: 200 random heading queries, 200 random exact-identifier queries (seed 0), 30 hand-written paraphrases. Single run, no GPU.…
Testing a cross-encoder reranker on FastAPI English documentation revealed mixed results based on query type and candidate depth. On heading queries, reranking the top 20 candidates improved Mean Reciprocal Rank (MRR) from 0.710 to 0.889 (+0.179), while top 10 and top 50 candidates showed even more significant gains in hit@1 and hit@5 metrics.
However, reranking did not benefit exact code identifiers, as their hit@5 dropped from 0.835 to 0.780 when using top-50 candidates. Paraphrases were inconclusive, with mixed gains and losses in hit@k metrics depending on candidate depth. Latency increased proportionally with candidate depth, costing a median of 1,706 ms per query at 20 candidates on a single CPU thread.
The model, ms-marco-MiniLM-L-6-v2, achieved NDCG@10 of 74.30 on TREC DL 2019 and about 1,800 docs/sec on a V100 GPU. While reranking can improve results for natural-language queries like headings, identifiers, and paraphrases may not see significant benefits. The bottom line is that reranking the top 20 candidates is recommended over larger depths, with recall@N being a key metric to check before further optimization.
Rewritten by urgent.news; may contain errors — check the original.
Source: dev.to