Search code examples
pythonsentiment-analysisfasttext

Exception: Cannot load model.bin


I have got the following error message trying to run a model:

Exception: fastText: Cannot load model.bin due to C++ extension failed to allocate the memory

The code I have used is the following:

import wget
from fasttext import load_model

wget.download("https://dl.fbaipublicfiles.com/fasttext/supervised-models/amazon_review_polarity.bin", 'model.bin')

model = load_model("model.bin")

I have tried to follow this answer: FastText - Cannot load model.bin due to C++ extension failed to allocate the memory but probably I am doing something wrong as the error is still there. Any idea on how to fix it?


Solution

  • Install the latest version of fasttext (0.9.2) following these steps:

    git clone https://github.com/facebookresearch/fastText.git
    cd fastText
    pip install .
    

    then try to execute your code. It should work.