UChicago-Computational-Content-Analysis / Frequently-Asked-Questions

0 stars 0 forks source link

Can't get attribute 'Vocab' on <module 'gensim.models.word2vec' #12

Open chuqingzhao opened 2 years ago

chuqingzhao commented 2 years ago

Does anyone encounter the same issue when loading the model?

model = gensim.models.Word2Vec.load('/home/cqzhao/Computational Content Analysis/data/1992embeddings_hs_new3.sg')

image

jacyanthis commented 2 years ago

This is a version incompatibility issue. If you run the code gensim.__version__, you will probably see '4.0.0' or later, but the 1992embeddings_hs_new3.sg was made in a previous version that can't be straightforwardly loaded in the most recent version. It's strange that Gensim did not make their own objects backwards-compatible, especially something as popular as word2vec embeddings.

You can run code like !pip install gensim==3.8.3 (the last v3 of Gensim) and restart your notebook to load that file. (This is pretty straightforward on Google Colab but can be messier on your local machine.) I'm working on a better solution that doesn't require installing an old version and will update in this thread when/if I find one. Sorry for the inconvenience.