Search code examples
nlpword2vec

How can I load word2vec vectors?


I have tried lots of different pre-trained models, most of them have 0 documentation the few that have some sort of documentation say that it is possible to load it with

from gensim.models.keyedvectors import KeyedVectors

word_vectors = KeyedVectors.load_word2vec_format('model102938_that_cannot_be_loaded.bin', binary=True)

but it never works and I always get a random error. Is there actually a way to load it? Or am I better off buying a couple hundred server racks and training it myself?


Solution

  • You can load w2v models directly using the gensim.models.Word2Vec class, like this:

    from gensim.models import Word2Vec
    model = Word2Vec.load(...)