pub struct EmbedEngine { /* private fields */ }Implementations§
Source§impl EmbedEngine
impl EmbedEngine
Sourcepub fn new() -> Result<Self, EmbedError>
pub fn new() -> Result<Self, EmbedError>
Initialize with default cache directory (~/.cache/fastembed).
Sourcepub fn new_with_cache(cache_dir: PathBuf) -> Result<Self, EmbedError>
pub fn new_with_cache(cache_dir: PathBuf) -> Result<Self, EmbedError>
Initialize with a custom model cache directory.
Sourcepub fn embed(&self, text: &str) -> Result<Vec<f32>, EmbedError>
pub fn embed(&self, text: &str) -> Result<Vec<f32>, EmbedError>
Embed a single text string. Returns a 384-dimensional vector.
Sourcepub fn embed_batch(&self, texts: &[&str]) -> Result<Vec<Vec<f32>>, EmbedError>
pub fn embed_batch(&self, texts: &[&str]) -> Result<Vec<Vec<f32>>, EmbedError>
Embed a batch of texts. Returns one vector per input text.
Sourcepub fn cosine_similarity(a: &[f32], b: &[f32]) -> f32
pub fn cosine_similarity(a: &[f32], b: &[f32]) -> f32
Compute cosine similarity between two f32 vectors. Returns 0.0 if either vector has zero magnitude.
Auto Trait Implementations§
impl !Freeze for EmbedEngine
impl !RefUnwindSafe for EmbedEngine
impl Send for EmbedEngine
impl Sync for EmbedEngine
impl Unpin for EmbedEngine
impl UnsafeUnpin for EmbedEngine
impl !UnwindSafe for EmbedEngine
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> 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