Fasttext: model cannot be opened for loading

Created on 26 Mar 2020  路  7Comments  路  Source: facebookresearch/fastText

Hi,

I get the error "model cannot be opened for loading" and really don't know how to fix this problem. I get the error when I run the next line of code:

ft = fasttext.load_model('cc.nl.300.bin')

where 'cc.nl.300.bin' is in the work-directory. The problem I can think of is the size of the model (4,2gb).

I downloaded the file from: https://fasttext.cc/docs/en/crawl-vectors.html

The traceback:

ValueError Traceback (most recent call last)
in
1 # fasttext.util.download_model('nl', if_exists='ignore')
----> 2 ft = fasttext.load_model('cc.nl.300.bin')

c:\users\name\appdata\local\programs\python\python37\lib\site-packages\fasttextFastText.py in load_model(path)
372 """Load a model given a filepath and return a model object."""
373 eprint("Warning : load_model does not return WordVectorModel or SupervisedModel any more, but a FastText object which is very similar.")
--> 374 return _FastText(model_path=path)
375
376

c:\users\name\appdata\local\programs\python\python37\lib\site-packages\fasttextFastText.py in __init__(self, model_path, args)
41 self.f = fasttext.fasttext()
42 if model_path is not None:
---> 43 self.f.loadModel(model_path)
44 self._words = None
45 self._labels = None

ValueError: cc.nl.300.bin cannot be opened for loading!

What should be the fix?

Most helpful comment

I solved this by setting the complete path to the file fasttext.load_model('/Users/Potato/Documents/Jupyter/Demo/fastText/cc.es.300.bin')

All 7 comments

Same problem. Waiting for someone to give us a solution...

I had the same problem before锛宑c.nl.300.bin maybe a old version file锛宼he lastest fasttext cannot load it.You can try it as following:
pip uninstall fastest
pip install fastest==0.6.0
Good luck!

same error and the size of the model is just 400mb

I have same problem

I also have the same problem

the thing that solved for me was saving the file (in my case cc.es.300.bin) inside the folder of the package fasttext

I solved this by setting the complete path to the file fasttext.load_model('/Users/Potato/Documents/Jupyter/Demo/fastText/cc.es.300.bin')

Was this page helpful?
0 / 5 - 0 ratings