> 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/ji-cheng/hermes-agent.md).

# 如何使用 Hermes Agent 运行本地 AI 模型

在本地使用 Hermes Agent 运行开源 LLM 的指南。

本指南可让你使用以下工具在本地运行开源 LLM： **Hermes Agent** 的形式通过 [**Unsloth**](https://github.com/unslothai/unsloth)。Nous Research 的 Hermes Agent 是一个 **开源** 可自主运行的 AI 代理，可连接到模型端点、执行任务，并通过记忆和学习到的技能不断改进。

{% columns %}
{% column width="58.333333333333336%" %}
Hermes 可与任何 **本地模型** 通过 Unsloth 的 **兼容 OpenAI 的 API**，包括：DeepSeek、Qwen、Gemma 等。Hermes 充当代理客户端，而 Unsloth 通过 [本地 API](/docs/zh/ji-chu-zhi-shi/api.md) 完全离线地加载并提供模型服务。

设置完成后，所有通过 Hermes 发送的提示词都会使用你设备上的本地模型运行。
{% endcolumn %}

{% column width="41.666666666666664%" %}

<figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FYhiTzkyz0fVPMxIfWg6D%2FScreenshot_20260718_122219.png?alt=media&amp;token=a8063d58-0d49-467a-aa2a-35b30c448390" alt=""><figcaption><p>通过 Unsloth 在 Hermes 中本地运行的 Qwen3.5。</p></figcaption></figure>
{% endcolumn %}
{% endcolumns %}

<a href="https://unsloth.ai/docs/integrations/hermes-agent#setup-hermes-agent" class="button primary" data-icon="caduceus">设置 Hermes</a><a href="https://unsloth.ai/docs/integrations/hermes-agent#integrate-hermes-with-unsloth-api" class="button primary">🦥 连接你的本地模型</a>

{% hint style="info" %}
在本教程中，你将安装 Hermes 并将其配置为使用 `unsloth/Qwen3.6-27B-GGUF` 由 Unsloth 提供服务的模型。想用别的模型？只需在 Unsloth 中加载另一个模型并更新配置即可替换。
{% endhint %}

### <i class="fa-caduceus">:caduceus:</i> 设置 Hermes Agent

**前提条件：**

该 [Hermes](https://github.com/NousResearch/hermes-agent/blob/main/website/docs/getting-started/installation.md) 命令行安装程序支持 Linux、macOS 和 WSL2。请确保 **Git** 已安装；在 Linux 上，还需安装 **curl** 和 **xz-utils**。安装程序会自动配置 `uv`、Python 3.11、Node.js 22、 `ripgrep`，以及 `ffmpeg`.

#### 1. 运行安装程序

```bash
curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash
```

安装程序会：

* 检测你的平台并检查依赖项。
* 将 Hermes 克隆到 `~/.hermes/hermes-agent/`.
* 创建 Python 虚拟环境并安装 Python 依赖。
* 安装浏览器工具依赖和 Playwright 的 Chromium 引擎。
* 添加 `hermes` 命令并启动设置向导。

{% columns %}
{% column %}
Playwright 可能会请求 `sudo` 以安装 Chromium 的共享系统库。Hermes 本身不需要 root 权限。
{% endcolumn %}

{% column %}

<figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FnabBNaHLvb1rH58cQwyC%2FScreenshot%202026-07-18%20at%205.31.57%E2%80%AFAM.png?alt=media&amp;token=4ac35864-89aa-45ce-84db-ad5b17f8b3e5" alt="" width="375"><figcaption></figcaption></figure>
{% endcolumn %}
{% endcolumns %}

#### **2. 重新加载你的 shell** 这样 `hermes` 命令就会位于你的 `PATH`:

{% code title="bash" %}

```bash
source ~/.bashrc
```

{% endcode %}

{% code title="zsh" %}

```bash
source ~/.zshrc
```

{% endcode %}

#### **3. 验证安装：**

```bash
hermes --version
```

如果命令可解析，说明 Hermes 已安装。一切内容都位于 `~/.hermes/`:

| 路径                                      | 内容                      |
| --------------------------------------- | ----------------------- |
| `~/.hermes/config.yaml`                 | 主要设置（模型、提供方、工具、TTS 等）   |
| `~/.hermes/.env`                        | API 密钥和其他机密信息           |
| `~/.hermes/hermes-agent/`               | Hermes 源码 + 虚拟环境        |
| `~/.hermes/cron/`, `sessions/`, `logs/` | 运行时数据                   |
| `~/.hermes/skills/`                     | 已安装的技能（从 Skills Hub 同步） |

{% hint style="info" %}
完整安装参考： [hermes-agent.nousresearch.com/docs/getting-started/installation](https://hermes-agent.nousresearch.com/docs/getting-started/installation)。如果安装程序报告缺少前提条件，请安装它并重新运行该一行命令。安装程序是幂等的。
{% endhint %}

### ⚡ 快速开始

安装 Hermes 后，我们需要安装 Unsloth Desktop，以便让 Hermes 提供本地模型服务并进行推理。

{% stepper %}
{% step %}

#### 下载 Unsloth

最简单的开始方式是安装 [Unsloth Desktop](/docs/zh/desktop.md) 应用。它支持 [MacOS](/docs/zh/kuai-su-kai-shi/install/mac.md)、Linux、 [Windows](/docs/zh/kuai-su-kai-shi/install/windows-installation.md), [NVIDIA](/docs/zh/kuai-su-kai-shi/install/pip-install.md), [AMD](/docs/zh/kuai-su-kai-shi/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)

或者，如果你更喜欢手动安装：

**MacOS、Linux、WSL：**

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

**Windows PowerShell：**

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

{% endstep %}

{% step %}

#### 安装

1. 打开 Unsloth 安装程序（`.dmg`, `.exe` 文件）
2. 在 Mac 上将 Unsloth 拖到 Applications，或在 Windows 上完成安装。
3. 启动应用并等待安装完成
   {% endstep %}

{% step %}

#### 选择模型

打开顶部的“选择模型”下拉菜单或“模型中心”选项卡，选择适合你设备的模型和量化方式，然后下载。完成后就可以开始聊天——无需额外设置。

<figure><img src="https://2657992854-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 现在已准备就绪

要开始聊天，请输入消息并按 Enter。

**连接 Hermes。** 运行 `unsloth start hermes` 在 Unsloth 打开时，在你的终端中运行。它会生成 API 密钥、写入配置，并让 Hermes 针对你加载的模型启动。

<figure><img src="https://2657992854-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 %}

### ⚡ 使用以下方式运行 Hermes Agent： `unsloth start`

要直接使用某个模型启动 Hermes，请运行：

```bash
unsloth start hermes \
    --model unsloth/Qwen3.8-27B-GGUF-GGUF:UD-Q4_K_XL
    --temp 1.0 \
    --top-p 0.95 \
    --top-k 20 \
    --min-p 0.0 \
    --reasoning-effort medium
```

{% hint style="success" %}
如果未设置任何参数/采样标志，Unsloth 会自动为该模型选择最佳/推荐设置，包括上下文长度、温度等。
{% endhint %}

在 Unsloth Studio 中加载模型后，运行：

```bash
unsloth start hermes
```

<figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FOaFdKwRASHSoxDQx06l5%2FScreenshot_20260714_152023.png?alt=media&amp;token=c7e13fb2-e03e-49d1-8efa-f7494578943a" alt="Hermes Agent connected to a local model through Unsloth Studio"><figcaption><p>通过其 Unsloth Studio 提供方运行的 Hermes Agent。</p></figcaption></figure>

Unsloth 会从一个单独管理的主目录启动 Hermes，其中已预先配置好 Unsloth 提供方、模型和上下文设置。你现有的 Hermes 配置不会被更改。

默认情况下，这个受管理的主目录是临时的。若要保留你的会话和状态，请添加 `--persist` 从首次启动开始：

```bash
unsloth start hermes --persist
```

之后若要返回到你最近的会话，请运行：

```bash
unsloth start hermes --persist --continue
```

若要重新打开特定会话，请使用 `--resume <session-id-or-title>` 代替。

查看完整的 [unsloth start](/docs/zh/ji-cheng/unsloth-start.md) 用于模型选择、远程连接和高级选项的参考。

如果你更愿意自行管理 Hermes 提供方，下面的设置向导仍然可用。

### 🔑 创建 API 密钥

1. 打开侧边栏，点击左下角的 **Unsloth** 头像。
2. 转到 **设置** → **API**.
3. 输入一个友好的名称（例如 `hermes-agent-macbook`).
4. *（可选）* 设置过期时间。
5. 点击 **创建**.
6. **立即复制密钥。** Unsloth 只会存储哈希值，你将无法再次查看它。

<figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FrWnqY5PgvZdbWK8pmlD5%2Fimage.png?alt=media&amp;token=3507e7d7-b552-447f-b503-2418802b8f6e" alt="" width="375"><figcaption></figcaption></figure>

所有密钥都以 `sk-unsloth-` 前缀开头。你可以随时在同一页面撤销某个密钥。使用被撤销密钥发出的请求将会返回 `401 Unauthorized`.

### 🦥 将 Hermes 与 Unsloth API 集成

Hermes 会将每一轮聊天发送到已配置的推理提供方，并连接到 **兼容 OpenAI 的** 端点。可在安装期间或稍后通过设置向导配置提供方。

**1. 打开设置向导：**

{% columns %}
{% column %}

```bash
hermes setup
```

选择 **模型与提供方** 在“您想做什么？”菜单中选择，仅配置推理端点，或者 **完整设置** 来逐步完成全部内容（TTS、工具、消息网关、代理设置）。
{% endcolumn %}

{% column %}

<figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FChF6By1Dl44hVQl63kGW%2FScreenshot%202026-07-18%20at%205.34.39%E2%80%AFAM.png?alt=media&amp;token=371a287e-1264-47d2-af3e-fa3ed302e038" alt="" width="539"><figcaption></figcaption></figure>
{% endcolumn %}
{% endcolumns %}

**2. 选择自定义兼容 OpenAI 的端点** 当 Hermes 提示你选择推理提供方时。

<figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FA5VVaVsL7GzZGq9Dn3Bt%2Fhermes_agent_setup_2.png?alt=media&amp;token=a234d29d-14f6-431f-be1f-9a4e14f5951d" alt="" width="563"><figcaption></figcaption></figure>

**3. 填写提示项** ，按 Hermes 的引导逐一填写：

| 提示项                  | 值                                                    |
| -------------------- | ---------------------------------------------------- |
| **API 基础 URL**       | `http://localhost:8888/v1` *（你的 Unsloth 端口 + `/v1`)* |
| **API 密钥**           | 你的 `sk-unsloth-…` 密钥                                 |
| **检测到的模型：…使用此模型吗？**  | `Y` *（Hermes 通过以下方式自动检测模型： `GET /v1/models`)*        |
| **上下文长度（以 token 计）** | *（留空以自动检测）*                                          |
| **显示名称**             | 任意你喜欢的名称，例如 `unsloth-api`                            |

