[][src]Trait finalfusion::similarity::EmbeddingSimilarity

pub trait EmbeddingSimilarity {
    fn embedding_similarity_masked(
        &self,
        query: ArrayView1<'_, f32>,
        limit: usize,
        skips: &HashSet<&str>
    ) -> Option<Vec<WordSimilarityResult<'_>>>; fn embedding_similarity(
        &self,
        query: ArrayView1<'_, f32>,
        limit: usize
    ) -> Option<Vec<WordSimilarityResult<'_>>> { ... } }

Trait for embedding similarity queries.

Required methods

fn embedding_similarity_masked(
    &self,
    query: ArrayView1<'_, f32>,
    limit: usize,
    skips: &HashSet<&str>
) -> Option<Vec<WordSimilarityResult<'_>>>

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

The similarity between the query embedding and other embeddings is defined by the dot product of the embeddings. The embeddings in the storage are l2-normalized, this method l2-normalizes the input query, therefore the dot product is equivalent to the cosine similarity.

Loading content...

Provided methods

fn embedding_similarity(
    &self,
    query: ArrayView1<'_, f32>,
    limit: usize
) -> Option<Vec<WordSimilarityResult<'_>>>

Find words that are similar to the query embedding.

The similarity between the query embedding and other embeddings is defined by the dot product of the embeddings. The embeddings in the storage are l2-normalized, this method l2-normalizes the input query, therefore the dot product is equivalent to the cosine similarity.

Loading content...

Implementors

impl<V, S> EmbeddingSimilarity for Embeddings<V, S> where
    V: Vocab,
    S: StorageView
[src]

Loading content...