> 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/jp/moderu/tutorials/qwen3-next.md).

# Qwen3-Next: ローカル実行ガイド

Qwen3-Next-80B-A3B-InstructとThinking版をデバイス上でローカル実行しましょう！

Qwenは2025年9月にQwen3-Nextをリリースしました。これは80BのMoEで、Thinking版とInstruct版のモデルバリアントがあります。 [Qwen3](/docs/jp/moderu/tutorials/qwen3-how-to-run-and-fine-tune.md)。256Kのコンテキストに対応し、Qwen3-Nextは新しいアーキテクチャ（MoEとGated DeltaNet + Gated Attentionのハイブリッド）で設計されており、特に長いコンテキスト長での高速推論に最適化されています。Qwen3-Nextの推論速度はQwen3-32Bの10倍です。

<a href="/docs/jp/moderu/tutorials/qwen3-next.md#run-qwen3-next-tutorials" class="button secondary">Qwen3-Next Instruct を実行</a><a href="/docs/jp/moderu/tutorials/qwen3-next.md#thinking-qwen3-next-80b-a3b-thinking" class="button secondary">Qwen3-Next Thinking を実行</a>

Qwen3-Next-80B-A3B Dynamic GGUF: [**インストラクト**](https://huggingface.co/unsloth/Qwen3-Next-80B-A3B-Instruct-GGUF) **•** [**思考**](https://huggingface.co/unsloth/Qwen3-Next-80B-A3B-Thinking-GGUF)

### ⚙️ 使用ガイド

{% hint style="success" %}
2025年12月6日時点で新規: Unsloth Qwen3-Next は、性能向上のため iMatrix で更新されました。

Thinkingモデルは `temperature = 0.6`を使用しますが、Instructモデルは `temperature = 0.7`\
Thinkingモデルは `top_p = 0.95`を使用しますが、Instructモデルは `top_p = 0.8`
{% endhint %}

最適な性能を達成するために、Qwenは次の設定を推奨しています:

| Instruct:                                                                  | Thinking:                                                                  |
| -------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
| <mark style="background-color:blue;">`Temperature = 0.7`</mark>            | <mark style="background-color:blue;">`Temperature = 0.6`</mark>            |
| `Min_P = 0.00` （llama.cppのデフォルトは0.1です）                                     | `Min_P = 0.00` （llama.cppのデフォルトは0.1です）                                     |
| `Top_P = 0.80`                                                             | `Top_P = 0.95`                                                             |
| `TopK = 20`                                                                | `TopK = 20`                                                                |
| `presence_penalty = 0.0 ～ 2.0` （llama.cppのデフォルトでは無効ですが、繰り返しを減らすためにこれを使えます） | `presence_penalty = 0.0 ～ 2.0` （llama.cppのデフォルトでは無効ですが、繰り返しを減らすためにこれを使えます） |

**十分な出力長**: 出力長を `32,768` トークンに設定してください。Thinking版の大半のクエリでは、 `16,384` を使用します。必要に応じて、Thinkingモデルの最大出力サイズを増やすことができます。

Thinking版とInstruct版の両方のチャットテンプレートは以下のとおりです（Thinkingには `<think></think>`があります）:

```
<|im_start|>user
やあ！<|im_end|>
<|im_start|>assistant
1+1はいくつ？<|im_end|>
<|im_start|>user
2<|im_end|>
<|im_start|>assistant
```

## 📖 Qwen3-Next チュートリアルを実行

以下は、 [思考](#thinking-qwen3-next-80b-a3b-thinking) そして [インストラクト](#instruct-qwen3-next-80b-a3b-instruct) モデルの各バージョン向けガイドです。

### Instruct: Qwen3-Next-80B-A3B-Instruct

これは非thinkingモデルなので、モデルは `<think> </think>` ブロックを生成しません。

#### ⚙️ベストプラクティス

最適な性能を達成するために、Qwenは以下の設定を推奨しています:

* 以下の使用を推奨します `temperature=0.7, top_p=0.8, top_k=20, min_p=0.0` `presence_penalty` を0から2の間で設定してください。フレームワークが対応していれば、終わりのない繰り返しを減らせます。
* **`temperature = 0.7`**
* `top_k = 20`
* `min_p = 0.00` （llama.cppのデフォルトは0.1です）
* **`top_p = 0.80`**
* `presence_penalty = 0.0 ～ 2.0` （llama.cppのデフォルトでは無効ですが、繰り返しを減らすためにこれを使えます） たとえば1.0を試してください。
* 最大 `262,144` コンテキストをネイティブにサポートしますが、 `32,768` トークンに設定してRAM使用量を減らせます

#### :sparkles: Llama.cpp: Qwen3-Next-80B-A3B-Instruct チュートリアルを実行

1. 最新の `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 -DLLAMA_CURL=ON
cmake --build llama.cpp/build --config Release -j --clean-first --target llama-cli llama-gguf-split
cp llama.cpp/build/bin/llama-* llama.cpp
```

2. HuggingFace から直接、以下を使って取得できます:

   ```bash
   ./llama.cpp/llama-cli \
       -hf unsloth/Qwen3-Next-80B-A3B-Instruct-GGUF:Q4_K_XL \
       --jinja -ngl 99 --ctx-size 32768 \
       --temp 0.7 --min-p 0.0 --top-p 0.80 --top-k 20 --presence-penalty 1.0
   ```
3. 以下をインストールした後、( `pip install huggingface_hub hf_transfer` をインストール後）。 `UD_Q4_K_XL` または他の量子化版を使ってダウンロードしてください。

```python
# !pip install huggingface_hub hf_transfer
import os
os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"
from huggingface_hub import snapshot_download
snapshot_download(
    repo_id = "unsloth/Qwen3-Next-80B-A3B-Instruct-GGUF",
    local_dir = "Qwen3-Next-80B-A3B-Instruct-GGUF",
    allow_patterns = ["*UD-Q4_K_XL*"],
)
```

### Thinking: Qwen3-Next-80B-A3B-Thinking

このモデルは、thinkingモードと256Kのコンテキストウィンドウのみをネイティブにサポートします。デフォルトのチャットテンプレートでは `<think>` が自動的に追加されるため、出力には閉じる `</think>` タグだけが表示される場合があります。

#### ⚙️ベストプラクティス

最適な性能を達成するために、Qwenは以下の設定を推奨しています:

* 以下の使用を推奨します `temperature=0.6, top_p=0.95, top_k=20, min_p=0.0` `presence_penalty` を0から2の間で設定してください。フレームワークが対応していれば、終わりのない繰り返しを減らせます。
* **`temperature = 0.6`**
* `top_k = 20`
* `min_p = 0.00` （llama.cppのデフォルトは0.1です）
* **`top_p = 0.95`**
* `presence_penalty = 0.0 ～ 2.0` （llama.cppのデフォルトでは無効ですが、繰り返しを減らすためにこれを使えます） たとえば1.0を試してください。
* 最大 `262,144` コンテキストをネイティブにサポートしますが、 `32,768` トークンに設定してRAM使用量を減らせます

#### :sparkles: Llama.cpp: Qwen3-Next-80B-A3B-Thinking チュートリアルを実行

1. 最新の `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 -DLLAMA_CURL=ON
cmake --build llama.cpp/build --config Release -j --clean-first --target llama-cli llama-gguf-split
cp llama.cpp/build/bin/llama-* llama.cpp
```

2. Hugging Faceから直接以下で取得できます:

   ```bash
   ./llama.cpp/llama-cli \
       -hf unsloth/Qwen3-Next-80B-A3B-Thinking-GGUF:Q4_K_XL \
       --jinja -ngl 99 --ctx-size 32768 \
       --temp 0.6 --min-p 0.0 --top-p 0.95 --top-k 20 --presence-penalty 1.0
   ```
3. 以下をインストールした後、( `pip install huggingface_hub hf_transfer` をインストール後）。 `UD_Q4_K_XL` または他の量子化版を使ってダウンロードしてください。

```python
# !pip install huggingface_hub hf_transfer
import os
os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"
from huggingface_hub import snapshot_download
snapshot_download(
    repo_id = "unsloth/Qwen3-Next-80B-A3B-Thinking-GGUF",
    local_dir = "Qwen3-Next-80B-A3B-Thinking-GGUF",
    allow_patterns = ["*UD-Q4_K_XL*"],
)
```

### 🛠️ 生成速度の改善 <a href="#improving-generation-speed" id="improving-generation-speed"></a>

VRAM がさらにあれば、より多くの MoE 層、または層全体のオフロードを試せます。

通常は、 `-ot ".ffn_.*_exps.=CPU"` すべての MoE 層を CPU にオフロードします！これにより、非MoE層すべてを1枚のGPUに収められるようになり、生成速度が向上します。GPU容量がさらにあれば、正規表現を調整してより多くの層を収めることもできます。

GPU メモリがもう少し多ければ、 `-ot ".ffn_(up|down)_exps.=CPU"` を試してください。これは up と down の projection MoE 層をオフロードします。

試してみてください `-ot ".ffn_(up)_exps.=CPU"` GPU メモリがさらに多い場合はこちら。これは up projection の MoE 層のみをオフロードします。

これは最も少ない VRAM を使用します。 `-ot "\.(6|7|8|9|[0-9][0-9]|[0-9][0-9][0-9])\.ffn_(gate|up|down)_exps.=CPU"` は、6層目以降から gate、up、down の MoE 層をオフロードすることを意味します。

その [最新のllama.cppリリース](https://github.com/ggml-org/llama.cpp/pull/14363) には高スループットモードも導入されています。 `llama-parallel`を使用してください。 [ここ](https://github.com/ggml-org/llama.cpp/tree/master/examples/parallel)について詳しくはこちらを読む **KV キャッシュを 4bit に量子化する** たとえばVRAM / RAM間の移動を減らすために使用してください。これにより生成プロセスも高速化できます。 [次のセクション](#how-to-fit-long-context-256k-to-1m) ではKVキャッシュの量子化について説明します。

### 📐長いコンテキストに収める方法 <a href="#how-to-fit-long-context-256k-to-1m" id="how-to-fit-long-context-256k-to-1m"></a>

より長いコンテキストに対応するには、 **KV キャッシュ量子化** を使って K と V のキャッシュをより低い bit に量子化できます。これにより、RAM / VRAM のデータ移動が減るため生成速度も上がります。K の量子化で使用できるオプション（デフォルトは `f16`）は以下の通りです。

`--cache-type-k f32, f16, bf16, q8_0, q4_0, q4_1, iq4_nl, q5_0, q5_1`

少し精度が向上する `_1` 版を使うべきです。少し遅くなりますが。たとえば `q4_1, q5_1` そのため、 `--cache-type-k q4_1`

V キャッシュも量子化できますが、その場合は **Flash Attention 対応で llama.cpp をコンパイルする必要があります** を `-DGGML_CUDA_FA_ALL_QUANTS=ON`で有効にし、 `--flash-attn` を有効にして試してください。Flash Attentionをインストールした後は、 `--cache-type-v q4_1`

<figure><img src="https://735611837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2Fgit-blob-be34c101c627020c7a6cfb6cd249f2462587d235%2Fqwen33%20mascot.png?alt=media" 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://unsloth.ai/docs/jp/moderu/tutorials/qwen3-next.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
