pub struct QuantizedVector {
pub data: Vec<i8>,
pub params: QuantizationParams,
pub norm: f32,
}Expand description
Unstable: INT8 quantized vector; struct layout and invariants may change.
Quantized int8 vector with its parameters.
Fields§
§data: Vec<i8>Unstable: raw quantized data; invariant ([-127, 127]) enforced by constructor.
§Invariant
All values must be in the range [-127, 127]. The value -128 causes
incorrect results in AVX-512 VNNI and AVX2 SIMD paths due to vpabsb
saturation behavior. The from_f32 constructor enforces this via clamping.
params: QuantizationParamsUnstable: quantization parameters; may be separated from the vector.
norm: f32Unstable: L2 norm; may be removed or moved.
Implementations§
Source§impl QuantizedVector
impl QuantizedVector
Sourcepub fn from_f32(vector: &[f32]) -> Self
pub fn from_f32(vector: &[f32]) -> Self
Unstable: quantization constructor; clamping behavior may change.
Sourcepub fn to_f32(&self) -> Vec<f32>
pub fn to_f32(&self) -> Vec<f32>
Unstable: dequantization; output precision may change with scheme update.
§Precision
INT8 symmetric quantization maps [-max_abs, max_abs] to [-127, 127],
so the quantization step size is max_abs / 127. The maximum per-element
round-trip error is bounded by half a quantization step: max_abs / 254.
For a 384-dim unit-norm embedding (max_abs ≈ 1.0), expect element-wise
absolute error ≤ 0.004 and cosine-similarity error ≤ 0.5%.
Sourcepub fn dot_product(&self, other: &QuantizedVector) -> f32
pub fn dot_product(&self, other: &QuantizedVector) -> f32
Unstable: delegates to dot_product_i8; SIMD dispatch may change.
Sourcepub fn cosine_similarity(&self, other: &QuantizedVector) -> f32
pub fn cosine_similarity(&self, other: &QuantizedVector) -> f32
Unstable: delegates to cosine_similarity_i8; SIMD dispatch may change.
Trait Implementations§
Source§impl Clone for QuantizedVector
impl Clone for QuantizedVector
Source§fn clone(&self) -> QuantizedVector
fn clone(&self) -> QuantizedVector
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more