pub struct EmbeddingCompressionCodec { /* private fields */ }Expand description
Codec for compressing dense embedding vectors.
Use register_codec to create named codec configurations,
then call compress / decompress as needed.
Implementations§
Source§impl EmbeddingCompressionCodec
impl EmbeddingCompressionCodec
Sourcepub fn register_codec(
&mut self,
name: &str,
method: EccMethod,
bits: u8,
block_size: usize,
) -> EccCodecId
pub fn register_codec( &mut self, name: &str, method: EccMethod, bits: u8, block_size: usize, ) -> EccCodecId
Register a new codec and return its id.
bits must be 4, 8, or 16. block_size is used by PQ / HybridPQ.
Sourcepub fn register_from_config(&mut self, config: &EccCodecConfig) -> EccCodecId
pub fn register_from_config(&mut self, config: &EccCodecConfig) -> EccCodecId
Register a codec from a full EccCodecConfig.
Sourcepub fn get_spec(&self, id: EccCodecId) -> Option<&EccCodecSpec>
pub fn get_spec(&self, id: EccCodecId) -> Option<&EccCodecSpec>
Look up a codec spec by id.
Sourcepub fn codec_count(&self) -> usize
pub fn codec_count(&self) -> usize
Return the number of registered codecs.
Sourcepub fn compress(
&mut self,
codec_id: EccCodecId,
embedding: &[f64],
) -> Result<EccCompressed, EccError>
pub fn compress( &mut self, codec_id: EccCodecId, embedding: &[f64], ) -> Result<EccCompressed, EccError>
Compress a single embedding vector using the specified codec.
Sourcepub fn decompress(
&self,
compressed: &EccCompressed,
) -> Result<Vec<f64>, EccError>
pub fn decompress( &self, compressed: &EccCompressed, ) -> Result<Vec<f64>, EccError>
Decompress a previously compressed payload.
Sourcepub fn compress_batch(
&mut self,
codec_id: EccCodecId,
embeddings: &[Vec<f64>],
) -> Vec<Result<EccCompressed, EccError>>
pub fn compress_batch( &mut self, codec_id: EccCodecId, embeddings: &[Vec<f64>], ) -> Vec<Result<EccCompressed, EccError>>
Compress a batch of embeddings with the same codec.
Sourcepub fn decompress_batch(
&self,
batch: &[EccCompressed],
) -> Vec<Result<Vec<f64>, EccError>>
pub fn decompress_batch( &self, batch: &[EccCompressed], ) -> Vec<Result<Vec<f64>, EccError>>
Decompress a batch of compressed payloads.
Sourcepub fn reconstruction_error(original: &[f64], decompressed: &[f64]) -> f64
pub fn reconstruction_error(original: &[f64], decompressed: &[f64]) -> f64
Compute mean squared error between original and decompressed vectors.
Sourcepub fn estimate_ratio(&self, codec_id: EccCodecId, dim: usize) -> f64
pub fn estimate_ratio(&self, codec_id: EccCodecId, dim: usize) -> f64
Estimate the theoretical compression ratio for a given codec and vector dimension.
The estimate is based on the quantization bit-width and method overhead.
Sourcepub fn codec_stats(&self) -> EccCodecStats
pub fn codec_stats(&self) -> EccCodecStats
Compute aggregate statistics over the compression log.
Sourcepub fn log_entries(&self) -> &VecDeque<EccCompressionRecord>
pub fn log_entries(&self) -> &VecDeque<EccCompressionRecord>
Return a read-only view of the compression log.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for EmbeddingCompressionCodec
impl RefUnwindSafe for EmbeddingCompressionCodec
impl Send for EmbeddingCompressionCodec
impl Sync for EmbeddingCompressionCodec
impl Unpin for EmbeddingCompressionCodec
impl UnsafeUnpin for EmbeddingCompressionCodec
impl UnwindSafe for EmbeddingCompressionCodec
Blanket Implementations§
impl<T> Allocation for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
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.