Skip to main content

ollama-forge

PyPI

Get models from Hugging Face, convert them, fine-tune, serve, and evaluate them locally — without needing deep expertise. One place for fetch, convert, adapters, training, agentic serving, and research tooling.

Install: pip install ollama-forge or uv tool install ollama-forge — PyPI. From this repo: uv sync then uv run ollama-forge; or uv tool install . to use the CLI from anywhere.

Quick start:

ollama-forge fetch TheBloke/Llama-2-7B-GGUF --name my-model && ollama run my-model

Or the shortest path: ollama-forge start --name my-model then ollama run my-model.


What's new

Feature Command Description
Unified API server forge api OpenAI-compatible /v1/chat/completions server that proxies Ollama and can serve local llama.cpp / MLX LM / MLX VLM backends with automatic routing and GPU memory tracking
Streamlit web UI forge ui Multi-tab chat + model management + training UI; connects to any OpenAI-compatible endpoint
Tool-call eval forge eval 8-case tool-call correctness mini-eval against any OpenAI-compatible endpoint; custom YAML suites supported
MLX fine-tuning forge mlx-train YAML-driven mlx-lm fine-tuning: --init to scaffold config, --dry-run to validate, real LoRA adapter training on Apple Silicon
Model router Python API ModelRouter.from_available(models) — heuristic routing (code→coder model, vision→VLM, etc.) from installed models
Context budget Python API ContextBudget(max_tokens=8192) — running token tracker with warn threshold and trim_to_fit() for agentic loops
Weight-Space Sharpening forge wsp 6-phase toolkit for surgical LLM weight editing: obstruction diagnosis, spectral analysis, rank-k sharpening, causal correction, and abliteration (residual stream orthogonalisation for refusal removal)

Documentation (Wiki)

Detailed guides live in the wiki/:

Topic Description
Installation Setup, check, doctor, setup-llama-cpp
Quick Start start / quickstart, profiles, task presets
Auto & Plan Auto-detect source, dry-run planner
Fetch & Convert GGUF from HF, GGUF file → Ollama
Recipes One-file YAML/JSON build
Modelfile Ollama Modelfile basics
Adapters LoRA: search, recommend, fetch-adapter, retrain
Training Data JSONL validate, prepare, train script
Retrain Pipeline Data → adapter → Ollama
Abliterate Refusal removal
Weight-Space Sharpening forge wsp pipeline: 6 phases from diagnosis through abliteration; forge wsp abliterate for refusal removal via residual stream orthogonalisation
Security Eval LLM security evaluation: prompt sets, KPIs, UI
Downsizing Teacher → student distillation
Hugging Face without GGUF When the repo has no GGUF
Quantization Smaller/faster GGUF (Q4_K_M, Q8_0, etc.)
TurboQuant Extreme 2-4 bit quantization, KV cache compression, layer-adaptive, temporal decay
VLM (Vision Language Models) Multimodal inference (image/audio/video), TurboQuant KV cache, VisionFeatureCache, fine-tuning (LoRA/ORPO) on Apple Silicon via mlx-vlm >=0.4.4
CI / Automation Example GitHub Actions
API Server forge api unified OpenAI-compatible server
UI forge ui Streamlit web interface
Eval forge eval tool-call correctness evaluation
MLX Training forge mlx-train YAML-driven fine-tuning
Command Reference All commands

Why ollama-forge

  • One place — Fetch, convert, adapters, training, serving, eval; no scattered scripts.
  • Simple — Clear commands and docs; try things without being an ML expert.
  • Local-first — Everything runs on your machine (Ollama, llama.cpp, MLX on Apple Silicon).
  • Research-ready — Agentic API server, model router, context budget, tool-call eval, and a growing weight-space toolkit for advanced experimentation.

Setup (one-time)

  • Python 3.10+. From PyPI: pip install ollama-forge or uv tool install ollama-forge (PyPI). From repo: uv sync then uv run ollama-forge; use uv tool install . from the repo root to put ollama-forge on your PATH.
  • Ollama — Install and ensure ollama is on your PATH.
  • Verify: ollama-forge check — see what’s installed. ollama-forge doctor for diagnosis; doctor --fix to apply safe fixes. See Installation for optional llama.cpp (finetune/quantize).
  • Dependencies: install with uv sync to get the full local toolchain.
  • Optional: Run Ruff and tests before commit/push: git config core.hooksPath .githooks. See .githooks/README.md. To fix lint before pushing without hooks: uv run ruff check src tests --fix && uv run ruff format src tests.

Commands at a glance

