Sentence2Vec
This computes the sentence vector of a sentence using word2vec for each word in the sentence.
The crate supports the txt format of word2vec and a custom format of word2vec for binary files.
Usage
use Sentence2Vec;
let sentence = "This is a sentence.";
let model = new.unwrap;
let vector = model.sentence_vector;
The sentence vector is a sum up of the word vectors of the sentence. We then have a vector of the same dimension as the word vectors.
Example
Here is an example to compute the cosine similarity between two sentences.
use Sentence2Vec;
let word2vec = load_from_bytes.await.unwrap;
let sentence2vec = new;
let similarity = sentence2vec.cosine.await.unwrap;
assert_eq!;
let similarity_fruits = sentence2vec.cosine.await.unwrap;
let similarity_fuits_cars = sentence2vec.cosine.await.unwrap;
assert!;
License
MIT