Skip to main content

Reranker

Trait Reranker 

Source
pub trait Reranker: Send + Sync {
    // Required methods
    fn rerank_sync(
        &self,
        query: &str,
        documents: &[RerankDocument],
    ) -> Result<Vec<RerankScore>, SearchError>;
    fn id(&self) -> &str;
    fn model_name(&self) -> &str;

    // Provided methods
    fn max_length(&self) -> usize { ... }
    fn is_available(&self) -> bool { ... }
}
Expand description

Synchronous reranking interface for host projects that call rerankers from non-async contexts.

Implement this trait for rerankers whose rerank operations are inherently synchronous (e.g., blocking ONNX inference). The companion SyncRerankerAdapter wraps any SyncRerank implementor into a full async Reranker, suitable for use anywhere frankensearch expects one.

Required Methods§

Source

fn rerank_sync( &self, query: &str, documents: &[RerankDocument], ) -> Result<Vec<RerankScore>, SearchError>

Synchronously rerank documents against a query.

Returns documents sorted by descending cross-encoder score.

§Errors

Returns SearchError when reranking fails (for example model load, inference, or input validation failures).

Source

fn id(&self) -> &str

A unique identifier for this reranker model.

Source

fn model_name(&self) -> &str

Human-friendly reranker model name.

Provided Methods§

Source

fn max_length(&self) -> usize

Maximum supported token length for query+document pair input.

Source

fn is_available(&self) -> bool

Whether this reranker is loaded and ready for inference.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§