pub trait Embedder: Send + Sync {
// Required methods
fn embed(&self, text: &str) -> Result<Vec<f32>, EmbedError>;
fn dimension(&self) -> usize;
fn model_name(&self) -> &str;
// Provided method
fn embed_batch(&self, texts: &[&str]) -> Result<Vec<Vec<f32>>, EmbedError> { ... }
}Expand description
Trait for converting text to embedding vectors.
Implementations may use local models (ONNX, TorchScript) or remote APIs (OpenAI, Cohere).
Required Methods§
Sourcefn embed(&self, text: &str) -> Result<Vec<f32>, EmbedError>
fn embed(&self, text: &str) -> Result<Vec<f32>, EmbedError>
Embed a single text string into a vector.
Sourcefn model_name(&self) -> &str
fn model_name(&self) -> &str
Name of the embedding model.
Provided Methods§
Sourcefn embed_batch(&self, texts: &[&str]) -> Result<Vec<Vec<f32>>, EmbedError>
fn embed_batch(&self, texts: &[&str]) -> Result<Vec<Vec<f32>>, EmbedError>
Embed multiple texts in a batch (more efficient for APIs).