pub struct StaticModel { /* private fields */ }Expand description
Static embedding model for Model2Vec
Implementations§
Source§impl StaticModel
impl StaticModel
Sourcepub fn from_pretrained<P: AsRef<Path>>(
repo_or_path: P,
token: Option<&str>,
normalize: Option<bool>,
subfolder: Option<&str>,
) -> Result<Self>
pub fn from_pretrained<P: AsRef<Path>>( repo_or_path: P, token: Option<&str>, normalize: Option<bool>, subfolder: Option<&str>, ) -> Result<Self>
Load a Model2Vec model from a local folder or the HuggingFace Hub.
§Arguments
repo_or_path- HuggingFace repo ID or local path to the model folder.token- Optional HuggingFace token for authenticated downloads.normalize- Optional flag to normalize embeddings (default from config.json).subfolder- Optional subfolder within the repo or path to look for model files.
Sourcepub fn encode_with_args(
&self,
sentences: &[String],
max_length: Option<usize>,
batch_size: usize,
) -> Vec<Vec<f32>>
pub fn encode_with_args( &self, sentences: &[String], max_length: Option<usize>, batch_size: usize, ) -> Vec<Vec<f32>>
Encode texts into embeddings.
§Arguments
sentences- the list of sentences to encode.max_length- max tokens per text.batch_size- number of texts per batch.
Sourcepub fn encode(&self, sentences: &[String]) -> Vec<Vec<f32>>
pub fn encode(&self, sentences: &[String]) -> Vec<Vec<f32>>
Default encode: max_length=512, batch_size=1024
pub fn encode_single(&self, sentence: &str) -> Vec<f32>
Trait Implementations§
Source§impl Clone for StaticModel
impl Clone for StaticModel
Source§fn clone(&self) -> StaticModel
fn clone(&self) -> StaticModel
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !Freeze for StaticModel
impl RefUnwindSafe for StaticModel
impl Send for StaticModel
impl Sync for StaticModel
impl Unpin for StaticModel
impl UnwindSafe for StaticModel
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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