pub struct CascadeRetriever { /* private fields */ }Expand description
Cascading retrieval orchestrator.
Coordinates the 4-tier retrieval pipeline, falling back to API only when CPU-local tiers cannot satisfy the query.
Implementations§
Source§impl CascadeRetriever
impl CascadeRetriever
Sourcepub fn new(config: CascadeConfig) -> Self
pub fn new(config: CascadeConfig) -> Self
Create a new cascade retriever with given configuration.
Sourcepub fn default_config() -> Self
pub fn default_config() -> Self
Create a new cascade retriever with default configuration.
Sourcepub fn add_episode(&mut self, id: &str, text: &str)
pub fn add_episode(&mut self, id: &str, text: &str)
Add an episode to the retrieval index.
This indexes the episode in BM25 and encodes it for HDC similarity search.
When the csm feature is not enabled, this just stores the episode data
for later retrieval.
Sourcepub fn retrieve(&self, query: &str) -> CascadeResult
pub fn retrieve(&self, query: &str) -> CascadeResult
Execute the cascading retrieval pipeline.
When the csm feature is enabled, this implements a 4-tier cascade:
- BM25 keyword search (CPU-local, 0 API calls)
- HDC similarity search (CPU-local, 0 API calls)
- ConceptGraph expansion (CPU-local, 0 API calls)
- API fallback (requires external embedding call)
Without csm, returns empty results (placeholder behavior).
Sourcepub fn config(&self) -> &CascadeConfig
pub fn config(&self) -> &CascadeConfig
Get the configuration for this retriever.
Sourcepub fn estimate_api_call_probability(&self, query: &str) -> f32
pub fn estimate_api_call_probability(&self, query: &str) -> f32
Estimate the probability that a query would require an API call.
Returns a value in [0.0, 1.0] where:
- 0.0 means CPU-local tiers (BM25/HDC/ConceptGraph) are very likely to suffice
- 1.0 means an API embedding call is almost certainly needed
Heuristic: short keyword-rich queries resolve via BM25 (low probability); long abstract queries with few known terms need semantic embedding (high probability).
Auto Trait Implementations§
impl Freeze for CascadeRetriever
impl RefUnwindSafe for CascadeRetriever
impl Send for CascadeRetriever
impl Sync for CascadeRetriever
impl Unpin for CascadeRetriever
impl UnsafeUnpin for CascadeRetriever
impl UnwindSafe for CascadeRetriever
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> 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 moreimpl<T> SendAlias for T
impl<T> SendAlias for T
impl<T> SendSyncUnwindSafe for Twhere
T: Send + Sync + UnwindSafe + ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.