Ternary-Bonsai-2.5-27B-mlx-2bit

prism-ml/Ternary-Bonsai-2.5-27B-mlx-2bit

作者
prism-ml
任务
多模态
下载量
11,540
点赞数
76
趋势分
26
许可证
apache-2.0
收录时间
2026/11/26

license: apache-2.0 library_name: mlx pipeline_tag: image-text-to-text base_model: Qwen/Qwen3.8-27B tags:

  • mlx
  • apple-silicon
  • 2-bit
  • ternary
  • vision

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.

内容来源:Hugging Face 模型卡

在 Hugging Face 查看