What you want Command
Easiest one-command start start or quickstart [--name my-model]
Auto-detect source and run auto <source> [--name my-model]
Preview operations (dry-run) plan <quickstart|auto|doctor-fix|adapters-apply> ...
GGUF from HF → Ollama fetch <repo_id> --name <name>
HF safetensors → GGUF → Ollama import <repo_or_dir> --name <name>
GGUF file → Ollama convert --gguf <path> --name <name>
Find / use adapters adapters search, adapters recommend, fetch-adapter, retrain
One-file config build build recipe.yaml
Unified OpenAI-compatible API server api [--port 11435] [NAME=PATH ...]
Streamlit web UI (chat + models + train) ui [--port 8501]
Tool-call correctness eval eval --model <model> [--suite builtins|path.yaml]
MLX LoRA fine-tuning (YAML config) mlx-train config.yaml [--init|--dry-run]
Serve GGUF directly (llama.cpp) serve <model.gguf> [--port 11434] [-ngl -1]
Chat with a running server chat [--base-url <url>]
Quantize HF model (TurboQuant) turboquant quantize <model> --bits 3
Serve TurboQuant model turboquant serve <model.tqf> --port 8811
Chat with TurboQuant model turboquant chat <model.tqf>
VLM generate (image+text) vlm generate --model <model> --prompt "..." --image photo.jpg
VLM generate + TurboQuant KV vlm generate --model <model> --prompt "..." --kv-bits 3.5
VLM interactive chat (cached) vlm chat --model <model> --vision-cache-size 20
VLM video understanding vlm video-generate --model <model> --video clip.mp4
VLM Gradio web UI vlm chat-ui --model <model>
VLM OpenAI-compatible server vlm serve --model <model> [--port 11434] [--kv-bits 3.5]
VLM convert HF → MLX vlm convert --hf-path <repo_id> [--q-mode mxfp4]
VLM quantize vlm quantize --model <repo_id> --bits 4 [--q-mode affine]
VLM fine-tune (LoRA/ORPO) vlm finetune --model <model> --dataset <path> [--train-mode orpo]
Remove soft-tier refusals (WSP abliteration) wsp abliterate <model-path> --n-layers 3 --output-path <path>
Download GGUF only (no Ollama) fetch <repo_id> --download-only
Check / fix environment check, doctor [--fix]
Install llama.cpp setup-llama-cpp

Full list: Command Reference. Run ollama-forge --help for options.


Simplest workflows

Beginner (one command):

uv run ollama-forge start --name my-model
ollama run my-model

Uses default model + balanced profile. Use --profile fast|balanced|quality|low-vram and --task chat|coding|creative. See Quick Start.

Auto (any source): Recipe, GGUF path, HF repo, base model, or adapter — the tool detects and runs the right flow:

uv run ollama-forge auto ./recipe.yaml
uv run ollama-forge auto TheBloke/Llama-2-7B-GGUF --name my-model
uv run ollama-forge auto llama3.2 --name my-assistant --system "You are helpful."

See Auto & Plan.

Fetch from Hugging Face: When the repo has GGUF files:

uv run ollama-forge fetch TheBloke/Llama-2-7B-GGUF --name my-model
ollama run my-model

Use --quant Q4_K_M to pick size. For gated or private repos, set HF_TOKEN or run huggingface-cli login. See Fetch & Convert.

Local GGUF: uv run ollama-forge convert --gguf /path/to/model.gguf --name my-model. Optional --quantize Q4_K_M (needs llama.cpp on PATH). See Quantization.

Recipe (one file): uv run ollama-forge build recipe.yaml. See Recipes for format and examples. Sampling options (temperature, top_p, repeat_penalty) are available on fetch, convert, build, and create-from-base (Modelfile, Recipes).

Serve a model directly (without Ollama): Download a GGUF and spin up an OpenAI-compatible server:

uv run ollama-forge fetch janhq/Jan-code-4b-gguf --download-only
uv run ollama-forge serve /path/to/model.gguf
# In another terminal:
uv run ollama-forge chat

serve auto-detects GPU (Metal on Apple Silicon, CUDA on NVIDIA, CPU fallback). fetch --download-only also handles repos with safetensors — it converts to GGUF automatically.

Adapters: adapters search "llama lora", then fetch-adapter <repo> --base <base> --name <name>, or retrain --base <base> --adapter <path> --name <name>. See Adapters.

Training data → model: Validate JSONL, prepare for trainer, generate script: train --data ./data/ --base llama3.2 --name my-model --write-script train.sh. See Training Data and Retrain Pipeline.

MLX fine-tuning: Scaffold a config, validate it, then train a LoRA adapter on Apple Silicon:

uv run ollama-forge mlx-train --init                # writes mlx_train_config.yaml
uv run ollama-forge mlx-train config.yaml --dry-run # validate without running
uv run ollama-forge mlx-train config.yaml           # run training

See mlx-train --help for all options (base model, dataset, learning rate, steps, batch size).

Unified API server + web UI: Serve any model (Ollama proxy or local llama.cpp/MLX) on a single OpenAI-compatible endpoint, then open the web interface:

# Proxy Ollama (all installed models available)
uv run ollama-forge api --port 11435

# Register local backends alongside Ollama
uv run ollama-forge api --port 11435 "mymodel=/path/to/model.gguf"
uv run ollama-forge api --port 11435 "qwen=/path/to/mlx-model-dir"

