Struct Embeddings

Source
pub struct Embeddings<V, S> { /* private fields */ }
👎Deprecated: rust2vec is superseded by the finalfusion crate
Expand description

Word embeddings.

This data structure stores word embeddings (also known as word vectors) and provides some useful methods on the embeddings, such as similarity and analogy queries.

Implementations§

Source§

impl<V, S> Embeddings<V, S>

Source

pub fn new(metadata: Option<Metadata>, vocab: V, storage: S) -> Self

👎Deprecated: rust2vec is superseded by the finalfusion crate

Construct an embeddings from a vocabulary and storage.

Source

pub fn into_parts(self) -> (Option<Metadata>, V, S)

👎Deprecated: rust2vec is superseded by the finalfusion crate

Decompose embeddings in its vocabulary and storage.

Source

pub fn metadata(&self) -> Option<&Metadata>

👎Deprecated: rust2vec is superseded by the finalfusion crate

Get metadata.

Source

pub fn metadata_mut(&mut self) -> Option<&mut Metadata>

👎Deprecated: rust2vec is superseded by the finalfusion crate

Get metadata mutably.

Source

pub fn set_metadata(&mut self, metadata: Option<Metadata>) -> Option<Metadata>

👎Deprecated: rust2vec is superseded by the finalfusion crate

Set metadata.

Returns the previously-stored metadata.

Source

pub fn storage(&self) -> &S

👎Deprecated: rust2vec is superseded by the finalfusion crate

Get the embedding storage.

Source

pub fn vocab(&self) -> &V

👎Deprecated: rust2vec is superseded by the finalfusion crate

Get the vocabulary.

Source§

impl<V, S> Embeddings<V, S>
where V: Vocab, S: Storage,

Source

pub fn dims(&self) -> usize

👎Deprecated: rust2vec is superseded by the finalfusion crate

Return the length (in vector components) of the word embeddings.

Source

pub fn embedding(&self, word: &str) -> Option<CowArray1<'_, f32>>

👎Deprecated: rust2vec is superseded by the finalfusion crate

Get the embedding of a word.

Source

pub fn iter(&self) -> Iter<'_> ⓘ

👎Deprecated: rust2vec is superseded by the finalfusion crate

Get an iterator over pairs of words and the corresponding embeddings.

Source

pub fn len(&self) -> usize

👎Deprecated: rust2vec is superseded by the finalfusion crate

Get the vocabulary size.

The vocabulary size excludes subword units.

Trait Implementations§

Source§

impl<V, S> Analogy for Embeddings<V, S>
where V: Vocab, S: StorageView,

Source§

fn analogy( &self, word1: &str, word2: &str, word3: &str, limit: usize, ) -> Option<Vec<WordSimilarity<'_>>>

Perform an analogy query. Read more
Source§

impl<V, S> AnalogyBy for Embeddings<V, S>
where V: Vocab, S: StorageView,

Source§

fn analogy_by<F>( &self, word1: &str, word2: &str, word3: &str, limit: usize, similarity: F, ) -> Option<Vec<WordSimilarity<'_>>>
where F: FnMut(ArrayView2<'_, f32>, ArrayView1<'_, f32>) -> Array1<f32>,

Perform an analogy query using the given similarity function. Read more
Source§

impl<V: Debug, S: Debug> Debug for Embeddings<V, S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<Embeddings<SimpleVocab, MmapArray>> for Embeddings<VocabWrap, StorageViewWrap>

Source§

fn from(from: Embeddings<SimpleVocab, MmapArray>) -> Self

Converts to this type from the input type.
Source§

impl From<Embeddings<SimpleVocab, MmapArray>> for Embeddings<VocabWrap, StorageWrap>

Source§

fn from(from: Embeddings<SimpleVocab, MmapArray>) -> Self

Converts to this type from the input type.
Source§

impl From<Embeddings<SimpleVocab, NdArray>> for Embeddings<VocabWrap, StorageViewWrap>

Source§

fn from(from: Embeddings<SimpleVocab, NdArray>) -> Self

Converts to this type from the input type.
Source§

impl From<Embeddings<SimpleVocab, NdArray>> for Embeddings<VocabWrap, StorageWrap>

Source§

fn from(from: Embeddings<SimpleVocab, NdArray>) -> Self

Converts to this type from the input type.
Source§

impl From<Embeddings<SimpleVocab, QuantizedArray>> for Embeddings<VocabWrap, StorageWrap>

Source§

fn from(from: Embeddings<SimpleVocab, QuantizedArray>) -> Self

Converts to this type from the input type.
Source§

impl From<Embeddings<SubwordVocab, MmapArray>> for Embeddings<VocabWrap, StorageViewWrap>

Source§

fn from(from: Embeddings<SubwordVocab, MmapArray>) -> Self

Converts to this type from the input type.
Source§

