pub struct AdaptiveQuantizer { /* private fields */ }Expand description
Adaptive quantizer that supports per-vector bit-width selection and tier promotion/demotion.
Wraps three TurboQuantizer instances (hot/warm/cold) and provides
methods to encode at a specific tier, promote to higher precision,
or demote to lower precision.
Implementations§
Source§impl AdaptiveQuantizer
impl AdaptiveQuantizer
Sourcepub fn builder(dim: usize, seed: u64) -> AdaptiveBuilder
pub fn builder(dim: usize, seed: u64) -> AdaptiveBuilder
Create a builder for an adaptive quantizer.
§Arguments
dim— Vector dimensionseed— Random seed for deterministic quantization
Sourcepub fn encode_adaptive(
&self,
vector: &[f32],
tier: Tier,
) -> Result<AdaptiveCode>
pub fn encode_adaptive( &self, vector: &[f32], tier: Tier, ) -> Result<AdaptiveCode>
Encode a vector at the specified tier.
Sourcepub fn decode_adaptive(&self, code: &AdaptiveCode) -> Vec<f32>
pub fn decode_adaptive(&self, code: &AdaptiveCode) -> Vec<f32>
Decode an adaptive code back to an approximate vector.
Sourcepub fn inner_product_estimate(
&self,
code: &AdaptiveCode,
query: &[f32],
) -> Result<f32>
pub fn inner_product_estimate( &self, code: &AdaptiveCode, query: &[f32], ) -> Result<f32>
Estimate inner product between a code and a query vector.
Sourcepub fn promote(&self, code: &AdaptiveCode) -> Result<AdaptiveCode>
pub fn promote(&self, code: &AdaptiveCode) -> Result<AdaptiveCode>
Promote a code to a higher-precision tier.
Decodes the current code and re-encodes at the next tier up. Hot codes cannot be promoted further.
Note: Promotion operates on the approximate reconstruction, not the original vector. The result is lower quality than encoding the original vector directly at the target tier. Use when the original is unavailable.
Sourcepub fn demote(&self, code: &AdaptiveCode) -> Result<AdaptiveCode>
pub fn demote(&self, code: &AdaptiveCode) -> Result<AdaptiveCode>
Demote a code to a lower-precision tier.
Decodes the current code and re-encodes at the next tier down. Cold codes cannot be demoted further.
Auto Trait Implementations§
impl Freeze for AdaptiveQuantizer
impl RefUnwindSafe for AdaptiveQuantizer
impl Send for AdaptiveQuantizer
impl Sync for AdaptiveQuantizer
impl Unpin for AdaptiveQuantizer
impl UnsafeUnpin for AdaptiveQuantizer
impl UnwindSafe for AdaptiveQuantizer
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<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.