Expand description
Lazy-loading embedding provider with idle eviction and LRU query cache.
Wraps FastembedProvider behind a state machine that defers model
download and ONNX session initialization until the first embed call.
After a configurable idle timeout, the ONNX session is dropped to
release memory while keeping model weights on disk for fast reload.
ⓘ
use llm_kernel::embedding::{
EmbeddingModel, LazyFastembedProvider, LazyOpts, EmbeddingProvider,
};
let provider = LazyFastembedProvider::new(
EmbeddingModel::BGESmallENV15,
"/path/to/cache".into(),
LazyOpts::default(),
);
// Constructor returns instantly — no download yet
let result = provider.embed("hello world")?; // triggers lazy loadStructs§
- Embedding
Cache - LRU cache for query embedding vectors.
- Lazy
Fastembed Provider - Lazy-loading embedding provider backed by
FastembedProvider. - Lazy
Opts - Configuration for
LazyFastembedProvider.
Enums§
- Model
State - Lifecycle state of a lazy-loaded embedding model.
Functions§
- is_
model_ cached - Check if model weights exist in the HuggingFace cache directory.