← All questions
RAGMedium· Retrieval· Reranking· Pipeline Optimization

Your pipeline returns the right document at rank 40 and...

A strong answer establishes the diagnosis before the fix: rank 40 means the document is in a candidate set of depth 100 and is not in the top-5 that reach the context, so R1 is fine and R2 is the failure. The repair is a second stage that rescores those 100 candidates with the query in hand. A weak answer jumps straight to ‘use a better embedding model,’ which is unhelpful because it targets the stage that is already working and may result in a costly re-index of the corpus without solving the ordering problem.

Code playground (Python)