Skip to content

Commit 9a4042b

Browse files
committed
Document the filter argument
1 parent cb9b7a4 commit 9a4042b

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/huggingface_hub/hf_api.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,29 @@ def logout(self, token: str) -> None:
132132
def list_models(self, filter: Optional[str] = None) -> List[ModelInfo]:
133133
"""
134134
Get the public list of all the models on huggingface.co
135+
136+
Args:
137+
filter (:obj:`str`, `optional`):
138+
A string which can be used to identify models on the hub by their tags.
139+
Example usage:
140+
141+
>>> from huggingface_hub import HfApi
142+
>>> api = HfApi()
143+
144+
>>> # List all models
145+
>>> api.list_models()
146+
147+
>>> # List only the text classification models
148+
>>> api.list_models(filter="text-classification")
149+
150+
>>> # List only the russian models
151+
>>> api.list_models(filter="ru")
152+
153+
>>> # List only the models trained on the "common_voice" dataset
154+
>>> api.list_models(filter="dataset:common_voice")
155+
156+
>>> # List only the models from the AllenNLP library
157+
>>> api.list_models(filter="allennlp")
135158
"""
136159
path = "{}/api/models".format(self.endpoint)
137160
params = {"filter": filter, "full": True} if filter is not None else None

0 commit comments

Comments
 (0)