Hermes 会根据 `/v1/models` 验证端点，并在继续之前确认检测到的模型。

<figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FehQjrLJ0ztoSdNp94dfH%2Fhermes_agent_setup_3.png?alt=media&amp;token=641c6e6a-44c3-4013-8c08-32472b256283" alt=""><figcaption></figcaption></figure>

**4. 对其余提示接受默认值** （TTS、工具、消息网关、代理设置）你之后都可以重新配置。Hermes 会将所有内容写入 `~/.hermes/config.yaml` 和 `~/.hermes/.env`.

<figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FWbj2YWKpXw9T2jR0QQjh%2Fhermes_agent_setup_5.png?alt=media&amp;token=59985534-69e3-46ec-8ab9-1db8829c1721" alt=""><figcaption></figcaption></figure>

**5. 启动 Hermes：**

```bash
hermes
```

启动横幅会在状态栏中显示你的 Unsloth 模型名称（例如 `unsloth/Qwen3.6-27B-GGUF`），提示符已准备好接收输入。

<figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FU8UlRyw9n1SrENvZXSjD%2Fhermes_unsloth_run.png?alt=media&amp;token=6fd14920-a287-4aed-815e-33b7e4d09c68" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
之后若只想重新配置模型，请运行 `hermes setup model`。若要直接编辑配置文件， `hermes config edit` 会打开 `~/.hermes/config.yaml` 在你的 `$EDITOR`.
{% endhint %}

### 可选：调整 Unsloth 服务器

`unsloth run` 会启动本地 API 服务器并加载一个模型供你的应用连接。你也可以在启动时自定义服务器的行为。

```bash
# 提供 Hermes 服务（--disable-tools 会透传代理自身的工具）
unsloth run \
  --model unsloth/gemma-4-26B-A4B-it-GGUF \
  --disable-tools \
  --reasoning off \
  -p 8888
```

{% hint style="warning" %}
使用 `--disable-tools` 在驱动 Hermes（或任何带有自身工具的外部代理）时。默认情况下，Unsloth Studio 会运行其自己的服务器端工具，这会吞掉代理的工具调用，因此 Hermes 只会回答，但不会运行其工具。 `--disable-tools` 会切换为直通模式，因此会使用 Hermes 自己的工具。
{% endhint %}

使用 `--reasoning off` 用于关闭思考，或使用 `--reasoning on` 为支持推理的模型开启它。

```bash
# 在你的本地网络上公开 API
unsloth run \
  --model unsloth/gemma-4-26B-A4B-it-GGUF \
  -H 0.0.0.0 \
  -p 8888
```

这将在 `0.0.0.0:8888`上启动服务器，允许本地网络上的其他设备连接。 `-p` 会更改服务器运行的端口。如果你希望手机、笔记本电脑或网络上的其他设备连接到 API 服务器，请使用以下方式启动： `-H 0.0.0.0`.

某些应用仍可能为单个请求覆盖生成设置。有关更高级的运行时配置，请参阅主要 [API 调优](https://unsloth.ai/docs/basics/api#unsloth-run-command) 部分。


---

# 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/ji-cheng/hermes-agent.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.
