ImportError: cannot import name 'ModelFilter' from 'huggingface_hub'

I am running this line in Kaggle notebook:

from huggingface_hub import ModelFilter

and getting back error:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
/tmp/ipykernel_36/1451250264.py in <cell line: 0>()
----> 1 from huggingface_hub import ModelFilter

ImportError: cannot import name 'ModelFilter' from 'huggingface_hub' (/usr/local/lib/python3.11/dist-packages/huggingface_hub/__init__.py)

My huggingface_hub._version_ is ‘0.33.1’

1 Like

ModelFilter is deprecated, please see here: ImportError: cannot import name 'ModelFilter' from 'huggingface_hub' ¡ Issue #2478 ¡ huggingface/huggingface_hub ¡ GitHub

2 Likes

Thank you so much for your answer. Do you what values I can use in filter field. I am looking for complete list. So far I know only a few values such text-classification

Minor update. Here is my search:

from huggingface_hub import HfApi
api = HfApi()
models = api.list_models(task=“text-classification”,
sort=‘downloads’, gated = False, limit = 100)
models = list(models)
print(len(models))
print(models[1].modelId)

It returns cross-encoder/ms-marco-MiniLM-L6-v2, which is “Text Ranking” and it is different from what I asked “Text Classification” as per tasks page.
I got the same result when using “filter” field.

1 Like

It returns cross-encoder/ms-marco-MiniLM-L6-v2, which is “Text Ranking” and it is different from what I asked “Text Classification” as per tasks page.
I got the same result when using “filter” field.

This is probably because this model is tagged as both as “Text Ranking” as well as “Text Classification”, see tags above:

2 Likes

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.