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

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

Hugging Face jobsとskillsを使って、SKILL付きでCodex / Claude CodeでLFMをファインチューニングします。

このガイドでは、〜の使い方を説明します [Unsloth](https://github.com/unslothai/unsloth) そして [Liquid LFM2.5](/docs/jp/moderu/tutorials/lfm2.5.md) Open Code、Claude Code、Codex のようなコーディングエージェントによる [Claude Code](/docs/jp/ji-chu/claude-code.md)。Unsloth は、標準的な方法と比べて約2倍高速な学習と約60%少ないVRAM使用量を提供します。

### 必要なもの

* ある [Hugging Face](https://huggingface.co) アカウント（HF Jobs に必要）
* 書き込み権限を持つ Hugging Face トークン
* コーディングエージェント（Open Code、Claude Code、Codex）
* こちらをお読みください [Claude Code](/docs/jp/ji-chu/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 プラグインのドキュメント](https://code.claude.com/docs/en/discover-plugins) と [Skills のドキュメント](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 のドキュメント](https://developers.openai.com/codex/skills) と [AGENTS.md ガイド](https://developers.openai.com/codex/guides/agents-md).

### クイックスタート

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

{% code overflow="wrap" %}

```
HF Jobs 上で Unsloth を使って trl-lib/Capybara で LiquidAI/LFM2.5-1.2B-Instruct を学習する
```

{% 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        | 概算コスト/時 |
| ------------- | ------------ | ------- |
| 10億パラメータ未満    | `t4-small`   | \~$0.40 |
| 10億〜30億パラメータ  | `t4-medium`  | \~$0.60 |
| 30億〜70億パラメータ  | `a10g-small` | \~$1.00 |
| 70億〜130億パラメータ | `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 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/deploying-llms-with-hugging-face-jobs.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.
