[−][src]Trait finalfusion::similarity::EmbeddingSimilarity
Trait for embedding similarity queries.
Required methods
fn embedding_similarity_masked(
&self,
query: ArrayView1<'_, f32>,
limit: usize,
skips: &HashSet<&str>
) -> Option<Vec<WordSimilarityResult<'_>>>
&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.
Provided methods
fn embedding_similarity(
&self,
query: ArrayView1<'_, f32>,
limit: usize
) -> Option<Vec<WordSimilarityResult<'_>>>
&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.
Implementors
impl<V, S> EmbeddingSimilarity for Embeddings<V, S> where
V: Vocab,
S: StorageView,
[src]
V: Vocab,
S: StorageView,
fn embedding_similarity_masked(
&self,
query: ArrayView1<'_, f32>,
limit: usize,
skip: &HashSet<&str>
) -> Option<Vec<WordSimilarityResult<'_>>>
[src]
&self,
query: ArrayView1<'_, f32>,
limit: usize,
skip: &HashSet<&str>
) -> Option<Vec<WordSimilarityResult<'_>>>