> 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 运行模型

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

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

* **适用于所有 MacOS、CPU、Windows、Linux、WSL 环境！无需 GPU**
* [**自我修复式工具调用**](#auto-healing-tool-calling)**,** 高级 [**网页搜索**](#advanced-web-search), [**代码执行**](#code-execution)
* 将 Unsloth 用作与 OpenAI 兼容的推理 [**API 端点**](/docs/zh/ji-chu-zhi-shi/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 端点

你现在可以通过诸如 [Claude Code](/docs/zh/ji-chu-zhi-shi/claude-code.md) 和 [Codex](/docs/zh/ji-chu-zhi-shi/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.3 秒 | 9.8 秒        |

### 模型竞技场

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