Ask the Hub for information before downloading a model
The website and the Hub API both expose information about repositories. In this lesson, start with read-only requests. They list models and inspect files without running model code or downloading weights. The current HfApi reference documents the Python names used below. Run the examples in a Python environment with a current huggingface_hub installed.
List models with a few filters
from huggingface_hub import HfApi
api = HfApi(token=False)
models = api.list_models(
pipeline_tag="automatic-speech-recognition",
filter=("transformers", "hi"),
sort="downloads",
limit=20,
cardData=True,
)
for model in models:
card = model.card_data
licence = card.license if card and card.license else "not listed"
print(model.id, model.downloads, licence)The task, library and language tags narrow the results. They do not show which model handles your audio well. The download count is a recent activity measure, not an accuracy score. A missing licence field does not give permission. Read the model card and licence terms before using a model.
Check file sizes and record the revision
repo = "openai/whisper-tiny"
info = api.model_info(repo, files_metadata=True)
print("Revision:", info.sha)
print("Last commit:", info.last_modified)
for file in info.siblings or []:
if file.size is None:
print(file.rfilename, "size not reported")
else:
print(file.rfilename, file.size, "bytes")siblings lists files at the selected revision. It can include several formats for the same weights, so a total for all files is not your own download estimate. Add up only the files you need and account for sizes that are not reported. In the Python result, use card_data and last_modified; field names shown by the raw JSON endpoint can differ.
Download only the small config for this exercise
from huggingface_hub import hf_hub_download
config_path = hf_hub_download(
"openai/whisper-tiny",
"config.json",
revision="169d4a4341b33bc18d8881c4b69c2e104e1cc0af",
token=False,
)
print(config_path)Using a specific commit makes this example reproducible. For several files, snapshot_download can take allow_patterns and ignore_patterns. An unfiltered snapshot may download every format at that revision. Start with the default transfer settings. The old hf_transfer setting is deprecated; the Hub transfer documentation explains the current options.
Translate the same read-only task to the command line
hf download openai/whisper-tiny config.json \
--revision 169d4a4341b33bc18d8881c4b69c2e104e1cc0af
hf cache ls --revisionsThe second command shows what is already stored locally. The cache guide explains how to review sizes before removing anything. For private repositories you need appropriate access; none of the examples here needs a private token.
Try it now
Change the language filter and compare a few results. Record one model’s exact revision, which file you would download, its reported size, and which licence you would check. If the query returns no results, remove one filter at a time and say which constraint caused the empty result.
Check your understanding
Why does model_info(repo, files_metadata=True) frequently report a total far larger than what you need to download?
Pick the one you would defend. Your answer stays private.
Your place and first choices stay on this browser. Classroom credit is recorded separately.
Every lesson here is open. Your progress is recorded once you pass the Image Generation, in Practice exam.
Stuck on something?Ask Arjun, your AI tutor