passdrill
AI & LLM Engineering · RAG & Embeddings · Card 007/012 medium

A RAG pipeline's first stage retrieves the 50 candidate passages whose embeddings are closest to the query, using a bi-encoder that embeds the query and each passage independently and compares the two embeddings afterward. Before generation, a second-stage model re-scores those 50 candidates by feeding the query and each passage together into a single transformer that outputs one relevance score per pair. Why is this second-stage model typically applied only to a shortlist rather than to the entire document collection?

  1. It cannot process any text that has already been converted into an embedding vector, so it can only ever run before an embedding index exists
  2. It produces scores that are only meaningful when compared against a bi-encoder's scores, so by definition it must always run after the bi-encoder stage
  3. Scoring a query together with a passage in a single joint pass is far more computationally expensive per pair than comparing two independently pre-computed embeddings, so running it against every document in a large collection would be too slow; restricting it to a small shortlist keeps the added latency manageable while still improving ranking accuracy where it matters most
  4. It can only ever reproduce the same ranking the first-stage retrieval already produced, so applying it to the full collection would be redundant
Next card → Shuffle