Skip to main content

hf2ollama

A Python CLI tool that searches, downloads, and imports HuggingFace GGUF models into Ollama. Handles model discovery, quantization selection, automatic Modelfile generation, and resumable downloads.

What it does

ollama pull only works with models hosted on the Ollama registry. Most open-weight GGUF models live on HuggingFace. This tool bridges that gap: search HuggingFace for GGUF repos, pick a quantization, download the file, auto-generate the correct Modelfile with chat template and stop tokens, and import into Ollama - all in one command.

It also handles a common Python SSL issue where certifi (the default CA bundle) doesn't include certificates from the operating system's trust store. The --ssl-fix flag exports the OS certificate store and configures Python to use it.

Installation

Works on Windows, macOS, and Linux. Requires Python 3.10+.

pip install hf2ollama

From source:

git clone https://github.com/rs2pydev/hf2ollama-python-cli-tool.git
cd hf2ollama-python-cli-tool
pip install -e ".[dev]"

Quick start

# Search for models
hf2ollama search "qwen 7b gguf"

# See available quantizations and file sizes
hf2ollama list-files bartowski/Qwen2.5-Coder-7B-Instruct-GGUF

# Download and import into Ollama
hf2ollama pull bartowski/Qwen2.5-Coder-7B-Instruct-GGUF --quant Q4_K_M

# Fix Python SSL certificate issues if downloads fail
hf2ollama pull bartowski/Qwen2.5-Coder-7B-Instruct-GGUF --ssl-fix

# Use alternative download method (Windows, PowerShell 7 required)
hf2ollama pull bartowski/Qwen2.5-Coder-7B-Instruct-GGUF --alt-download

Commands

pull

Download a GGUF model from HuggingFace and import into Ollama.

hf2ollama pull <repo> [--quant Q4_K_M] [--name my-model] [--keep-gguf] [--ssl-fix] [--alt-download]

Options:

  • --quant / -q - Quantization level (Q2_K, Q3_K_M, Q4_K_M, Q5_K_M, Q6_K, Q8_0). Default: Q4_K_M.
  • --name / -n - Ollama model name. Auto-generated from filename if not specified.
  • --keep-gguf - Keep the GGUF file after importing into Ollama.
  • --ssl-fix - Use OS certificate store instead of Python's default CA bundle.
  • --alt-download - Use alternative PowerShell-based download method (Windows only, requires PowerShell 7).

The tool auto-detects the model family from the filename and generates the correct Modelfile with chat template and stop tokens.

search

Search HuggingFace for GGUF model repositories.

hf2ollama search "llama 70b" --limit 20 --sort downloads

list-files

Show available GGUF files in a repository with their sizes.

hf2ollama list-files bartowski/Qwen2.5-Coder-7B-Instruct-GGUF

list

List locally installed Ollama models.

hf2ollama list

remove

Delete an Ollama model.

hf2ollama remove my-model:q4_k_m

info

Show details about an installed Ollama model.

hf2ollama info my-model:q4_k_m

recommend

Recommend quantization based on your GPU VRAM and model size.

# Auto-detect GPU VRAM
hf2ollama recommend --params 7

# Specify VRAM manually
hf2ollama recommend --params 70 --vram 24

network-check

Check whether HuggingFace is reachable and whether SSL certificates are configured correctly.

hf2ollama network-check

Supported model families

The tool auto-detects model families from GGUF filenames and generates the correct Ollama Modelfile:

  • Llama 3 / 3.1 / 3.2 / 3.3 / 4
  • Gemma (2, 3, 4)
  • Qwen (2, 2.5, 3)
  • Mistral / Mixtral
  • Phi (3, 4)
  • DeepSeek (R1, V3)
  • Granite
  • Command-R
  • ChatML (fallback for unrecognized models)

Supported quantizations

Q2_K, Q3_K_M, Q4_K_M (default), Q5_K_M, Q6_K, Q8_0

Configuration

Persistent config is stored in ~/.hf2ollama/config.toml:

download_dir = "C:/Users/you/.hf2ollama/downloads"
default_quant = "Q4_K_M"
hf_token = "hf_xxxxx"

Requirements

  • Python 3.10+
  • Ollama installed locally
  • For --alt-download: Windows + PowerShell 7

Dependencies

  • click - CLI framework
  • httpx - HTTP client with resumable downloads
  • rich - Terminal tables and progress bars
  • truststore - OS certificate store access
  • certifi - Public CA bundle

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hf2ollama_python_cli_tool-1.0.0.tar.gz (18.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hf2ollama_python_cli_tool-1.0.0-py3-none-any.whl (27.7 kB view details)

Uploaded Python 3

File details

Details for the file hf2ollama_python_cli_tool-1.0.0.tar.gz.

File metadata

File hashes

Hashes for hf2ollama_python_cli_tool-1.0.0.tar.gz
Algorithm Hash digest
SHA256 9f7fe97e3b098550b5b1cce3c9218d62dccd96fd7e2af40da8099bf4fa1ce2c2
MD5 1142d0332fe17bda38350cba1e32c29c
BLAKE2b-256 ed429b9fb1026d84f79afb129364cc832891024d97c059088c0e092328a5ab04

See more details on using hashes here.

Provenance

The following attestation bundles were made for hf2ollama_python_cli_tool-1.0.0.tar.gz:

Publisher: publish.yml on rs2pydev/hf2ollama-python-cli-tool

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hf2ollama_python_cli_tool-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for hf2ollama_python_cli_tool-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 70d0e84f80ed8931d87ffab7b72da773de30681f5fad9d8402a3742e3d3ea373
MD5 5328e93aec2251e5e697b5db09a85802
BLAKE2b-256 f0955b65b35a499dbc795997b23d47fb67bef13ea614e7900712b6380f827c57

See more details on using hashes here.

Provenance

The following attestation bundles were made for hf2ollama_python_cli_tool-1.0.0-py3-none-any.whl:

Publisher: publish.yml on rs2pydev/hf2ollama-python-cli-tool

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page