# Open the Streamlit UI (chat, model list, train tab)
uv run ollama-forge ui --port 8501

Tool-call eval: Test any model's function-calling accuracy against 8 built-in cases or a custom YAML suite:

uv run ollama-forge eval --model llama3.2:3b
uv run ollama-forge eval --model llama3.2:3b --suite my_suite.yaml

Other topics

  • Hugging Face repo without GGUF — Convert with llama.cpp first, then convert. Wiki.
  • Refusal removal (abliterate) — Quickstart: abliterate easy --model <id> --name <name> or abliterate wizard for prompts. Install deps with uv sync. For agents with tool support use the lightweight proxy: abliterate proxy --name <name>. Wiki.
  • Weight-space sharpening (WSP) — 6-phase pipeline for surgical LLM weight editing without gradient descent: obstruction diagnosis, spectral analysis, rank-k sharpening, Behavioral + Gradient-Guided Causal Correction, and abliteration (residual stream orthogonalisation). Sweet spot for Qwen2.5-7B: forge wsp abliterate <model-path> --n-layers 3 --output-path <path>. Wiki.
  • Downsizing (distillation) — downsize --teacher <hf> --student <hf> --name <name>. Wiki.
  • LLM security evaluation — Run prompt sets against Ollama/serve, score refusal/compliance, get ASR and KPIs: security-eval run <prompt_set>. Install deps with uv sync, then run security-eval ui for the UI. Wiki: Security Eval.
  • TurboQuant — Extreme 2-4 bit quantization with near-optimal quality. No llama.cpp needed. turboquant quantize <model> --bits 3 then turboquant serve or turboquant chat. Includes asymmetric K/V cache compression, layer-adaptive precision (protects quality-critical layers), and temporal decay (progressively compresses old KV tokens). Wiki.
  • VLM (Vision Language Models) — Multimodal (image + audio + video + text) inference on Apple Silicon via mlx-vlm >=0.4.4. Generate, chat, serve (OpenAI-compatible), video understanding, convert, quantize (affine/mxfp4/nvfp4/mxfp8), and fine-tune (LoRA/QLoRA/full/ORPO). Features TurboQuant KV cache (--kv-bits 3.5 for 76% memory savings) and VisionFeatureCache (--vision-cache-size 20 for 11x+ multi-turn speedup). vlm generate --model <model> --prompt "Describe this" --image photo.jpg. Wiki.
  • Unified API server — api --port 11435 [NAME=PATH ...] starts an OpenAI-compatible /v1/chat/completions server that proxies Ollama and optionally runs local llama.cpp / MLX LM / MLX VLM backends. Automatic GPU budget tracking, model routing, and concurrent request management. Wiki.
  • Streamlit web UI — ui [--port 8501] launches a multi-tab interface: Chat (streaming, model selector), Models (health + budget metrics), and Train (form → YAML → mlx-train). Wiki.
  • Tool-call eval — eval --model <model> [--base-url <url>] [--suite builtins|path.yaml] runs a correctness mini-eval of a model's function-calling against 8 built-in cases or a custom YAML suite. Wiki.
  • MLX fine-tuning — mlx-train config.yaml runs YAML-driven LoRA fine-tuning via mlx-lm on Apple Silicon. --init scaffolds a starter config; --dry-run validates without running. Wiki.
  • CI — Example GitHub Actions in CI / Automation.

Metadata

Release files for ollama-forge 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ollama-forge 1.0.2
File Size Uploaded Provenance Actions
ollama_forge-1.0.2.tar.gz 1.5 MB Without provenance Details for ollama_forge-1.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ollama-forge 1.0.2
File Interpreter ABI Platform Actions
ollama_forge-1.0.2-py3-none-any.whl Python 3 none any Details for ollama_forge-1.0.2-py3-none-any.whl

Total release size: 2.7 MB

Release files / ollama_forge-1.0.2.tar.gz

Download URL ollama_forge-1.0.2.tar.gz
Size 1.5 MB
Tags Source
SHA-256 checksum
How to use checksums
e5cc825a9a3f0cea6c921b832c2db76f53b8bae072a5bef59e5cea42bf3a550b
BLAKE2b-256 checksum
How to use checksums
2a7bde9700cfb71f35a129af8fcdd9c9d884fee4678a796c8c55c2e234a46f84
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.18

Release files / ollama_forge-1.0.2-py3-none-any.whl

Download URL ollama_forge-1.0.2-py3-none-any.whl
Size 1.1 MB
Tags Python 3
SHA-256 checksum
How to use checksums
657e71e13758bedafe709b0ccf5fbac83c7be2bd0547163f51303786a1675f2f
BLAKE2b-256 checksum
How to use checksums
6566f1f5c9a8888e69cefbc14298464cbd8cc90b83b95571a30164e072613e7b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.18

Security for ollama-forge 1.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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