Search code examples
pythonword2vecgensimword-embedding

How can I load Word2vec with Gensim without getting an AttributeError?


I am new to Gensim, and I am trying to load my given (pre-trained) Word2vec model. I have 2 files: xxxx.model.wv and a bigger one xxxx.model.wv.syn0.npy.

When I call the following line:

gensim.models.Word2Vec.load('xxxx.model.wv')

I get the following error:

AttributeError: 'EuclideanKeyedVectors' object has no attribute 'negative'

How can I solve this error?


Solution

  • Are you sure your xxxx.model.wv file was a saved full Word2Vec model object?

    That error suggests it was instead a EuclideanKeyedVectors – just the vectors, and not a full model with all properties like negative – so you might need to load it as that instead.