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

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

CLI Reference

Flag Short Default Description
--input-dir -i ./ Path to directory containing MLX or HF PEFT adapter files.
--output-dir -o ./converted_adapter Output directory for converted PEFT safetensors.
--ollama-base-model -m gemma4:12b-mlx Base model registered in Ollama.
--ollama-target-name, --name -n gemma4-adapted Name for the new model 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

Download files

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

Source Distribution

lora_ollama_bridge-0.1.3.tar.gz (13.9 kB view details)

Uploaded Source

Built Distribution

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

lora_ollama_bridge-0.1.3-py3-none-any.whl (14.0 kB view details)

Uploaded Python 3

File details

Details for the file lora_ollama_bridge-0.1.3.tar.gz.

File metadata

  • Download URL: lora_ollama_bridge-0.1.3.tar.gz
  • Upload date:
  • Size: 13.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for lora_ollama_bridge-0.1.3.tar.gz
Algorithm Hash digest
SHA256 7651d9ce8488b512c966708de45074a51f773bed3f750c9dc37be1d99be18785
MD5 c6cb10ac00557ba22d6769e0e7f8bc1e
BLAKE2b-256 f881d9673ba24d4d6dfcbaeb71afaa951dfd816093a57ae35a596f74c4ba2633

See more details on using hashes here.

File details

Details for the file lora_ollama_bridge-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for lora_ollama_bridge-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4d1b39899067ca2a1b375f5615259ebbba0daae4fcf0b08c8f5b9490192c59e6
MD5 dfd79bfe48463fb2f386a0b932b12c11
BLAKE2b-256 36faec1d7753e5918bc1ded7878f3813045d7d640e76226ba8fb999a56640c10

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page