> 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/vllm-guide.md).

# vLLMデプロイメント＆推論ガイド

本番環境でLLMを提供するために、LLMをvLLMへ保存・デプロイするためのガイド

### :computer:vLLMのインストール

NVIDIA GPUの場合は、uvを使って次を実行します：

```bash
pip install --upgrade pip
pip install uv
uv pip install -U vllm --torch-backend=auto
```

AMD GPUの場合は、nightly Dockerイメージを使用してください： `rocm/vllm-dev:nightly`

NVIDIA GPU向けのnightlyブランチの場合は、次を実行します：

{% code overflow="wrap" %}

```bash
pip install --upgrade pip
pip install uv
uv pip install -U vllm --torch-backend=auto --extra-index-url https://wheels.vllm.ai/nightly
```

{% endcode %}

こちらを参照 [vLLMドキュメント](https://docs.vllm.ai/en/stable/getting_started/installation) 詳細については

### :truck:vLLMモデルのデプロイ

ファインチューニング結果を保存したら、次のようにするだけです：

```bash
vllm serve unsloth/gpt-oss-120b
```

### :fire\_engine:vLLMデプロイメントサーバーのフラグ、エンジン引数、オプション

使用すべき重要なサーバーフラグは次にあります： [#vllm-deployment-server-flags-engine-arguments-and-options](#vllm-deployment-server-flags-engine-arguments-and-options "mention")

### 🦥 vLLMでUnslothのファインチューニング結果をデプロイする

ファインチューニング後 [Fine-tuning Guide](/docs/jp/meru/fine-tuning-llms-guide.md) または、次のノートブックを使用して [Unslothノートブック](/docs/jp/meru/unsloth-notebooks.md)、モデルをvLLMを介して単一のワークフロー内で直接保存またはデプロイできます。例として、Unslothのファインチューニングスクリプトは次のとおりです：

```python
from unsloth import FastLanguageModel
import torch
model, tokenizer = FastLanguageModel.from_pretrained(
    model_name = "unsloth/gpt-oss-20b",
    max_seq_length = 2048,
    load_in_4bit = True,
)
model = FastLanguageModel.get_peft_model(model)
```

**vLLM用に16ビットで保存するには、次を使用します：**

{% code overflow="wrap" %}

```python
model.save_pretrained_merged("finetuned_model", tokenizer, save_method = "merged_16bit")
## または HuggingFace にアップロードするには：
model.push_to_hub_merged("hf/model", tokenizer, save_method = "merged_16bit", token = "")
```

{% endcode %}

**LoRAアダプターのみを保存するには**、次のいずれかを使用します：

```python
model.save_pretrained("finetuned_lora")
tokenizer.save_pretrained("finetuned_lora")
```

または、そのための組み込み関数を使うだけです：

{% code overflow="wrap" %}

```python
model.save_pretrained_merged("finetuned_model", tokenizer, save_method = "lora")
## または HuggingFace にアップロードするには
model.push_to_hub_merged("hf/model", tokenizer, save_method = "lora", token = "")
```

{% endcode %}

HuggingFaceで読み込むために4bitにマージするには、まず次を呼び出します `merged_4bit`。その後、次を使用します `merged_4bit_forced` 4bitにマージしたいと確信している場合のみ使用してください。4bitモデルをどう扱うか（たとえばDPO学習やHuggingFaceのオンライン推論エンジンなど）を理解していない限り、私は強くおすすめしません

{% code overflow="wrap" %}

```python
model.save_pretrained_merged("finetuned_model", tokenizer, save_method = "merged_4bit")
## HuggingFace にアップロードするには：
model.push_to_hub_merged("hf/model", tokenizer, save_method = "merged_4bit", token = "")
```

{% endcode %}

その後、別のターミナルでvLLMにファインチューニング済みモデルを読み込むには：

```bash
vllm serve finetuned_model
```

上記がうまくいかない場合は、完全なパスを指定する必要があるかもしれません。たとえば：

```bash
vllm serve /mnt/disks/daniel/finetuned_model
```

他のコンテンツを見る：

### [vLLMエンジン引数](/docs/jp/ji-chu/inference-and-deployment/vllm-guide/vllm-engine-arguments.md)

### [LoRAホットスワップガイド](/docs/jp/ji-chu/inference-and-deployment/vllm-guide/lora-hot-swapping-guide.md)


---

# 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/vllm-guide.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.
