Search code examples
python-3.xloadpickleword2vec

UnpicklingError: invalid load key, '`'


Tried use pretrained model for russian lang. from https://wikipedia2vec.github.io/wikipedia2vec/pretrained/

But can't load model from pkl file. Tried to use other encoders as cp1251, latin1, windows-1252. Unfortunately, it drops down.

model = Word2Vec.load_word2vec_format('ruwiki_20180420_100d.pkl')

UnpicklingError: invalid load key, '`'

Solution

  • According to the text on the page you've referenced, https://wikipedia2vec.github.io/wikipedia2vec/pretrained/, the binary files there should be loaded with Wikipedia2Vec.load().

    Only the other text files there, with suffixes .txt, can be loaded with gensim's load_word2vec_format() method.

    Either use Wikipedia2Vec.load() with the file you've mentioned, or try the text file variants instead.