Skip to content

Latest commit

 

History

History
282 lines (216 loc) · 8.09 KB

File metadata and controls

282 lines (216 loc) · 8.09 KB

🚀 hugdl - Fast HuggingFace Model Downloader

A fast and reliable model downloader written in Go for downloading HuggingFace models.

✨ Features

  • Fast downloads - Written in Go for maximum performance
  • 📊 Progress tracking - Shows download progress for each file
  • 🔍 Auto-discovery - Automatically finds all model files
  • 🛡️ Error handling - Robust error handling and retry logic
  • 📁 Organized output - Creates proper directory structure
  • 🎯 Flexible - Download any HuggingFace model via command-line arguments

📦 Installation

  1. Install Go (if not already installed):

    winget install GoLang.Go
  2. Navigate to downloader directory:

    cd downloader

🚀 Usage

Two Versions Available

This project includes two versions of the downloader:

📁 hugdl.go - Simple Version (No External Dependencies)

What it is:

  • A lightweight, standalone Go script
  • Uses only Go's standard library (no external packages)
  • No progress bars, just simple text output
  • Faster to compile and run

Features:

  • No dependencies - Works out of the box
  • Fast compilation - No external packages to download
  • Simple output - Basic text progress
  • Small executable - Minimal file size
  • Easy deployment - Single file, no dependencies

Usage:

# Download specific model (model name required)
go run hugdl.go -model microsoft/DialoGPT-medium

# Download with custom output directory
go run hugdl.go -model meta-llama/Llama-2-7b-chat-hf -output /custom/models

# Show help
go run hugdl.go -help

Output example:

🚀 hugdl - Fast HuggingFace Model Downloader
==================================================
📦 Model: Qwen/Qwen2.5-Coder-0.5B
📁 Output: /home/you/models/Qwen_Qwen2.5-Coder-0.5B
==================================================
🔍 Checking available files...
✅ Found 12 files

📥 Starting downloads...
--------------------------------------------------
[1/12] Downloading config.json...
   📥 Downloading config.json (642 bytes)...
   ✅ Downloaded config.json (642 bytes)
✅ Downloaded config.json

🎯 main.go - Full Version (With Progress Bars)

What it is:

  • Enhanced version with visual progress bars
  • Uses external library github.com/schollz/progressbar/v3
  • More professional-looking output
  • Better user experience

Features:

  • Visual progress bars - Shows download progress visually
  • Color-coded output - Better visual feedback
  • Professional UI - More polished appearance
  • Better UX - Users can see download speed and progress
  • Same functionality - All the same features as hugdl.go

Usage:

# Install dependencies first
go mod tidy

# Download specific model (model name required)
go run main.go -model Qwen/Qwen2.5-Coder-0.5B

# Download with custom output directory
go run main.go -model meta-llama/Llama-2-7b-chat-hf -output /custom/models

# Show help
go run main.go -help

Output example:

🚀 hugdl - Fast HuggingFace Model Downloader (Full Version)
==================================================
📦 Model: Qwen/Qwen2.5-Coder-0.5B
📁 Output: /home/you/models/Qwen_Qwen2.5-Coder-0.5B
==================================================
🔍 Checking available files...
✅ Found 12 files

📥 Starting downloads...
--------------------------------------------------
[1/12] Downloading config.json...
[██████████████████████████████████████████████████] 100% | 642 B/s
✅ Downloaded config.json

📊 Version Comparison

Feature hugdl.go main.go
Dependencies None External progress bar library
Compilation Instant Requires go mod tidy
File Size Small Larger (includes dependencies)
Progress Display Text only Visual progress bars
Colors Basic Color-coded output
User Experience Simple Professional
Deployment Single file Multiple files
Speed Very fast Slightly slower

🎯 When to Use Which?

Use hugdl.go when:

  • ✅ You want a quick, no-fuss downloader
  • ✅ You're in a hurry and don't want to install dependencies
  • ✅ You prefer simple text output
  • ✅ You want the smallest possible executable
  • ✅ You're deploying to environments with limited resources

Use main.go when:

  • ✅ You want a professional-looking tool
  • ✅ You want visual progress feedback
  • ✅ You don't mind installing dependencies
  • ✅ You're building a tool for others to use
  • ✅ You want the best user experience

📋 Command Line Options

Option Description Default
-model Model name to download required
-output Output directory for files OS-aware home models dir
-help Show help message false

Output default: On Windows the default output is %USERPROFILE%\hf\models; on Linux/macOS it is $HOME/models. The directory is created automatically if it does not exist.

🎯 Supported Models

  • Qwen models - All Qwen variants
  • Llama models - Llama 2, Llama 3
  • Mistral models - Mistral 7B, Mixtral
  • Microsoft models - DialoGPT, Phi
  • Any HuggingFace model - Works with any public model

📁 Output Structure

models/
└── Qwen_Qwen2.5-Coder-0.5B/
    ├── config.json
    ├── model.safetensors
    ├── tokenizer.json
    ├── tokenizer_config.json
    ├── vocab.json
    ├── merges.txt
    ├── generation_config.json
    ├── README.md
    └── LICENSE

🔧 Examples

Download Different Models

# Download Qwen model
go run hugdl.go -model Qwen/Qwen2.5-Coder-0.5B

# Download Llama model
go run hugdl.go -model meta-llama/Llama-2-7b-chat-hf

# Download Mistral model
go run hugdl.go -model mistralai/Mistral-7B-Instruct-v0.2

# Download Microsoft model
go run hugdl.go -model microsoft/DialoGPT-medium

# Download custom model
go run hugdl.go -model "your-username/your-model-name"

Custom Output Directory

# Download to different drive
go run hugdl.go -model Qwen/Qwen2.5-Coder-0.5B -output D:\my_models

# Download to custom path
go run hugdl.go -model meta-llama/Llama-2-7b-chat-hf -output C:\Users\user\Documents\models

🚀 Performance

  • Download Speed: 2-5x faster than Python
  • Memory Usage: Lower memory footprint
  • Concurrent Downloads: Can be easily extended for parallel downloads
  • Error Recovery: Automatic retry on network failures

📊 Comparison with Python

Feature Python Go
Speed ⭐⭐ ⭐⭐⭐⭐⭐
Memory ⭐⭐⭐ ⭐⭐⭐⭐⭐
Error Handling ⭐⭐⭐ ⭐⭐⭐⭐⭐
Progress Tracking ⭐⭐⭐ ⭐⭐⭐⭐⭐
Deployment ⭐⭐⭐ ⭐⭐⭐⭐⭐
Flexibility ⭐⭐ ⭐⭐⭐⭐⭐

🎉 Benefits

  1. Faster Downloads - Go's efficient HTTP client
  2. Better Error Handling - Robust error recovery
  3. Progress Tracking - Visual progress bars
  4. Easy Deployment - Single binary output
  5. Cross-Platform - Works on Windows, Linux, macOS
  6. Flexible - Download any model via command-line

🔄 Next Steps

After downloading, convert to GGUF format:

cd ..\llama.cpp
python convert_hf_to_gguf.py "C:\Users\user\hf\models\Qwen_Qwen2.5-Coder-0.5B" --outfile "C:\Users\user\hf\models\qwen2.5-coder-0.5b.gguf" --outtype q8_0

🚀 Build Executable

Create a standalone executable:

# Build simple version
go build -o hugdl.exe hugdl.go

# Build full version
go build -o hugdl-full.exe main.go

# Use the executable
./hugdl.exe -model Qwen/Qwen2.5-Coder-0.5B

🤝 Contributing

Feel free to contribute to this project! Some ideas:

  • Add concurrent downloads
  • Add resume capability for interrupted downloads
  • Add support for private models
  • Add more output formats
  • Add download speed limits

📄 License

This project is open source and available under the MIT License.