pub trait Embedder: Send + Sync {
// Required methods
fn embed<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
texts: &'life1 [&'life2 str],
) -> Pin<Box<dyn Future<Output = Result<Vec<Embedding>, EmbedError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn dimension(&self) -> usize;
fn model_id(&self) -> &str;
// Provided methods
fn embed_one<'life0, 'life1, 'async_trait>(
&'life0 self,
text: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Embedding, EmbedError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn max_batch_size(&self) -> usize { ... }
fn fingerprint(&self) -> String { ... }
}Required Methods§
fn embed<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
texts: &'life1 [&'life2 str],
) -> Pin<Box<dyn Future<Output = Result<Vec<Embedding>, EmbedError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Sourcefn dimension(&self) -> usize
fn dimension(&self) -> usize
Number of dimensions every vector this embedder produces has.
A store built for one dimension cannot hold vectors of another, so an index persists this and refuses to mix them.
Sourcefn model_id(&self) -> &str
fn model_id(&self) -> &str
Stable identifier for the model behind this embedder, e.g.
"fastembed:AllMiniLML6V2" or "openai:text-embedding-3-small".
It must stay the same across runs and versions for the same model, and
differ whenever the produced vectors would be incompatible. It is the
discriminating half of fingerprint.
Provided Methods§
fn embed_one<'life0, 'life1, 'async_trait>(
&'life0 self,
text: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Embedding, EmbedError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Sourcefn max_batch_size(&self) -> usize
fn max_batch_size(&self) -> usize
Largest number of texts a single embed call should
receive. Callers indexing many chunks split their work into groups of at
most this size, bounding peak memory (local models) and request size
(remote APIs). The default suits the on-device models; raise or lower it
to match a backend’s limits.
Sourcefn fingerprint(&self) -> String
fn fingerprint(&self) -> String
Fingerprint an index stores to detect that it was built with a different embedder. Re-indexing is required whenever this changes.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".