pub trait Embedder: Send + Sync {
// Required methods
fn embed(&self, text: &str) -> Result<Vec<f32>>;
fn embed_batch(&self, texts: &[&str]) -> Result<Vec<Vec<f32>>>;
fn dimension(&self) -> usize;
fn model_id(&self) -> &str;
// Provided methods
fn embed_query(&self, query: &str) -> Result<Vec<f32>> { ... }
fn embed_document(&self, document: &str) -> Result<Vec<f32>> { ... }
fn embed_chunks(&self, chunks: &mut [Chunk]) -> Result<()> { ... }
}Expand description
Trait for embedding generation
Required Methods§
Provided Methods§
Sourcefn embed_document(&self, document: &str) -> Result<Vec<f32>>
fn embed_document(&self, document: &str) -> Result<Vec<f32>>
Embed a document (may use document prefix)
Sourcefn embed_chunks(&self, chunks: &mut [Chunk]) -> Result<()>
fn embed_chunks(&self, chunks: &mut [Chunk]) -> Result<()>
Embed chunks and update them in place
Trait Implementations§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl Embedder for Box<dyn Embedder>
Blanket impl so HybridRetriever<Box<dyn Embedder>> works without
requiring the caller to know the concrete embedder type at compile time.
impl Embedder for Box<dyn Embedder>
Blanket impl so HybridRetriever<Box<dyn Embedder>> works without
requiring the caller to know the concrete embedder type at compile time.
fn embed(&self, text: &str) -> Result<Vec<f32>>
fn embed_batch(&self, texts: &[&str]) -> Result<Vec<Vec<f32>>>
fn dimension(&self) -> usize
fn model_id(&self) -> &str
fn embed_query(&self, query: &str) -> Result<Vec<f32>>
fn embed_document(&self, document: &str) -> Result<Vec<f32>>
fn embed_chunks(&self, chunks: &mut [Chunk]) -> Result<()>
Implementors§
impl Embedder for FastEmbedder
Available on crate feature
embeddings only.impl Embedder for MockEmbedder
impl Embedder for NemotronEmbedder
Available on crate feature
nemotron only.