Skip to main content

Bridge between Unsloth and Ollama

A utility for registering LoRA adapters into Ollama without weight fusion or GGUF quantization. It's tested on MLX models so far, but it should support other variants as well.

Standard conversion paths from Unsloth tuned model (mlx_vlm.fuse $\rightarrow$ convert_hf_to_gguf) are CPU-bound and result in multi-gigabyte files for a 150MB adapter change. This tool bridge MLX/Unsloth adapters to the HF PEFT schema, allowing for ADAPTER registration in Ollama. It removes the need for de-quantization and re-quantization cycles which prevents additional quantization degradation.


Installation

pip install lora-ollama-bridge

Or install from source:

git clone https://github.com/filtercodes/LoRA-Ollama-Bridge.git
cd LoRA-Ollama-Bridge
pip install -e .

NOTE - bridge support is currently pending upstream review in Ollama PR #17377. To use this tool right now, run the patched Ollama built from source:

git clone https://github.com/filtercodes/ollama.git
cd ollama
go build .
./ollama serve

You only need the patched binary for the one-time ollama create step. Once registered, you can switch back to standard official Ollama, and model will stay registered.


Quickstart

1. Register Adapter in Ollama

Point the tool to the adapter directory (containing adapters.safetensors and adapter_config.json). It converts the tensors to HuggingFace PEFT schema and registers the model in Ollama:

lora-ollama-bridge -i ./mlx_adapters --name new-fine-tuned-model

2. Convert Adapter Only (Skip Ollama)

To convert the adapter format without calling the Ollama API:

lora-ollama-bridge -i ./mlx_adapters -o ./converted_adapter --skip-ollama

3. Custom Checkpoint & System Prompt

Specify a checkpoint file, system prompt, or context length:

lora-ollama-bridge \
  -i ./mlx_adapters \
  -w 0000400_adapters.safetensors \
  --name gemma4-fine-tune \
  -s "You are a helpful assistant." \
  --num-ctx 65536

4. Passing Modelfile Template

Alternatively use Modelfile directly rather than typing CLI flags:

lora-ollama-bridge -i ./mlx_adapters -f my_custom.modelfile --name gemma4-custom

CLI Reference

Flag Short Default Description
--input -i ./ Path to local directory containing adapter files, HuggingFace repo ID / URL.
--output -o ./converted_adapter Output directory for converted PEFT safetensors.
--modelfile -f None Path to a custom Modelfile template.
--ollama-base-model -m Auto-inferred Base model tag in Ollama.
--ollama-target-name, --name -n gemma4-adapted Name for the new model variant in Ollama.
--adapter-weights -w None Specific adapter weights file (e.g. 0000400_adapters.safetensors).
--system-prompt, --system -s None System prompt to include in the Modelfile.
--ollama-url -u http://localhost:11434 Ollama server URL.
--num-ctx 65536 Context window size (num_ctx).
--skip-ollama False Convert adapter format without calling Ollama API.
--force False Bypass safety checks.

Requirements

  • Python 3.10+
  • Dependencies: mlx, torch, safetensors, requests, jinja2

Testing

python3 -m unittest discover -s tests

Metadata

Release files for lora-ollama-bridge 0.1.5

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

Source distribution (sdist)

Source distribution for lora-ollama-bridge 0.1.5
File Size Uploaded
lora_ollama_bridge-0.1.5.tar.gz 15.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for lora-ollama-bridge 0.1.5
File Interpreter ABI Platform
lora_ollama_bridge-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 30.9 kB

Release files / lora_ollama_bridge-0.1.5.tar.gz

Download URL lora_ollama_bridge-0.1.5.tar.gz
Size 15.5 kB
Tags Source
SHA-256 checksum
How to use checksums
ae9fe1487f86b2016eb807bcb7b2c387a2ad5acd908da1b997f110c3d32df94f
BLAKE2b-256 checksum
How to use checksums
9537ba71ea44bceac3bcaad6b93fbb76401330e158de9f878693702810c152a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Release files / lora_ollama_bridge-0.1.5-py3-none-any.whl

Download URL lora_ollama_bridge-0.1.5-py3-none-any.whl
Size 15.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1a9871226f0295f5eca194579eca0aecae5e8ff4e64ce743ad62c053c82bd586
BLAKE2b-256 checksum
How to use checksums
37f2f66375b32774c5b88e085baa5a9798f2dc68e03f3efdca51b5abab1ce95e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release 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