I am creating a chatbot. So, i need word2vec file in binary format. When i am loading bin file then i am getting this type of error.
import gensim
model = gensim.models.Word2Vec.load('GoogleNews-vectors-negative300.bin')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/surya/anaconda3/lib/python3.6/site-packages/gensim/models/word2vec.py", line 975, in load
return super(Word2Vec, cls).load(*args, **kwargs)
File "/home/surya/anaconda3/lib/python3.6/site-packages/gensim/models/base_any2vec.py", line 629, in load
model = super(BaseWordEmbeddingsModel, cls).load(*args, **kwargs)
File "/home/surya/anaconda3/lib/python3.6/site-packages/gensim/models/base_any2vec.py", line 278, in load
return super(BaseAny2VecModel, cls).load(fname_or_handle, **kwargs)
File "/home/surya/anaconda3/lib/python3.6/site-packages/gensim/utils.py", line 395, in load
obj = unpickle(fname)
File "/home/surya/anaconda3/lib/python3.6/site-packages/gensim/utils.py", line 1302, in unpickle
return _pickle.load(f, encoding='latin1')_pickle.
UnpicklingError: invalid load key, '3'.
If it is a binary file you need to mention it like this:
import gensim.models.keyedvectors as word2vec
model = word2vec.KeyedVectors.load_word2vec_format('GoogleNews-vectors-negative300.bin', binary=True)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With