> 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-ben/inference-and-deployment/deploying-llms-with-hugging-face-jobs.md).

# Hugging Face Jobs を使った LLM のデプロイ

このガイドでは、どのように使用するかを解説します [Unsloth](https://github.com/unslothai/unsloth) および [Liquid LFM2.5](/docs/jp/moderu/tutorials/lfm2.5.md) を使って、のようなコーディングエージェント経由で高速にLLMをファインチューニングする方法 [Claude Code](/docs/jp/ji-ben/claude-code.md)。Unslothは、標準的な手法と比べて約2倍高速な学習と約60%少ないVRAM使用量を実現します。

### 必要なものは以下です

* A [Hugging Face](https://huggingface.co) アカウント（HF Jobsに必要）
* 書き込み権限のあるHugging Faceトークン
* コーディングエージェント（Open Code、Claude Code、Codex）
* こちらの [Claude Code](/docs/jp/ji-ben/claude-code.md) セットアップガイドをお読みください。

### スキルのインストール

#### Claude Code

Claude Codeは、その [プラグインシステム](https://code.claude.com/docs/en/discover-plugins).

1. を通じてスキルを見つけます：

```bash
/plugin marketplace add huggingface/skills
```

2. 利用可能なスキルを **Discover** タブで閲覧します：

```bash
/plugin
```

3. モデルトレーナースキルをインストールします：

```bash
/plugin install hugging-face-model-trainer@huggingface-skills
```

詳細は、 [Claude Code plugins docs](https://code.claude.com/docs/en/discover-plugins) および [Skills docs](https://code.claude.com/docs/en/skills).

#### Codex

をご覧ください。Codexは、 [`AGENTS.md`](https://developers.openai.com/codex/guides/agents-md) ファイルと [`.agents/skills/`](https://developers.openai.com/codex/skills) ディレクトリを通じてスキルを見つけます。

**個別のスキルは次の方法でインストールします `$skill-installer`**

{% code overflow="wrap" %}

```bash
$skill-installer install https://github.com/huggingface/skills/tree/main/skills/hugging-face-model-trainer
```

{% endcode %}

詳細は、 [Codex Skills docs](https://developers.openai.com/codex/skills) および [AGENTS.md guide](https://developers.openai.com/codex/guides/agents-md).

### クイックスタート

スキルがインストールされたら、コーディングエージェントにモデルの学習を依頼します。ここでは [Liquid LFM2.5](/docs/jp/moderu/tutorials/lfm2.5.md)

{% code overflow="wrap" %}

```
Train LiquidAI/LFM2.5-1.2B-Instruct on trl-lib/Capybara using Unsloth on HF Jobs
```

{% endcode %}

エージェントは、スキル内の [例](https://github.com/huggingface/skills/blob/main/skills/hugging-face-model-trainer/scripts/unsloth_sft_example.py)に基づいて学習スクリプトを生成し、学習をHF Jobsに送信し、Trackio経由で監視リンクを提供します。

### Hugging Face Jobsの使用

学習ジョブは [Hugging Face Jobs](https://huggingface.co/docs/huggingface_hub/guides/jobs) 上で実行されます。これは完全管理型のクラウドGPUです。Google Colabのクレジットに慣れている方なら、Hugging Face Jobsにも同様のクレジット制度があります。これは従量課金制で、あらかじめクレジットを取得することもできます。エージェントは次のことを行います：

1. インライン依存関係を含むUVスクリプトを生成する
2. それを次経由でHF Jobsに送信する `hf` CLI
3. ジョブIDと監視URLを報告する
4. 学習済みモデルは、あなたのHugging Face Hubリポジトリにプッシュされます

#### 学習スクリプトの例

このスキルは次のようなスクリプトを生成します：

{% code expandable="true" %}

```py
# /// script
# dependencies = ["unsloth", "trl>=0.12.0", "datasets", "trackio"]
# ///

from unsloth import FastLanguageModel
from trl import SFTTrainer, SFTConfig
from datasets import load_dataset

model, tokenizer = FastLanguageModel.from_pretrained(
    "Qwen/Qwen2.5-0.5B",
    load_in_4bit=True,
    max_seq_length=2048,
)

model = FastLanguageModel.get_peft_model(
    model,
    r=16,
    lora_alpha=32,
    lora_dropout=0,
    target_modules=["q_proj", "k_proj", "v_proj", "o_proj",
                    "gate_proj", "up_proj", "down_proj"],
)

dataset = load_dataset("trl-lib/Capybara", split="train")

trainer = SFTTrainer(
    model=model,
    tokenizer=tokenizer,
    train_dataset=dataset,
    args=SFTConfig(
        output_dir="./output",
        push_to_hub=True,
        hub_model_id="username/my-model",
        per_device_train_batch_size=4,
        gradient_accumulation_steps=4,
        num_train_epochs=1,
        learning_rate=2e-4,
        report_to="trackio",
    ),
)

trainer.train()
trainer.push_to_hub()
```

{% endcode %}

Hugging Face Jobsでの学習コストは以下のとおりです：

| モデルサイズ       | 推奨GPU        | 概算費用/時  |
| ------------ | ------------ | ------- |
| <1B params   | `t4-small`   | \~$0.40 |
| 1-3B params  | `t4-medium`  | \~$0.60 |
| 3-7B params  | `a10g-small` | \~$1.00 |
| 7-13B params | `a10g-large` | \~$3.00 |

Hugging Face spaceの料金の全体像については、ガイドを確認してください [こちら](https://huggingface.co/docs/hub/en/spaces-overview#hardware-resources).

### コーディングエージェントを使う際のヒント

* 使用するモデルとデータセットを具体的に指定し、Hub IDを含めてください（例： `Qwen/Qwen2.5-0.5B`, `trl-lib/Capybara`）。エージェントは、それらの組み合わせを検索し、検証します。
* Unslothを使ってほしい場合は、明示的に言及してください。そうでない場合、エージェントはモデルと予算に基づいてフレームワークを判断します。
* 大規模ジョブを開始する前に、コスト見積もりを依頼してください
* リアルタイムの損失曲線のためにTrackio監視を依頼してください
* 送信後にエージェントにログを確認させて、ジョブの状態を確認してください

### リソース

* [Hugging Face Skills リポジトリ](https://github.com/huggingface/skills)

{% embed url="<https://youtu.be/Gh5P4niIFNA>" %}


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://unsloth.ai/docs/jp/ji-ben/inference-and-deployment/deploying-llms-with-hugging-face-jobs.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
