HF-Mirror Logo
HF-Mirror Mirror Gateway
🌐 δΈ­ζ–‡
πŸ“š Developer Knowledge Base

Frequently Asked Questions & Troubleshooting (FAQ)

Comprehensive hands-on troubleshooting guide for large models, covering CLI, Python, Git LFS, and edge delivery

Q1: Why is huggingface-cli strongly recommended over browser downloads or git clone?

The official command line tool huggingface-cli (powered by huggingface_hub) is the most robust way to fetch large AI models.

  • Multi-threading & Resume: When a massive 20GB download is interrupted at 95%, adding --resume-download picks up exactly where it dropped off, whereas web browsers frequently abort and force a full restart.
  • Zero Git History Bloat: Running git clone pulls every commit history and tree index, consuming excessive disk space and memory; furthermore, Git LFS easily times out leaving corrupted pointer stubs.
  • Wildcard Filtering: Flags like --include "*.safetensors" pull only required model weights, skipping unneeded .bin or .onnx artifacts.

Q2: How do I persistently configure the mirror environment variable across platforms?

Running export in your terminal only impacts the active shell session. To persist across reboots, add it to your profile configuration:

Linux / macOS (Bash or Zsh):
# For Bash users
echo 'export HF_ENDPOINT="https://hf-mirror.net"' >> ~/.bashrc
source ~/.bashrc

# For Zsh users (default on macOS)
echo 'export HF_ENDPOINT="https://hf-mirror.net"' >> ~/.zshrc
source ~/.zshrc
Windows (PowerShell):
[System.Environment]::SetEnvironmentVariable('HF_ENDPOINT', 'https://hf-mirror.net', [System.EnvironmentVariableTarget]::User)

Q3: How to fix 401/403 errors when downloading Gated Models (e.g., LLaMA 3.3, Gemma 2)?

Gated repositories require explicit author approval before weights can be retrieved:

  1. Log in to Hugging Face, visit the model card (e.g., meta-llama/Llama-3.3-70B-Instruct), and accept the community license agreement;
  2. Navigate to Account Settings and generate a Read Token: https://huggingface.co/settings/tokens;
  3. Authenticate in your terminal by executing huggingface-cli login, or pass --token hf_xxxx directly into your download command.

* Security Reminder: HF-Mirror uses end-to-end transparent TLS forwarding. Your token verifies directly against official Hugging Face servers and is never intercepted or retained on our systems.

Q4: Why does git clone only download 100-byte text pointer files?

This occurs when Git LFS is not installed or initialized on your host, causing Git to checkout only SHA256 text descriptors.

Resolution:

# 1. Install git-lfs (Ubuntu/Debian example)
sudo apt-get install git-lfs
git lfs install

# 2. Enter your cloned repository and trigger large file pulling
git lfs pull

Q5: How to use HF-Mirror inside Python scripts (e.g., transformers / diffusers)?

Inject the endpoint environment variable before importing the transformers or diffusers libraries:

import os
os.environ["HF_ENDPOINT"] = "https://hf-mirror.net"

from transformers import AutoTokenizer, AutoModelForCausalLM

model_name = "Qwen/Qwen2.5-7B-Instruct"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name)

Q6: How to configure HF-Mirror elegantly in Docker containers and Kubernetes?

Inject the environment variable in your Dockerfile or when starting the container:

# Inside Dockerfile
ENV HF_ENDPOINT=https://hf-mirror.net

# Or mount host cache to avoid redundant downloads when launching container
docker run -it -e HF_ENDPOINT="https://hf-mirror.net" \
  -v ~/.cache/huggingface:/root/.cache/huggingface \
  pytorch/pytorch:latest

Q7: Why do browser visits to model cards prompt a redirect to official Hugging Face?

HF-Mirror's core purpose is a high-throughput file-level distribution acceleration proxy. The web UI on Hugging Face includes discussions, active Spaces demos, interactive code sandboxes, and sensitive session cookies.

To protect developer privacy and eliminate intermediate MITM vulnerabilities, this site strictly proxies binary file download APIs and does not render web UI cards. When interactive browser requests are detected, we guide visitors to view the official Model Card.

Q: What is the difference between hf-mirror.net and legacy mirrors like hf-mirror.com?

Many developers switching from export HF_ENDPOINT=https://hf-mirror.com report that small config files load fine, while multi-gigabyte weights stall or fail with Connection reset. Key architectural differences include:

  • No 302 Overseas Redirection: Legacy mirrors (such as hf-mirror.com) frequently return 302 Found for large binary files under resolve/main/, bouncing clients back to overseas S3/R2 storage across congested transit.
  • True Anycast Streaming on hf-mirror.net: Our gateway maintains persistent edge connections, returning HTTP 200 OK / 206 Partial Content directly streamed via edge PoPs with zero offshore bouncing.
  • One-Line Drop-In Switch: Replace your endpoint with export HF_ENDPOINT="https://hf-mirror.net" to unlock 150+ MB/s multi-threaded HTTP Range resume downloads.

Q8: How to download only a single GGUF quantization weight or specific files?

Use the --include filter in huggingface-cli download:

export HF_ENDPOINT="https://hf-mirror.net"
huggingface-cli download bartowski/DeepSeek-R1-Distill-Qwen-7B-GGUF --include "*Q4_K_M.gguf" --local-dir ./

Q9: How do I accelerate Hugging Face Datasets (load_dataset / Parquet) without datasets-server?

The official datasets-server (/rows and viewer API) is built for browser previews and is heavily rate-limited. For training pipelines, point HF_ENDPOINT to https://hf-mirror.net and fetch raw Parquet shards directly via datasets or CLI:

export HF_ENDPOINT="https://hf-mirror.net"
huggingface-cli download --repo-type dataset fka/awesome-chatgpt-prompts --local-dir ./prompts-data

See our full walkthrough on streaming load_dataset() and Parquet mirror downloads: Hugging Face Datasets Mirror Guide β†’

Have more technical questions?

Submit an incident report or reach out to our engineering team via email.

Contact Engineering Support