Skip to main content

Embedder

Trait Embedder 

Source
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§

Source

fn embed(&self, text: &str) -> Result<Vec<f32>>

Embed a single text

Source

fn embed_batch(&self, texts: &[&str]) -> Result<Vec<Vec<f32>>>

Batch embed multiple texts

Source

fn dimension(&self) -> usize

Get embedding dimension

Source

fn model_id(&self) -> &str

Get model identifier

Provided Methods§

Source

fn embed_query(&self, query: &str) -> Result<Vec<f32>>

Embed a query (may use query prefix)

Source

fn embed_document(&self, document: &str) -> Result<Vec<f32>>

Embed a document (may use document prefix)

Source

fn embed_chunks(&self, chunks: &mut [Chunk]) -> Result<()>

Embed chunks and update them in place

Trait Implementations§

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.

Source§

fn embed(&self, text: &str) -> Result<Vec<f32>>

Embed a single text
Source§

fn embed_batch(&self, texts: &[&str]) -> Result<Vec<Vec<f32>>>

Batch embed multiple texts
Source§

fn dimension(&self) -> usize

Get embedding dimension
Source§

fn model_id(&self) -> &str

Get model identifier
Source§

fn embed_query(&self, query: &str) -> Result<Vec<f32>>

Embed a query (may use query prefix)
Source§

fn embed_document(&self, document: &str) -> Result<Vec<f32>>

Embed a document (may use document prefix)
Source§

fn embed_chunks(&self, chunks: &mut [Chunk]) -> Result<()>

Embed chunks and update them in place

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.

Source§

fn embed(&self, text: &str) -> Result<Vec<f32>>

Source§

fn embed_batch(&self, texts: &[&str]) -> Result<Vec<Vec<f32>>>

Source§

fn dimension(&self) -> usize

Source§

fn model_id(&self) -> &str

Source§

fn embed_query(&self, query: &str) -> Result<Vec<f32>>

Source§

fn embed_document(&self, document: &str) -> Result<Vec<f32>>

Source§

fn embed_chunks(&self, chunks: &mut [Chunk]) -> Result<()>

Implementors§

Source§

impl Embedder for FastEmbedder

Available on crate feature embeddings only.
Source§

impl Embedder for MockEmbedder

Source§

impl Embedder for NemotronEmbedder

Available on crate feature nemotron only.
Source§

impl Embedder for TfIdfEmbedder