pub struct ToyEmbedder { /* private fields */ }Expand description
Deterministic hashed bag-of-tokens embedder.
embed(text) lowercases, ASCII-tokenises on non-alphanumeric
boundaries, hashes each token to two bucket positions
(FNV-1a-style) and adds 1.0 to each. The output vector is L2-
normalised so dense cosine similarity ranks documents by
(count-weighted) shared-token overlap.
Implementations§
Source§impl ToyEmbedder
impl ToyEmbedder
Sourcepub fn new(dim: u32) -> Self
pub fn new(dim: u32) -> Self
Construct a new embedder with the given dimension. dim
must be > 0; values < 32 lead to heavy hash collisions on
natural text.
Sourcepub fn model(&self) -> &str
pub fn model(&self) -> &str
Model identifier (passed to mnem’s vector lane so embeddings match query vectors at retrieve time).
Sourcepub fn embed_text(&self, text: &str) -> Vec<f32>
pub fn embed_text(&self, text: &str) -> Vec<f32>
Embed a string into a unit-norm vector.
Trait Implementations§
Source§impl Clone for ToyEmbedder
impl Clone for ToyEmbedder
Source§fn clone(&self) -> ToyEmbedder
fn clone(&self) -> ToyEmbedder
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ToyEmbedder
impl RefUnwindSafe for ToyEmbedder
impl Send for ToyEmbedder
impl Sync for ToyEmbedder
impl Unpin for ToyEmbedder
impl UnsafeUnpin for ToyEmbedder
impl UnwindSafe for ToyEmbedder
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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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 more