How to Download AI Models from Hugging Face (hf CLI, Ollama and Gated Models)
Note: Some future links on this site may be affiliate links. We never claim hands-on testing; guides are researched from the public sources listed in each article.
How we wrote this: A summary of Hugging Face's official documentation for the
hfCLI, downloading, the cache, gated models and Ollama (linked below), checked October 28, 2026. Check the docs for the version you install.
Hugging Face hosts most of the open-weight models people run at home. You can browse in a web browser, but for multi-gigabyte files the official command-line tool makes it easier to pick exactly the files you need, preview the size first and clean up afterward.
Install the hf CLI
The hf command comes with the huggingface_hub Python package. The CLI guide lists several ways to get it:
pip install -U "huggingface_hub"
Or, without installing anything permanently, run it through uvx (part of the uv tool): uvx hf download .... Homebrew is also supported. Run hf --help to see every command.
Download a whole model
hf download HuggingFaceH4/zephyr-7b-beta
By default, files go into a shared cache and the command prints where they ended up. The cache guide says the default location is ~/.cache/huggingface/hub. You can move it with the HF_HOME or HF_HUB_CACHE environment variable, which helps if your system drive is small.
Download only what you need
Many repositories hold several versions of the same model. Downloading everything can waste tens of gigabytes. The CLI gives you three ways to be selective:
- Name the files:
hf download gpt2 config.json model.safetensors - Filter with patterns:
--includeand--exclude, for example--include "*.safetensors" --exclude "*.fp16.*". For GGUF repositories, an include pattern for the one quantization you want (such as"*Q4_K_M*") keeps the download to a single file. See what a GGUF file is for how to choose. - Preview first:
--dry-runlists what would be downloaded, how much is already cached and the total size, without downloading anything.
Download into a normal folder
If a tool such as llama.cpp or LM Studio expects files in a specific folder, use --local-dir:
hf download adept/fuyu-8b model-00001-of-00002.safetensors --local-dir fuyu
The docs say this creates a small .cache/huggingface/ folder inside that directory with metadata, so a later run only fetches files that changed. Our llama.cpp guide shows how to load a GGUF from disk.
Shortcut: run a Hugging Face GGUF straight from Ollama
If you use Ollama, you may not need the CLI at all. Hugging Face's Ollama page explains that any public GGUF repository can be run directly:
ollama run hf.co/{username}/{repository}
The docs say Ollama picks the Q4_K_M quantization when the repository has one, and otherwise a reasonable alternative. Add a tag to choose another, in the form hf.co/{username}/{repository}:{quantization}. New to Ollama? Start with our Ollama beginner walkthrough.
Gated models: request access first
Some model authors turn on access requests. Hugging Face calls these gated models. To use one:
- Sign in to a Hugging Face account in your browser. The docs say requests can only be made there.
- Open the model page and submit the request. This shares your username and email address with the authors, unless they opted out of collecting it, plus any extra fields they ask for.
- Wait for approval, which may be automatic or manual.
- Sign the CLI in with
hf auth login, which stores an access token on your computer. Treat that token like a password.
Gating is separate from the license. Read the model's license before you use it for work. Our guide to open-weight model licenses covers the common ones.
Keep the cache under control
Model files add up fast. The cache guide covers these commands:
hf cache lslists what is stored locally, and it can filter, for example by size or by when something was last used.hf cache rmdeletes cached repositories, andhf cache pruneremoves leftover shared files that nothing uses.hf cache verifychecks cached files against the checksums on the Hub.