Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use huggingface transformers without IPyWidgets

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

like image 892
Josh Zwiebel Avatar asked Oct 22 '25 13:10

Josh Zwiebel


1 Answers

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 ;)

like image 132
Jakub Žitný Avatar answered Oct 25 '25 02:10

Jakub Žitný