8

I'm struggling to suppress a specific warning related to fasttext.

The warning is Warning : 'load_model' does not return WordVectorModel or SupervisedModel any more, but a 'FastText' object which is very similar.

And here is the offending block of code:

with warnings.catch_warnings():
    warnings.filterwarnings('ignore')
    return fasttext.load_model(str(model_path))  # this line

I've attempted several ways to suppress the warning, mostly from this thread without success.

I'm using Python 3.8, fasttext v0.9.2.

Ian
  • 3,605
  • 4
  • 31
  • 66

1 Answers1

19

For fasttext v0.9.2 this can be solved by adding the monkey patch below to your code (as per this GitHub issue).

import fasttext

fasttext.FastText.eprint = lambda x: None

As mentioned in that same GitHub issue, the warning message was removed in commit 9ef22d9 in May 2020, which will likely be in the next official release (fasttext v0.9.3), whenever that is.

prrao
  • 2,656
  • 5
  • 34
  • 39