I am trying to use the huggingface transformers library in a hosted Jupyter notebook platform called Deepnote. I want to download a model through the pipeline class but unfortunately deepnote does not support IPyWidgets. Is there a way to disable IPywidgets when using transformers? Specifically the below command.
classifier = pipeline("zero-shot-classification")
And the error I receive.
ImportError: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
Note: Installing IPyWidgets is not an option
Advertisement
Answer
You have to disable transformers logging. Even though it is possible to use transformers.logging.set_verbosity to change the log level, it’s not possible to set it to logging.NOTSET
which is required to skip using IProgress
and tqdm
. So we need to hack it like this:
import transformers import logging transformers.logging.get_verbosity = lambda: logging.NOTSET # transformers.logging.get_verbosity()
After that you should be able to use:
from transformers import pipeline pipeline('sentiment-analysis')('we love you')
Check out my Deepnote project for details ;)