Struct finalfusion::embeddings::Embeddings[][src]

pub struct Embeddings<V, S> { /* fields omitted */ }
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

Construct an embeddings from a vocabulary, storage, and norms.

The embeddings for known words must be normalized. However, this is not verified due to the high computational cost.

Decompose embeddings in its vocabulary, storage, and optionally norms.

Get metadata.

Get metadata mutably.

Get embedding norms.

Set metadata.

Returns the previously-stored metadata.

Get the embedding storage.

Get the vocabulary.

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

Get the embedding of a word.

Realize the embedding of a word into the given vector.

This variant of embedding realizes the embedding into the given vector. This makes it possible to look up embeddings without any additional allocations. This method returns false and does not modify the vector if no embedding could be found.

Panics when then the vector does not have the same dimensionality as the word embeddings.

Get a batch of embeddings.

The embeddings of all words are computed and returned. This method also return a Vec indicating for each word if an embedding could be found.

Get a batch of embeddings.

The embeddings of all words are computed and written to output. A Vec is returned that indicates for each word if an embedding could be found.

This method panics when output does not have the correct shape.

Get the embedding and original norm of a word.

Returns for a word:

  • The word embedding.
  • The norm of the embedding before normalization to a unit vector.

The original embedding can be reconstructed by multiplying all embedding components by the original norm.

If the model does not have associated norms, 1 will be returned as the norm for vocabulary words.

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

Get an iterator over triples of words, embeddings, and norms.

Returns an iterator that returns triples of:

  • A word.
  • Its word embedding.
  • The original norm of the embedding before normalization to a unit vector.

The original embedding can be reconstructed by multiplying all embedding components by the original norm.

If the model does not have associated norms, the norm is always 1.

Get the vocabulary size.

The vocabulary size excludes subword units.

Convert to explicitly indexed subword Embeddings.

Try to convert to explicitly indexed subword embeddings.

Conversion fails if the wrapped vocabulary is SimpleVocab, FloretSubwordVocab or already an ExplicitSubwordVocab.

Trait Implementations

Perform an analogy query. Read more

Perform an analogy query. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Find words that are similar to the query embedding while skipping certain words. Read more

Find words that are similar to the query embedding. Read more

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

Quantize the embedding matrix using the provided RNG. Read more

Quantize the embedding matrix. Read more

Read the embeddings.

Read embeddings in the fastText format.

Read embeddings in the fastText format lossily. Read more

Read embeddings in the floret format.

Read the embeddings from the given buffered reader.

Read the embeddings from the given buffered reader. Read more

Read the embeddings from the given buffered reader.

Read the embeddings from the given buffered reader. Read more

Read the embeddings from the given buffered reader.

Read the embeddings from the given buffered reader. Read more

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

Write the embeddings to the given writer in fastText format. Read more

Read embeddings in the floret format.

Read the embeddings from the given buffered reader. Read more

Write the embeddings to the given writer. Read more

Write the embeddings from the given writer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

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

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.