pub struct EmbeddingEngine { /* private fields */ }Implementations§
Source§impl EmbeddingEngine
impl EmbeddingEngine
Sourcepub fn load(model_dir: &Path) -> Result<Self>
pub fn load(model_dir: &Path) -> Result<Self>
Load embedding model and vocabulary from a directory. Downloads model automatically from HuggingFace if not present.
Sourcepub fn load_model(base_dir: &Path, model_id: EmbeddingModel) -> Result<Self>
pub fn load_model(base_dir: &Path, model_id: EmbeddingModel) -> Result<Self>
Load a specific embedding model from a directory.
Sourcepub fn load_default() -> Result<Self>
pub fn load_default() -> Result<Self>
Load from default model directory (~/.lean-ctx/models/).
Sourcepub fn embed(&self, text: &str) -> Result<Vec<f32>>
pub fn embed(&self, text: &str) -> Result<Vec<f32>>
Generate an embedding vector for a single text (document/code).
Sourcepub fn embed_query(&self, query: &str) -> Result<Vec<f32>>
pub fn embed_query(&self, query: &str) -> Result<Vec<f32>>
Generate an embedding vector for a query string. Applies query-specific prefix if the model requires one.
Sourcepub fn embed_batch(&self, texts: &[&str]) -> Result<Vec<Vec<f32>>>
pub fn embed_batch(&self, texts: &[&str]) -> Result<Vec<Vec<f32>>>
Generate embedding vectors for multiple texts using true batched ONNX
inference. Sends a single [batch, max_seq_len] tensor through the model
instead of batch separate calls — up to 50× faster on CPU for typical
batch sizes (64–128) by leveraging matrix-matrix instead of matrix-vector
operations inside the transformer.
pub fn dimensions(&self) -> usize
pub fn model_id(&self) -> &EmbeddingModel
pub fn model_name(&self) -> &str
Sourcepub fn model_directory() -> PathBuf
pub fn model_directory() -> PathBuf
Resolve the model directory (respects LEAN_CTX_MODELS_DIR env).
Sourcepub fn is_available() -> bool
pub fn is_available() -> bool
Check if the model files are present and loadable.
Auto Trait Implementations§
impl !Freeze for EmbeddingEngine
impl RefUnwindSafe for EmbeddingEngine
impl Send for EmbeddingEngine
impl Sync for EmbeddingEngine
impl Unpin for EmbeddingEngine
impl UnsafeUnpin for EmbeddingEngine
impl UnwindSafe for EmbeddingEngine
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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