Can't suppress fasttext warning: 'load_model' does not return [...]
Asked Answered
S

1

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.

Swamy answered 24/2, 2021 at 14:56 Comment(0)
S
24

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 this commit in May 2020, which will likely be in the next official release (v0.9.3), whenever that is.

Scaffold answered 27/2, 2021 at 17:36 Comment(3)
It's been over 3 years and it's still showing up, pretty annoying ngl. Thanks for the monkey patch.Adorn
Thank you, I found this to be useful in 2024.Caliper
I cannot believe this is still proving useful after more than 3 years! I presume we won't ever be seeing a new release of FastText again, oh well.Scaffold

© 2022 - 2024 — McMap. All rights reserved.