All entries

    Build a Two-Stage Search Ranker with a Cross-Encoder

    Retrieve a small candidate set quickly, then use a cross-encoder to score the query and each candidate together.

    A large candidate set narrows to a short ranked list
    Conceptual pixel-art illustration.

    Retrieve a small candidate set quickly, then use a cross-encoder to score the query and each candidate together.

    Build the example

    Create fictional help documents about password reset, recovery codes and account deletion. Use a lexical or embedding index for the first stage and choose K based on validation recall. Rerank only those K candidates with the cross-encoder. A relevant document missing from the candidate set cannot be recovered by the second stage.

    Create a query whose correct result uses different words from the query. Have the first stage miss it at K=2 and recover it at K=5. Run the reranker against both candidate sets. Measure how many pairs are evaluated so the relevance improvement has a corresponding compute cost in the same example.

    EXPLAINED / SYSTEM FLOW

    Retrieve and rerank

    Retrieve a small candidate set quickly, then use a cross-encoder to score the query and each candidate together.

    Example

    1. Retriever

      select K candidates

    2. Cross-encoder

      score each query and candidate together

    3. Ranked results

      measure relevance and latency

    THE KEY DISTINCTION

    measure relevance and latency

    Conceptual diagram for the synthetic example in this guide.

    Watch the failure boundary

    Batch query–document pairs at the reranking stage and impose a maximum document length. If a relevant sentence falls beyond truncation, compare passage-based scoring with document-level scoring. Track whether improvements come from retrieving additional candidates or from moving an already-retrieved candidate upward.

    Verify the behavior

    Compare candidate recall, final NDCG and median and tail latency on the same queries. Include paraphrases and ambiguous terms. Lower K to find where candidate recall begins to drop, then choose a deployment budget that fits both relevance and latency needs.

    FURTHER READING

    Sources

    Technical references checked .

    END OF ENTRY / 70
    Eeshan Singh with Big Ben in London
    BEHIND THE JOURNAL

    Eeshan Singh

    I’m Eeshan Singh Pokharia, an AI Full Stack Developer and CoFounder of UltraFit360. I work across AI features, full-stack product development, and web and mobile experiences—from Figma and frontend interactions to the systems behind them.

    Batch query–document pairs at the reranking stage and impose a maximum document length. If a relevant sentence falls beyond truncation, compare passage-based scoring with document-level scoring. Track whether improvements come from retrieving additional candidates or from moving an already-retrieved candidate upward.

    Meet the author
    THE CONVERSATION

    Your side of the story.