pub struct Model2VecBackend { /* private fields */ }Expand description
Static-embedding backend powered by model2vec-rs.
Construct via Self::load — the call is async and offloads the
(blocking) StaticModel::from_pretrained download/load onto
tokio::task::spawn_blocking.
Implementations§
Source§impl Model2VecBackend
impl Model2VecBackend
Sourcepub async fn load(model_type: EmbeddingModelType) -> Result<Self>
pub async fn load(model_type: EmbeddingModelType) -> Result<Self>
Download (if needed) and load a Model2Vec model from the HuggingFace
Hub. Verifies the runtime embedding dimension against the
EmbeddingModelType constant and returns an error on mismatch —
silent drift would corrupt every downstream HNSW index.
Trait Implementations§
Source§impl EmbeddingBackend for Model2VecBackend
impl EmbeddingBackend for Model2VecBackend
Source§fn is_bert_based(&self) -> bool
fn is_bert_based(&self) -> bool
Model2Vec is not BERT — the engine’s BERT branch (concurrency controller, adaptive batching, timeout) is bypassed. The static path dispatches directly because each call is ms-cheap.
Source§fn embedding_dimension(&self) -> usize
fn embedding_dimension(&self) -> usize
Dimension of the produced embedding vectors.
Source§fn process_batch<'life0, 'async_trait>(
&'life0 self,
texts: Vec<String>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn process_batch<'life0, 'async_trait>(
&'life0 self,
texts: Vec<String>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Process a batch of texts and return one embedding vector per text.
The engine slices large inputs into chunks no larger than the engine’s
current_batch_size before calling this method.Auto Trait Implementations§
impl Freeze for Model2VecBackend
impl RefUnwindSafe for Model2VecBackend
impl Send for Model2VecBackend
impl Sync for Model2VecBackend
impl Unpin for Model2VecBackend
impl UnsafeUnpin for Model2VecBackend
impl UnwindSafe for Model2VecBackend
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