MIT License Β· Open Source

HuggingFace Models,
Via BitTorrent.

Scan your local HF cache, create .torrent files for any model or dataset, and share or download them using the BitTorrent protocol β€” with a beautiful CLI and Web UI.

Terminal
$ hf-torrent list
bert-base-uncased .............. 440 MB
gpt2 ......................... 548 MB
meta-llama/Llama-2-7b ........ 13.5 GB
stable-diffusion-v1-5 ......... 4.2 GB
$ hf-torrent create bert-base-uncased
βœ“ Torrent created: bert-base-uncased.torrent
$ hf-torrent
Web UI started at http://127.0.0.1:8400

Features

Everything you need to share HuggingFace models peer-to-peer.

πŸ”

Scan Local Cache

Auto-discovers models and datasets in your ~/.cache/huggingface/hub directory. No manual configuration needed.

πŸ“¦

Create Torrents

Generate .torrent files for any cached repository with file hashing. Share them with anyone.

⬇️

P2P Download

Download repositories using the BitTorrent protocol (libtorrent) with real-time progress tracking.

πŸ–₯️

CLI & Web UI

Full-featured command-line tool and a beautiful web-based UI for visual repo browsing and management.

🌍

Multilingual

Built-in support for English and Chinese. Extensible locale system β€” just add a JSON file.

πŸ–₯️

Cross-Platform

Works on Windows, macOS, and Linux. One tool everywhere.

Installation

Get up and running in seconds.

1

Clone the repository

git clone https://github.com/Block233/huggingface-bittorrent.git
2

Install dependencies

cd hf-torrent && pip install -e .
3

Launch

hf-torrent

Usage

CLI and Web UI β€” pick your workflow.

Command Line

# List cached repos
$ hf-torrent list

# Scan a specific directory
$ hf-torrent scan /path/to/hf/cache

# Create torrent for a repo
$ hf-torrent create bert-base-uncased

# List saved torrents
$ hf-torrent torrents

# Download via torrent
$ hf-torrent download bert-base-uncased

Web Interface

Launch with a single command and open your browser:

$ hf-torrent
Web UI started at http://127.0.0.1:8400
πŸ“ Browse cached repos
πŸ“¦ Create torrents with one click
⬇️ Download with live progress
πŸŒ™ Dark / Light theme

Architecture

Clean, modular Python project structure.

hf-torrent/
β”œβ”€β”€ src/
β”‚   └── hf_torrent/
β”‚       β”œβ”€β”€ cli/          # Command-line interface
β”‚       β”œβ”€β”€ core/         # Cache scanning, torrent creation, download engine
β”‚       β”œβ”€β”€ i18n/         # Internationalization (en_US, zh_CN)
β”‚       β”œβ”€β”€ utils/        # Path helpers
β”‚       └── web/          # FastAPI app, routes, templates, static assets
β”‚           β”œβ”€β”€ routes/   # Pages, cache, torrent, download APIs
β”‚           β”œβ”€β”€ static/   # CSS + JS
β”‚           └── templates/# Jinja2 templates
β”œβ”€β”€ torrents/             # Generated .torrent files
β”œβ”€β”€ tests/
└── pyproject.toml

Dependencies

huggingface_hub HF cache integration
libtorrent BitTorrent protocol (optional)
FastAPI Web server framework
uvicorn ASGI server
Jinja2 HTML templating

Ready to share models peer-to-peer?

Star the repo, try it out, and contribute.