pub struct StaticBackend { /* private fields */ }Expand description
Model2Vec static embedding backend.
Holds the vocabulary matrix in memory (optionally memory-mapped for cold-start speed). The tokenizer used is the same tokenizer.json as the source model (BGE-Large / ModernBERT), so token IDs are consistent with the ONNX/Candle paths.
Implementations§
Source§impl StaticBackend
impl StaticBackend
Sourcepub async fn new(config: &ModelConfig) -> Result<Self>
pub async fn new(config: &ModelConfig) -> Result<Self>
Build a new StaticBackend.
Downloads vocab_matrix.bin and the model tokenizer from HuggingFace
on first run; subsequent calls use the local cache.
Sourcepub fn from_matrix(
matrix: Vec<f32>,
tokenizer: Tokenizer,
dimension: usize,
) -> Result<Self>
pub fn from_matrix( matrix: Vec<f32>, tokenizer: Tokenizer, dimension: usize, ) -> Result<Self>
Build from a pre-loaded vocabulary matrix (useful for tests).
matrix must be a flat row-major array of shape [vocab_size × dimension].
Sourcepub fn model2vec_dimension() -> usize
pub fn model2vec_dimension() -> usize
Configured Model2Vec output dimension (DAKERA_MRL_DIM, default 256).
Trait Implementations§
Source§impl EmbeddingBackend for StaticBackend
impl EmbeddingBackend for StaticBackend
Source§fn embed_batch<'life0, 'life1, 'async_trait>(
&'life0 self,
texts: &'life1 [String],
) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn embed_batch<'life0, 'life1, 'async_trait>(
&'life0 self,
texts: &'life1 [String],
) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Embed a batch of raw texts and return a float32 embedding per input. Read more
Source§fn dimension(&self) -> usize
fn dimension(&self) -> usize
Embedding dimensionality (fixed for the lifetime of the backend).
Source§fn backend_kind(&self) -> BackendKind
fn backend_kind(&self) -> BackendKind
The concrete backend kind — used for metrics and re-embed bookkeeping.
Auto Trait Implementations§
impl Freeze for StaticBackend
impl RefUnwindSafe for StaticBackend
impl Send for StaticBackend
impl Sync for StaticBackend
impl Unpin for StaticBackend
impl UnsafeUnpin for StaticBackend
impl UnwindSafe for StaticBackend
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