#[non_exhaustive]pub struct TernaryCodec {
pub dim: usize,
}Expand description
BitNet b1.58 ternary codec.
Stateless aside from dim. Per-vector scaling (absmean) is computed in
VectorCodec::encode and stored in the header’s global_scale field.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.dim: usizeImplementations§
Trait Implementations§
Source§impl VectorCodec for TernaryCodec
impl VectorCodec for TernaryCodec
Source§type Quantized = TernaryQuantized
type Quantized = TernaryQuantized
The packed quantized form. Must be convertible to a
UnifiedQuantizedVector
reference via AsRef.Source§type Query = TernaryQuery
type Query = TernaryQuery
The prepared query form (codec-specific).
Source§fn encode(&self, v: &[f32]) -> TernaryQuantized
fn encode(&self, v: &[f32]) -> TernaryQuantized
Encode a single FP32 vector into the codec’s packed form.
Source§fn prepare_query(&self, q: &[f32]) -> TernaryQuery
fn prepare_query(&self, q: &[f32]) -> TernaryQuery
Prepare a query for distance computations against this codec.
May rotate, normalize, build a LUT, etc.
Source§fn fast_symmetric_distance(
&self,
q: &Self::Quantized,
v: &Self::Quantized,
) -> f32
fn fast_symmetric_distance( &self, q: &Self::Quantized, v: &Self::Quantized, ) -> f32
Fast symmetric distance — bitwise / heuristic. Used during HNSW
upper-layer routing. Both arguments are quantized; no scalar
correction; no outlier resolution. Hot path; must be inline-friendly.
Source§fn exact_asymmetric_distance(
&self,
q: &TernaryQuery,
v: &Self::Quantized,
) -> f32
fn exact_asymmetric_distance( &self, q: &TernaryQuery, v: &Self::Quantized, ) -> f32
Exact asymmetric distance — full ADC with scalar correction and
sparse outlier resolution. Used at base-layer rerank only. Slower
but high-fidelity.
Auto Trait Implementations§
impl Freeze for TernaryCodec
impl RefUnwindSafe for TernaryCodec
impl Send for TernaryCodec
impl Sync for TernaryCodec
impl Unpin for TernaryCodec
impl UnsafeUnpin for TernaryCodec
impl UnwindSafe for TernaryCodec
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<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.