pub struct EmbeddingBackend {
pub model: EmbeddingModelWeights,
pub tokenizer: Tokenizer,
pub device: Device,
}Expand description
A loaded embedding model ready for inference.
Fields§
§model: EmbeddingModelWeights§tokenizer: Tokenizer§device: DeviceImplementations§
Source§impl EmbeddingBackend
impl EmbeddingBackend
Sourcepub fn load(model_dir: &Path, device: Device) -> Result<Self, InferenceError>
pub fn load(model_dir: &Path, device: Device) -> Result<Self, InferenceError>
Load a Qwen3-Embedding GGUF model + tokenizer from a directory.
Sourcepub fn embed_one(&mut self, text: &str) -> Result<Vec<f32>, InferenceError>
pub fn embed_one(&mut self, text: &str) -> Result<Vec<f32>, InferenceError>
Embed a single text. Returns L2-normalized hidden state vector.
Sourcepub fn embed_batch(
&mut self,
texts: &[String],
) -> Result<Vec<Vec<f32>>, InferenceError>
pub fn embed_batch( &mut self, texts: &[String], ) -> Result<Vec<Vec<f32>>, InferenceError>
Embed multiple texts. Processes sequentially (no batch padding needed).
Sourcepub fn embed_query(
&mut self,
text: &str,
instruction: &str,
) -> Result<Vec<f32>, InferenceError>
pub fn embed_query( &mut self, text: &str, instruction: &str, ) -> Result<Vec<f32>, InferenceError>
Embed with instruction prefix (for queries). Format: “Instruct: {instruction}\nQuery:{text}”
Auto Trait Implementations§
impl !Freeze for EmbeddingBackend
impl !RefUnwindSafe for EmbeddingBackend
impl Send for EmbeddingBackend
impl Sync for EmbeddingBackend
impl Unpin for EmbeddingBackend
impl UnsafeUnpin for EmbeddingBackend
impl !UnwindSafe for EmbeddingBackend
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