> For the complete documentation index, see [llms.txt](https://unsloth.ai/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://unsloth.ai/docs/zh/mo-xing/qwen3.5.md).

# Qwen3.5：如何在本地运行

在你的本地设备上运行新的 Qwen3.5 LLM，包括中型：Qwen3.5-35B-A3B、27B、122B-A10B，小型：Qwen3.5-0.8B、2B、4B、9B 和 397B-A17B！

Qwen3.5 是阿里巴巴的新模型系列，包括 Qwen3.5-**35B**-A3B, **27B**, **122B**-A10B 和 **397B**-A17B 以及新的 **小型** 系列：Qwen3.5-0.8B、2B、4B 和 9B。多模态混合推理 LLM 在各自规模上提供最强性能。它们支持 **256K 上下文** 覆盖 201 种语言，具备 **思考** + **非**思考，并在智能体编码、视觉、聊天和长上下文任务中表现出色。35B 和 27B 模型可在 22GB 的 Mac / RAM 设备上运行。在此查看所有 [GGUF](https://huggingface.co/collections/unsloth/qwen35).

<a href="/pages/1427becb679b955148197a06de42a82ae44b05b6#qwen3.5-inference-tutorials" class="button primary">运行 Qwen3.5 教程</a><a href="/docs/zh/mo-xing/qwen3.5/fine-tune.md" class="button secondary">微调 Qwen3.5</a>

{% hint style="success" %}
**3 月 17 日更新：** 你现在可以在 [**Unsloth Studio**](#unsloth-studio-guide).

**3 月 5 日更新：** 重新下载 Qwen3.5-**35B**, **27B**, **122B** 和 **397B**.

* 所有 GGUF 现在都已更新，采用了 **改进的量化** 算法。
* 全部使用我们的 **新 imatrix 数据**。查看在聊天、编码、长上下文和工具调用场景中的一些改进。
* **工具调用已改进** ，这得益于我们对聊天模板的修复。 **此修复是通用的** 并适用于 **任何** Qwen3.5 格式和 **任何** 上传器。
* [**查看新的 GGUF 基准测试**](/docs/zh/mo-xing/qwen3.5/gguf-benchmarks.md) **，了解 Unsloth 性能结果 + 我们的** [**MXFP4 调查**](/docs/zh/mo-xing/qwen3.5/gguf-benchmarks.md#id-1-some-tensors-are-very-sensitive-to-quantization)**.**
* 我们正在从 3 个 Qwen3.5 GGUF 中移除 MXFP4 层：Q2\_K\_XL、Q3\_K\_XL 和 Q4\_K\_XL。
  {% endhint %}

所有上传都使用 Unsloth [Dynamic 2.0](/docs/zh/ji-chu/dynamic-3.0-ggufs.md) ，以获得最先进的量化性能——因此 4 位版本中一些重要层会提升到 8 位或 16 位。感谢 Qwen 为 Unsloth 提供首日访问权限。你还可以 [**微调** Qwen3.5](/docs/zh/mo-xing/qwen3.5/fine-tune.md) ，使用 Unsloth。

{% hint style="info" %}
要启用或禁用思考，请参见 [#how-to-enable-or-disable-reasoning-and-thinking](#how-to-enable-or-disable-reasoning-and-thinking "mention").Qwen3.5 小型模型默认禁用。
{% endhint %}

### :gear: 使用指南

**表：推理硬件需求** （单位 = 总内存：RAM + VRAM，或统一内存）

<table><thead><tr><th>Qwen3.5</th><th>3比特</th><th>4比特</th><th width="128">6比特</th><th>8比特</th><th>BF16</th></tr></thead><tbody><tr><td><a href="#qwen3.5-small-0.8b-2b-4b-9b"><strong>0.8B</strong></a> <strong>+</strong> <a href="#qwen3.5-small-0.8b-2b-4b-9b"><strong>2B</strong></a></td><td>3 GB</td><td>3.5 GB</td><td>5 GB</td><td>7.5 GB</td><td>9 GB</td></tr><tr><td><a href="#qwen3.5-small-0.8b-2b-4b-9b"><strong>4B</strong></a></td><td>4.5 GB</td><td>5.5 GB</td><td>7 GB</td><td>10 GB</td><td>14 GB</td></tr><tr><td><a href="#qwen3.5-small-0.8b-2b-4b-9b"><strong>9B</strong></a></td><td>5.5 GB</td><td>6.5 GB</td><td>9 GB</td><td>13 GB</td><td>19 GB</td></tr><tr><td><a href="#qwen3.5-27b"><strong>27B</strong></a></td><td>14 GB</td><td>17 GB</td><td>24 GB</td><td>30 GB</td><td>54 GB</td></tr><tr><td><a href="#qwen3.5-35b-a3b"><strong>35B-A3B</strong></a></td><td>17 GB</td><td>22 GB</td><td>30 GB</td><td>38 GB</td><td>70 GB</td></tr><tr><td><a href="#qwen3.5-122b-a10b"><strong>122B-A10B</strong></a></td><td>60 GB</td><td>70 GB</td><td>106 GB</td><td>132 GB</td><td>245 GB</td></tr><tr><td><a href="#qwen3.5-397b-a17b"><strong>397B-A17B</strong></a></td><td>180 GB</td><td>214 GB</td><td>340 GB</td><td>512 GB</td><td>810 GB</td></tr></tbody></table>

{% hint style="success" %}
为了获得最佳性能，请确保你的可用总内存（VRAM + 系统 RAM）大于你正在下载的量化模型文件大小。如果不满足，llama.cpp 仍然可以通过 SSD/HDD 卸载运行，但推理会更慢。
{% endhint %}

在 **27B** 和 **35B-A3B**之间，如果你想要稍微更准确的结果且无法装入你的设备，请使用 27B。如果你想要更快的推理，请选择 35B-A3B。

### 推荐设置

* **最大上下文窗口：** `262,144` （可通过 YaRN 扩展到 1M）
* `presence_penalty = 0.0 到 2.0` 默认情况下这是关闭的，但为了减少重复，你可以使用它，不过使用更高的值可能导致 **性能略有下降**
* **合适的输出长度**: `32,768` 个 token 适用于大多数查询

{% hint style="info" %}
如果你看到的是乱码，你的上下文长度可能设置得太低。或者试试使用 `--cache-type-k bf16 --cache-type-v bf16` ，这可能会有帮助。
{% endhint %}

由于 Qwen3.5 采用混合推理，思考和非思考模式有不同的设置：

#### 思考模式：

| 通用任务                      | 精确编码任务（例如 WebDev）         |
| ------------------------- | ------------------------- |
| temperature = 1.0         | temperature = 0.6         |
| top\_p = 0.95             | top\_p = 0.95             |
| top\_k = 20               | top\_k = 20               |
| min\_p = 0.0              | min\_p = 0.0              |
| presence\_penalty = 1.5   | presence\_penalty = 0.0   |
| repeat\_penalty = 禁用或 1.0 | repeat\_penalty = 禁用或 1.0 |

{% columns %}
{% column %}
通用任务的思考模式：

{% code overflow="wrap" %}

```bash
temperature=1.0, top_p=0.95, top_k=20, min_p=0.0, presence_penalty=1.5, repetition_penalty=1.0
```

{% endcode %}
{% endcolumn %}

{% column %}
精确编码任务的思考模式：

{% code overflow="wrap" %}

```bash
temperature=0.6, top_p=0.95, top_k=20, min_p=0.0, presence_penalty=0.0, repetition_penalty=1.0
```

{% endcode %}
{% endcolumn %}
{% endcolumns %}

#### 指令（非思考）模式设置：

| 通用任务                      | 推理任务                      |
| ------------------------- | ------------------------- |
| temperature = 0.7         | temperature = 1.0         |
| top\_p = 0.8              | top\_p = 0.95             |
| top\_k = 20               | top\_k = 20               |
| min\_p = 0.0              | min\_p = 0.0              |
| presence\_penalty = 1.5   | presence\_penalty = 1.5   |
| repeat\_penalty = 禁用或 1.0 | repeat\_penalty = 禁用或 1.0 |

{% hint style="warning" %}
要 [禁用思考 / 推理](#how-to-enable-or-disable-reasoning-and-thinking)，请使用 `--chat-template-kwargs '{"enable_thinking":false}'`

如果你使用的是 **Windows** PowerShell，请使用： `--chat-template-kwargs "{\"enable_thinking\":false}"`

可互换使用 'true' 和 'false'。

**对于 Qwen3.5 0.8B、2B、4B 和 9B，推理默认是禁用的**。要启用它，请使用： `--chat-template-kwargs '{"enable_thinking":true}'`
{% endhint %}

{% columns %}
{% column %}
通用任务的指令（非思考）模式：

{% code overflow="wrap" %}

```bash
temperature=0.7, top_p=0.8, top_k=20, min_p=0.0, presence_penalty=1.5, repetition_penalty=1.0
```

{% endcode %}
{% endcolumn %}

{% column %}
推理任务的指令（非思考）模式：

{% code overflow="wrap" %}

```bash
temperature=1.0, top_p=0.95, top_k=20, min_p=0.0, presence_penalty=1.5, repetition_penalty=1.0
```

{% endcode %}
{% endcolumn %}
{% endcolumns %}

## Qwen3.5 推理教程：

由于 Qwen3.5 有许多不同尺寸，我们将使用 Dynamic 4-bit `MXFP4_MOE` 适用于所有推理工作负载的 GGUF 变体。点击下方跳转到指定模型说明：

<a href="/docs/zh/mo-xing/qwen3.5.md#unsloth-studio-guide" class="button primary">在 Unsloth Studio 中运行</a><a href="#qwen3.5-35b-a3b" class="button secondary">Qwen3.5-35B-A3B</a><a href="#qwen3.5-27b" class="button secondary">27B</a><a href="#qwen3.5-122b-a10b" class="button secondary">122B-A10B</a><a href="#qwen3.5-397b-a17b" class="button secondary">397B-A17B</a><a href="#qwen3.5-small-0.8b-2b-4b-9b" class="button secondary">小型（0.8B - 9B）</a>

**Unsloth Dynamic GGUF 上传：**

| [Qwen3.5-**35B-A3B**](https://huggingface.co/unsloth/Qwen3.5-35B-A3B-GGUF) | [Qwen3.5-**27B**](https://huggingface.co/unsloth/Qwen3.5-27B-GGUF) | [Qwen3.5-**122B-A10B**](https://huggingface.co/unsloth/Qwen3.5-122B-A10B-GGUF) | [Qwen3.5-**397B-A17B**](https://huggingface.co/unsloth/Qwen3.5-397B-A17B-GGUF) |
| -------------------------------------------------------------------------- | ------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ |
| [Qwen3.5-**0.8B**](https://huggingface.co/unsloth/Qwen3.5-0.8B-GGUF)       | [Qwen3.5-**2B**](https://huggingface.co/unsloth/Qwen3.5-2B-GGUF)   | [Qwen3.5-**4B**](https://huggingface.co/unsloth/Qwen3.5-4B-GGUF)               | [Qwen3.5-**9B**](https://huggingface.co/unsloth/Qwen3.5-9B-GGUF)               |

{% hint style="warning" %}
`presence_penalty = 0.0 到 2.0` 默认情况下这是关闭的，但为了减少重复，你可以使用它，不过使用更高的值可能导致 **性能略有下降。**

**目前由于独立的 mmproj 视觉文件，没有任何 Qwen3.5 GGUF 能在 Ollama 中工作。请使用与 llama.cpp 兼容的后端。**
{% endhint %}

## 🦥 Unsloth Studio 指南

Qwen3.5 可以在 [Unsloth Desktop](/docs/zh/desktop.md)中运行和微调，我们新的本地 AI 开源桌面 UI。Unsloth Studio 让你可以在本地运行模型，适用于 **MacOS、Windows**、Linux 以及：

{% columns %}
{% column %}

* 搜索、下载、 [运行 GGUF](/docs/zh/xin/studio.md#run-models-locally) 和 safetensor 模型
* [**自我修复** 工具调用](/docs/zh/xin/studio.md#execute-code--heal-tool-calling) + **网络搜索**
* [**代码执行**](/docs/zh/xin/studio.md#run-models-locally) （Python、Bash）
* [自动推理](https://unsloth.ai/docs/desktop#feature-deep-dive) 参数调优（温度、top-p 等）
* 通过 llama.cpp 实现快速 CPU + GPU 推理
* [训练 LLM](/docs/zh/xin/studio.md#no-code-training) 速度快 2 倍，VRAM 占用减少 70%
  {% endcolumn %}

{% column %}

<div data-with-frame="true"><figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FFeQ0UUlnjXkDdqhcWglh%2Fskinny%20studio%20chat.png?alt=media&amp;token=c2ee045f-c243-4024-a8e4-bb4dbe7bae79" alt=""><figcaption></figcaption></figure></div>
{% endcolumn %}
{% endcolumns %}

{% stepper %}
{% step %}

#### 安装 Unsloth

开始使用的最简单方法是下载 [Unsloth Desktop 应用](/docs/zh/desktop.md)。支持 [macOS](/docs/zh/kai-shi-shi-yong/install/mac.md), [Windows](/docs/zh/kai-shi-shi-yong/install/windows-installation.md)，以及 [Linux](/docs/zh/kai-shi-shi-yong/install/linux.md).

<a href="https://unsloth.ai/download" class="button primary" data-icon="down-to-bracket">下载 Unsloth</a>

* <i class="fa-apple">:apple:</i> [下载适用于 macOS 的版本](https://unsloth.ai/download/mac)
* <i class="fa-windows">:windows:</i> [下载适用于 Windows 的版本](https://unsloth.ai/download/windows)
* <i class="fa-linux">:linux:</i> [下载适用于 Linux 的版本](https://unsloth.ai/download/linux)

或者，如果你更喜欢手动安装：

**MacOS、Linux、WSL：**

```bash
curl -fsSL https://unsloth.ai/install.sh | sh
```

**Windows PowerShell：**

```bash
irm https://unsloth.ai/install.ps1 | iex
```

{% hint style="success" %}
**安装会很快，大约需要 1-2 分钟。**
{% endhint %}
{% endstep %}

{% step %}

#### 启动 Unsloth

**MacOS、Linux、WSL 和 Windows：**

```bash
unsloth studio -H 0.0.0.0 -p 8888
```

<div data-with-frame="true"><figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2Fd1yMMNa65Ccz50Ke0E7r%2FScreenshot%202026-03-17%20at%2012.32.38%E2%80%AFAM.png?alt=media&amp;token=9369cfe7-35b1-4955-b8cb-42f7ecb43780" alt="" width="375"><figcaption></figcaption></figure></div>

**然后打开 `http://localhost:8888` 在你的浏览器中。**
{% endstep %}

{% step %}

#### 搜索并下载 Qwen3.5

首次启动时，你需要创建一个密码来保护你的账户，并在之后再次登录。然后前往 [Unsloth Chat](/docs/zh/xin/studio/chat.md) 选项卡，在搜索栏中搜索 Qwen3.5，并下载你想要的模型和量化版本。

<div data-with-frame="true"><figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FfQAcYOCryMEa6CMPdpt7%2FScreenshot%202026-03-17%20at%2012.35.11%E2%80%AFAM.png?alt=media&amp;token=d9215f41-5f43-47d4-9fa7-020282bb4663" alt="" width="375"><figcaption></figcaption></figure></div>
{% endstep %}

{% step %}

#### 运行 Qwen3.5

在使用 Unsloth Studio 时，推理参数应会自动设置，不过你仍然可以手动更改。你还可以编辑上下文长度、聊天模板和其他设置。

更多信息请查看我们的 [Unsloth Studio 推理指南](/docs/zh/xin/studio/chat.md).

<div data-with-frame="true"><figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FXPQGEEr1YoKofrTatAKK%2Ftoolcallingif.gif?alt=media&amp;token=25d68698-fb13-4c46-99b2-d39fb025df08" alt="" width="563"><figcaption></figcaption></figure></div>
{% endstep %}
{% endstepper %}

## 🦙 Llama.cpp 指南

### Qwen3.5-35B-A3B

在本指南中，我们将使用 Dynamic 4-bit，它在 24GB RAM / Mac 设备上表现很好，适合快速推理。由于该模型在完整 F16 精度下只有大约 72GB，我们无需太担心性能。GGUF： [Qwen3.5-35B-A3B-GGUF](https://huggingface.co/unsloth/Qwen3.5-35B-A3B-GGUF)

对于这些教程，我们将使用 [llama.cpp](llama.cpphttps://github.com/ggml-org/llama.cpp) 进行快速本地推理，尤其是如果你有 CPU。

{% stepper %}
{% step %}
获取最新的 `llama.cpp` **在** [**GitHub 上这里**](https://github.com/ggml-org/llama.cpp)。你也可以按照下面的构建说明操作。将 `-DGGML_CUDA=ON` 改为 `-DGGML_CUDA=OFF` 如果你没有 GPU，或者只是想进行 CPU 推理。 **对于 Apple Mac / Metal 设备**，设置 `-DGGML_CUDA=OFF` 然后照常继续——Metal 支持默认开启。

```bash
apt-get update
apt-get install pciutils build-essential cmake curl libcurl4-openssl-dev -y
git clone https://github.com/ggml-org/llama.cpp
cmake llama.cpp -B llama.cpp/build \\
    -DBUILD_SHARED_LIBS=OFF -DGGML_CUDA=ON
cmake --build llama.cpp/build --config Release -j --clean-first --target llama-cli llama-mtmd-cli llama-server llama-gguf-split
cp llama.cpp/build/bin/llama-* llama.cpp
```

{% endstep %}

{% step %}
如果你想直接使用 `llama.cpp` 加载模型，你可以使用下面的方法：(:Q4\_K\_M) 是量化类型。你也可以通过 Hugging Face（第 3 点）下载。这类似于 `ollama run` 。使用 `export LLAMA_CACHE="folder"` 来强制 `llama.cpp` 保存到特定位置。该模型的最大上下文长度为 256K。

根据你的使用场景，按照下面的某个特定命令操作：

**思考模式：**

精确编码任务（例如 WebDev）：

```bash
export LLAMA_CACHE="unsloth/Qwen3.5-35B-A3B-GGUF"
./llama.cpp/llama-cli \\
    -hf unsloth/Qwen3.5-35B-A3B-GGUF:UD-Q4_K_XL \\
    --temp 0.6 \\
    --top-p 0.95 \\
    --top-k 20 \\
    --min-p 0.00
```

通用任务：

```bash
export LLAMA_CACHE="unsloth/Qwen3.5-35B-A3B-GGUF"
./llama.cpp/llama-cli \\
    -hf unsloth/Qwen3.5-35B-A3B-GGUF:UD-Q4_K_XL \\
    --temp 1.0 \\
    --top-p 0.95 \\
    --top-k 20 \\
    --min-p 0.00
```

**非思考模式：**

通用任务：

```bash
export LLAMA_CACHE="unsloth/Qwen3.5-35B-A3B-GGUF"
./llama.cpp/llama-server \\
    -hf unsloth/Qwen3.5-35B-A3B-GGUF:UD-Q4_K_XL \\
    --temp 0.7 \\
    --top-p 0.8 \\
    --top-k 20 \\
    --min-p 0.00 \\
    --chat-template-kwargs '{"enable_thinking":false}'
```

推理任务：

```bash
export LLAMA_CACHE="unsloth/Qwen3.5-35B-A3B-GGUF"
./llama.cpp/llama-server \\
    -hf unsloth/Qwen3.5-35B-A3B-GGUF:UD-Q4_K_XL \\
    --temp 1.0 \\
    --top-p 0.95 \\
    --top-k 20 \\
    --min-p 0.00 \\
    --chat-template-kwargs '{"enable_thinking":false}'
```

{% endstep %}

{% step %}
通过以下方式下载模型（在安装 `pip install huggingface_hub hf_transfer` 之后）。你可以选择 Q4\_K\_M 或其他量化版本，例如 `UD-Q4_K_XL` 。我们建议至少使用 2-bit 动态量化 `UD-Q2_K_XL` ，以平衡大小和准确性。如果下载卡住，请参阅： [Hugging Face Hub、XET 调试](/docs/zh/ji-chu/troubleshooting-and-faqs/hugging-face-hub-xet-debugging.md)

```bash
hf download unsloth/Qwen3.5-35B-A3B-GGUF \\
    --local-dir unsloth/Qwen3.5-35B-A3B-GGUF \\
    --include "*mmproj-F16*" \\
    --include "*UD-Q4_K_XL*" # 动态 2bit 请使用 "*UD-Q2_K_XL*"
```

{% endstep %}

{% step %}
然后以对话模式运行模型：

{% code overflow="wrap" %}

```bash
./llama.cpp/llama-cli \\
    --model unsloth/Qwen3.5-35B-A3B-GGUF/Qwen3.5-35B-A3B-UD-Q4_K_XL.gguf \\
    --mmproj unsloth/Qwen3.5-35B-A3B-GGUF/mmproj-F16.gguf \\
    --temp 1.0 \\
    --top-p 0.95 \\
    --min-p 0.00 \\
    --top-k 20
```

{% endcode %}
{% endstep %}
{% endstepper %}

### Qwen3.5 小型（0.8B • 2B • 4B • 9B）

{% hint style="warning" %}
**对于 Qwen3.5 0.8B、2B、4B 和 9B，** [**推理已被禁用**](#how-to-enable-or-disable-reasoning-and-thinking) **默认情况下**。要启用它，请使用： `--chat-template-kwargs '{"enable_thinking":true}'`

在 Windows 上使用： `--chat-template-kwargs "{\"enable_thinking\":true}"`
{% endhint %}

对于 Qwen3.5 小型系列，由于它们非常小，你只需要把脚本中的模型名称改成想要的变体即可。对于本指南，我们将使用 9B 参数变体。要以接近完整精度运行它们，你只需要一台 12GB RAM / VRAM / 统一内存的设备。GGUF：

| [Qwen3.5-**0.8B**](https://huggingface.co/unsloth/Qwen3.5-0.8B-GGUF) | [Qwen3.5-**2B**](https://huggingface.co/unsloth/Qwen3.5-2B-GGUF) | [Qwen3.5-**4B**](https://huggingface.co/unsloth/Qwen3.5-4B-GGUF) | [Qwen3.5-**9B**](https://huggingface.co/unsloth/Qwen3.5-9B-GGUF) |
| -------------------------------------------------------------------- | ---------------------------------------------------------------- | ---------------------------------------------------------------- | ---------------------------------------------------------------- |

{% stepper %}
{% step %}
获取最新的 `llama.cpp` **在** [**GitHub 上这里**](https://github.com/ggml-org/llama.cpp)。你也可以按照下面的构建说明操作。将 `-DGGML_CUDA=ON` 改为 `-DGGML_CUDA=OFF` 如果你没有 GPU，或者只是想进行 CPU 推理。

```bash
apt-get update
apt-get install pciutils build-essential cmake curl libcurl4-openssl-dev -y
git clone https://github.com/ggml-org/llama.cpp
cmake llama.cpp -B llama.cpp/build \\
    -DBUILD_SHARED_LIBS=OFF -DGGML_CUDA=ON
cmake --build llama.cpp/build --config Release -j --clean-first --target llama-cli llama-mtmd-cli llama-server llama-gguf-split
cp llama.cpp/build/bin/llama-* llama.cpp
```

{% endstep %}

{% step %}
如果你想直接使用 `llama.cpp` 加载模型，你可以使用下面的方法：(:Q4\_K\_XL) 是量化类型。你也可以通过 Hugging Face（第 3 点）下载。这类似于 `ollama run` 。使用 `export LLAMA_CACHE="folder"` 来强制 `llama.cpp` 保存到特定位置。该模型的最大上下文长度为 256K。

根据你的使用场景，按照下面的某个特定命令操作：

{% hint style="success" %}
**如果你想使用 9B 以外的其他变体，可以将 '9B' 改为：0.8B、2B 或 4B 等。**
{% endhint %}

**思考模式（默认禁用）**

{% hint style="danger" %}
Qwen3.5 小型模型默认禁用思考。使用 llama-server 来启用它。
{% endhint %}

```bash
export LLAMA_CACHE="unsloth/Qwen3.5-9B-GGUF"
./llama.cpp/llama-server \\
    -hf unsloth/Qwen3.5-9B-GGUF:UD-Q4_K_XL \\
    --temp 0.6 \\
    --top-p 0.95 \\
    --top-k 20 \\
    --min-p 0.00 \\
    --alias "unsloth/Qwen3.5-9B-GGUF" \\
    --port 8001 \\
    --chat-template-kwargs '{"enable_thinking":true}'
```

通用任务：

```bash
export LLAMA_CACHE="unsloth/Qwen3.5-9B-GGUF"
./llama.cpp/llama-server \\
    -hf unsloth/Qwen3.5-9B-GGUF:UD-Q4_K_XL \\
    --temp 1.0 \\
    --top-p 0.95 \\
    --top-k 20 \\
    --min-p 0.00 \\
    --alias "unsloth/Qwen3.5-9B-GGUF" \\
    --port 8001 \\
    --chat-template-kwargs '{"enable_thinking":true}'
```

{% hint style="success" %}
**如果你想使用 9B 以外的其他变体，可以将 '9B' 改为：0.8B、2B 或 4B 等。**
{% endhint %}

**非思考模式默认已经开启**

通用任务：

```bash
export LLAMA_CACHE="unsloth/Qwen3.5-9B-GGUF"
./llama.cpp/llama-cli \\
    -hf unsloth/Qwen3.5-9B-GGUF:UD-Q4_K_XL \\
    --temp 0.7 \\
    --top-p 0.8 \\
    --top-k 20 \\
    --min-p 0.00
```

推理任务：

```bash
export LLAMA_CACHE="unsloth/Qwen3.5-9B-GGUF"
./llama.cpp/llama-cli \\
    -hf unsloth/Qwen3.5-9B-GGUF:UD-Q4_K_XL \\
    --temp 1.0 \\
    --top-p 0.95 \\
    --top-k 20 \\
    --min-p 0.00
```

{% endstep %}

{% step %}
通过以下方式下载模型（在安装 `pip install huggingface_hub hf_transfer` 之后）。你可以选择 Q4\_K\_M 或其他量化版本，例如 `UD-Q4_K_XL` 。我们建议至少使用 2-bit 动态量化 `UD-Q2_K_XL` ，以平衡大小和准确性。如果下载卡住，请参阅： [Hugging Face Hub、XET 调试](/docs/zh/ji-chu/troubleshooting-and-faqs/hugging-face-hub-xet-debugging.md)

```bash
hf download unsloth/Qwen3.5-9B-GGUF \\
    --local-dir unsloth/Qwen3.5-9B-GGUF \\
    --include "*mmproj-F16*" \\
    --include "*UD-Q4_K_XL*" # 动态 2bit 请使用 "*UD-Q2_K_XL*"
```

{% endstep %}

{% step %}
然后以对话模式运行模型：

{% code overflow="wrap" %}

```bash
./llama.cpp/llama-cli \\
    --model unsloth/Qwen3.5-9B-GGUF/Qwen3.5-9B-UD-Q4_K_XL.gguf \\
    --mmproj unsloth/Qwen3.5-9B-GGUF/mmproj-F16.gguf \\
    --temp 1.0 \\
    --top-p 0.95 \\
    --min-p 0.00 \\
    --top-k 20
```

{% endcode %}
{% endstep %}
{% endstepper %}

### Qwen3.5-27B

在本指南中，我们将使用 Dynamic 4-bit，它在 18GB RAM / Mac 设备上表现很好，适合快速推理。GGUF： [Qwen3.5-27B-GGUF](https://huggingface.co/unsloth/Qwen3.5-27B-GGUF)

{% stepper %}
{% step %}
获取最新的 `llama.cpp` **在** [**GitHub 上这里**](https://github.com/ggml-org/llama.cpp)。你也可以按照下面的构建说明操作。将 `-DGGML_CUDA=ON` 改为 `-DGGML_CUDA=OFF` 如果你没有 GPU，或者只是想进行 CPU 推理。

```bash
apt-get update
apt-get install pciutils build-essential cmake curl libcurl4-openssl-dev -y
git clone https://github.com/ggml-org/llama.cpp
cmake llama.cpp -B llama.cpp/build \\
    -DBUILD_SHARED_LIBS=OFF -DGGML_CUDA=ON
cmake --build llama.cpp/build --config Release -j --clean-first --target llama-cli llama-mtmd-cli llama-server llama-gguf-split
cp llama.cpp/build/bin/llama-* llama.cpp
```

{% endstep %}

{% step %}
如果你想直接使用 `llama.cpp` 加载模型，你可以使用下面的方法：(:Q4\_K\_M) 是量化类型。你也可以通过 Hugging Face（第 3 点）下载。这类似于 `ollama run` 。使用 `export LLAMA_CACHE="folder"` 来强制 `llama.cpp` 保存到特定位置。该模型的最大上下文长度为 256K。

根据你的使用场景，按照下面的某个特定命令操作：

**思考模式：**

精确编码任务（例如 WebDev）：

```bash
export LLAMA_CACHE="unsloth/Qwen3.5-27B-GGUF"
./llama.cpp/llama-cli \\
    -hf unsloth/Qwen3.5-27B-GGUF:UD-Q4_K_XL \\
    --temp 0.6 \\
    --top-p 0.95 \\
    --top-k 20 \\
    --min-p 0.00
```

通用任务：

```bash
export LLAMA_CACHE="unsloth/Qwen3.5-27B-GGUF"
./llama.cpp/llama-cli \\
    -hf unsloth/Qwen3.5-27B-GGUF:UD-Q4_K_XL \\
    --temp 1.0 \\
    --top-p 0.95 \\
    --top-k 20 \\
    --min-p 0.00
```

**非思考模式：**

通用任务：

```bash
export LLAMA_CACHE="unsloth/Qwen3.5-27B-GGUF"
./llama.cpp/llama-server \\
    -hf unsloth/Qwen3.5-27B-GGUF:UD-Q4_K_XL \\
    --temp 0.7 \\
    --top-p 0.8 \\
    --top-k 20 \\
    --min-p 0.00 \\
    --chat-template-kwargs '{"enable_thinking":false}'
```

推理任务：

```bash
export LLAMA_CACHE="unsloth/Qwen3.5-27B-GGUF"
./llama.cpp/llama-server \\
    -hf unsloth/Qwen3.5-27B-GGUF:UD-Q4_K_XL \\
    --temp 1.0 \\
    --top-p 0.95 \\
    --top-k 20 \\
    --min-p 0.00 \\
    --chat-template-kwargs '{"enable_thinking":false}'
```

{% endstep %}

{% step %}
通过以下方式下载模型（在安装 `pip install huggingface_hub hf_transfer` ）。你可以选择 `MXFP4_MOE` 或其他量化版本，例如 `UD-Q4_K_XL` 。我们建议至少使用 2-bit 动态量化 `UD-Q2_K_XL` ，以平衡大小和准确性。如果下载卡住，请参阅： [Hugging Face Hub、XET 调试](/docs/zh/ji-chu/troubleshooting-and-faqs/hugging-face-hub-xet-debugging.md)

```bash
hf download unsloth/Qwen3.5-27B-GGUF \\
    --local-dir unsloth/Qwen3.5-27B-GGUF \\
    --include "*mmproj-F16*" \\
    --include "*UD-Q4_K_XL*" # 动态 2bit 请使用 "*UD-Q2_K_XL*"
```

{% endstep %}

{% step %}
然后以对话模式运行模型：

{% code overflow="wrap" %}

```bash
./llama.cpp/llama-cli \\
    --model unsloth/Qwen3.5-27B-GGUF/Qwen3.5-27B-UD-Q4_K_XL.gguf \\
    --mmproj unsloth/Qwen3.5-27B-GGUF/mmproj-F16.gguf \\
    --temp 1.0 \\
    --top-p 0.95 \\
    --min-p 0.00 \\
    --top-k 20
```

{% endcode %}
{% endstep %}
{% endstepper %}

### Qwen3.5-122B-A10B

在本指南中，我们将使用 Dynamic 4-bit，它在 70GB RAM / Mac 设备上表现很好，适合快速推理。GGUF： [Qwen3.5-122B-A10B-GGUF](https://huggingface.co/unsloth/Qwen3.5-122B-A10B-GGUF)

{% stepper %}
{% step %}
获取最新的 `llama.cpp` **在** [**GitHub 上这里**](https://github.com/ggml-org/llama.cpp)。你也可以按照下面的构建说明操作。将 `-DGGML_CUDA=ON` 改为 `-DGGML_CUDA=OFF` 如果你没有 GPU，或者只是想进行 CPU 推理。

```bash
apt-get update
apt-get install pciutils build-essential cmake curl libcurl4-openssl-dev -y
git clone https://github.com/ggml-org/llama.cpp
cmake llama.cpp -B llama.cpp/build \\
    -DBUILD_SHARED_LIBS=OFF -DGGML_CUDA=ON
cmake --build llama.cpp/build --config Release -j --clean-first --target llama-cli llama-mtmd-cli llama-server llama-gguf-split
cp llama.cpp/build/bin/llama-* llama.cpp
```

{% endstep %}

{% step %}
如果你想直接使用 `llama.cpp` 加载模型，你可以使用下面的方法：(:Q4\_K\_M) 是量化类型。你也可以通过 Hugging Face（第 3 点）下载。这类似于 `ollama run` 。使用 `export LLAMA_CACHE="folder"` 来强制 `llama.cpp` 保存到特定位置。该模型的最大上下文长度为 256K。

根据你的使用场景，按照下面的某个特定命令操作：

**思考模式：**

精确编码任务（例如 WebDev）：

```bash
export LLAMA_CACHE="unsloth/Qwen3.5-122B-A10B-GGUF"
./llama.cpp/llama-cli \\
    -hf unsloth/Qwen3.5-122B-A10B-GGUF:UD-Q4_K_XL \
    --temp 0.6 \\
    --top-p 0.95 \\
    --top-k 20 \\
    --min-p 0.00
```

通用任务：

```bash
export LLAMA_CACHE="unsloth/Qwen3.5-122B-A10B-GGUF"
./llama.cpp/llama-cli \\
    -hf unsloth/Qwen3.5-122B-A10B-GGUF:UD-Q4_K_XL \
    --temp 1.0 \\
    --top-p 0.95 \\
    --top-k 20 \\
    --min-p 0.00
```

**非思考模式：**

通用任务：

```bash
export LLAMA_CACHE="unsloth/Qwen3.5-122B-A10B-GGUF"
./llama.cpp/llama-server \\
    -hf unsloth/Qwen3.5-122B-A10B-GGUF:UD-Q4_K_XL \
    --temp 0.7 \\
    --top-p 0.8 \\
    --top-k 20 \\
    --min-p 0.00 \\
    --chat-template-kwargs '{"enable_thinking":false}'
```

推理任务：

```bash
export LLAMA_CACHE="unsloth/Qwen3.5-122B-A10B-GGUF"
./llama.cpp/llama-server \\
    -hf unsloth/Qwen3.5-122B-A10B-GGUF:UD-Q4_K_XL \
    --temp 1.0 \\
    --top-p 0.95 \\
    --top-k 20 \\
    --min-p 0.00 \\
    --chat-template-kwargs '{"enable_thinking":false}'
```

{% endstep %}

{% step %}
通过以下方式下载模型（在安装 `pip install huggingface_hub hf_transfer` ）。你可以选择 `MXFP4_MOE` （动态 4bit）或其他量化版本，例如 `UD-Q4_K_XL` 。我们建议至少使用 2-bit 动态量化 `UD-Q2_K_XL` ，以平衡大小和准确性。如果下载卡住，请参阅： [Hugging Face Hub、XET 调试](/docs/zh/ji-chu/troubleshooting-and-faqs/hugging-face-hub-xet-debugging.md)

```bash
hf download unsloth/Qwen3.5-122B-A10B-GGUF \
    --local-dir unsloth/Qwen3.5-122B-A10B-GGUF \
    --include "*mmproj-F16*" \\
    --include "*UD-Q4_K_XL*" # 动态 2bit 请使用 "*UD-Q2_K_XL*"
```

{% endstep %}

{% step %}
然后以对话模式运行模型：

{% code overflow="wrap" %}

```bash
./llama.cpp/llama-cli \\
    --model unsloth/Qwen3.5-122B-A10B-GGUF/UD-Q4_K_XL/Qwen3.5-122B-A10B-UD-Q4_K_XL-00001-of-00003.gguf \
    --mmproj unsloth/Qwen3.5-122B-A10B-GGUF/mmproj-F16.gguf \
    --temp 0.6 \\
    --top-p 0.95 \\
    --top-k 20 \\
    --min-p 0.00
```

{% endcode %}
{% endstep %}
{% endstepper %}

### Qwen3.5-397B-A17B

Qwen3.5-397B-A17B 的性能档位与 Gemini 3 Pro、Claude Opus 4.5 和 GPT-5.2 处于同一水平。完整的 397B 检查点在磁盘上约为 807GB，但通过 [Unsloth 的 397B GGUF](https://huggingface.co/unsloth/Qwen3.5-397B-A17B-GGUF) 你可以运行：

* **3比特**：可适用于 **192GB RAM** 系统（例如 192GB 的 Mac）
* **4-bit（MXFP4）**：可适用于 **256GB RAM**. Unsloth **4-bit 动态** **UD-Q4\_K\_XL** 是 **磁盘占用约 214GB** - 可直接加载在 **256GB M3 Ultra**
* 可运行于 **单张 24GB GPU + 256GB 系统内存** 通过 **MoE 卸载**，达到 **25+ tokens/s**
* **8比特** 需要 **约 512GB RAM/VRAM**

{% hint style="info" %}
查看 [397B 量化基准测试](#unsloth-gguf-benchmarks) 了解 Unsloth GGUF 的性能表现。
{% endhint %}

{% stepper %}
{% step %}
获取最新的 `llama.cpp` **在** [**GitHub 上这里**](https://github.com/ggml-org/llama.cpp)。你也可以按照下面的构建说明操作。将 `-DGGML_CUDA=ON` 改为 `-DGGML_CUDA=OFF` 如果你没有 GPU，或者只是想进行 CPU 推理。

```bash
apt-get update
apt-get install pciutils build-essential cmake curl libcurl4-openssl-dev -y
git clone https://github.com/ggml-org/llama.cpp
cmake llama.cpp -B llama.cpp/build \\
    -DBUILD_SHARED_LIBS=OFF -DGGML_CUDA=ON
cmake --build llama.cpp/build --config Release -j --clean-first --target llama-cli llama-mtmd-cli llama-server llama-gguf-split
cp llama.cpp/build/bin/llama-* llama.cpp
```

{% endstep %}

{% step %}
如果你想直接使用 `llama.cpp` 加载模型，你可以使用下面的方法：(:Q4\_K\_M) 是量化类型。你也可以通过 Hugging Face（第 3 点）下载。这类似于 `ollama run` 。使用 `export LLAMA_CACHE="folder"` 来强制 `llama.cpp` 以保存到指定位置。请记住该模型的最大上下文长度只有 256K。

按此进行 **思考** 模式：

```bash
export LLAMA_CACHE="unsloth/Qwen3.5-397B-A17B-GGUF"
./llama.cpp/llama-cli \\
    -hf unsloth/Qwen3.5-397B-A17B-GGUF:UD-Q4_K_XL \
    --temp 0.6 \\
    --top-p 0.95 \\
    --top-k 20 \\
    --min-p 0.00
```

按此进行 **非思考** 模式：

```bash
export LLAMA_CACHE="unsloth/Qwen3.5-397B-A17B-GGUF"
./llama.cpp/llama-server \\
    -hf unsloth/Qwen3.5-397B-A17B-GGUF:UD-Q4_K_XL \
    --temp 0.7 \\
    --top-p 0.8 \\
    --top-k 20 \\
    --min-p 0.00 \\
    --chat-template-kwargs '{"enable_thinking":false}'
```

{% endstep %}

{% step %}
通过以下方式下载模型（在安装 `pip install huggingface_hub hf_transfer` ）。你可以选择 `MXFP4_MOE` （动态 4bit）或其他量化版本，例如 `UD-Q4_K_XL` 。我们建议至少使用 2-bit 动态量化 `UD-Q2_K_XL` ，以平衡大小和准确性。如果下载卡住，请参阅： [Hugging Face Hub、XET 调试](/docs/zh/ji-chu/troubleshooting-and-faqs/hugging-face-hub-xet-debugging.md)

```bash
hf download unsloth/Qwen3.5-397B-A17B-GGUF \
    --local-dir unsloth/Qwen3.5-397B-A17B-GGUF \
    --include "*mmproj-F16*" \\
    --include "*UD-Q4_K_XL" # 动态 2bit 使用 "*UD-Q2_K_XL*"
```

{% endstep %}

{% step %}
你可以编辑 `--threads 32` 用于设置 CPU 线程数， `--n-gpu-layers 2` 用于 GPU 卸载的层数。若 GPU 显存不足，请尝试调整它。如果你只进行 CPU 推理，也请把它移除。

{% code overflow="wrap" %}

```bash
./llama.cpp/llama-cli \\
    --model unsloth/Qwen3.5-397B-A17B-GGUF/UD-Q4_K_XL/Qwen3.5-397B-A17B-UD-Q4_K_XL-00001-of-00006.gguf \
    --mmproj unsloth/Qwen3.5-397B-A17B-GGUF/mmproj-F16.gguf \
    --temp 0.6 \\
    --top-p 0.95 \\
    --top-k 20 \\
    --min-p 0.00
```

{% endcode %}
{% endstep %}
{% endstepper %}

### 👾 LM Studio 指南

在本指南中，我们将使用 [LM Studio](https://lmstudio.ai/)，这是一个用于运行 LLM 的统一 UI 界面。默认情况下可能不会显示“💡思考”和“非思考”切换，因此我们需要额外步骤来使其生效。

{% stepper %}
{% step %}
下载 [LM Studio](https://lmstudio.ai/download) 适用于你的设备的版本。然后打开 Model Search，搜索“unsloth/qwen3.5”，并下载你想要的 GGUF（量化）版本。

<div data-with-frame="true"><figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2F7H0N7guLeBxQJzMTQeJ4%2FScreenshot%202026-03-05%20at%203.59.09%E2%80%AFAM.png?alt=media&amp;token=3f3c6c7d-e249-409c-b95b-106e430205ee" alt="" width="563"><figcaption></figcaption></figure></div>
{% endstep %}

{% step %}
**思考切换说明：** 下载后，打开你的终端 / PowerShell，然后尝试： `lms --help`。如果 LM Studio 正常显示并带有许多命令，则运行：

{% code overflow="wrap" expandable="true" %}

```bash
lms get unsloth/qwen3.5-4b
```

{% endcode %}

这将获取一个 yaml 文件，使你的 GGUF 显示“💡思考”和“非思考”切换。你可以把  `4b` 更改为你希望的量化版本。

<div data-with-frame="true"><figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FDXrygqUv9LcTo9pkjotZ%2FScreenshot%202026-03-05%20at%204.04.31%E2%80%AFAM.png?alt=media&amp;token=1e860fc4-1015-4a71-8151-2d8646f76a6d" alt="" width="563"><figcaption></figcaption></figure></div>

否则，你可以前往 [我们的 LM Studio 页面](https://lmstudio.ai/unsloth) 并下载特定的 yaml 文件。
{% endstep %}

{% step %}
重新启动 LM Studio，然后加载你下载的模型（带有你下载的特定思考切换）。你现在应该能看到思考切换已启用。别忘了设置 [正确的参数](#recommended-settings).&#x20;

<div data-with-frame="true"><figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FuGDncmuDdnaPL9gXwqNM%2FScreenshot%202026-03-05%20at%204.21.55%E2%80%AFAM.png?alt=media&amp;token=40ddffe8-bf9c-46de-b0d1-d6b760bbb6a4" alt=""><figcaption></figcaption></figure></div>
{% endstep %}
{% endstepper %}

### 🦙 Llama-server 服务与 OpenAI 的 completion 库

要将 Qwen3.5-397B-A17B 部署到生产环境，我们使用 `llama-server` 在一个新终端中，例如通过 tmux，使用以下方式部署模型：

{% code overflow="wrap" %}

```bash
./llama.cpp/llama-server \\
--model unsloth/Qwen3.5-35B-A3B-GGUF/Qwen3.5-35B-A3B-UD-Q4_K_XL.gguf \\
    --mmproj unsloth/Qwen3.5-35B-A3B-GGUF/mmproj-F16.gguf \\
    --alias "unsloth/Qwen3.5-35B-A3B" \
    --temp 0.6 \\
    --top-p 0.95 \\
    --top-k 20 \\
    --min-p 0.00 \\
    --port 8001
```

{% endcode %}

然后在一个新终端中，先执行 `pip install openai`，然后：

{% code overflow="wrap" %}

```python
from openai import OpenAI
import json
openai_client = OpenAI(
    base_url = "http://127.0.0.1:8001/v1",
    api_key = "sk-no-key-required",
)
completion = openai_client.chat.completions.create(
    model = "unsloth/Qwen3.5-397B-A17B",
    messages = [{"role": "user", "content": "Create a Snake game."},],
)
print(completion.choices[0].message.content)
```

{% endcode %}

### :thinking: 如何启用或禁用推理与思考

{% columns %}
{% column %}
对于下面的命令，你可以将“`true`”和“`false`”互换使用。

[**Unsloth Studio**](#unsloth-studio-guide) 默认自带适用于思考模型的“Think”切换。

要在 LM Studio 中使用 Think 切换， [请阅读我们的指南](#lm-studio-guide).
{% endcolumn %}

{% column %}

<div data-with-frame="true"><figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2Fj34CUWyxrf0ZxZj4Dn4Z%2Fcurrent%20weather%20in%20amazon.png?alt=media&amp;token=c0688e60-8d7d-4273-87af-25332fbd540c" alt=""><figcaption><p>Unsloth Studio 默认带有 Think 切换</p></figcaption></figure></div>
{% endcolumn %}
{% endcolumns %}

{% hint style="info" %}
要 **禁用** 思考 / 推理，在 llama-server 中使用：

```
    --chat-template-kwargs '{"enable_thinking":false}'
```

如果你使用的是 **Windows** 或在 Powershell 中，使用： `--chat-template-kwargs "{\"enable_thinking\":false}"`
{% endhint %}

{% hint style="info" %}
要 **启用** 思考 / 推理，在 llama-server 中使用：

```
    --chat-template-kwargs '{"enable_thinking":true}'
```

如果你使用的是 **Windows** 或在 Powershell 中，使用： `--chat-template-kwargs "{\"enable_thinking\":true}"`
{% endhint %}

{% hint style="danger" %}
**对于 Qwen3.5 0.8B、2B、4B 和 9B，推理默认是禁用的**。要启用它，请使用： `--chat-template-kwargs '{"enable_thinking":true}'`

而在 Windows 或 Powershell 中： `--chat-template-kwargs "{\"enable_thinking\":true}"`
{% endhint %}

例如，对于 Qwen3.5-9B，要启用思考（默认是禁用的）：

```bash
./llama.cpp/llama-server \\
    --model unsloth/Qwen3.5-9B-GGUF/Qwen3.5-9B-BF16.gguf \
    --alias "unsloth/Qwen3.5-9B-GGUF" \\
    --temp 0.6 \\
    --top-p 0.95 \\
    --top-k 20 \\
    --min-p 0.00 \\
    --port 8001 \\
    --chat-template-kwargs '{"enable_thinking":true}'
```

然后在 Python 中：

```python
from openai import OpenAI
import json
openai_client = OpenAI(
    base_url = "http://127.0.0.1:8001/v1",
    api_key = "sk-no-key-required",
)
completion = openai_client.chat.completions.create(
    model = "unsloth/Qwen3.5-9B-GGUF",
    messages = [{"role": "user", "content": "2+2 等于多少？"},],
)
print(completion.choices[0].message.content)
print(completion.choices[0].message.reasoning_content)
```

<figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FXmr4SuoHKcBOgYJi4S9D%2Fimage.png?alt=media&amp;token=3d2a52d8-0734-47cc-9658-e8d096d42b2f" alt=""><figcaption></figcaption></figure>

### 👨‍💻 OpenAI Codex 与 Claude Code <a href="#claude-codex" id="claude-codex"></a>

若要通过本地编码代理工作负载运行模型，你可以 [遵循我们的指南](#claude-codex)。使用 `llama-server` 我们刚刚设置的那个，并将模型名称设置为它在 `GET /v1/models` 返回的精确 id（ `--alias` 上面的值，例如 `unsloth/Qwen3.5-9B-GGUF`）。请遵循正确的 Qwen3.5 参数和使用说明。

{% columns %}
{% column %}
{% content-ref url="/pages/1a707991086189a8e5cd8374f3ce1b81915bc159" %}
[Claude Code](/docs/zh/ji-chu/claude-code.md)
{% endcontent-ref %}
{% endcolumn %}

{% column %}
{% content-ref url="/pages/b71ddea7924324c058a771e5e831c3cb6fc75b18" %}
[OpenAI Codex](/docs/zh/ji-chu/codex.md)
{% endcontent-ref %}
{% endcolumn %}
{% endcolumns %}

例如，按照 Claude Code 的说明后，你会看到：

<figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2Fup2DMSMPjNR8BM9pgR0v%2Fimage.png?alt=media&amp;token=152e9ee0-2491-4379-af18-8fca0789b19d" alt="" width="563"><figcaption></figcaption></figure>

然后我们可以请求例如 `创建一个 Python 国际象棋游戏` :

<div><figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2F9TfMAoKSdMpb8OHKNnHH%2Fimage.png?alt=media&amp;token=771df3aa-91ab-4c1e-8676-1830058001ca" alt="" width="563"><figcaption></figcaption></figure> <figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FWP3lI5mQW2EHB79qqgDz%2Fimage.png?alt=media&amp;token=55cf3189-e100-419c-a615-024b45948284" alt="" width="563"><figcaption></figcaption></figure> <figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2Fn8DZddDODQZGCP8giKYY%2Fimage.png?alt=media&amp;token=996c8cb9-d199-4045-90f0-408690e02667" alt="" width="563"><figcaption></figcaption></figure></div>

### :hammer:使用 Qwen3.5 进行工具调用

查看 [Tool Calling Guide](/docs/zh/ji-chu/tool-calling-guide-for-local-llms.md) 了解更多关于如何进行工具调用的细节。接着在一个新终端中（如果使用 tmux，请按 CTRL+B+D），我们创建一些工具，比如加两个数、执行 Python 代码、执行 Linux 函数等等：

{% code expandable="true" %}

```python
import json, subprocess, random
from typing import Any
def add_number(a: float | str, b: float | str) -> float:
    return float(a) + float(b)
def multiply_number(a: float | str, b: float | str) -> float:
    return float(a) * float(b)
def subtract_number(a: float | str, b: float | str) -> float:
    return float(a) - float(b)
def write_a_story() -> str:
    return random.choice([
        "很久很久以前，在一个遥远的星系里...",
        "有两个朋友，他们热爱树懒和代码...",
        "世界即将终结，因为每一只树懒都进化出了超人的智慧...",
        "其中一个朋友并不知道，另一个朋友不小心写了一个让树懒进化的程序...",
    ])
def terminal(command: str) -> str:
    if "rm" in command or "sudo" in command or "dd" in command or "chmod" in command:
        msg = "无法执行 'rm, sudo, dd, chmod' 命令，因为它们很危险"
        print(msg); return msg
    print(f"正在执行终端命令 `{command}`")
    try:
        return str(subprocess.run(command, capture_output = True, text = True, shell = True, check = True).stdout)
    except subprocess.CalledProcessError as e:
        return f"命令失败：{e.stderr}"
def python(code: str) -> str:
    data = {}
    exec(code, data)
    del data["__builtins__"]
    return str(data)
MAP_FN = {
    "add_number": add_number,
    "multiply_number": multiply_number,
    "subtract_number": subtract_number,
    "write_a_story": write_a_story,
    "terminal": terminal,
    "python": python,
}
tools = [
    {
        "type": "function",
        "function": {
            "name": "add_number",
            "description": "添加两个数字。",
            "parameters": {
                "type": "object",
                "properties": {
                    "a": {
                        "type": "string",
                        "description": "第一个数字。",
                    },
                    "b": {
                        "type": "string",
                        "description": "第二个数字。",
                    },
                },
                "required": ["a", "b"],
            },
        },
    },
    {
        "type": "function",
        "function": {
            "name": "multiply_number",
            "description": "将两个数字相乘。",
            "parameters": {
                "type": "object",
                "properties": {
                    "a": {
                        "type": "string",
                        "description": "第一个数字。",
                    },
                    "b": {
                        "type": "string",
                        "description": "第二个数字。",
                    },
                },
                "required": ["a", "b"],
            },
        },
    },
    {
        "type": "function",
        "function": {
            "name": "subtract_number",
            "description": "减去两个数字。",
            "parameters": {
                "type": "object",
                "properties": {
                    "a": {
                        "type": "string",
                        "description": "第一个数字。",
                    },
                    "b": {
                        "type": "string",
                        "description": "第二个数字。",
                    },
                },
                "required": ["a", "b"],
            },
        },
    },
    {
        "type": "function",
        "function": {
            "name": "write_a_story",
            "description": "写一个随机故事。",
            "parameters": {
                "type": "object",
                "properties": {},
                "required": [],
            },
        },
    },
    {
        "type": "function",
        "function": {
            "name": "terminal",
            "description": "执行终端中的操作。",
            "parameters": {
                "type": "object",
                "properties": {
                    "command": {
                        "type": "string",
                        "description": "你希望启动的命令，例如 `ls`、`rm`，...",
                    },
                },
                "required": ["command"],
            },
        },
    },
    {
        "type": "function",
        "function": {
            "name": "python",
            "description": "调用一个 Python 解释器来运行一些 Python 代码。",
            "parameters": {
                "type": "object",
                "properties": {
                    "code": {
                        "type": "string",
                        "description": "要运行的 Python 代码",
                    },
                },
                "required": ["code"],
            },
        },
    },
]
```

{% endcode %}

然后我们使用下面的函数（复制并粘贴后执行），它会自动解析函数调用，并为任何模型调用 OpenAI 端点：

{% code overflow="wrap" expandable="true" %}

```python
from openai import OpenAI
def unsloth_inference(
    messages,
    temperature = 0.6,
    top_p = 0.95,
    top_k = 20,
    min_p = 0.00,
    repetition_penalty = 1.0,
):
    messages = messages.copy()
    openai_client = OpenAI(
        base_url = "http://127.0.0.1:8001/v1",
        api_key = "sk-no-key-required",
    )
    model_name = next(iter(openai_client.models.list())).id
    print(f"正在使用模型 = {model_name}")
    has_tool_calls = True
    original_messages_len = len(messages)
    while has_tool_calls:
        print(f"当前消息 = {messages}")
        response = openai_client.chat.completions.create(
            model = model_name,
            messages = messages,
            temperature = temperature,
            top_p = top_p,
            tools = tools if tools else None,
            tool_choice = "auto" if tools else None,
            extra_body = {"top_k": top_k, "min_p": min_p, "repetition_penalty" :repetition_penalty,}
        )
        tool_calls = response.choices[0].message.tool_calls or []
        content = response.choices[0].message.content or ""
        tool_calls_dict = [tc.to_dict() for tc in tool_calls] if tool_calls else tool_calls
        messages.append({"role": "assistant", "tool_calls": tool_calls_dict, "content": content,})
        for tool_call in tool_calls:
            fx, args, _id = tool_call.function.name, tool_call.function.arguments, tool_call.id
            out = MAP_FN[fx](**json.loads(args))
            messages.append({"role": "tool", "tool_call_id": _id, "name": fx, "content": str(out),})
        else:
            has_tool_calls = False
    return messages
```

{% endcode %}

在通过 `llama-server` 启动 Qwen3.5 之后，例如在 [#deploy-with-llama-server-and-openais-completion-library](#deploy-with-llama-server-and-openais-completion-library "mention") 中，或者查看 [Tool Calling Guide](/docs/zh/ji-chu/tool-calling-guide-for-local-llms.md) 了解更多细节后，我们就可以进行一些工具调用。

## 📊 基准测试

### Unsloth GGUF 基准测试

我们更新了 Qwen3.5-35B Unsloth 动态量化 **达到 SOTA** 在几乎所有位宽上。我们做了超过 150 次 KL 散度基准测试，总计 **9TB 的 GGUF**。我们上传了所有研究产物。我们还修复了一个 **工具调用** 聊天模板 **bug** （影响所有量化上传器）

* 所有 GGUF 现在都已更新，采用了 **改进的量化** 算法。
* 全部使用我们的 **新 imatrix 数据**。查看在聊天、编码、长上下文和工具调用场景中的一些改进。
* Qwen3.5-35B-A3B GGUF 已更新以使用新的修复（112B、27B 仍在转换中，更新后请重新下载）
* **99.9% KL 散度显示为 SOTA** 在帕累托前沿上的 UD-Q4\_K\_XL、IQ3\_XXS 等版本。
* **弃用 MXFP4** 从所有 GGUF 量化版本中移除：Q2\_K\_XL、Q3\_K\_XL 和 Q4\_K\_XL，纯 MXFP4\_MOE 除外。

<div><figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FeynyrSMxDkkw0zl0haJH%2FCode_Generated_Image(10).png?alt=media&amp;token=c62eef1c-fdd7-4838-8f69-bab227b56e23" alt=""><figcaption><p>35B-A3B - KLD 基准测试（越低越好）</p></figcaption></figure> <figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2F1XLNe1MoxtF1ODs5gDej%2F122b%20final.png?alt=media&amp;token=9eee5d8d-f16c-4c3f-8e36-18856e5609aa" alt=""><figcaption><p>122B-A10B - KLD 基准测试（越低越好）</p></figcaption></figure></div>

**点击此处阅读我们详细的 QWEN3.5 分析 + 基准测试：**

{% content-ref url="/pages/29170937075312be229b292fa371d86315687849" %}
[Qwen3.5 GGUF 基准测试](/docs/zh/mo-xing/qwen3.5/gguf-benchmarks.md)
{% endcontent-ref %}

#### Qwen3.5-397B-A17B 基准测试

<figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2F1oo4wA5EB6z3uWhEK9iF%2FHB2gDSgWEAAF5Sr.png?alt=media&amp;token=82216bf7-4f44-49d6-b98b-51ad5f956ca3" alt="" width="563"><figcaption></figcaption></figure>

[Benjamin Marie（第三方）对以下内容进行了基准测试](https://x.com/bnjmn_marie/status/2025951400119751040/photo/1) **Qwen3.5-397B-A17B** 使用 Unsloth GGUF，在一个 **750 提示混合套件** （LiveCodeBench v6、MMLU Pro、GPQA、Math500），并报告了 **总体准确率** 和 **相对错误增加** （量化模型比原始模型更频繁出错的程度）。

**关键结果（准确率；相对原始模型的变化；相对错误增加）：**

* **原始权重：** **81.3%**
* **UD-Q4\_K\_XL：** **80.5%** *（−0.8 分；+4.3% 相对错误增加）*
* **UD-Q3\_K\_XL：** **80.7%** *（−0.6 分；+3.5% 相对错误增加）*

`UD-Q4_K_XL` 和 `UD-Q3_K_XL` 与原始版本几乎完全接近， **在这个测试集中，准确率下降远低于 1 分，** Ben 暗示这意味着你可以 **显著降低内存占用** (**约少 500 GB**），而在测试任务上几乎没有实际损失。

**如何选择：** 在这里 Q3 略高于 Q4 完全可能，这只是该规模下正常的运行间波动，因此请把 **Q3 和 Q4 视为质量上实际上相近** 在这个基准中：

* 选择 **Q3** 如果你想要 **最小的占用 / 最佳内存节省**
* 选择 **Q4** 如果你想要一个 **稍微更保守的** 选项，且 **结果相近** 。

列出的所有量化版本都采用了我们的动态方法。即使 `UD-IQ2_M` 也使用相同的动态方法，但转换过程不同于 `UD-Q2-K-XL` 其中 K-XL 通常比 `UD-IQ2_M` 更快，尽管它更大，所以这就是为什么 `UD-IQ2_M` 的表现可能优于 `UD-Q2-K-XL`.

### 官方 Qwen 基准测试

#### Qwen3.5-35B-A3B、27B 和 122B-A10B 基准测试

<figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FgRKh7QnQWxdxsaal64RE%2Fqwen3.5_middle_size_score.png?alt=media&amp;token=0d314ef8-20a4-4a06-8a36-fdeff7192c2b" alt=""><figcaption></figcaption></figure>

#### Qwen3.5-4B 和 9B 基准测试

<figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FYfZwIWZJD3le86I8mPIS%2Fqwen3.5_small_size_score(1).png?alt=media&amp;token=095334eb-6ad3-4610-b685-c76e13957e6e" alt=""><figcaption></figcaption></figure>

#### Qwen3.5-397B-A17B 基准测试

<figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FFoWc77o90b32jEuCw48W%2Fqwen3.5_397b_a17b_score.png?alt=media&amp;token=76e4dc26-d9bd-4106-bc1c-0ef20e066128" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://unsloth.ai/docs/zh/mo-xing/qwen3.5.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
