Skip to content

How-ToGPU

How to Download AI Models from Hugging Face on Windows

How to download AI models from Hugging Face on Windows: install the hf command-line tool, download a single GGUF file or filtered files, choose where models are stored, log in for gated models, clean up the cache and avoid unsafe pickle files.

By , Systems & Technical Editor

4 min read

How to Download AI Models from Hugging Face on Windows

Almost every open AI model, from chat models to image generators, is published on Hugging Face. Apps like LM Studio can download from it for you, but sooner or later you'll want a model or a file your app doesn't list, or you'll want to put large downloads on a different drive. This guide covers the official way to do it, based on Hugging Face's documentation.

Before you start: pick the right file

A model repository often contains many files, and you rarely need all of them.

  • For llama.cpp, LM Studio and similar apps, you usually want a single GGUF file. Hugging Face describes GGUF as a binary format optimised for quick loading and saving of models, designed for use with GGML and other executors, and created by the developer of llama.cpp. GGUF repositories typically offer several quantisation levels; our GGUF quantisation explainer explains which to choose, and how much VRAM you need depends on that choice and the context length.

  • For Python tools such as Transformers or ComfyUI, you'll usually want safetensors files. See GGUF vs safetensors for the difference.

Check the file sizes in the repository's file list before downloading. Large models can run to tens of gigabytes, so make sure you have space (see how much storage you need for local AI).

Step 1: Install the hf command-line tool

Hugging Face's CLI documentation lists a standalone installer as the recommended method. On Windows, run this in PowerShell:

powershell -ExecutionPolicy ByPass -c "irm https://hf.co/cli/install.ps1 | iex"

If you already use Python, you can instead install it with pip install -U "huggingface_hub". Hugging Face says you can update later with hf update.

Step 2: Download a single file

To download one file, give the repository name and the file name:

hf download gpt2 config.json

That's Hugging Face's own example. For a model, replace them with the repository ID (shown at the top of the model page, in the form organisation/model-name) and the exact GGUF file name from the repository's file list. The command prints the path of the downloaded file on its last line.

Step 3: Download several files, or filter by pattern

If you want a subset of a repository, Hugging Face's documentation shows two methods. List the files one after another:

hf download gpt2 config.json model.safetensors

Or use --include and --exclude patterns. Hugging Face's example downloads all safetensors files from Stable Diffusion XL except the FP16 versions:

hf download stabilityai/stable-diffusion-xl-base-1.0 --include "*.safetensors" --exclude "*.fp16.*"

Running hf download with only a repository ID downloads the whole repository, which is rarely what you want for GGUF models with many quantisations.

Step 4: Choose where files go

By default, files go into Hugging Face's cache. The documentation gives the default cache location as ~/.cache/huggingface/hub (on Windows, that's inside your user folder), and says you can change it with the HF_HOME or HF_HUB_CACHE environment variables, or per download with --cache-dir.

If you'd rather put a file in a normal folder, for example on a second SSD where your app looks for models, use --local-dir:

hf download adept/fuyu-8b model-00001-of-00002.safetensors --local-dir fuyu

Hugging Face notes that a small .cache/huggingface folder is created inside that directory to track what's already been downloaded, so files aren't fetched again if they're up to date.

One Windows note from the documentation: the cache normally uses symlinks, which aren't supported on all machines, especially on Windows. When they're not available, files are stored directly and the cache still works, but it can be less efficient, because the same file may be downloaded more than once across different revisions of a repository.

Step 5: Gated models need a login

Some models are "gated": the authors ask you to accept terms before downloading. Hugging Face's documentation says you need to be logged in to a Hugging Face account and request access from your browser on the model's page. Once you have access, log the CLI in with:

hf auth login

The CLI then uses the saved token for downloads, or you can pass one with --token.

Step 6: Manage and clean up the cache

Model files add up quickly. The CLI includes cache commands: hf cache ls lists what's stored, hf cache rm removes specific items and hf cache prune removes unreferenced revisions.

Stay safe: prefer safetensors and GGUF

Hugging Face's security documentation warns that pickle, the default format for PyTorch model weights, can be used for arbitrary code execution attacks when a file is loaded, and suggests loading models from users and organisations you trust. It also points to safetensors, a newer serialisation format for weights. In practice, stick to GGUF or safetensors files from reputable uploaders, and be wary of repositories that only offer pickle-based files.

Our verdict

The hf command-line tool is the most reliable way to get models from Hugging Face: download only the GGUF or safetensors files you need, use --local-dir to put them on the drive your app uses, and log in only when a model is gated. If you'd rather avoid the command line, LM Studio's built-in search is easier; our guide to choosing models in LM Studio covers that route, and our best local LLM models list suggests what to download first.

The bottom line

The `hf` command-line tool is the most reliable way to get models from Hugging Face: download only the GGUF or safetensors files you need, use `--local-dir` to put them on the drive your app uses, and log in only when a model is gated. If you'd rather avoid the command line, LM Studio's built-in search is easier; our guide to choosing models in LM Studio covers that route, and our best local LLM models list suggests what to download first.

Sources

  1. 01Hugging Face, Command Line Interface (CLI) guide
  2. 02Hugging Face, Download files from the Hub
  3. 03Hugging Face, Understand caching
  4. 04Hugging Face, Gated models
  5. 05Hugging Face, GGUF
  6. 06Hugging Face, Pickle scanning

About the author

Marcus Thorne

Systems & Technical Editor

Marcus writes Forge PC's step-by-step build, troubleshooting and system optimisation guides. His background spans Windows kernel and power-state diagnostics, UEFI/BIOS configuration, NVMe storage arrays, ATX 3.1 power delivery and running local AI and LLM workloads on consumer graphics cards.

More from Marcus Thorne

Read next

How to Fix a Mouse That Double-Clicks When You Click Once

How-To

How to Fix a Mouse That Double-Clicks When You Click Once

How to fix a mouse that double-clicks when you click once: check Windows' click and double-click speed settings, test in other apps, change USB port, clean the button and test on another PC, plus what to do if the mouse is faulty.

Marcus Thorne3 min

How to Use the Windows Backup App in Windows 11

How-To

How to Use the Windows Backup App in Windows 11

How to use the Windows Backup app in Windows 11 to save your folders to OneDrive and your apps, settings and Wi-Fi details to your Microsoft account, restore them on a new PC, change what's backed up and understand its limits.

Marcus Thorne3 min

How to Remove or Turn Off Copilot in Windows 11

How-To

How to Remove or Turn Off Copilot in Windows 11

How to remove or turn off Microsoft Copilot in Windows 11: uninstall the Copilot app in Settings or with PowerShell, change what the Copilot key does, and the AppLocker option Microsoft recommends for IT admins.

Marcus Thorne3 min

How to Translate Text Offline on Your PC with LibreTranslate

How-To

How to Translate Text Offline on Your PC with LibreTranslate

How to run LibreTranslate, a free and open-source translation service, on your own PC: install it with pip, load only the languages you need, translate in the browser or through its API, keep it local and add optional CUDA acceleration.

Marcus Thorne3 min