[][src]Trait finalfusion::similarity::AnalogyBy

pub trait AnalogyBy {
    fn analogy_by_masked<F>(
        &self,
        query: [&str; 3],
        remove: [bool; 3],
        limit: usize,
        similarity: F
    ) -> Result<Vec<WordSimilarityResult>, [bool; 3]>
    where
        F: FnMut(ArrayView2<f32>, ArrayView1<f32>) -> Array1<f32>
; fn analogy_by<F>(
        &self,
        query: [&str; 3],
        limit: usize,
        similarity: F
    ) -> Result<Vec<WordSimilarityResult>, [bool; 3]>
    where
        F: FnMut(ArrayView2<f32>, ArrayView1<f32>) -> Array1<f32>
, { ... } }

Trait for analogy queries with a custom similarity function.

Required methods

fn analogy_by_masked<F>(
    &self,
    query: [&str; 3],
    remove: [bool; 3],
    limit: usize,
    similarity: F
) -> Result<Vec<WordSimilarityResult>, [bool; 3]> where
    F: FnMut(ArrayView2<f32>, ArrayView1<f32>) -> Array1<f32>, 

Perform an analogy query using the given similarity function.

This method returns words that are close in vector space the analogy query word1 is to word2 as word3 is to ?. More concretely, it searches embeddings that are similar to:

embedding(word2) - embedding(word1) + embedding(word3)

At most, limit results are returned.

remove specifies which parts of the queries are excluded from the output candidates. If remove[0] is true, word1 cannot be returned as an answer to the query.

Result::Err is returned when no embedding could be computed for one or more of the tokens, indicating which of the tokens were present.

Loading content...

Provided methods

fn analogy_by<F>(
    &self,
    query: [&str; 3],
    limit: usize,
    similarity: F
) -> Result<Vec<WordSimilarityResult>, [bool; 3]> where
    F: FnMut(ArrayView2<f32>, ArrayView1<f32>) -> Array1<f32>, 

Perform an analogy query using the given similarity function.

This method returns words that are close in vector space the analogy query word1 is to word2 as word3 is to ?. More concretely, it searches embeddings that are similar to:

embedding(word2) - embedding(word1) + embedding(word3)

At most, limit results are returned.

Result::Err is returned when no embedding could be computed for one or more of the tokens, indicating which of the tokens were present.

Loading content...

Implementors

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

Loading content...