Module: Parse::Retrieval::Reranker
- Defined in:
- lib/parse/retrieval/reranker.rb,
lib/parse/retrieval/reranker/cohere.rb
Overview
Cross-encoder reranking for retrieved documents.
A reranker takes a query and a list of candidate document texts and returns a relevance-ordered scoring. It runs AFTER the (vector, lexical, or hybrid) retrieval step and BEFORE chunking, reordering the retrieved documents by a more expensive cross-encoder relevance model than the first-stage similarity score.
== Protocol
A reranker is any object that responds to:
#rerank(query:, documents:, top_n: nil) -> Array
where documents is an Arrayindex into documents, plus relevance_score),
descending by relevance. Implementations MUST:
- Return at most
documents.lengthresults (and at mosttop_nwhen given). - Use 0-based
indexvalues that are valid positions in the input. - Never raise for an empty
documentslist — return[].
Base provides input validation and result normalization so adapters only implement the network call (Base#rerank_scores).
Defined Under Namespace
Classes: Base, Cohere, Error, Fixture, InvalidResponseError, Result