pub struct Embedder { /* private fields */ }Expand description
Thread-safe wrapper around a fastembed TextEmbedding instance.
Clone is cheap — inner state is Arc-wrapped.
Implementations§
Source§impl Embedder
impl Embedder
Sourcepub fn new() -> Result<Self, EmbedError>
pub fn new() -> Result<Self, EmbedError>
Create a new embedder with the default model (all-MiniLM-L6-v2).
On first call this will download the ONNX model (~23 MB) to
~/.cache/huggingface/hub/ if not already cached.
Sourcepub fn embed(&self, texts: &[&str]) -> Result<Vec<Vec<f32>>, EmbedError>
pub fn embed(&self, texts: &[&str]) -> Result<Vec<Vec<f32>>, EmbedError>
Embed a slice of strings, returning one Vec<f32> per input.
Sourcepub fn embed_one(&self, text: &str) -> Result<Vec<f32>, EmbedError>
pub fn embed_one(&self, text: &str) -> Result<Vec<f32>, EmbedError>
Convenience: embed a single string.
Sourcepub fn to_vector32_json(v: &[f32]) -> String
pub fn to_vector32_json(v: &[f32]) -> String
Serialize a Vec<f32> to a JSON array string suitable for vector32(?)
in Turso SQL.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Embedder
impl RefUnwindSafe for Embedder
impl Send for Embedder
impl Sync for Embedder
impl Unpin for Embedder
impl UnsafeUnpin for Embedder
impl UnwindSafe for Embedder
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