pub struct Word2Vec {
pub syn0: Vec<f32>,
pub syn1neg: Vec<f32>,
/* private fields */
}Expand description
Word2Vec model
Fields§
§syn0: Vec<f32>Input embeddings (word vectors) Shape: [vocab_size, vector_size]
syn1neg: Vec<f32>Output embeddings (context vectors for negative sampling) Shape: [vocab_size, vector_size]
Implementations§
Source§impl Word2Vec
impl Word2Vec
Sourcepub fn new(config: TrainingConfig, vocab: Vocabulary) -> Self
pub fn new(config: TrainingConfig, vocab: Vocabulary) -> Self
Create a new Word2Vec model with given configuration
Sourcepub fn train_from_file<P: AsRef<Path>>(&mut self, corpus_path: P) -> Result<()>
pub fn train_from_file<P: AsRef<Path>>(&mut self, corpus_path: P) -> Result<()>
Train model from corpus file
Sourcepub fn save_text<P: AsRef<Path>>(&self, path: P) -> Result<()>
pub fn save_text<P: AsRef<Path>>(&self, path: P) -> Result<()>
Save embeddings in word2vec text format
Sourcepub fn save_mcv1<P: AsRef<Path>>(&self, path: P, max_word_id: u32) -> Result<()>
pub fn save_mcv1<P: AsRef<Path>>(&self, path: P, max_word_id: u32) -> Result<()>
Save embeddings in MCV1 binary format
Sourcepub fn vocab(&self) -> &Vocabulary
pub fn vocab(&self) -> &Vocabulary
Get vocabulary
Auto Trait Implementations§
impl Freeze for Word2Vec
impl RefUnwindSafe for Word2Vec
impl Send for Word2Vec
impl Sync for Word2Vec
impl Unpin for Word2Vec
impl UnwindSafe for Word2Vec
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> 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