> 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/zh/xin/studio/chat.md).

# 如何使用 Unsloth Studio 运行模型

使用 Unsloth Studio 在本地运行 AI 模型、LLM 和 GGUF。

[Unsloth Studio](/docs/zh/xin/studio.md) 让你在电脑上 100% 离线运行 AI 模型。可运行 GGUF 和 safetensors 等模型格式，来源于 Hugging Face 或本地文件。

* **适用于所有 MacOS、CPU、Windows、Linux、WSL 环境！无需 GPU**
* [**自我修复式工具调用**](#auto-healing-tool-calling)**,** 高级 [**网页搜索**](#advanced-web-search), [**代码执行**](#code-execution)
* 将 Unsloth 用作与 OpenAI 兼容的推理 [**API 端点**](/docs/zh/ji-chu/api.md) 或连接一个 [提供方](/docs/zh/ji-cheng/connections.md)
* 搜索 + 下载 + 运行 + [比较](#model-arena) 任意模型，如 GGUF、LoRA 适配器、safetensors 等。
* [**自动推理参数**](#auto-parameter-tuning) 调优（temp、top-p 等）并编辑聊天模板
* 上传图片、音频、PDF、代码、DOCX 及更多文件类型，与之聊天。

<figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FVrjsMhR9uLeIlqzD2jAL%2Fqwen37b.gif?alt=media&amp;token=f1bb11b4-d4fa-4765-83b7-bbba563082c9" alt="" width="563"><figcaption></figcaption></figure>

### 使用 Unsloth Studio Chat

{% hint style="success" %}
Unsloth Studio Chat 会自动支持 **多 GPU 配置** 用于推理。
{% endhint %}

{% columns %}
{% column %}

#### 代码执行

Unsloth Studio 让 LLM 不仅能运行 JavaScript，还能运行 Bash 和 Python。它还会像 Claude Artifacts 一样对程序进行沙盒隔离，因此模型可以测试代码、生成文件，并通过真实计算验证答案。

这使模型给出的答案更可靠、更准确。
{% endcolumn %}

{% column %}

<div data-with-frame="true"><figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2Fel6jjv4rUTRCRwcRpIr7%2Flong%20code%20exec.png?alt=media&amp;token=9d3d5930-0fdc-4d97-941c-983e5629296d" alt=""><figcaption></figcaption></figure></div>
{% endcolumn %}
{% endcolumns %}

{% columns %}
{% column %}

#### 自动修复式工具调用

Unsloth Studio 不仅支持 [工具调用](#id-50-tool-calling-accuracy)，并会自动修复格式错误或损坏的工具调用，提升 50% 的修复率。

这意味着你始终会获得推理输出 **而不会出现** 损坏的工具调用。&#x20;

例如，Qwen3.5-4B 搜索了 20+ 个网站并引用了来源，网页搜索发生在其思考轨迹中。
{% endcolumn %}

{% column %}

<div data-with-frame="true"><figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FXPQGEEr1YoKofrTatAKK%2Ftoolcallingif.gif?alt=media&amp;token=25d68698-fb13-4c46-99b2-d39fb025df08" alt=""><figcaption></figcaption></figure></div>
{% endcolumn %}
{% endcolumns %}

{% columns %}
{% column %}

#### 高级网页搜索

Unsloth 提供无限且安全的网页搜索，它会直接访问页面以收集相关信息和数据，而不只是扫描网站摘要。这能提供更准确、更深入的信息和上下文。搜索使用 DuckDuckGo 私密且安全的 API。
{% endcolumn %}

{% column %}

<div data-with-frame="true"><figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FVrjsMhR9uLeIlqzD2jAL%2Fqwen37b.gif?alt=media&amp;token=f1bb11b4-d4fa-4765-83b7-bbba563082c9" alt=""><figcaption></figcaption></figure></div>
{% endcolumn %}
{% endcolumns %}

{% columns %}
{% column %}

#### 将 Unsloth 用作 API 端点

你现在可以通过以下工具使用本地 LLM： [Claude Code](/docs/zh/ji-chu/claude-code.md) 和 [Codex](/docs/zh/ji-chu/codex.md) 通过将其连接到 Unsloth 的 [API 端点](#use-unsloth-as-an-api-endpoint)。这意味着你将能够直接在这些工具中运行 Qwen 和 Gemma 模型，并使用 Unsloth 的推理功能，其中包括自我修复式工具调用、网页搜索等功能。
{% endcolumn %}

{% column %}

<figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2F1s98Id9xclzwMfxjXw2O%2Funsloth%20api%20cropped.png?alt=media&amp;token=64fac263-ca5b-4447-a740-41f58ec94904" alt=""><figcaption></figcaption></figure>
{% endcolumn %}
{% endcolumns %}

{% columns %}
{% column %}

#### 自动推理设置

如以下推理参数： **temperature**, **top-p**, **top-k**, [**MTP**](/docs/zh/mo-xing/qwen3.6.md#mtp-guide) 会为 Qwen3.5 等新模型自动预设，因此你无需担心设置就能获得最佳输出。你也可以手动调整参数并编辑系统提示词。

在 llama.cpp 的智能自动上下文功能下，已无需再调整上下文长度，它只会使用你需要的上下文，而不会额外加载任何内容。
{% endcolumn %}

{% column %}

<div data-with-frame="true"><figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FAQKsjtynvCXKtadvKhq1%2FRecording%202026-03-13%20114257.gif?alt=media&amp;token=b5bfff0c-8189-4358-9344-08d0ae17782a" alt=""><figcaption></figcaption></figure></div>
{% endcolumn %}
{% endcolumns %}

{% columns %}
{% column %}

#### 连接提供方

[Unsloth 可连接](/docs/zh/ji-cheng/connections.md) 到 OpenAI、Anthropic、Ollama、llama.cpp、vLLM 等。

添加 API 密钥或模型服务器 URL，然后在同一个聊天界面中使用外部模型，以及本地 + 云端模型。可使用 [提示缓存](/docs/zh/ji-cheng/connections.md#prompt-caching)、工具调用、思考，以及提供方原生功能，例如 OpenAI 的 [网页搜索](#web-search-and-thinking) 和 [代码执行](#code-execution).
{% endcolumn %}

{% column %}

<div data-with-frame="true"><figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FAQKsjtynvCXKtadvKhq1%2FRecording%202026-03-13%20114257.gif?alt=media&amp;token=b5bfff0c-8189-4358-9344-08d0ae17782a" alt=""><figcaption></figcaption></figure></div>
{% endcolumn %}
{% endcolumns %}

{% columns %}
{% column %}

#### 搜索并运行模型

你可以通过 Hugging Face 搜索并下载任意模型，或使用本地文件。

Unsloth 支持广泛的模型类型，包括 **GGUF**、视觉-语言和文本转语音模型。可运行最新模型，例如 [Qwen3.5](/docs/zh/mo-xing/qwen3.5.md) 或 NVIDIA [Nemotron 3](/docs/zh/mo-xing/nemotron-3.md).

上传图片、音频、PDF、代码、DOCX 及更多文件类型，与之聊天。
{% endcolumn %}

{% column %}

<div data-with-frame="true"><figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FBf3UDywdNSlvCBhUuVsp%2FScreenshot%202026-03-17%20at%2012.34.23%E2%80%AFAM.png?alt=media&amp;token=b6127cbf-76f7-48da-b869-3760ed5e9b42" alt=""><figcaption></figcaption></figure></div>
{% endcolumn %}
{% endcolumns %}

{% columns %}
{% column %}

#### 聊天工作区

输入提示，附加任意文档、图片（webp、png）、代码文件、txt 或音频作为额外上下文，并实时查看模型的回复。

切换开启或关闭：思考 + 网页搜索。
{% endcolumn %}

{% column %}

<div data-with-frame="true"><figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FHlOKWnSB6slhE1EXgAeZ%2Fimage.png?alt=media&amp;token=b5bdfe4e-fe0e-4a2a-9eba-b04b15a79018" alt=""><figcaption></figcaption></figure></div>
{% endcolumn %}
{% endcolumns %}

### **+50% 工具调用准确率**

Unsloth 提供了多项独特功能，可改进工具调用，包括：

* Unsloth 中所有模型的工具调用都 **准确率高出 30% 到 80%**.
* 网页搜索会检索实际网页内容，而不仅仅是摘要。
* 允许的最大工具调用次数为 **超过 25 次。**
* 工具调用终止得更可靠，从而减少循环和重复调用。
* 改进的工具调用修复和去重逻辑有助于防止 XML 泄漏到输出中。

查看以下测试结果： `unsloth/Qwen3.5-4B-GGUF (UD-Q4_K_XL)` 启用网页搜索、代码执行和思考：

| 指标            | 普通工具调用 | Unsloth 工具调用 |
| ------------- | ------ | ------------ |
| 响应中出现 XML 泄漏  | 10/10  | 0/10         |
| 使用的 URL 抓取次数  | 0      | 10 次运行中有 4 次 |
| 使用正确歌曲名称的运行次数 | 0/10   | 2/10         |
| 平均工具调用次数      | 5.5    | 3.8          |
| 平均响应时间        | 12.3s  | 9.8s         |

### 模型竞技场

Unsloth Chat 让你能使用相同的提示词并排比较任意两个模型。例如，比较基础模型和 LoRA 适配器。推理会先加载一个模型，再加载第二个模型（并行推理正在开发中）。

<div data-with-frame="true"><figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FC3xjqlunbpUr7nx6sQ4j%2Fimage.png?alt=media&amp;token=65501d63-1346-4a1e-b055-c94294a24305" alt="" width="563"><figcaption></figcaption></figure></div>

{% columns %}
{% column %}
训练后，你可以使用相同的提示词并排比较基础模型和微调后的模型，看看有哪些变化，以及结果是否有所改进。

这个工作流程能让你轻松看出微调如何改变了模型的回复，以及它是否改善了你的使用场景中的结果。
{% endcolumn %}

{% column %}

<div align="center" data-with-frame="true"><figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FVgnE7eMPQk2vaFboJ4BU%2Fmodel%20arena%20closeup.png?alt=media&amp;token=8b0a910b-440c-4859-a846-0060e61e157b" alt=""><figcaption></figcaption></figure></div>
{% endcolumn %}
{% endcolumns %}

{% hint style="success" %}
Unsloth Studio Chat 会自动运行于 **多 GPU 配置** 用于推理。
{% endhint %}

### 使用旧的 / 现有的 GGUF 模型

{% columns %}
{% column %}
**4 月 1 日更新：** 你现在可以选择一个现有文件夹，让 Unsloth 从中检测。

**3 月 27 日更新：** Unsloth Studio 现在 **会自动检测较旧 / 预先存在的模型** 这些模型可来自 Hugging Face、LM Studio 等下载。
{% endcolumn %}

{% column %}

<div data-with-frame="true"><figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FBn3Fs1cchFchl328wSOs%2FScreenshot%202026-04-05%20at%205.43.57%E2%80%AFAM.png?alt=media&amp;token=cc57ec6e-653a-4824-8e8d-a6bfbcd27493" alt=""><figcaption></figcaption></figure></div>
{% endcolumn %}
{% endcolumns %}

**手动说明：** Unsloth Studio 会检测下载到你的 Hugging Face Hub 缓存中的模型 `(C:\Users{your_username}.cache\huggingface\hub)`。如果你通过 LM Studio 下载了 GGUF 模型，请注意它们存储在 `C:\Users\{your_username}.cache\lm-studio\models` ***或*** `C:\Users{your_username}\lm-studio\models` 中，并且默认情况下 llama.cpp 无法看到它们——你需要将这些 .gguf 文件移动或复制到你的 Hugging Face Hub 缓存目录（或另一个 llama.cpp 可访问的路径）中，Unsloth Studio 才能加载它们。

在 Unsloth 中对模型或适配器完成微调后，你可以将其导出为 GGUF，并使用 **llama.cpp** 直接在 Unsloth Chat 中运行。Unsloth Studio 由 llama.cpp 和 Hugging Face 提供支持。

### 将文件添加为上下文

Unsloth Chat 直接在对话中支持多模态输入。你可以附加文档、图片或音频，作为提示的额外上下文。

<div data-with-frame="true"><figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FSitddQpGkOwUvirMem5P%2Fimage.png?alt=media&amp;token=43b7af91-ea86-4279-a787-b4b444640d82" alt="" width="563"><figcaption></figcaption></figure></div>

这使得测试模型如何处理真实世界输入变得很容易，例如 PDF、截图或参考资料。文件会在本地处理，并作为上下文提供给模型。

### **删除模型文件**

你可以通过模型搜索中的垃圾桶图标删除旧模型文件，或者从默认的 Hugging Face 缓存目录中移除相关的缓存模型文件夹。默认情况下，Hugging Face 使用 `~/.cache/huggingface/hub/` 在 macOS/Linux/WSL 上，以及 `C:\Users\<username>\.cache\huggingface\hub\` 在 Windows 上。

* **MacOS、Linux、WSL：** `~/.cache/huggingface/hub/`
* **Windows：** `%USERPROFILE%\.cache\huggingface\hub\`

如果 `HF_HUB_CACHE` 或 `HF_HOME` 已设置，则使用该位置。在 Linux 和 WSL 上， `XDG_CACHE_HOME` 也可以更改默认缓存根目录。

### **Unsloth 未检测到或未使用我的 GPU**

如果模型在 Docker 中没有使用你的 GPU，可以尝试：

手动拉取最新镜像：

```bash
 docker pull unsloth/unsloth:latest
```

* 启动带有 GPU 访问权限的容器：
  * `docker run`: `--gpus all`
  * Docker Compose： `capabilities: [gpu]`
* 在 Linux 上，请确保已安装 NVIDIA Container Toolkit。
* 在 Windows 上：
  * 检查 `nvcc --version` 是否与以下位置显示的 CUDA 版本一致： `nvidia-smi`
  * 请参阅： <https://docs.docker.com/desktop/features/gpu/>


---

# 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/zh/xin/studio/chat.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.
