pub struct SQuaJLConfig {
pub input_dim: usize,
pub sketch_dim: usize,
pub bits: u8,
pub hashes_per_input: u8,
pub clip: f32,
pub seed: u64,
pub metric: SimilarityMetric,
pub norm_log2_min: f32,
pub norm_log2_max: f32,
}Expand description
Configuration for the stateless sparse-JL quantizer.
The defaults are chosen to be a practical starting point for 384-dimensional
sentence embeddings such as all-MiniLM-L6-v2.
Fields§
§input_dim: usizeInput embedding dimension.
sketch_dim: usizeOutput sketch dimension.
Larger values usually improve recall at the cost of more memory.
bits: u8Number of bits per quantized coordinate.
Supported range: 1..=8.
hashes_per_input: u8Number of non-zero sketch updates per input coordinate.
Larger values reduce projection noise but cost more CPU at encode time.
clip: f32Symmetric clip range for the scaled sketch.
Coordinates are clipped to [-clip, clip] before scalar quantization.
seed: u64Global seed used to derive sparse bucket locations and signs.
metric: SimilarityMetricSimilarity objective for scoring.
norm_log2_min: f32Lower bound for log2(norm) when the norm channel is enabled.
norm_log2_max: f32Upper bound for log2(norm) when the norm channel is enabled.
Implementations§
Source§impl SQuaJLConfig
impl SQuaJLConfig
Sourcepub fn new(input_dim: usize) -> Self
pub fn new(input_dim: usize) -> Self
Creates a configuration with the provided input dimension and sensible defaults for the remaining fields.
Sourcepub fn with_sketch_dim(self, sketch_dim: usize) -> Self
pub fn with_sketch_dim(self, sketch_dim: usize) -> Self
Sets the output sketch dimension.
Sourcepub fn with_hashes_per_input(self, hashes_per_input: u8) -> Self
pub fn with_hashes_per_input(self, hashes_per_input: u8) -> Self
Sets the number of sparse hash updates performed for each input dimension.
Sourcepub fn with_clip(self, clip: f32) -> Self
pub fn with_clip(self, clip: f32) -> Self
Sets the symmetric clip range used by the scalar quantizer.
Sourcepub fn with_seed(self, seed: u64) -> Self
pub fn with_seed(self, seed: u64) -> Self
Sets the deterministic seed used by the sparse signed projection.
Sourcepub fn with_metric(self, metric: SimilarityMetric) -> Self
pub fn with_metric(self, metric: SimilarityMetric) -> Self
Sets the similarity objective.
Sourcepub fn with_norm_log2_range(self, min: f32, max: f32) -> Self
pub fn with_norm_log2_range(self, min: f32, max: f32) -> Self
Sets the log2(norm) range for the optional norm channel.
Trait Implementations§
Source§impl Clone for SQuaJLConfig
impl Clone for SQuaJLConfig
Source§fn clone(&self) -> SQuaJLConfig
fn clone(&self) -> SQuaJLConfig
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 SQuaJLConfig
impl Debug for SQuaJLConfig
Source§impl Default for SQuaJLConfig
impl Default for SQuaJLConfig
Source§impl PartialEq for SQuaJLConfig
impl PartialEq for SQuaJLConfig
Source§fn eq(&self, other: &SQuaJLConfig) -> bool
fn eq(&self, other: &SQuaJLConfig) -> bool
self and other values to be equal, and is used by ==.