fastrag.retrieval.reranking.base#
The Reranker contract: scoring documents against a query.
Classes
|
Scores documents against a query with a cross-encoder. |
- class fastrag.retrieval.reranking.base.Reranker[source]#
Bases:
ABCScores documents against a query with a cross-encoder.
A cross-encoder reads the query and a document together, rather than comparing precomputed embeddings, so it is far more accurate than vector similarity — and far more expensive, which is why it narrows a retriever’s over-fetch instead of searching a whole collection; see
RerankingRetriever.- abstractmethod async rerank(query, documents, *, top_k)[source]#
Score
documentsagainstqueryand return them best-first.Results are best-first, number at most
top_k, and each carries the reserved metadata keysscore(the model’s own relevance score, on the model’s own scale — never comparable with a vector store’s similarity score) andrank(0-based, contiguous) restated from this reranker — anyscore/ranka document already carried is overwritten, not merged. An emptydocumentsreturns[]without a network call.- Parameters:
- Return type: