Skip to content

DrGo/hfget

Repository files navigation

hfget - A Robust Hugging Face Downloader

hfget is a lightweight, command-line utility for downloading models and datasets from HuggingFace. It is designed to be fast, reliable, and script-friendly, with features like concurrent downloads, file integrity verification, and advanced filtering.

$ hfget lmstudio-community/Qwen3-Coder-Next-MLX-6bit
Fetching repository information...
Analysis complete.
----------------------------------------------------
Repository:    lmstudio-community/Qwen3-Coder-Next-MLX-6bit
Last Modified: Mon, 02 Feb 2026 23:52:11 UTC
----------------------------------------------------
Files to download (Reason: missing):
  - .gitattributes                                               (1.5 KB)
  - README.md                                                    (2.1 KB)
  - chat_template.jinja                                          (5.9 KB)
  - config.json                                                  (21.7 KB)
  - generation_config.json                                       (214 B)
  - model-00001-of-00013.safetensors                             (4.8 GB)
  - model-00002-of-00013.safetensors                             (5.0 GB)
  - model-00003-of-00013.safetensors                             (5.0 GB)
  - model-00004-of-00013.safetensors                             (5.0 GB)
  - model-00005-of-00013.safetensors                             (5.0 GB)
  - model-00006-of-00013.safetensors                             (5.0 GB)
  - model-00007-of-00013.safetensors                             (5.0 GB)
  - model-00008-of-00013.safetensors                             (5.0 GB)
  - model-00009-of-00013.safetensors                             (5.0 GB)
  - model-00010-of-00013.safetensors                             (5.0 GB)
  - model-00011-of-00013.safetensors                             (5.0 GB)
  - model-00012-of-00013.safetensors                             (5.0 GB)
  - model-00013-of-00013.safetensors                             (659.6 MB)
  - model.safetensors.index.json                                 (169.4 KB)
  - tokenizer.json                                               (10.9 MB)
  - tokenizer_config.json                                        (6.8 KB)
----------------------------------------------------
Total download size: 60.3 GB
Proceed with download? [y/N]: y
Starting download...
Overall: 100.0% (60.3 GB/60.3 GB) | Complete.

Features

  • Concurrent Downloads: Utilizes multiple connections to download large files in parallel, significantly speeding up the process.
  • Integrity Verification: Automatically verifies downloaded files against their expected size and SHA256 checksum (for LFS files) to ensure they are not corrupted.
  • Intelligent Syncing: Only downloads files that are missing or have failed local verification, saving time and bandwidth.
  • Advanced Filtering: Include or exclude specific files from a repository using glob patterns.
  • Robust Error Handling: Features an idle timeout to prevent freezes on stalled connections and retries on transient network errors. A single file failure will not stop the entire download job.
  • Accurate Progress Display: Provides smooth, accurate progress bars for both the initial file analysis and the download phases.
  • Interactive & Scriptable: Provides an interactive summary and confirmation prompt for manual use, which is automatically bypassed when not run in a terminal or when using the --force flag.
  • Verbose Logging: An optional --verbose flag provides detailed diagnostic output for troubleshooting.
  • Lightweight & Portable: The compiled binary is self-contained and works on major platforms with no runtime dependencies. It has minimal external Go library dependencies.

Installation

Via Pre-compiled Binary (Recommended)

You can download the latest pre-compiled binary for your operating system (Linux, macOS, Windows) from the Releases page on GitHub. This is the simplest way to get started.

Via go install

If you have a working Go environment, you can also install hfget with a single command:

go install 
[github.com/drgo/hfget/cmd/hfget@latest](https://github.com/drgo/hfget/cmd/hfget
@latest)

This will download the source, compile it, and place the hfget binary in your $GOPATH/bin directory. Make sure this directory is in your system's PATH.

Usage

Basic Syntax

The tool is invoked by providing the repository name as an argument, followed by any optional flags.

hfget [OPTIONS] REPOSITORY_NAME

Examples

1. Download a Model

This will download the nanollama model from the user imdatta0 into a directory named imdatta0_nanollama in the current folder.

hfget imdatta0/nanollama

2. Download to a Specific Directory

Using the -d flag specifies the destination directory. (The long form is --dest).

# This will save files to the 'my_models' directory
hfget -d ./my_models imdatta0/nanollama

3. Download a Dataset

To download a dataset, you must use the --dataset flag.

hfget --dataset squad

4. Download with Filtering

Use the --include and --exclude flags with comma-separated glob patterns to control which files are downloaded.

# Download only the Q4 and Q5 quantizations from a model
hfget imdatta0/nanollama --include "*.Q4_K_M.gguf,*.Q5_K_M.gguf"

# Download everything EXCEPT the safetensors files
hfget imdatta0/nanollama --exclude "*.safetensors"

5. Force a Re-download

To re-download all files from a repository, regardless of their local state, use the -f flag. This will also skip all interactive prompts.

hfget -f imdatta0/nanollama

Command-Line Flags

Flags can also be set via environment variables (e.g., setting HFGET_TOKEN instead of using the -t flag).

Flag Shorthand Environment Variable Description Default
--dataset Specify that the repository is a dataset. false
--branch -b HFGET_BRANCH The repository branch to download from. "main"
--dest -d HFGET_DEST The local directory where files will be saved. "./"
-c HFGET_CONCURRENT_CONNECTIONS Number of concurrent connections for downloading. 5
--token -t HFGET_TOKEN Your Hugging Face auth token. ""
--skip-checksum HFGET_SKIP_CHECKSUM Skip SHA256 checksum verification. false
--tree Use nested tree structure for output directory. false
--include Comma-separated glob patterns for files to include. ""
--exclude Comma-separated glob patterns for files to exclude. ""
--max-retries Maximum retries on transient network errors. 3
--retry-interval The time to wait between retries. 5s
--quiet -q Suppress interactive progress and prompts. false
--force -f Force re-download of all files (implies --quiet). false
--verbose -v Enable verbose diagnostic logging to stderr. false
--version Show version information and exit. false

License

This project is licensed under the MIT License.

About

A lightweight, command-line utility for downloading models and datasets from HuggingFace

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors