fornix 0.4.0

Knowledge storage, retrieval, and graph infrastructure for cognitive systems
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//! Reranker trait and implementations.

use crate::rag::{error::Result, types::Context};

/// The reranker interface: takes a query and a list of contexts, and returns
/// them reordered (and optionally rescored) by relevance.
pub trait Reranker: Send + Sync {
    fn name(&self) -> &'static str;

    /// Rerank `contexts` for `query`, returning at most `top_k` results.
    fn rerank(&self, query: &str, contexts: Vec<Context>, top_k: Option<usize>) -> Result<Vec<Context>>;
}

pub mod null;
pub use null::NullReranker;