0

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?

  • What is the solution that you tried from the link? – drum May 24 '20 at 00:31
  • I have tried to install fastText (capital T) from fasttext repo. However I got the same error. From a previous question: https://stackoverflow.com/questions/61978549/sentiment-analysis-and-fasttext-import-error/61978758#61978758 I got the above indications on how to run the model. But it seems there is a problem with the load_model function. For my understanding, FastText should be used in case you want analyse Facebook. But in my case are only text (no tweets/posts) –  May 24 '20 at 01:05
  • Your problem probably consists in version mismatch. Based in my experience, fastText is suitable for any type of text classification task. – Stefano Fiorucci - anakin87 May 26 '20 at 09:35
  • Hi @Anakin87. If you do not mind,could you please tell me which packages(modules, libraries) should I download and the links? I really have no idea why it have not been working. Many thanks –  May 28 '20 at 17:50

1 Answers1

0

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.