Cranjis
Cranjis

Reputation: 1960

How to get word2vec from google's pre-trained model

I want to fetch vector representation of words. I tried to use GENSIM api but got the same error as here (for Python 3.6): ValueError when downloading gensim data set

What is the best way to get the vector out of the pre-trained model?

Upvotes: 2

Views: 2779

Answers (1)

gojomo
gojomo

Reputation: 54210

You can download the compressed vectors directly form the Google link on the page:

https://code.google.com/archive/p/word2vec/

(Search for GoogleNews-vectors to find the link about 2/3 through the page.)

Take note of the local file path where you downloaded the file.

Then load the set of vecors as a Gensim KeyedVectors model:

from gensim.models import KeyedVectors

goog_model = KeyedVectors.load_word2vec_format('/WHERE/YOU/DOWNLOADED/GoogleNews-vectors-negative300.bin.gz', binary=True)

Upvotes: 1

Related Questions