How to Download Hugging Face Models Using Command Line

When training LoRAs with AI-Toolkit, you usually need the original base model files stored locally. If you don’t store them locally, ai-toolkit might download the same files multiple times onto temp directory. Also, downloading models via the browser is slow and unreliable for large repositories, so the recommended approach is using the hf command-line tool from the huggingface_hub Python module.

If you’re thinking about purchasing a new GPU, we’d greatly appreciate it if you used our Amazon Associate links. The price you pay will be exactly the same, but Amazon provides us with a small commission for each purchase. It’s a simple way to support our site and helps us keep creating useful content for you. Recommended GPUs: RTX 5090, RTX 5080, and RTX 5070. #ad

This guide shows how to download popular models like Z-Image-Turbo and Qwen-Image-2512 specifically for LoRA training.

1. Install the Hugging Face CLI

Install or upgrade the Hugging Face Hub client:

pip install -U huggingface_hub xet

Verify the CLI is available:

hf --help

2. Authenticate (Recommended)

Some models are gated, and authentication also improves download reliability. You will need a read-only token. To get a read-only Hugging Face token, go to your Hugging Face account settings and open the Access Tokens page. Create a new token, set the token type to Read, generate it, and copy the token somewhere safe. Note that you can only view the token once. This token can then be used when logging in with hf auth login to download models.

hf auth login

To confirm login:

hf auth whoami

3. Download the Base Model Repository

AI-Toolkit expects local model files. Always download into a dedicated folder.

Example: Z-Image-Turbo (for LoRA training)

hf download Tongyi-MAI/Z-Image-Turbo --local-dir D:\Z-Image-Turbo

This ensures:

  • All weights are downloaded locally

  • Files are safe to move or back up

  • AI-Toolkit can read them directly

Example: Qwen-Image-2512

hf download Qwen/Qwen-Image-2512 --local-dir D:\Qwen-Image-2512

4. Verify Files Before Training

After downloading, your model folder should contain:

  • .safetensors or weight files

  • configuration files (config.json, etc.)

  • tokenizer / text encoder files (if required)

Point AI-Toolkit’s base_model_path to this folder when starting LoRA training.

Conclusion

For LoRA training with AI-Toolkit, the hf CLI is the safest and fastest way to download Hugging Face models locally. Whether you’re training on Z-Image-Turbo, Qwen-Image-2512, or other modern image models, this approach ensures your base model is clean, portable, and ready for training.

Reference

Further Reading

How to Train a Qwen-Image LoRA with ai-toolkit

How to Use Qwen-Image-2512 GGUF in ComfyUI

Generate Realistic Images with Z-Image-Turbo GGUF in ComfyUI

 

Be the first to comment

Leave a Reply