Gensim: error loading pretrained vectors No such file or directory: 'word2vec.kv.vectors.npy'

Viewed 269

I am trying to load a Pretrained word2vec embeddings that is in gensim keyedvector 'word2vec.kv'

pretrained = KeyedVectors.load(args.pretrained mmap = 'r')

where arg.pretrained is "/ptembs/word2vec.kv" and iam getting this error

File "main.py", line 60, in main
pretrained = KeyedVectors.load(args.pretrained, mmap = 'r')
File "C:\Users\ASUS\anaconda3\lib\site-packages\gensim\models\keyedvectors.py", line 1553, in load
model = super(WordEmbeddingsKeyedVectors, cls).load(fname_or_handle, **kwargs)
File "C:\Users\ASUS\anaconda3\lib\site-packages\gensim\models\keyedvectors.py", line 228, in load
return super(BaseKeyedVectors, cls).load(fname_or_handle, **kwargs)
File "C:\Users\ASUS\anaconda3\lib\site-packages\gensim\utils.py", line 436, in load obj._load_specials(fname, mmap, compress, subname)
File "C:\Users\ASUS\anaconda3\lib\site-packages\gensim\utils.py", line 478, in _load_specials
val = np.load(subname(fname, attrib), mmap_mode=mmap)
File "C:\Users\ASUS\anaconda3\lib\site-packages\numpy\lib\npyio.py", line 417, in load
fid = stack.enter_context(open(os_fspath(file), "rb"))
FileNotFoundError: [Errno 2] No such file or directory: 'ptembs/word2vec.kv.vectors.npy'

i dont understand why it need word2vec.kv.vectors.npy file ? and i dont have it. Any idea how to solve this problem?


gensim version 3.8.3 tried it on 4.1.2 also same error.

1 Answers

Where did you get the file 'word2vec.kv'?

If loading that file triggers an error mentioning a 2nd file by name, then that 2nd file should've been created alongside 'word2vec.kv' when it was 1st saved using a .save() operation.

That other file needs to be kept alongside 'word2vec.kv' in order for 'word2vec.kv' to be .load()ed again in the future.

Related