pub struct CandleEmbeddingEngine { /* private fields */ }Expand description
Pure-Rust embedding engine using candle for BERT inference.
Uses candle-transformers’ BERT implementation with tokenizers for tokenisation. No C/C++ FFI dependencies — compiles on all platforms.
A dedicated OS thread owns the model exclusively. Async callers send work via a channel and await a oneshot reply. If a call times out, the caller gets an error immediately; the worker finishes its current task, discards the stale reply channel, and picks up the next request — no restart needed.
Implementations§
Source§impl CandleEmbeddingEngine
impl CandleEmbeddingEngine
Sourcepub fn new(
embed_timeout: Duration,
queue_size: usize,
reporter: SubsystemReporter,
) -> Result<Self, MemoryError>
pub fn new( embed_timeout: Duration, queue_size: usize, reporter: SubsystemReporter, ) -> Result<Self, MemoryError>
Initialise the candle embedding engine.
Downloads model weights from HuggingFace Hub on first use (cached
in the standard HF cache directory, respects HF_HOME).
embed_timeout caps how long a single embed call may
block. If the worker is still running when the timeout fires, the caller
gets an error but the engine recovers automatically — no restart needed.
queue_size sets the bounded channel capacity — how many requests can
queue behind the one being processed. Extra callers get an immediate
“busy” error.
reporter receives report_ok/report_err after each embed call so
the /readyz handler can reflect the engine’s operational state without
active probing.
Trait Implementations§
Source§impl Drop for CandleEmbeddingEngine
impl Drop for CandleEmbeddingEngine
Source§impl EmbeddingBackend for CandleEmbeddingEngine
impl EmbeddingBackend for CandleEmbeddingEngine
Source§fn embed<'life0, 'life1, 'async_trait>(
&'life0 self,
texts: &'life1 [String],
) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>, MemoryError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn embed<'life0, 'life1, 'async_trait>(
&'life0 self,
texts: &'life1 [String],
) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>, MemoryError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn dimensions(&self) -> usize
fn dimensions(&self) -> usize
Auto Trait Implementations§
impl Freeze for CandleEmbeddingEngine
impl !RefUnwindSafe for CandleEmbeddingEngine
impl Send for CandleEmbeddingEngine
impl Sync for CandleEmbeddingEngine
impl Unpin for CandleEmbeddingEngine
impl UnsafeUnpin for CandleEmbeddingEngine
impl !UnwindSafe for CandleEmbeddingEngine
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
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>
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>
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