Solved – How to use pre trained word2vec model

kerastensorflowword2vec

Where can I find a reliable word2vec model trained on some English articles?

I need a word2vec black box, where I, for example, can pass a sentence as array:
["London", "is", "the", "capital", "of", "Great", "Britain"]

and receive:
[some_vector_of_floats1, some_vector_of_floats2, some_vector_of_floats3, some_vector_of_floats4, some_vector_of_floats5, some_vector_of_floats6, some_vector_of_floats7]

Best Answer

In Python, you can use Gensim

import gensim
model = gensim.models.Word2Vec.load_word2vec_format('path-to-vectors.txt', binary=False)
# if you vector file is in binary format, change to binary=True
sentence = ["London", "is", "the", "capital", "of", "Great", "Britain"]
vectors = [model[w] for w in sentence]

These vectors should give you better performance than the pre-trained ones you'd get with word2vec.

Related Question