pub struct EmbeddingCosineReranker { /* private fields */ }Expand description
Cosine reranker bound to one runtime, caller token and named engine.
Query embedding uses the runtime’s token-aware query-role path. Candidate
scoring uses KhiveRuntime::rerank_in, without a namespace-wide KNN cut.
The signed canonical cosine score replaces each stored candidate’s score;
missing vectors retain the exact incoming score instead.
Self::rerank_detailed exposes the fallback flag and typed runtime errors.
The Reranker implementation projects hits to tuples and maps failures to
RetrievalError::Rerank, losing their typed causes and retry classification.
Implementations§
Source§impl EmbeddingCosineReranker
impl EmbeddingCosineReranker
Sourcepub fn new(
runtime: Arc<KhiveRuntime>,
token: NamespaceToken,
engine: impl Into<String>,
) -> RuntimeResult<Self>
pub fn new( runtime: Arc<KhiveRuntime>, token: NamespaceToken, engine: impl Into<String>, ) -> RuntimeResult<Self>
Bind a registered engine, canonicalizing built-in aliases without loading its embedding service. Unknown or request-excluded engines are refused.
Sourcepub async fn rerank_detailed(
&self,
query: &str,
results: Vec<(Uuid, DeterministicScore)>,
top_k: usize,
) -> RuntimeResult<Vec<EmbeddingRerankHit>>
pub async fn rerank_detailed( &self, query: &str, results: Vec<(Uuid, DeterministicScore)>, top_k: usize, ) -> RuntimeResult<Vec<EmbeddingRerankHit>>
Score every supplied entry, retaining missing vectors and duplicate IDs.
Vector reads deduplicate IDs; output does not. Missing duplicates each retain their own incoming score. Results sort by descending final score, ascending UUID, then original position for identical ID/score ties. The limit applies after scored and missing entries are merged.
Engine and generated-vector validation still run for empty candidates or
a zero limit. Embedding and storage failures fail the whole call, rather
than marking candidates missing. More than u32::MAX distinct IDs refuse
because the underlying scorer’s result bound cannot represent that set.
Trait Implementations§
Source§impl Clone for EmbeddingCosineReranker
impl Clone for EmbeddingCosineReranker
Source§impl Reranker<Uuid> for EmbeddingCosineReranker
impl Reranker<Uuid> for EmbeddingCosineReranker
Source§fn rerank<'life0, 'life1, 'async_trait>(
&'life0 self,
query: &'life1 str,
results: Vec<(Uuid, DeterministicScore)>,
top_k: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<(Uuid, DeterministicScore)>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn rerank<'life0, 'life1, 'async_trait>(
&'life0 self,
query: &'life1 str,
results: Vec<(Uuid, DeterministicScore)>,
top_k: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<(Uuid, DeterministicScore)>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
results using query context. Returns top top_k pairs.Auto Trait Implementations§
impl !RefUnwindSafe for EmbeddingCosineReranker
impl !UnwindSafe for EmbeddingCosineReranker
impl Forget for EmbeddingCosineReranker
impl Freeze for EmbeddingCosineReranker
impl Move for EmbeddingCosineReranker
impl Send for EmbeddingCosineReranker
impl Sync for EmbeddingCosineReranker
impl Unpin for EmbeddingCosineReranker
impl UnsafeUnpin for EmbeddingCosineReranker
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more