Instructions to use prism-ml/Ternary-Bonsai-2.5-27B-mlx-2bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use prism-ml/Ternary-Bonsai-2.5-27B-mlx-2bit with MLX:
# Make sure mlx-vlm is installed # pip install --upgrade mlx-vlm from mlx_vlm import load, generate from mlx_vlm.prompt_utils import apply_chat_template from mlx_vlm.utils import load_config # Load the model model, processor = load("prism-ml/Ternary-Bonsai-2.5-27B-mlx-2bit") config = load_config("prism-ml/Ternary-Bonsai-2.5-27B-mlx-2bit") # Prepare input image = ["http://images.cocodataset.org/val2017/000000039769.jpg"] prompt = "Describe this image." # Apply chat template formatted_prompt = apply_chat_template( processor, config, prompt, num_images=1 ) # Generate output output = generate(model, processor, formatted_prompt, image) print(output) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Pi
How to use prism-ml/Ternary-Bonsai-2.5-27B-mlx-2bit with Pi:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "prism-ml/Ternary-Bonsai-2.5-27B-mlx-2bit"
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "mlx-lm": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "prism-ml/Ternary-Bonsai-2.5-27B-mlx-2bit" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent
How to use prism-ml/Ternary-Bonsai-2.5-27B-mlx-2bit with Hermes Agent:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "prism-ml/Ternary-Bonsai-2.5-27B-mlx-2bit"
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default prism-ml/Ternary-Bonsai-2.5-27B-mlx-2bit
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use prism-ml/Ternary-Bonsai-2.5-27B-mlx-2bit with OpenClaw:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "prism-ml/Ternary-Bonsai-2.5-27B-mlx-2bit"
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "prism-ml/Ternary-Bonsai-2.5-27B-mlx-2bit" \ --custom-provider-id mlx-lm \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
Ternary Bonsai 2.5 27B for MLX
This Apple Silicon pack contains the 2-bit, group-128 Bonsai 2.5 27B language model and an FP16 vision tower. It supports text and image input. An optional v2 MTP head is included. For llama.cpp and other packings, see the GGUF companion.
Install and download
Use Python 3 on an Apple Silicon Mac. The bundled loader applies the signed Hadamard transforms required by the language weights.
python3 -m venv .venv
source .venv/bin/activate
python -m pip install huggingface_hub
hf download prism-ml/Ternary-Bonsai-2.5-27B-mlx-2bit --local-dir ./bonsai-25-mlx
cd ./bonsai-25-mlx
python -m pip install -r runtime/requirements.txt
If the repo is private, sign in with hf auth login before downloading.
Run text and image inference
Run this from the downloaded pack directory. Replace /path/to/image.jpg with your image file.
PYTHONPATH=runtime python - /path/to/image.jpg <<'PY'
import sys
from pathlib import Path
from mlx_vlm import generate
from mlx_vlm.prompt_utils import apply_chat_template
from vision_artifact import chat_config, load_vl_model
model, processor, config = load_vl_model(Path.cwd())
image = sys.argv[1] if len(sys.argv) > 1 else None
question = "Describe this image." if image else "What is 2 plus 2?"
prompt = apply_chat_template(
processor, chat_config(config), question,
num_images=int(image is not None), enable_thinking=False,
)
result = generate(
model, processor, prompt, image=image,
max_tokens=256, temperature=0, verbose=False,
)
print(result if isinstance(result, str) else result.text)
PY
For text only, remove /path/to/image.jpg from the first line or run python quickstart.py "What is 2 plus 2?".
Run with the optional MTP head
Use the same installation and model download as above. The v2 draft head shares the target modelβs embedding and output projection.
Run this in the downloaded pack directory. To use an image, add its path after python -.
PYTHONPATH=runtime python - <<'PYTHON'
import sys
from pathlib import Path
from mlx_vlm import generate
from mlx_vlm.prompt_utils import apply_chat_template
from mtp_artifact import load_mtp_head
from vision_artifact import chat_config, load_vl_model
pack = Path.cwd()
model, processor, config = load_vl_model(pack)
draft = load_mtp_head(model, pack / "mtp/mtp-v2-head.safetensors")
image = sys.argv[1] if len(sys.argv) > 1 else None
question = "Describe this image." if image else "Name the capital of France."
prompt = apply_chat_template(
processor, chat_config(config), question,
num_images=int(image is not None), enable_thinking=False,
)
result = generate(
model, processor, prompt, image=image, max_tokens=128, temperature=0,
draft_model=draft, draft_kind="mtp", draft_block_size=2,
)
print(result.text)
PYTHON
This example uses one draft token per round. On Apple Silicon, drafting preserved the greedy output tokens on a text prompt and a red-image prompt. Throughput has yet to be measured.
The head manifest records the source GGUF revision and SHA-256 of the sidecar. It is a verification record. The example enables MTP through the Python API.
Validation
The language weights match the validated Bonsai 2.5 text-only MLX pack byte for byte after accounting for the multimodal tensor namespace. The bundled loader passed a text arithmetic test and correctly distinguished red and blue images on Apple Silicon.
License
Released under Apache 2.0. See NOTICE.txt for upstream attribution and runtime/LICENSE for the bundled loader.
- Downloads last month
- 13,252
2-bit