pub struct StaticEmbedder { /* private fields */ }Expand description
A loaded model2vec-format model. Cheap to share behind an Arc; embed takes &self.
Implementations§
Source§impl StaticEmbedder
impl StaticEmbedder
Sourcepub fn load(paths: &ModelPaths, manifest: &ArtefactManifest) -> Result<Self>
pub fn load(paths: &ModelPaths, manifest: &ArtefactManifest) -> Result<Self>
Loads and verifies a model from local files. Fails, never warns, when either file’s
blake3 digest differs from the manifest, when the files do not parse, when the
matrix is not [vocab, dim], contains a non-finite value, or has fewer rows than
the tokenizer has ids.
pub fn load_with( paths: &ModelPaths, manifest: &ArtefactManifest, opts: LoadOptions, ) -> Result<Self>
Sourcepub fn embed_one(&self, text: &str) -> Result<Embedding>
pub fn embed_one(&self, text: &str) -> Result<Embedding>
Embeds one input. Errors only on a tokenizer failure, which no ordinary text causes.
Sourcepub fn embed_all(&self, texts: &[&str]) -> Result<Vec<Embedding>>
pub fn embed_all(&self, texts: &[&str]) -> Result<Vec<Embedding>>
Embeds a batch, in input order, splitting large batches across rayon’s pool.
pub fn vocab_rows(&self) -> usize
pub fn unk_id(&self) -> Option<u32>
pub fn manifest(&self) -> &ArtefactManifest
pub fn info(&self) -> ModelInfo
Trait Implementations§
Source§impl Debug for StaticEmbedder
impl Debug for StaticEmbedder
Source§impl Embedder for StaticEmbedder
impl Embedder for StaticEmbedder
Source§fn profile_id(&self) -> &str
fn profile_id(&self) -> &str
Identifies model, dimension and pooling together. Stored alongside the vectors so a
changed model is detected instead of silently degrading search (SPEC §5).
Auto Trait Implementations§
impl !Freeze for StaticEmbedder
impl RefUnwindSafe for StaticEmbedder
impl Send for StaticEmbedder
impl Sync for StaticEmbedder
impl Unpin for StaticEmbedder
impl UnsafeUnpin for StaticEmbedder
impl UnwindSafe for StaticEmbedder
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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