pub struct QuantizedMatrix { /* private fields */ }Expand description
A row-quantized f32 matrix: one i8 code per element plus one f32 scale per row.
Implementations§
Source§impl QuantizedMatrix
impl QuantizedMatrix
Sourcepub fn dequantize(&self) -> Array2<f32>
pub fn dequantize(&self) -> Array2<f32>
Reconstruct (decode) the approximate f32 matrix as code * scale[row].
Sourcepub fn from_parts(
data: Array2<i8>,
scales: Array1<f32>,
) -> Result<Self, EmbeddingError>
pub fn from_parts( data: Array2<i8>, scales: Array1<f32>, ) -> Result<Self, EmbeddingError>
Construct a QuantizedMatrix from existing codes and scales (for example, decoded from a
wire format).
§Errors
Returns EmbeddingError::EmptyInput when data is empty and
EmbeddingError::DimensionMismatch when scales.len() != data.nrows().
Sourcepub fn query_corpus_scores_quantized(
&self,
corpus: &QuantizedMatrix,
metric: Metric,
) -> Result<Array2<f32>, EmbeddingError>
pub fn query_corpus_scores_quantized( &self, corpus: &QuantizedMatrix, metric: Metric, ) -> Result<Array2<f32>, EmbeddingError>
Score this quantized matrix as queries against a quantized corpus under metric.
Implemented as dequantize-then-existing-kernel: both operands are decoded to f32 and
scored with query_corpus_scores. Results approximate the full-precision path within the
quantization tolerance.
§Errors
Returns the same errors as query_corpus_scores (empty input, dimension mismatch, or
cosine zero-norm rows).
Trait Implementations§
Source§impl Clone for QuantizedMatrix
impl Clone for QuantizedMatrix
Source§fn clone(&self) -> QuantizedMatrix
fn clone(&self) -> QuantizedMatrix
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 QuantizedMatrix
impl Debug for QuantizedMatrix
Source§impl PartialEq for QuantizedMatrix
impl PartialEq for QuantizedMatrix
Source§fn eq(&self, other: &QuantizedMatrix) -> bool
fn eq(&self, other: &QuantizedMatrix) -> bool
self and other values to be equal, and is used by ==.