pub struct PQConfig {
pub dim: usize,
pub num_subspaces: usize,
pub dims_per_block: usize,
pub num_centroids: usize,
pub seed: u64,
pub anisotropic: bool,
pub aniso_eta: f32,
pub aniso_threshold: f32,
pub use_opq: bool,
pub opq_iters: usize,
}Expand description
Configuration for Product Quantization with OPQ and Anisotropic Loss
Fields§
§dim: usizeVector dimension
num_subspaces: usizeNumber of subspaces (M) - computed from dim / dims_per_block
dims_per_block: usizeDimensions per subspace block (ScaNN recommends 2)
num_centroids: usizeNumber of centroids per subspace (K) - typically 256 for u8 codes
seed: u64Random seed for reproducibility
anisotropic: boolUse anisotropic quantization (true ScaNN-style parallel/orthogonal weighting)
aniso_eta: f32Anisotropic eta: ratio of parallel to orthogonal error weight (η)
aniso_threshold: f32Anisotropic threshold T: only consider inner products >= T
use_opq: boolUse OPQ rotation matrix (learned via SVD)
opq_iters: usizeNumber of OPQ iterations
Implementations§
Source§impl PQConfig
impl PQConfig
Sourcepub fn new_fast(dim: usize) -> Self
pub fn new_fast(dim: usize) -> Self
Create config with larger subspaces (faster but less accurate)
Sourcepub fn new_balanced(dim: usize) -> Self
pub fn new_balanced(dim: usize) -> Self
Create balanced config (good recall/speed tradeoff) Uses 16 subspaces for 128D+ vectors, 8 for smaller
pub fn with_dims_per_block(self, d: usize) -> Self
pub fn with_subspaces(self, m: usize) -> Self
pub fn with_centroids(self, k: usize) -> Self
pub fn with_anisotropic(self, enabled: bool, eta: f32) -> Self
pub fn with_opq(self, enabled: bool, iters: usize) -> Self
Sourcepub fn subspace_dim(&self) -> usize
pub fn subspace_dim(&self) -> usize
Dimension of each subspace
Trait Implementations§
Source§impl<'de> Deserialize<'de> for PQConfig
impl<'de> Deserialize<'de> for PQConfig
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 PQConfig
impl RefUnwindSafe for PQConfig
impl Send for PQConfig
impl Sync for PQConfig
impl Unpin for PQConfig
impl UnwindSafe for PQConfig
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 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>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
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
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.