# 推論のトラブルシューティング

### Unslothでの実行はうまくいきますが、エクスポートして他のプラットフォームで実行すると結果が悪い

モデルがUnsloth上では正しく動作して良い結果を出すのに、OllamaやvLLMのような別のプラットフォームで使うと結果が悪くなったり、意味不明な出力や終わりのない／無限の生成が発生することがあります。 *または* 繰り返し出&#x529B;**.**

* このエラーの最も一般的な原因は、 <mark style="background-color:blue;">**誤ったチャットテンプレート**</mark>**.** です。Unslothでモデルを訓練したときに使用したのと同じチャットテンプレートを、llama.cppやOllamaなど別のフレームワークで実行する際にも必ず使用することが重要です。保存されたモデルから推論する場合、正しいテンプレートを適用することが不可欠です。
* 正しい `eos トークン`を使用する必要があります。そうしないと、長い生成で意味のない出力が出ることがあります。
* また、推論エンジンが不要な「シーケンス開始」トークンを追加している（あるいは逆に欠如している）ことが原因の可能性もあるため、両方の仮説を確認してください！
* <mark style="background-color:green;">**チャットテンプレートを強制する私たちの会話用ノートブックを使用してください — これでほとんどの問題が解決します。**</mark>
  * Qwen-3 14B 会話用ノートブック [**Colabで開く**](https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Qwen3_\(14B\)-Reasoning-Conversational.ipynb)
  * Gemma-3 4B 会話用ノートブック [**Colabで開く**](https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Gemma3_\(4B\).ipynb)
  * Llama-3.2 3B 会話用ノートブック [**Colabで開く**](https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Llama3.2_\(1B_and_3B\)-Conversational.ipynb)
  * Phi-4 14B 会話用ノートブック [**Colabで開く**](https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Phi_4-Conversational.ipynb)
  * Mistral v0.3 7B 会話用ノートブック [**Colabで開く**](https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Mistral_v0.3_\(7B\)-Conversational.ipynb)
  * **その他のノートブックは私たちの** [**ノートブックリポジトリ**](https://github.com/unslothai/notebooks)**.**

### に保存しています `safetensors`、ではなく `bin` Colabでのフォーマット

私たちは `.bin` をColabで保存しているので約4倍速いですが、 `safe_serialization = None` を設定して強制的に保存する `.safetensors`。したがって `model.save_pretrained(..., safe_serialization = None)` または `model.push_to_hub(..., safe_serialization = None)`

### GGUFやvLLMの16bitで保存中にクラッシュする場合

保存中の最大GPU使用量を減らすには、 `maximum_memory_usage`.

のデフォルトは `model.save_pretrained(..., maximum_memory_usage = 0.75)`です。ピークGPUメモリの50%を使うように0.5などに下げるか、それ以下にしてください。これにより保存中のOOMクラッシュを減らせます。


---

# 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/ji-ben/inference-and-deployment/troubleshooting-inference.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.
