Re-ranking
Resorted found fragments by relevance.
Why is it needed
Vector search returns 10–20 candidates, but the most useful ones do not always occupy the top spots. Sending all to an LLM increases token costs and reduces accuracy.
Re-ranking takes the candidates and resorts them.
How Cross-Encoder works
Cross-Encoder is a model that takes a pair of texts at once:
query + fragment → relevance score
Unlike embeddings, which encode the query and document separately, Cross-Encoder sees them together. Therefore, it is more accurate.
Process flow
flowchart LR
A[Query] --> B[Vector Search]
B --> C[Top-20]
C --> D[Cross-Encoder]
D --> E[Top-3]
E --> F[LLM]
Popular re-rankers
- Cohere Rerank — cloud service;
- bge-reranker — open model;
- Cross-Encoder from Sentence Transformers — locally.