huggingface / setfit

Efficient few-shot learning with Sentence Transformers
https://hf.co/docs/setfit
Apache License 2.0
2.24k stars 222 forks source link

ImportError: cannot import name 'DatasetFilter' from 'huggingface_hub' (/opt/conda/lib/python3.10/site-packages/huggingface_hub/__init__.py) #544

Closed JayeetaP closed 4 months ago

JayeetaP commented 4 months ago

Hi,

I have been using Setfit for the last month with no errors. This morning when I tried to rerun the same code, with no changes, looks 'DatasetFilter' import from huggingface_hub is failing.

Here's the setup and error details:

Name: transformers Version: 4.39.0 Name: setfit Version: 1.0.3 Name: huggingface-hub Version: 0.24.0 Python: 3.10

from setfit import SetFitModel, Trainer, TrainingArguments

ImportError Traceback (most recent call last) Cell In[15], line 8 6 from sklearn.metrics import confusion_matrix, ConfusionMatrixDisplay, precision_score, recall_score, f1_score, classification_report 7 import matplotlib.pyplot as plt ----> 8 from setfit import SetFitModel, Trainer, TrainingArguments 9 from sentence_transformers.losses import CosineSimilarityLoss 10 from datasets import Dataset

File /opt/conda/lib/python3.10/site-packages/setfit/init.py:8 5 import warnings 7 from .data import get_templated_dataset, sample_dataset ----> 8 from .model_card import SetFitModelCardData 9 from .modeling import SetFitHead, SetFitModel 10 from .span import AbsaModel, AbsaTrainer, AspectExtractor, AspectModel, PolarityModel

File /opt/conda/lib/python3.10/site-packages/setfit/model_card.py:14 12 import transformers 13 from datasets import Dataset ---> 14 from huggingface_hub import CardData, DatasetFilter, ModelCard, dataset_info, list_datasets, model_info 15 from huggingface_hub.repocard_data import EvalResult, eval_results_to_model_index 16 from huggingface_hub.utils import yaml_dump

ImportError: cannot import name 'DatasetFilter' from 'huggingface_hub' (/opt/conda/lib/python3.10/site-packages/huggingface_hub/init.py)

JayeetaP commented 4 months ago

@tomaarsen Would you be able to share some insights on what might be going on?

daniellok-db commented 4 months ago

Should be solved by https://github.com/huggingface/setfit/pull/527, when it gets merged

Wauplin commented 4 months ago

Hi @JayeetaP @daniellok-db , thanks for reporting and sorry for the inconvenience. The error is due to huggingface_hub 0.24.0 release: https://github.com/huggingface/huggingface_hub/releases/tag/v0.24.0. Indeed https://github.com/huggingface/setfit/pull/527 would solve it. I've pinged internally the correct people to fix this soon. In the meantime what you can do is:

Hope this will unblock you and sorry again for the inconvenience!

JayeetaP commented 4 months ago

@Wauplin That was it, I had to uninstall, re-install, and restart so now huggingface_hub version 0.23.5 works. I am unblocked for now! :)

Thanks for the update on the fix. I appreciate everything you all do!

Wauplin commented 4 months ago

Glad to know you're unblocked!