#[non_exhaustive]pub enum RankingStrategy {
Hybrid {
alpha: f32,
decay: DecayFn,
},
Blended {
weights: BlendWeights,
decay: DecayFn,
},
}Expand description
How Client::query orders the candidate set.
Reach for Self::Hybrid when relevance and recency are the only signals
that matter (it ignores confidence and category); reach for Self::Blended
to also reward high-confidence facts and preferred categories — the typical
choice once the categorize/confidence pipeline is populated. Blended is a
strict superset, so Hybrid is just the w_conf = 0, no-category special
case. For raw nearest-neighbor hits with no re-ranking at all, use
Client::search instead of query.
Constructing a variant explicitly is the caller’s opt-in to that specific behavior — those parameter values become part of the stability contract for the caller’s code. The default behavior (when no strategy is passed) is allowed to drift pre-1.0.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Hybrid
Blend of cosine similarity and recency.
score = alpha * cosine + (1 - alpha) * decay(age). alpha in
[0.0, 1.0]; 0.0 is pure recency, 1.0 is pure cosine. Age is
computed against event_at when present, falling back to
created_at.
Fields
Blended
Linear blend of cosine, confidence, recency, and a category bonus.
score = w_cos·cosine + w_conf·(confidence/100) + w_rec·decay(age),
plus category_bonus when the memory’s category is preferred. The
superset of Self::Hybrid (which is the w_conf = 0, no-category
case). Confidence is normalized from 0-100 to [0, 1] before
weighting so no single signal dominates by scale. Pure math + indexed
lookups — no inference in the read path.
Fields
weights: BlendWeightsSignal weights and the optional category preference.
Implementations§
Source§impl RankingStrategy
impl RankingStrategy
Sourcepub fn default_hybrid() -> Self
pub fn default_hybrid() -> Self
The default Hybrid configuration query() uses when no strategy is
passed. Parameter values may drift pre-1.0.
Sourcepub fn blended(weights: BlendWeights) -> Self
pub fn blended(weights: BlendWeights) -> Self
A Self::Blended strategy with the given weight preset and the
default exponential recency decay.
Convenience over constructing Blended { weights, decay } by hand
when the default half-life is fine:
RankingStrategy::blended(BlendWeights::trust_first()).
Trait Implementations§
Source§impl Clone for RankingStrategy
impl Clone for RankingStrategy
Source§fn clone(&self) -> RankingStrategy
fn clone(&self) -> RankingStrategy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RankingStrategy
impl Debug for RankingStrategy
Source§impl PartialEq for RankingStrategy
impl PartialEq for RankingStrategy
Source§fn eq(&self, other: &RankingStrategy) -> bool
fn eq(&self, other: &RankingStrategy) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for RankingStrategy
Auto Trait Implementations§
impl Freeze for RankingStrategy
impl RefUnwindSafe for RankingStrategy
impl Send for RankingStrategy
impl Sync for RankingStrategy
impl Unpin for RankingStrategy
impl UnsafeUnpin for RankingStrategy
impl UnwindSafe for RankingStrategy
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
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> 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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request