Skip to main content
InterviewHubPRO
Section Overview
Q18

Question 18 of 50

Part 2: Core Architecture & Implementation (Mid-Level)

36%
Vector DBs & RAG (50 Qs)•Part 2: Core Architecture & Implementation (Mid-Level)

What is Re-ranking and how do Cross-Encoders improve RAG retrieval?

senior LevelMost AskedSystem DesignData Structures

In Simple Words:

  • Bi-Encoder (Vector DB stage): Embeds document and query independently. Fast (O(1) ANN search), but misses token-level cross-interactions.
  • Cross-Encoder (Re-ranker stage): Passes both the query and document into a transformer simultaneously, allowing self-attention across every word pair.
  • Two-Stage Retrieval Pipeline:
    1. Retrieve top 50 candidates from Vector DB in 5ms.
    2. Pass the 50 candidates to a Cross-Encoder (e.g. Cohere Rerank, BGE-Reranker-v2) to select the definitive top 5 most relevant chunks.