Hugging Face Hub: Models, Datasets and Spaces
The Hugging Face Hub is the central website where models, datasets and Spaces are stored and shared. Every item is a Git repository identified by an owner and a name, such as Qwen/Qwen2.5-0.5B-Instruct or sentence-transformers/all-MiniLM-L6-v2.
Learning to read the Hub well saves you hours: the right model card tells you what a model is for, how big it is, how it was trained and whether you are allowed to use it commercially.
The Three Repository Types
- Models: weights (usually .safetensors files), a config.json, tokenizer files and a README model card.
- Datasets: data files (Parquet, CSV, JSON, images, audio) plus a dataset card describing them.
- Spaces: small web apps (Gradio, Streamlit, Docker or static HTML) that run a demo in the cloud.
Finding the Right Model
On huggingface.co/models, filter by task (for example Text Generation or Sentence Similarity), library, language and license. Sort by downloads or trending to see what the community actually uses.
Open a model and read the card. Look for the parameter count (0.5B, 7B, 70B), the intended use, the evaluation results, the license, and example code. A model with "Instruct" or "Chat" in its name has been tuned to follow instructions; a "base" model only continues text.
Download Files with huggingface_hub
transformers downloads files automatically, but sometimes you want one specific file, for example a GGUF file for llama.cpp. hf_hub_download fetches a single file and returns its local path:
from huggingface_hub import hf_hub_download
path = hf_hub_download(
repo_id="sentence-transformers/all-MiniLM-L6-v2",
filename="config.json",
)
print(path)/home/you/.cache/huggingface/hub/models--sentence-transformers--all-MiniLM-L6-v2/snapshots/<commit-hash>/config.json
snapshot_download works the same way but grabs a whole repository. Both accept a revision argument, which you can set to a branch, tag or commit hash to pin an exact version for reproducible results.
Search the Hub from Python
from huggingface_hub import HfApi
api = HfApi()
models = api.list_models(task="text-classification", sort="downloads", limit=3)
for m in models:
print(m.id)distilbert/distilbert-base-uncased-finetuned-sst-2-english cardiffnlp/twitter-roberta-base-sentiment-latest ... (sample output — rankings change over time)
Uploading Your Own Model
After logging in with a write token, you can create a repository and upload a folder. Models trained with transformers can also call model.push_to_hub("my-model") directly.
from huggingface_hub import HfApi
api = HfApi()
api.create_repo("your-username/my-first-model", exist_ok=True)
api.upload_folder(folder_path="./my-model", repo_id="your-username/my-first-model")
print("Uploaded!")Uploaded!
Gated and Private Repositories
Some publishers require you to accept their license terms on the model page before downloading. These are called gated models. Once approved, your token grants access. Private repositories are only visible to you or your organization and always need a token.
Frequently asked questions
What is the Hugging Face Hub?
It is a platform at huggingface.co that hosts machine learning models, datasets and demo apps as Git repositories, each with documentation and a license.
How do I download a model from Hugging Face?
Usually you just call from_pretrained with the model ID and transformers downloads it for you. For individual files use hf_hub_download, and for whole repositories use snapshot_download or the hf download command.
What is a model card?
The README of a model repository. It describes what the model does, how it was trained, its limitations, its license and how to use it.
What does gated model mean on Hugging Face?
The author requires you to log in and accept terms before downloading. After approval, your access token unlocks the files.