inspirehep / magpie

Deep neural network framework for multi-label text classification
MIT License
683 stars 191 forks source link

Loading a pre-trained word embedding model #165

Open isegura opened 5 years ago

isegura commented 5 years ago

Thanks for this tool for multi-label classification!!!

I would like to use a pre-trained word embedding model (such as GoogleNews-vectors-negative300.bin or wikipedia-pubmed-and-PMC-w2v.bin).

I have created a Magpie object indicating the path that contains this pre-trained word embedding model, for example:
magpie=Magpie(word2vec_model='models/embeddings/GoogleNews-vectors-negative300.bin')

However, I gets the following error: UnpicklingError: invalid load key, '3'.

Please, could you help me?. Thanks, Thanks, Thanks!!!

rajeshkumargp commented 5 years ago

@isegura Try using this

from gensim.test.utils import datapath wv_from_bin = KeyedVectors.load_word2vec_format(datapath("euclidean_vectors.bin"), binary=True)

word2vec_model = wv_from_bin magpie=Magpie(word2vec_model=word2vec_model)

Refer https://radimrehurek.com/gensim/models/keyedvectors.html#module-gensim.models.keyedvectors