pub struct VsaConfigSchema {
pub dimension: usize,
pub density: f64,
pub scaling: Option<SparsityScaling>,
pub auto_thin: Option<usize>,
pub min_nnz: Option<usize>,
pub max_nnz: Option<usize>,
pub target_accuracy: Option<f64>,
}Expand description
User-provided schema for custom VSA configuration
This allows users to specify their own parameters for specialized use cases without needing to understand the internal scaling formulas.
§Example
use embeddenator_vsa::{VsaConfig, VsaConfigSchema, SparsityScaling};
// Custom schema for a specific application
let schema = VsaConfigSchema {
dimension: 8192,
density: 0.015,
scaling: Some(SparsityScaling::SquareRoot),
auto_thin: Some(1000),
min_nnz: Some(16),
max_nnz: Some(512),
target_accuracy: Some(0.97),
};
let config = VsaConfig::from_schema(schema);
assert_eq!(config.dimension, 8192);Fields§
§dimension: usizeRequired: Number of dimensions
density: f64Required: Target density (0.0-1.0)
scaling: Option<SparsityScaling>Optional: Sparsity scaling mode
auto_thin: Option<usize>Optional: Auto-thinning threshold (0 to disable)
min_nnz: Option<usize>Optional: Minimum non-zero elements
max_nnz: Option<usize>Optional: Maximum non-zero elements
target_accuracy: Option<f64>Optional: Target reconstruction accuracy
Implementations§
Source§impl VsaConfigSchema
impl VsaConfigSchema
Sourcepub fn new(dimension: usize, density: f64) -> Self
pub fn new(dimension: usize, density: f64) -> Self
Create a minimal schema with just dimension and density
Sourcepub fn with_scaling(self, mode: SparsityScaling) -> Self
pub fn with_scaling(self, mode: SparsityScaling) -> Self
Set scaling mode
Sourcepub fn with_auto_thin(self, threshold: usize) -> Self
pub fn with_auto_thin(self, threshold: usize) -> Self
Set auto-thin threshold
Trait Implementations§
Source§impl Clone for VsaConfigSchema
impl Clone for VsaConfigSchema
Source§fn clone(&self) -> VsaConfigSchema
fn clone(&self) -> VsaConfigSchema
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for VsaConfigSchema
impl Debug for VsaConfigSchema
Source§impl<'de> Deserialize<'de> for VsaConfigSchema
impl<'de> Deserialize<'de> for VsaConfigSchema
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for VsaConfigSchema
impl RefUnwindSafe for VsaConfigSchema
impl Send for VsaConfigSchema
impl Sync for VsaConfigSchema
impl Unpin for VsaConfigSchema
impl UnwindSafe for VsaConfigSchema
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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