impl From<Embeddings<SubwordVocab, MmapArray>> for Embeddings<VocabWrap, StorageWrap>

Source§

fn from(from: Embeddings<SubwordVocab, MmapArray>) -> Self

Converts to this type from the input type.
Source§

impl From<Embeddings<SubwordVocab, NdArray>> for Embeddings<VocabWrap, StorageViewWrap>

Source§

fn from(from: Embeddings<SubwordVocab, NdArray>) -> Self

Converts to this type from the input type.
Source§

impl From<Embeddings<SubwordVocab, NdArray>> for Embeddings<VocabWrap, StorageWrap>

Source§

fn from(from: Embeddings<SubwordVocab, NdArray>) -> Self

Converts to this type from the input type.
Source§

impl From<Embeddings<SubwordVocab, QuantizedArray>> for Embeddings<VocabWrap, StorageWrap>

Source§

fn from(from: Embeddings<SubwordVocab, QuantizedArray>) -> Self

Converts to this type from the input type.
Source§

impl<'a, V, S> IntoIterator for &'a Embeddings<V, S>
where V: Vocab, S: Storage,

Source§

type Item = (&'a str, CowArray<'a, f32, Dim<[usize; 1]>>)

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<V, S> MmapEmbeddings for Embeddings<V, S>
where Self: Sized, V: ReadChunk, S: MmapChunk,

Source§

impl<V, S> ReadEmbeddings for Embeddings<V, S>
where V: ReadChunk, S: ReadChunk,

Source§

fn read_embeddings<R>(read: &mut R) -> Result<Self, Error>
where R: Read + Seek,

Read the embeddings.
Source§

impl<R> ReadText<R> for Embeddings<SimpleVocab, NdArray>
where R: BufRead,

Source§

fn read_text(reader: &mut R, normalize: bool) -> Result<Self, Error>

Read the embeddings from the given buffered reader.
Source§

impl<R> ReadTextDims<R> for Embeddings<SimpleVocab, NdArray>
where R: BufRead,

Source§

fn read_text_dims(reader: &mut R, normalize: bool) -> Result<Self, Error>

Read the embeddings from the given buffered reader.
Source§

impl<R> ReadWord2Vec<R> for Embeddings<SimpleVocab, NdArray>
where R: BufRead,

Source§

fn read_word2vec_binary(reader: &mut R, normalize: bool) -> Result<Self, Error>

Read the embeddings from the given buffered reader.
Source§

impl<V, S> Similarity for Embeddings<V, S>
where V: Vocab, S: StorageView,

Source§

fn similarity( &self, word: &str, limit: usize, ) -> Option<Vec<WordSimilarity<'_>>>

Find words that are similar to the query word. Read more
Source§

impl<V, S> SimilarityBy for Embeddings<V, S>
where V: Vocab, S: StorageView,

Source§

fn similarity_by<F>( &self, word: &str, limit: usize, similarity: F, ) -> Option<Vec<WordSimilarity<'_>>>
where F: FnMut(ArrayView2<'_, f32>, ArrayView1<'_, f32>) -> Array1<f32>,

Find words that are similar to the query word using the given similarity function. Read more
Source§

impl<V, S> WriteEmbeddings for Embeddings<V, S>
where V: WriteChunk, S: WriteChunk,

Source§

fn write_embeddings<W>(&self, write: &mut W) -> Result<(), Error>
where W: Write + Seek,

Source§

impl<W, V, S> WriteText<W> for Embeddings<V, S>
where W: Write, V: Vocab, S: Storage,

Source§

fn write_text(&self, write: &mut W) -> Result<(), Error>

Write the embeddings to the given writer.

Source§

impl<W, V, S> WriteTextDims<W> for Embeddings<V, S>
where W: Write, V: Vocab, S: Storage,

Source§

fn write_text_dims(&self, write: &mut W) -> Result<(), Error>

Write the embeddings to the given writer.
Source§

impl<W, V, S> WriteWord2Vec<W> for Embeddings<V, S>
where W: Write, V: Vocab, S: Storage,

Source§

fn write_word2vec_binary(&self, w: &mut W) -> Result<(), Error>
where W: Write,

Write the embeddings from the given writer.

Auto Trait Implementations§

§

impl<V, S> Freeze for Embeddings<V, S>
where S: Freeze, V: Freeze,

§

impl<V, S> RefUnwindSafe for Embeddings<V, S>

§

impl<V, S> Send for Embeddings<V, S>
where S: Send, V: Send,

§

impl<V, S> Sync for Embeddings<V, S>
where S: Sync, V: Sync,

§

impl<V, S> Unpin for Embeddings<V, S>
where S: Unpin, V: Unpin,

§

impl<V, S> UnwindSafe for Embeddings<V, S>
where S: UnwindSafe, V: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.