pub struct RouterConfig {
pub dimension: usize,
pub metric: DistanceMetric,
pub max_connections: usize,
pub ef_construction: usize,
pub ef_search: usize,
pub cache_size: usize,
}Expand description
Configuration for semantic router
Fields§
§dimension: usizeVector dimension for embeddings
metric: DistanceMetricDistance metric to use
max_connections: usizeMaximum connections per HNSW layer
ef_construction: usizeHNSW construction parameter
ef_search: usizeDefault search parameter
cache_size: usizeQuery result cache size (number of queries to cache)
Implementations§
Source§impl RouterConfig
impl RouterConfig
Sourcepub fn low_latency(dimension: usize) -> Self
pub fn low_latency(dimension: usize) -> Self
Create configuration optimized for low latency queries
Best for: Real-time applications, interactive search, chat systems Trade-offs: Slightly lower recall (~90%), faster queries
§Example
use ipfrs_semantic::RouterConfig;
let config = RouterConfig::low_latency(768);
assert_eq!(config.dimension, 768);
// Optimized for speed with reasonable accuracySourcepub fn high_recall(dimension: usize) -> Self
pub fn high_recall(dimension: usize) -> Self
Create configuration optimized for high recall (accuracy)
Best for: Research applications, critical retrieval, high-quality recommendations Trade-offs: Slower queries, higher memory usage
§Example
use ipfrs_semantic::RouterConfig;
let config = RouterConfig::high_recall(768);
assert_eq!(config.dimension, 768);
// Optimized for accuracy with acceptable latencySourcepub fn memory_efficient(dimension: usize) -> Self
pub fn memory_efficient(dimension: usize) -> Self
Create configuration optimized for memory efficiency
Best for: Edge devices, constrained environments, large datasets with limited RAM Trade-offs: Lower recall (~85%), smaller cache
§Example
use ipfrs_semantic::RouterConfig;
let config = RouterConfig::memory_efficient(384);
assert_eq!(config.dimension, 384);
// Smaller connections and cache for low memory footprintSourcepub fn large_scale(dimension: usize) -> Self
pub fn large_scale(dimension: usize) -> Self
Create configuration optimized for large-scale datasets (100k+ vectors)
Best for: Production systems, large knowledge bases, document collections Trade-offs: Higher memory usage, optimized for throughput
§Example
use ipfrs_semantic::RouterConfig;
let config = RouterConfig::large_scale(768);
assert_eq!(config.dimension, 768);
// Balanced for large datasets with good performanceSourcepub fn balanced(dimension: usize) -> Self
pub fn balanced(dimension: usize) -> Self
Create configuration for balanced performance (alias for default)
Best for: General purpose, getting started, typical applications Trade-offs: Balanced recall (~95%) and latency
§Example
use ipfrs_semantic::RouterConfig;
let config = RouterConfig::balanced(768);
assert_eq!(config.dimension, 768);
// Good all-around configurationSourcepub fn with_metric(dimension: usize, metric: DistanceMetric) -> Self
pub fn with_metric(dimension: usize, metric: DistanceMetric) -> Self
Create configuration with custom distance metric
§Example
use ipfrs_semantic::{RouterConfig, DistanceMetric};
let config = RouterConfig::with_metric(768, DistanceMetric::L2);
assert_eq!(config.dimension, 768);Sourcepub fn with_cache_size(self, size: usize) -> Self
pub fn with_cache_size(self, size: usize) -> Self
Set the query result cache size
§Example
use ipfrs_semantic::RouterConfig;
let config = RouterConfig::balanced(768).with_cache_size(5000);
assert_eq!(config.cache_size, 5000);Sourcepub fn with_ef_search(self, ef_search: usize) -> Self
pub fn with_ef_search(self, ef_search: usize) -> Self
Set the ef_search parameter for query-time search
Higher values improve recall but increase latency
§Example
use ipfrs_semantic::RouterConfig;
let config = RouterConfig::balanced(768).with_ef_search(100);
assert_eq!(config.ef_search, 100);Trait Implementations§
Source§impl Clone for RouterConfig
impl Clone for RouterConfig
Source§fn clone(&self) -> RouterConfig
fn clone(&self) -> RouterConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RouterConfig
impl Debug for RouterConfig
Auto Trait Implementations§
impl Freeze for RouterConfig
impl RefUnwindSafe for RouterConfig
impl Send for RouterConfig
impl Sync for RouterConfig
impl Unpin for RouterConfig
impl UnwindSafe for RouterConfig
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> 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> Pointable for T
impl<T> Pointable for T
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.