I just want to use model = api.load("word2vec-google-news-300"),but it occurs MemoryError.I don't know how to solve this problem.

435 views
Skip to first unread message

jiaqi Jiang

unread,
Feb 4, 2020, 4:53:49 AM2/4/20
to Gensim
File "demo.py", line 95, in <module>
    model = api.load("word2vec-google-news-300")
  File "/home/weifeng/anaconda3/lib/python3.6/site-packages/gensim/downloader.py", line 502, in load
    return module.load_data()
  File "/home/weifeng/gensim-data/word2vec-google-news-300/__init__.py", line 8, in load_data
    model = KeyedVectors.load_word2vec_format(path, binary=True)
  File "/home/weifeng/anaconda3/lib/python3.6/site-packages/gensim/models/keyedvectors.py", line 1498, in load_word2vec_format
    limit=limit, datatype=datatype)
  File "/home/weifeng/anaconda3/lib/python3.6/site-packages/gensim/models/utils_any2vec.py", line 349, in _load_word2vec_format
    result.vectors = zeros((vocab_size, vector_size), dtype=datatype)
MemoryError

Radim Řehůřek

unread,
Feb 4, 2020, 8:54:36 AM2/4/20
to Gensim
You don't have enough RAM to load the dataset.

IIRC the word2vec-google-news-300 is pretty large – ~2GB zipped, and probably 4x as much unzipped.

Either free up some RAM, or load only a part of the dataset, using the optional limit parameter:

HTH,
Radim
Reply all
Reply to author
Forward
0 new messages