How to get vector for a sentence from the word2vec of tokens in sentence

trialcritic picture trialcritic · Apr 21, 2015 · Viewed 63k times · Source

I have generated the vectors for a list of tokens from a large document using word2vec. Given a sentence, is it possible to get the vector of the sentence from the vector of the tokens in the sentence.

Answer

neel picture neel · Jul 31, 2015

There are differet methods to get the sentence vectors :

  1. Doc2Vec : you can train your dataset using Doc2Vec and then use the sentence vectors.
  2. Average of Word2Vec vectors : You can just take the average of all the word vectors in a sentence. This average vector will represent your sentence vector.
  3. Average of Word2Vec vectors with TF-IDF : this is one of the best approach which I will recommend. Just take the word vectors and multiply it with their TF-IDF scores. Just take the average and it will represent your sentence vector.