huggingface_downloader 1.0.1 copy "huggingface_downloader: ^1.0.1" to clipboard
huggingface_downloader: ^1.0.1 copied to clipboard

Download complete model snapshots directly from Hugging Face repositories with resume, overwrite, extension filters, and CLI support.

huggingface_downloader #

pub package Null Safety GitHub Tag Last Commit License

huggingface_downloader is a native Dart utility for downloading complete model snapshots directly from Hugging Face Hub.

It provides a lightweight implementation similar in spirit to Python's huggingface_hub.snapshot_download(), allowing Dart applications, AI runtimes, and CLI tools to fetch Hugging Face repositories without external Python dependencies.

Ideal for:

  • ๐Ÿค– downloading LLM repositories
  • ๐Ÿง  fetching tokenizer/config/model artifacts
  • โš™๏ธ automation pipelines
  • ๐Ÿงช CI model fixture downloads
  • ๐Ÿ“ฆ building local inference environments
  • ๐Ÿ”„ resumable large file downloads

Features #

  • ๐Ÿ“ฅ Download complete Hugging Face repository snapshots
  • ๐Ÿ“‚ Preserve nested directory structure
  • ๐Ÿ” Resume interrupted downloads automatically
  • โ™ป๏ธ Optional full overwrite/redownload mode
  • ๐Ÿ” Support gated/private repositories via HF token
  • ๐ŸŽฏ Inclusion filters (--ext)
  • ๐Ÿšซ Exclusion filters (--exclude)
  • ๐Ÿค– Built-in --llm-only mode for common LLM artifacts
  • ๐Ÿ“„ Returns downloaded file list programmatically
  • ๐Ÿ’ป CLI utility included
  • ๐Ÿงฉ Native dependency-free Dart implementation using HttpClient

CLI Usage #

Activate globally:

dart pub global activate huggingface_downloader

Run:

huggingface_downloader <repoId> <outputDir> [options]

Arguments #

  • <repoId> โ†’ Hugging Face repository id
  • <outputDir> โ†’ local directory where files will be downloaded

Options #

  • --token=hf_xxx โ†’ Hugging Face access token for private/gated models
  • --ext=.json,.safetensors โ†’ download only selected extensions
  • --exclude=.onnx,.gguf,.pt โ†’ exclude unwanted artifact types
  • --llm-only โ†’ keep only common LLM files
  • --overwrite โ†’ force full redownload even if files already exist
  • -h, --help โ†’ show help message

CLI Examples #

Download SmolLM2:

huggingface_downloader HuggingFaceTB/SmolLM2-135M-Instruct ./models/smollm2 --llm-only

Force overwrite existing local files:

huggingface_downloader HuggingFaceTB/SmolLM2-135M-Instruct ./models/smollm2 --llm-only --overwrite

Download Qwen excluding ONNX/GGUF:

huggingface_downloader Qwen/Qwen2-0.5B ./models/qwen2 --exclude=.onnx,.gguf

Download private/gated repository:

huggingface_downloader meta-llama/Llama-3.2-1B-Instruct ./models/llama --token=hf_xxxxxxxxx --llm-only

Example CLI Output #

HuggingFace Downloader
----------------------
Repository : HuggingFaceTB/SmolLM2-135M-Instruct
Output Dir : ./models/smollm2
Mode       : LLM ONLY

Files selected for download: 6
  config.json
  tokenizer.json
  tokenizer_config.json
  generation_config.json
  special_tokens_map.json
  model.safetensors

model.safetensors -> 100.0% (542.13 MB / 542.13 MB)

Download completed successfully.

Downloaded files (6):
----------------------
models/smollm2/config.json
models/smollm2/tokenizer.json
models/smollm2/tokenizer_config.json
models/smollm2/generation_config.json
models/smollm2/special_tokens_map.json
models/smollm2/model.safetensors

Programmatic Usage #

huggingface_downloader can be embedded directly into Dart scripts, model preparation tools, or local inference pipelines.

import 'dart:io';
import 'package:huggingface_downloader/huggingface_downloader.dart';

Future<void> main() async {
  final downloader = HuggingFaceDownloader();

  final files = await downloader.downloadSnapshot(
    repoId: 'HuggingFaceTB/SmolLM2-135M-Instruct',
    localDir: Directory('./models/smollm2'),
    excludeExtensions: ['.onnx', '.gguf'],
    overwriteExisting: false,
    progress: (file, received, total) {
      print('$file -> $received / $total');
    },
  );

  for (final file in files) {
    print('Downloaded: ${file.path}');
  }

  downloader.close();
}

LLM Only Mode #

--llm-only is a convenience mode designed for the most common local inference workflow.

Automatically includes:

  • .json
  • .txt
  • .model
  • .safetensors
  • .bin

Automatically excludes:

  • .onnx
  • .gguf
  • .h5
  • .msgpack
  • .tflite
  • .pt
  • .pth
  • .ot
  • .ckpt

This avoids downloading unrelated framework artifacts commonly present in Hugging Face repositories.


How It Works #

  1. Fetch repository manifest from Hugging Face Hub API
  2. Read repository file list (siblings)
  3. Apply include/exclude filters
  4. Resolve each file through Hugging Face resolve endpoints
  5. Resume or overwrite existing files as requested
  6. Stream files directly to disk
  7. Return the final downloaded file list

Why This Package #

Python has huggingface_hub.snapshot_download().

Dart had no native equivalent.

huggingface_downloader fills that gap with a simple automation-friendly downloader suitable for:

  • Dart AI runtimes
  • local LLM preparation
  • CI artifact fetching
  • reproducible model bootstrapping
  • CLI tooling

Test Repository #

For automated tests and CI validation, a tiny public repository works very well:

fxmarty/really-tiny-falcon-testing

Issues & Feature Requests #

Please report issues or request features via the issue tracker.


Author #

Graciliano M. Passos: gmpassos@GitHub


License #

Dart free & open-source - BSD 3-Clause License.

1
likes
150
points
172
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Download complete model snapshots directly from Hugging Face repositories with resume, overwrite, extension filters, and CLI support.

Repository (GitHub)
View/report issues

Topics

#huggingface #downloader #machine-learning #llm #ai

License

BSD-3-Clause (license)

Dependencies

path

More

Packages that depend on huggingface_downloader