> 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/ji-chu/inference-and-deployment/troubleshooting-inference.md).

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

モデルの実行や保存時に問題が発生している場合。

### 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)
  * **さらに多くのノートブックは** [**notebooksリポジトリ**](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)`。たとえば0.5に下げると、GPUピークメモリの50%以下を使用します。これにより、保存時のOOMクラッシュを減らせることがあります。


---

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