Zenaique

After a cross-encoder reranker was added on every query, costs doubled: keep the quality, cut the bill

Short answer·Medium·4.0 · 0·~3 min·Asked atInflection AiInfosysQualcomm
Attempt it

Adding a cross-encoder reranker on every query measurably improved answer quality, but it roughly doubled inference cost because the reranker now scores a wide candidate set on each request. How do you preserve most of the quality gain while cutting the cost?

Free · 2 AI evals / day
TL;DR

Don't rerank every query at full width. Gate the reranker on first-stage ambiguity, shrink the candidate N, use a cheaper distilled reranker, and cache repeats — measuring each against the quality metric.

Memory aid
Sign in to see the mnemonic that makes this stick.
Easy to grasp

Imagine a busy clinic where every patient, even one with a paper cut, gets sent for a full body scan. The scans help the hard cases, but the bill explodes. A smarter clinic asks a quick question first: does this person actually need the scan? It scans only the unclear cases, uses a faster machine for routine ones, scans a smaller area when the problem is obvious, and reuses yesterday's scan if the same patient returns with the same issue. A reranker is that body scan. You keep its benefit for the cases that need it and stop paying for it on the easy ones, so the bill drops without losing the quality where it mattered.

Concept explanation~2 min read

Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.

A reranker is one of the highest-leverage quality upgrades in RAG, and also one of the easiest to deploy carelessly. The default integration — run a cross-encoder over the full first-stage candidate set on every single query — is what most tutorials show, and it is what doubled this team's bill. The quality gain is real, so ripping the reranker out is the wrong response. The right response is to recognize that the reranker's workload is a set of independent knobs, most of which were left at their most expensive setting.

This question separates engineers who treat a reranker as a black box from those who understand its cost model. This deep dive builds that cost model, then works through the four levers — selective firing, candidate width, model capacity, and caching — and closes with the measurement discipline that keeps cost cuts from quietly becoming quality regressions.

The cross-encoder cost model

You cannot optimize what you have not modeled, so start with where a reranker's cost comes from. A cross-encoder scores relevance by feeding the query and a candidate document together through a transformer and reading out a relevance score. The critical word is together: unlike the first-stage bi-encoder, which embeds query and documents separately and compares cheap vectors, the cross-encoder runs a fresh joint forward pass for every query-candidate pair.

That gives a simple cost expression. Per query, the reranker cost is roughly the number of candidates scored times the per-pair forward-pass cost:

costQNcpair\text{cost} \approx Q \cdot N \cdot c_{\text{pair}}

where Q is the number of queries that get reranked, N is the candidate count per query, and c_pair is the cost of one query-candidate forward pass, which scales with the model size.

This expression is the whole optimization map. There are exactly three multiplicative terms, and each one is a lever. Reduce Q by reranking fewer queries. Reduce N by scoring fewer candidates per query. Reduce c_pair by using a smaller model. Caching is a fourth lever that removes work entirely for repeats. The doubled bill came from leaving Q at 100% of traffic, N at the full first-stage width, and c_pair at a large model — all three terms at maximum at once.

Lever one: rerank fewer queries
Levers two and three: narrower candidate set and lighter model
Lever four and the measurement loop that protects quality
Sign in to unlock the full deep dive.

Situations where this technique stops working.

Sign in to see when this approach fails.

2–4 min · Everything important, quickly.

Sign in to see the quick scan of the deep dive.
python
def retrieve(query, k=5):
    cands = vector_search(query, n=50)
    margin = cands[0].score - cands[1].score
    # Only pay for the cross-encoder when the head is ambiguous
    if margin < MARGIN:
        cands = cross_encoder.rerank(query, cands)
    return cands[:k]

Real products, models, and research that use this idea.

  • Cohere Rerank is commonly gated to fire only when first-stage retrieval scores are close, skipping confident queries.
  • Teams swap a large cross-encoder for a distilled MiniLM-based reranker to cut latency while holding most of the NDCG gain.
Sign in to see more production examples.

What an interviewer would ask next. Try answering before peeking at the approach.

QWhat concrete first-stage signal would you gate the reranker on, and how would you set the threshold?
A

Use the score margin between the top candidates from the first-stage retriever — a large gap means the top result is unambiguous and reranking is unlikely to change the order. Set the threshold by sweeping it on a labeled set: plot quality and rerank-call rate against the margin cutoff, and pick the point where skipping more queries starts to cost quality. A small classifier on query features is an alternative gate.

2 more follow-ups an interviewer would ask next. Sign in to reveal them.

Red flags & common mistakes

The phrases that signal junior thinking. Click to expand.

Most common mistake

Treating rerank every query at full width as a fixed constant rather than a knob, so the only optimization considered is a faster model instead of reranking less.

Sign in to see all red flags and common mistakes.

60 second bullets to scan on the way to the call.

  • Challenge the rerank every query at full width premise as the first move

  • Explain selective reranking gated on first-stage score ambiguity

Sign in to unlock the revision sheet.

Primary sources. Browse if you want the original framing.

Similar questions

Same topic, related formats. Practice these next.

4 curated
Next question
Which metric best measures whether a RAG answer is grounded in the retrieved context?
MCQ·Medium