> 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/tong-he/vs-codederkaruaimoderuwosuru.md).

# VS CodeでローカルAIモデルを実行する方法

VS CodeでローカルLLMを実行する方法

このガイドでは、Unsloth で動作するローカルモデルを VS Code の Copilot Chat に接続する方法を説明します。Unsloth がモデルを読み込み提供し、VS Code はチャットインターフェースとコーディング用ツールを提供します。

コードについてチャットしたり、質問したり、ツール呼び出しに対応したモデルを使って Agent モードでファイルを作成・編集したりできます。

### VS Code をインストールする

{% tabs %}
{% tab title="macOS" %}
{% stepper %}
{% step %}

#### VS Code をダウンロード

以下を開き、 [VS Code のダウンロードページ](https://code.visualstudio.com/download) Mac 用の macOS 版をダウンロードします。次のいずれかを選択してください。 **Apple シリコン**, **Intel**、または **Universal** 迷う場合はこれを選んでください。
{% endstep %}

{% step %}

#### VS Code をセットアップする

ダウンロードした `.zip` ファイルを開き、次に **Visual Studio Code.app** を **アプリケーション** フォルダにドラッグします。

その後、開くには **アプリケーション** へ移動して **Visual Studio Code**.
{% endstep %}
{% endstepper %}
{% endtab %}

{% tab title="Windows" %}
{% stepper %}
{% step %}

#### VS Code をダウンロード

以下を開き、 [VS Code のダウンロードページ](https://code.visualstudio.com/download) をダウンロードし、Windows **ユーザーインストーラー** をお使いのデバイス用にダウンロードします。ほとんどのPCでは **x64**.
{% endstep %}

{% step %}

#### VS Code をセットアップする

ダウンロードした `.exe` ファイルを使用し、インストーラーの指示に従います。

その後、開くにはスタートメニューを開いて **Visual Studio Code**を検索し、起動します。

インストール中にターミナルを開いていた場合は、閉じてから再度開き、更新された PATH を反映してください。
{% endstep %}
{% endstepper %}
{% endtab %}

{% tab title="Linux" %}
{% stepper %}
{% step %}

#### VS Code をダウンロード

以下を開き、 [VS Code のダウンロードページ](https://code.visualstudio.com/download) を選び、ディストリビューションに合ったパッケージを選択します:

* **Ubuntu または Debian:** `.deb`
* **Fedora または RHEL:** `.rpm`
  {% endstep %}

{% step %}

#### VS Code をセットアップする

ダウンロードしたファイルがあるフォルダでターミナルを開き、次を実行します:

**Ubuntu または Debian:**

```bash
sudo apt install ./code_*.deb
```

**Fedora または RHEL:**

```bash
sudo dnf install ./code-*.rpm
```

その後、起動するにはアプリケーションランチャーを開き、 **Visual Studio Code**を検索し、起動します。
{% endstep %}
{% endstepper %}
{% endtab %}
{% endtabs %}

### ⚡ クイックスタート

VS Code のインストール後、 [Unsloth Desktop](/docs/jp/desktop.md) をインストールして、VS Code がローカルモデルを提供・推論実行できるようにします。

{% stepper %}
{% step %}

#### Unsloth をダウンロード

最も簡単に始める方法は、Unsloth Desktop アプリをインストールすることです。次をサポートしています。 [MacOS](/docs/jp/meru/install/mac.md)、Linux、 [Windows](/docs/jp/meru/install/windows-installation.md), [NVIDIA](/docs/jp/meru/install/pip-install.md), [AMD](/docs/jp/meru/install/amd.md)、Intel および CPU 構成。

<a href="https://unsloth.ai/download" class="button primary" data-icon="down-to-bracket">Unsloth をダウンロード</a>

* <i class="fa-apple">:apple:</i> [macOS 用をダウンロード](https://unsloth.ai/download/mac)
* <i class="fa-windows">:windows:</i> [Windows 用をダウンロード](https://unsloth.ai/download/windows)
* <i class="fa-linux">:linux:</i> [Linux 用をダウンロード](https://unsloth.ai/download/linux)

または、手動インストールを希望する場合:

{% tabs %}
{% tab title="ネイティブインストール" %}
**MacOS、Linux、WSL:**

```bash
curl -fsSL https://unsloth.ai/install.sh | sh
```

**Windows:**

```powershell
irm https://unsloth.ai/install.ps1 | iex
```

{% endtab %}

{% tab title="Docker" %}
その [UnslothのDockerイメージ](https://hub.docker.com/r/unsloth/unsloth) `unsloth/unsloth` Dockerで利用できます。 [ガイドを読む。](https://unsloth.ai/docs/get-started/install/docker)
{% endtab %}

{% tab title="Homebrew" %}
Unsloth Desktopをインストール:

{% code collapsedlinecount="10" %}

```bash
brew install --cask unsloth
```

{% endcode %}

Unsloth Desktopを更新:

```bash
brew upgrade --cask unsloth
```

{% endtab %}

{% tab title="WinGet" %}
Unsloth Desktopをインストール:

```powershell
winget install --id UnslothAI.Unsloth -e
```

Unsloth Desktopを更新:

```powershell
winget upgrade --id UnslothAI.Unsloth -e
```

{% endtab %}
{% endtabs %}
{% endstep %}

{% step %}

#### インストール

1. Unsloth インストーラー（`.dmg`, `.exe` ファイル）を開きます。
2. Mac では Unsloth をアプリケーションにドラッグするか、Windows ではセットアップを完了します。
3. アプリを起動し、インストールが完了するのを待ちます
   {% endstep %}

{% step %}

#### モデルを選ぶ

上部の「モデルを選択」ドロップダウンまたは「Model hub」タブを開き、デバイスに合ったモデルと量子化を選んでダウンロードします。完了したら、そのままチャットを始められます。セットアップは不要です。

<figure><img src="https://735611837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FNCEVgKLJI0goPqjgcg9B%2Fmodel%20hub%20models.png?alt=media&amp;token=533b5e3c-a901-4b33-963e-4a703cc9d5a6" alt="" width="563"><figcaption></figcaption></figure>
{% endstep %}

{% step %}

#### これで Unsloth の準備ができました

モデルが Unsloth に読み込まれたら、ターミナルで次を実行します:

```bash
unsloth start vscode
```

開く **Copilot Chat** を VS Code で開き、 **Unsloth** のモデルピッカーで自分のモデルを選択します。メッセージを送って接続を確認してください。

モデルを使っている間は、Unsloth を起動したままにしてください。

<figure><img src="https://735611837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FpAGvwjGD0iVMZKBoyu7m%2Fgreeennn.png?alt=media&amp;token=d17a5528-8375-444c-9aff-f9e9f7903bcd" alt="" width="563"><figcaption></figcaption></figure>
{% endstep %}
{% endstepper %}

### 🔌 モデルを接続する

Unsloth にモデルが読み込まれた状態で、ターミナルを開いて次を実行します:

```bash
unsloth start vscode
```

これにより、Unsloth が現在提供しているモデルが VS Code のモデルピッカーに追加されます。接続が構成されます。VS Code がまだ起動していない場合は、別途開いてください。

モデルを読み込み、同時に VS Code を構成することもできます:

```bash
unsloth start vscode --model unsloth/Qwen3.8-27B-GGUF:UD-Q4_K_XL --context-length 32768
```

別のモデルを使いますか？モデル ID を希望のものに置き換えてください。ローカルの GGUF ファイルを指定することもできます:

```bash
unsloth start vscode --model "/path/to/model.gguf" --context-length 32768
```

このコマンドは接続を自動で設定し、他のモデルを保持したまま、VS Code のモデル設定をバックアップします。

また、次の名前の API キーも作成されます **VS Code**。取り消すには、Unsloth の **設定** を開き、 **API**.

### <i class="fa-vscode">:vscode:</i> VS Code でローカルモデルを使う

VS Code でプロジェクトフォルダを開くか、試しに空のフォルダを開いてみてください。

開く **Copilot Chat**、チャット入力欄の下にあるモデルピッカーをクリックし、 **Unsloth**の下から自分のモデルを選択します。 **エージェント** を選んでファイルの作成・編集を任せるか、 **Ask** を選んでコードについてチャットします。

<div data-with-frame="true"><figure><img src="https://735611837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2Fdimfm9IrGcW4PK2OFNan%2Fimage.png?alt=media&amp;token=6ab59f12-9fdf-4e08-82fc-e52dbe70f375" alt="" width="563"><figcaption></figcaption></figure></div>

Agent モードにはツール呼び出しのサポートが必要です。少なくとも **32Kコンテキスト**.

シンプルなゲームを作ってみましょう。次のプロンプトを試してください:

{% code overflow="wrap" %}

```
単一の index.html ファイルで遊べる Snake ゲームを作成してください。

矢印キーで移動できるようにし、スコアを表示し、再開ボタンを追加してください。

明るい背景に鮮やかな緑のヘビを使ってください。HTML、CSS、JavaScript を使用し、外部依存はなしでお願いします。
```

{% endcode %}

{% columns %}
{% column %}
承認する前に、ツール権限を確認してください。エージェントが `index.html`を作成したら、ブラウザで開いて遊んでください。

何か変更したいですか？難易度レベルやハイスコア記録を追加するよう依頼してみてください。

作業中はモデルを読み込んだまま、Unsloth サーバーを起動したままにしてください。
{% endcolumn %}

{% column %}

<div data-with-frame="true"><figure><img src="https://735611837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2F7CYu4PotqktrbwiRXkPP%2Fwormgif.gif?alt=media&amp;token=08dbd04f-c6a4-48ea-986a-428131c8e970" alt="" width="375"><figcaption></figcaption></figure></div>

{% endcolumn %}
{% endcolumns %}

モデルが表示されない場合は、 **モデルの管理** をモデルピッカーで確認してください。また、次を実行して VS Code を更新することもできます `Developer: Reload Window` をコマンドパレットから。

#### モデルを切り替える

Unsloth で別のモデルを読み込んでから、次を実行します:

```bash
unsloth start vscode
```

新しいモデルを **Unsloth** Copilot Chat で選択してください。

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

**モデルが表示されません**

開く **モデルの管理** をモデルピッカーで確認し、 **Unsloth**を探してください。見つからない場合は、GitHub Copilot Chat が有効になっていることを確認してから、 `unsloth start vscode` をもう一度実行してください。

それでも表示されない場合は、コマンドパレットを開いて **Developer: Reload Window**.

**Ask には表示されるが Agent モードには表示されない**

Agent モードにはツール呼び出しのサポートが必要です。 **Ask** をこのモデルで使うか、チャットテンプレートがツールをサポートする別のモデルに切り替えてください。

**コンテキスト長エラーが出ます**

Agent の指示とツールは、モデルのコンテキストウィンドウの一部を使用します。少なくとも **32Kコンテキスト** を Agent モードに推奨します。

下のパスを GGUF ファイルに置き換えて、次を実行してください:

{% code overflow="wrap" %}

```bash
unsloth start vscode --model "/path/to/model.gguf" --context-length 32768
```

{% endcode %}

モデルの詳細が更新されていない場合は VS Code を再読み込みしてください。32,768 トークンが **33K**.

#### Unsloth がリモートマシンで動作しています

VS Code のユーザーディレクトリがない SSH またはコンテナセッションでは、このコマンドはローカルに追加する構成と接続手順を出力します。

出力された手順に従ってサーバーを自分のコンピュータから到達可能にし、その後、ローカルの VS Code インストールに構成を追加してください。

リモートの VS Code、WSL、または dev container ウィンドウでモデルが表示されない場合は、 **ローカルの VS Code ウィンドウ** を、リモートの Unsloth サーバーに接続してみてください。

その他のモデル読み込みオプションやリモート接続設定については、 [Unsloth Start ガイド](https://unsloth.ai/docs/integrations/unsloth-start).


---

# 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/tong-he/vs-codederkaruaimoderuwosuru.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.
