# Cogito v2.1: ローカル実行方法

{% hint style="success" %}
Deep Cogito v2.1 は、2025年11月19日時点で最も強力なオープンウェイトモデルである更新版 671B MoE です。
{% endhint %}

Cogito v2.1 は 1 種類の 671B MoE サイズで提供され、一方 Cogito v2 Preview は [Deep Cogito](https://www.deepcogito.com/)のモデル公開は、70B から 671B までの 4 つのモデルサイズに及びます。 **IDA（Iterated Distillation & Amplification）**&#x3092;用いることで、これらのモデルは、推論時に単により長く探索するのではなく（DeepSeek R1 のように）、反復的な方策改善を用いて推論過程をモデル内部に内面化するよう訓練されています。

Deep Cogito は [米国サンフランシスコに拠点を置いています](https://techcrunch.com/2025/04/08/deep-cogito-emerges-from-stealth-with-hybrid-ai-reasoning-models/) （Unsloth のように :flag\_us:）そして、4 つすべてのモデルサイズ向けに量子化された動的モデルを提供できることを嬉しく思います！ すべてのアップロードは Unsloth [Dynamic 2.0](/docs/jp/ji-ben/unsloth-dynamic-2.0-ggufs.md) を使用しており、SOTA の 5-shot MMLU と KL Divergence の性能を実現しています。つまり、最小限の精度低下で、これらの LLM を量子化したまま実行・ファインチューニングできます！

**チュートリアルのナビゲーション：**

<a href="https://docs.unsloth.ai/basics/tutorials-how-to-fine-tune-and-run-llms/cogito-v2-how-to-run-locally#run-cogito-671b-moe-in-llama.cpp" class="button secondary">671B MoE を実行</a><a href="https://docs.unsloth.ai/basics/tutorials-how-to-fine-tune-and-run-llms/cogito-v2-how-to-run-locally#run-cogito-109b-moe-in-llama.cpp" class="button secondary">109B MoE を実行</a><a href="https://docs.unsloth.ai/basics/tutorials-how-to-fine-tune-and-run-llms/cogito-v2-how-to-run-locally#run-cogito-405b-dense-in-llama.cpp" class="button secondary">405B Dense を実行</a><a href="https://docs.unsloth.ai/basics/tutorials-how-to-fine-tune-and-run-llms/cogito-v2-how-to-run-locally#run-cogito-70b-dense-in-llama.cpp" class="button secondary">70B Dense を実行</a>

{% hint style="success" %}
どのモデルサイズがあなたのハードウェアに合うか選びましょう！ 4 つすべてのモデルサイズ向けに、1.58bit から 16bit までのバリエーションをアップロードしています！
{% endhint %}

## :gem: モデルサイズとアップロード

モデルサイズは 4 種類あります：

1. Llama ベースの Dense モデルが 2 種類 - 70B と 405B
2. Llama 4 Scout（109B）と DeepSeek R1（671B）をベースにした MoE モデルが 2 種類

<table data-full-width="false"><thead><tr><th>モデルサイズ</th><th width="256.9999694824219">推奨 Quant &#x26; リンク</th><th>ディスクサイズ</th><th>アーキテクチャ</th></tr></thead><tbody><tr><td>70B Dense</td><td><a href="https://huggingface.co/unsloth/cogito-v2-preview-llama-70B-GGUF">UD-Q4_K_XL</a></td><td><strong>44GB</strong></td><td>Llama 3 70B</td></tr><tr><td>109B MoE</td><td><a href="https://huggingface.co/unsloth/cogito-v2-preview-llama-109B-MoE-GGUF">UD-Q3_K_XL</a></td><td><strong>50GB</strong></td><td>Llama 4 Scout</td></tr><tr><td>405B Dense</td><td><a href="https://huggingface.co/unsloth/cogito-v2-preview-llama-405B-GGUF">UD-Q2_K_XL</a></td><td><strong>152GB</strong></td><td>Llama 3 405B</td></tr><tr><td>671B MoE</td><td><a href="https://huggingface.co/unsloth/cogito-v2-preview-deepseek-671B-MoE-GGUF">UD-Q2_K_XL</a></td><td><strong>251GB</strong></td><td>DeepSeek R1</td></tr></tbody></table>

{% hint style="success" %}
必須ではありませんが、最高の性能を得るには、VRAM と RAM の合計がダウンロードする量子化サイズと同じになるようにしてください。VRAM + RAM がそれより少ない場合でも量子化は動作しますが、かなり遅くなります。
{% endhint %}

## 🐳 llama.cpp で Cogito 671B MoE を実行

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 サポートは既定で有効です。

{% code overflow="wrap" %}

```shellscript
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-quantize llama-cli llama-gguf-split llama-mtmd-cli
cp llama.cpp/build/bin/llama-* llama.cpp
```

{% endcode %}

2. もし `llama.cpp` モデルを直接読み込むには、以下のようにできます。(:IQ1\_S) は量子化タイプです。Hugging Face からもダウンロードできます（ポイント 3）。これは次のものに似ています `ollama run` に似ています。使用 `export LLAMA_CACHE="folder"` して `llama.cpp` 特定の場所に保存するために。

{% hint style="success" %}
ぜひお試しください `-ot ".ffn_.*_exps.=CPU"` すべての MoE レイヤーを CPU にオフロードします！これにより、非 MoE レイヤーを 1 枚の GPU に収められるようになり、生成速度が向上します。GPU 容量がさらにある場合は、正規表現を調整してより多くのレイヤーを収めることができます。

GPU メモリがもう少し多い場合は、試してみてください `-ot ".ffn_(up|down)_exps.=CPU"` これにより、アップ投影とダウン投影の MoE レイヤーがオフロードされます。

試してみてください `-ot ".ffn_(up)_exps.=CPU"` GPU メモリがさらに多い場合は、これを使ってください。これにより、アップ投影の MoE レイヤーのみがオフロードされます。

そして最後に、 `-ot ".ffn_.*_exps.=CPU"` を使ってすべてのレイヤーをオフロードします。

これは最も少ない VRAM を使用します。 `正規表現をカスタマイズすることもできます。例えば` -ot "\\.(6|7|8|9|\[0-9]\[0-9]|\[0-9]\[0-9]\[0-9])\\.ffn\_(gate|up|down)\_exps.=CPU"
{% endhint %}

```shellscript
export LLAMA_CACHE="unsloth/cogito-671b-v2.1-GGUF"
./llama.cpp/llama-cli \\
    -hf unsloth/cogito-671b-v2.1-GGUF:UD-Q2_K_XL \\
    --n-gpu-layers 99 \\
    --temp 0.6 \\
    --top-p 0.95 \
    --min-p 0.01 \\
    --ctx-size 16384 \\
    --seed 3407 \\
    --jinja \
    -ot ".ffn_.*_exps.=CPU"
```

3. モデルのダウンロード（ `pip install huggingface_hub hf_transfer` のインストール後）。 `UD-IQ1_S`（動的 1.78bit 量子化）または次のような他の量子化版 `Q4_K_M` 私たちは <mark style="background-color:green;">**当社の 2.7bit 動的量子化版の使用を推奨します**</mark><mark style="background-color:green;">**&#x20;**</mark><mark style="background-color:green;">**`UD-Q2_K_XL`**</mark><mark style="background-color:green;">**&#x20;**</mark><mark style="background-color:green;">**サイズと精度のバランスを取るためです**</mark>。その他のバージョンはこちら： <https://huggingface.co/unsloth/cogito-671b-v2.1-GGUF>

{% code overflow="wrap" %}

```python
# !pip install huggingface_hub hf_transfer
import os
os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "0" # 場合によってはレート制限がかかることがあるため、無効にするには 0 に設定
from huggingface_hub import snapshot_download
snapshot_download(
    repo_id = "unsloth/cogito-671b-v2.1-GGUF",
    local_dir = "unsloth/cogito-671b-v2.1-GGUF",
    allow_patterns = ["*UD-IQ1_S*"], # 動的 1bit（168GB） 動的 2bit（251GB）には "*UD-Q2_K_XL*" を使用
)
```

{% endcode %}

4. 編集 `--threads 32` CPU スレッド数を `--ctx-size 16384` コンテキスト長を `--n-gpu-layers 2` GPU オフロードする層数を指定します。GPU のメモリ不足になる場合は調整してみてください。CPU のみで推論する場合は、これも削除してください。

## :mouse\_three\_button:llama.cpp で Cogito 109B MoE を実行

1. 上の [671B モデルを実行する場合と同じ手順に従ってください](#run-cogito-671b-moe-in-llama.cpp).
2. その後、以下を実行します：

```shellscript
export LLAMA_CACHE="unsloth/cogito-v2-preview-llama-109B-MoE-GGUF"
./llama.cpp/llama-cli \\
    -hf unsloth/cogito-v2-preview-llama-109B-MoE-GGUF:Q3_K_XL \\
    --n-gpu-layers 99 \\
    --temp 0.6 \\
    --min-p 0.01 \\
    --top-p 0.9 \\
    --ctx-size 16384 \\
    --jinja \
    -ot ".ffn_.*_exps.=CPU"
```

## :deciduous\_tree:llama.cpp で Cogito 405B Dense を実行

1. 上の [671B モデルを実行する場合と同じ手順に従ってください](#run-cogito-671b-moe-in-llama.cpp).
2. その後、以下を実行します：

```shellscript
export LLAMA_CACHE="unsloth/cogito-v2-preview-llama-405B-GGUF"
./llama.cpp/llama-cli \\
    -hf unsloth/cogito-v2-preview-llama-405B-GGUF:Q2_K_XL \\
    --n-gpu-layers 99 \\
    --temp 0.6 \\
    --min-p 0.01 \\
    --top-p 0.9 \\
    --jinja \
    --ctx-size 16384
```

## :sunglasses: llama.cpp で Cogito 70B Dense を実行

1. 上の [671B モデルを実行する場合と同じ手順に従ってください](#run-cogito-671b-moe-in-llama.cpp).
2. その後、以下を実行します：

```shellscript
export LLAMA_CACHE="unsloth/cogito-v2-preview-llama-70B-GGUF"
./llama.cpp/llama-cli \\
    -hf unsloth/cogito-v2-preview-llama-70B-GGUF:Q4_K_XL \\
    --n-gpu-layers 99 \\
    --temp 0.6 \\
    --min-p 0.01 \\
    --top-p 0.9 \\
    --jinja \
    --ctx-size 16384
```

参照 <https://www.deepcogito.com/research/cogito-v2-1> 詳細はこちら


---

# Agent Instructions: 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:

```
GET https://unsloth.ai/docs/jp/moderu/tutorials/cogito-v2-how-to-run-locally.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
