> ## Documentation Index
> Fetch the complete documentation index at: https://docs.prismml.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Ternary Bonsai 2.5 27B

> The flagship Bonsai, built for agents: FP16-level tool calling and a 262K-token context in 5.93 GB of ternary weights.

Ternary Bonsai 2.5 27B is the largest model in the family and the one built for agents: long sequences of tool calls, coding in a real repository, and multi-step tasks that have to stay on track. It is derived from Qwen3.8-27B, a hybrid-attention causal language model, with the architecture unchanged. Every language-model weight is ternary, `{−1, 0, +1}` with an FP16 scale per group of 128 weights, which puts the whole model in **5.93 GB** at 1.76 bits per weight, against 53.8 GB at FP16. It takes images as well as text, carries a 262K-token context, calls tools natively, and reasons before it answers.

> [!TIP]
>
> **Before you run it:** the recommended sampling settings differ between thinking and instruct mode, llama.cpp needs `--min-p 0` passed explicitly, and `low` reasoning effort is not supported. See [Best practices](#best-practices).

## What changed from Bonsai 2 27B

Bonsai 2.5 replaces Ternary Bonsai 2 27B. The base model, the ternary format, the file size, and the runtimes are all the same; what changed is how the model behaves over a long task. It reads tool results, recovers when a step fails, and keeps the objective in view, and it finishes in fewer turns and fewer tokens, with less of the over-thinking and repetition the earlier model could fall into.

| Benchmark | Qwen3.8-27B FP16 | Bonsai 2 27B | **Bonsai 2.5 27B** |
| - | -: | -: | -: |
| SWE-bench Verified | 80.6 | 60.8 | **75.6** |
| DeepSWE | 30.1 | 0.0 | **27.0** |
| Terminal-Bench 2.1 | 70.8 | 52.8 | **60.1** |
| AppWorld | 93.2 | 51.2 | **90.5** |
| τ³-Bench | 72.8 | 69.1 | **73.9** |

Three practical differences if you are coming from Bonsai 2:

* **Speculative decoding is built in.** MTP variants of each file carry a draft head that speeds up decode by 1.5–1.8× on NVIDIA GPUs. See [Speculative decoding](#speculative-decoding).
* **`min_p` is now 0.0 in thinking mode**, where Bonsai 2 recommended 0.05.
* **The `Q2_0` file sits in the main GGUF repo**, next to the other two packings.

The Bonsai 2 27B weights stay on Hugging Face as [`prism-ml/Ternary-Bonsai-2-27B-gguf`](https://huggingface.co/prism-ml/Ternary-Bonsai-2-27B-gguf) and [`-mlx-2bit`](https://huggingface.co/prism-ml/Ternary-Bonsai-2-27B-mlx-2bit).

## Specifications

| | |
| - | - |
| Base model | Qwen3.8-27B (architecture unchanged) |
| Parameters | 27.36B total (24.35B language backbone + 2.54B embedding/LM head + 0.47B vision tower) |
| Architecture | Hybrid attention (\~75% linear / \~25% full), SwiGLU MLP, RoPE, RMSNorm |
| Weight format | Ternary g128 with FP16 group-wise scaling, blockwise Hadamard rotation folded into the stored weights |
| Size | 1.76 bits per weight, 5.93 GB in `PTQ1_0` |
| Max context | 262,144 tokens |
| Modalities | Text + image in, text out |
| Reasoning efforts | `xhigh` (default) or `medium` |
| License | Apache 2.0 |

## Benchmarks

All figures are in thinking mode at `xhigh` reasoning effort, from the model card.

| Suite | Qwen3.8-27B FP16 (53.8 GB) | **Bonsai 2.5 27B (5.93 GB)** |
| - | -: | -: |
| Agentic tool calling, average of 5 (τ²-Bench, τ³-Bench, BFCL v3, BFCL v4, AppWorld) | 77.7 | **77.2** |
| Agentic coding, average of 3 (Terminal-Bench 2.1, SWE-bench Verified, DeepSWE) | 60.5 | **54.2** |
| General capability, average of 5 categories over 14 benchmarks | 84.4 | **82.3** |

Tool calling is level with full precision, agentic coding keeps 90% of it, and general capability stays within about two points. Among low-bit GGUF builds of the same base model, Bonsai 2.5 is the smallest compared and leads every build under 10 GB on both agentic suites. The per-benchmark tables, the comparison builds, and the evaluation setup are on the [model card](https://huggingface.co/prism-ml/Ternary-Bonsai-2.5-27B-gguf#benchmarks) and in the [whitepaper](https://github.com/PrismML-Eng/Bonsai-demo/blob/main/bonsai-2-5-27b-whitepaper.pdf).

## Artifacts

| Format | Repository | Notes |
| - | - | - |
| GGUF (`PTQ1_0`, `PQ2_0`, `Q2_0`) | [`prism-ml/Ternary-Bonsai-2.5-27B-gguf`](https://huggingface.co/prism-ml/Ternary-Bonsai-2.5-27B-gguf) | The three packings, plus the vision tower as a separate `mmproj` file |
| GGUF with MTP draft head | [`prism-ml/Ternary-Bonsai-2.5-27B-gguf-mtp`](https://huggingface.co/prism-ml/Ternary-Bonsai-2.5-27B-gguf-mtp) | The same three packings with the draft head built in, for [speculative decoding](#speculative-decoding) |
| MLX (2-bit, text only) | [`prism-ml/Ternary-Bonsai-2.5-27B-mlx-2bit`](https://huggingface.co/prism-ml/Ternary-Bonsai-2.5-27B-mlx-2bit) | Exported from `PQ2_0`, with a bundled loader |

The three packings are the same ternary model in different layouts:

| File | Size | Runs on |
| - | - | - |
| `Ternary-Bonsai-2.5-27B-PTQ1_0.gguf` | 5.93 GB | PrismML llama.cpp binaries |
| `Ternary-Bonsai-2.5-27B-PQ2_0.gguf` | about 7.2 GB | PrismML llama.cpp binaries |
| `Ternary-Bonsai-2.5-27B-Q2_0.gguf` | about 7.6 GB | Upstream llama.cpp `b11556` or newer |

> [!NOTE]
>
> **Which runtime runs which file.** Upstream llama.cpp from release [`b11556`](https://github.com/ggml-org/llama.cpp/releases/tag/b11556) runs the `Q2_0` file; older upstream builds load it without a warning and produce garbage, so check `llama-cli --version` first. `PTQ1_0` and `PQ2_0` need the [PrismML llama.cpp binaries](https://github.com/PrismML-Eng/llama.cpp/releases), which the demo's `setup.sh` installs; upstream refuses them as unknown types. See [Formats & runtime support](https://docs.prismml.com/download/formats.md).

## How to run it

Through the [demo repo](https://docs.prismml.com/get-started/quickstart.md), where the 27B is the default, so no flags are needed:

```bash theme={null}
./scripts/start_llama_server.sh   # OpenAI-compatible API + chat/vision UI on :8080
```

Or download a file and run a single generation directly with [llama.cpp](https://docs.prismml.com/run/llamacpp.md):

```bash PrismML binaries (NVIDIA) theme={null}
hf download prism-ml/Ternary-Bonsai-2.5-27B-gguf Ternary-Bonsai-2.5-27B-PTQ1_0.gguf --local-dir .
./llama-cli -m Ternary-Bonsai-2.5-27B-PTQ1_0.gguf -ngl 99 -fa on -c 32768 \
  --temp 1.0 --top-p 0.95 --top-k 20 --min-p 0 \
  -p "Explain KV cache growth in one paragraph." -n 16384
```

```bash PrismML binaries (Apple Silicon) theme={null}
hf download prism-ml/Ternary-Bonsai-2.5-27B-gguf Ternary-Bonsai-2.5-27B-PQ2_0.gguf --local-dir .
./llama-cli -m Ternary-Bonsai-2.5-27B-PQ2_0.gguf -ngl 99 -fa on -c 32768 \
  --temp 1.0 --top-p 0.95 --top-k 20 --min-p 0 \
  -p "Explain KV cache growth in one paragraph." -n 16384
```

```bash Upstream llama.cpp (b11556+) theme={null}
hf download prism-ml/Ternary-Bonsai-2.5-27B-gguf Ternary-Bonsai-2.5-27B-Q2_0.gguf --local-dir .
llama-cli -m Ternary-Bonsai-2.5-27B-Q2_0.gguf -ngl 99 -fa on -c 32768 \
  --temp 1.0 --top-p 0.95 --top-k 20 --min-p 0 \
  -p "Explain KV cache growth in one paragraph." -n 16384
```

`-n 16384` (or `max_tokens`) leaves room for the thinking trace: the template defaults to `xhigh` reasoning effort, so a small cap ends generation mid-thought, before any answer. On Apple Silicon the [MLX pack](https://huggingface.co/prism-ml/Ternary-Bonsai-2.5-27B-mlx-2bit) is a text-only alternative; its model card has the loading steps. The [demo repo](https://github.com/PrismML-Eng/Bonsai-demo) is the source of truth for running these models; tested setups and current implementation details live there.

## Best practices

### Generation parameters

> [!WARNING]
>
> Use the set that matches the mode you're running in. Thinking and instruct mode want different sampling settings, and mixing them degrades output quality.

| Parameter | Thinking (default) | Instruct / non-thinking |
| - | - | - |
| `temperature` | 1.0 | 0.7 |
| `top_p` | 0.95 | 0.80 |
| `top_k` | 20 | 20 |
| `min_p` | 0.0 | 0.0 |
| `presence_penalty` | 0.0 | 1.5 |
| `repetition_penalty` | 1.0 | 1.0 |

llama.cpp applies `min_p = 0.05` when you don't set it, so pass `--min-p 0` explicitly, as the commands on this page do. The published benchmarks used the thinking-mode values.

### Reasoning effort

> [!NOTE]
>
> The model uses **`xhigh`** by default, which is the most accurate. **`medium`** gives shorter responses and a balance of speed and accuracy. **`low` is not supported**: when selected, the model behaves close to `xhigh`. To bound reasoning, use a token budget instead (see [Thinking mode](#thinking-mode)).

Send `reasoning_effort` per request, or make `medium` the server-wide default while letting a request still ask for `xhigh`:

```bash theme={null}
./scripts/start_llama_server.sh --chat-template-kwargs '{"reasoning_effort":"medium"}'
```

### System prompt

A plain system message works well:

```text theme={null}
You are a helpful assistant
```

### Choosing a packing

| | `PTQ1_0` (5.93 GB) | `PQ2_0` (about 7.2 GB) | `Q2_0` (about 7.6 GB) |
| - | - | - | - |
| Pick it for | NVIDIA GPUs | Apple Silicon | Stock llama.cpp |
| Why | The smallest file, and the faster decode on every NVIDIA GPU measured | The packing benchmarked on Apple Metal, and the source of the MLX export | The only packing upstream llama.cpp runs today |

Prompt processing is mixed on NVIDIA: `PQ2_0` is ahead on H200, H100, B200, and L40S, and `PTQ1_0` is slightly ahead on the rest. `PTQ1_0` also runs on Metal with the PrismML binaries.

## Speculative decoding

The files in [`Ternary-Bonsai-2.5-27B-gguf-mtp`](https://huggingface.co/prism-ml/Ternary-Bonsai-2.5-27B-gguf-mtp) carry a **multi-token prediction (MTP) draft head**: one extra layer that guesses the next few tokens. The full model checks every guess in one pass and keeps only the tokens it would have produced itself, so the output distribution is unchanged and only speed differs. Load an MTP file instead of the plain one, not alongside it; without the flags below it runs as the plain model. MTP drafting needs the PrismML binaries.

```bash theme={null}
./llama-server -m Ternary-Bonsai-2.5-27B-PTQ1_0-mtp.gguf -ngl 99 -fa on -c 32768 -np 1 \
  --temp 1.0 --top-p 0.95 --top-k 20 --min-p 0 \
  --spec-type draft-mtp --spec-draft-n-min 0 --spec-draft-n-max 3 --spec-draft-p-min 0.1
```

`--spec-draft-n-max` is the number of tokens drafted per pass and `--spec-draft-p-min` is the confidence below which the head stops drafting. The best values differ by device:

| Device | File | Drafts, cut-off | Decode, MTP off → on (tok/s) |
| - | - | - | - |
| NVIDIA H200 | `PTQ1_0` | 3, 0.1 | 194 → 296 (1.53×) |
| NVIDIA H100 | `PTQ1_0` | 3, 0.1 | 184 → 282 (1.53×) |
| RTX 5090 | `PTQ1_0` | 3, 0.1 | 174 → 305 (1.75×) |
| RTX 4090 | `PTQ1_0` | 3, 0 | 111 → 204 (1.83×) |
| Apple M4 Pro (Metal) | `PQ2_0` | 1, 0.6 | 22.9 → 25.3 (1.10×) |
| Core Ultra laptop (SYCL) | `PTQ1_0` | 8, 0.6 | 11.1 → 23.1 (2.08×) |

Two things to weigh. The head makes its own pass over the prompt, so prompt processing is 9–23% slower on NVIDIA GPUs with drafting on; for long prompts with short answers, run without it. And on Apple Silicon the gain is small today. Kernels now in testing lift both: about 300 tok/s on an H200 or B200, and 1.27× on the M4 Pro. Measurement details and the full device table are on the [model card](https://huggingface.co/prism-ml/Ternary-Bonsai-2.5-27B-gguf#inference-speed).

## Vision and tool calling

27B is trained for both. Send an image as a normal OpenAI-style `image_url` content part, and a `tools` array for function calling. Both come back through the standard API, no prompt hacks required:

```bash theme={null}
curl http://localhost:8080/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "messages": [{"role": "user", "content": "What is the weather in Lisbon?"}],
    "tools": [{
      "type": "function",
      "function": {
        "name": "get_weather",
        "description": "Get current weather for a city",
        "parameters": {"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]}
      }
    }]
  }'
```

The response's `choices[0].message.tool_calls` carries the call. Image input needs the `mmproj` file from the GGUF repo, loaded with `--mmproj`; it is used only when an image arrives, so text-only serving never pays for it. The demo's server launcher loads it for you. See [Tool calling & MCP](https://github.com/PrismML-Eng/Bonsai-demo/blob/main/TOOLS.md) in the demo repo for MCP server setup and the full agentic walkthrough, and [Open WebUI](https://docs.prismml.com/run/open-webui.md) for a point-and-click demo of the same capabilities.

## Thinking mode

27B reasons by default. Toggle it per request with `thinking_budget_tokens` (`0` to disable, `-1` for unlimited), cap it server-wide with `--reasoning-budget N`, or turn it off entirely by passing `--reasoning-budget 0` through the launcher (`./scripts/start_llama_server.sh --reasoning-budget 0`). The built-in chat UI has a Reasoning effort picker (Off / Low / Medium / High / Max) that overrides the server default per conversation. The UI's levels are fixed token budgets (Medium is 2,048 tokens), which cut thinking off at that length; the model's own `reasoning_effort: "medium"` asks it to think less instead, and rarely runs out mid-reasoning.

> [!NOTE]
>
> Large images are downscaled to \~1,024 vision tokens by default on Metal, Vulkan, and CPU to keep latency reasonable; CUDA and ROCm run uncapped. Override with `BONSAI_IMAGE_MAX_TOKENS` (`0` disables the cap, useful for reading small text in screenshots).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.