> ## Documentation Index
> Fetch the complete documentation index at: https://docs.monostate.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# 加载模型

> 将训练好的模型加载到聊天界面

# 加载模型

聊天界面可以从本地路径或 Hugging Face 加载模型。

## 加载本地模型

使用 AITraining 训练后，您的模型会保存在本地。要加载它：

1. 找到您的模型路径（例如：`./my-project/`）
2. 在模型选择器中输入路径
3. 点击 "Load Model"

```
Model path: ./my-project
```

### 需要查找的内容

您训练好的模型目录应包含：

* `config.json` - 模型配置
* `model.safetensors` 或 `pytorch_model.bin` - 模型权重
* `tokenizer.json` 和相关 tokenizer 文件

## 从 Hugging Face 加载

从 Hugging Face Hub 加载任何兼容的模型：

```
Model path: meta-llama/Llama-3.2-1B
```

热门模型：

* `meta-llama/Llama-3.2-1B` - 小型、快速的 Llama
* `mistralai/Mistral-7B-v0.1` - 高效的 7B 模型
* `google/gemma-2b` - Google 的 Gemma

<Note>
  大型模型需要大量 GPU 内存。7B 模型需要 \~14GB VRAM。
</Note>

## 加载 LoRA 适配器

PEFT/LoRA 模型会被**自动检测**并正确加载。只需提供适配器目录的路径：

```
Model path: ./my-lora-model
```

聊天界面会自动：

1. 检测 `adapter_config.json` 文件
2. 加载适配器配置中指定的基础模型
3. 应用 LoRA 适配器

<Tip>
  如果您使用 `--merge-adapter`（默认）进行训练，您的模型已经合并，可以像任何标准模型一样加载。
</Tip>

## 内存要求

| 模型大小 | 大约 VRAM |
| ---- | ------- |
| 1B   | \~2GB   |
| 3B   | \~6GB   |
| 7B   | \~14GB  |
| 13B  | \~26GB  |

<Tip>
  使用量化模型 (int4/int8) 可将内存减少 2-4 倍。
</Tip>

## 切换模型

要切换到不同的模型：

1. 输入新的模型路径
2. 点击 "Load Model"
3. 之前的模型会被卸载

注意：切换模型时，对话历史会被清除。

## 故障排除

<AccordionGroup>
  <Accordion title="找不到模型">
    检查：

    * 路径是否正确且存在
    * 对于 HuggingFace 模型，检查模型 ID
    * 确保您有访问权限（某些模型需要身份验证）
  </Accordion>

  <Accordion title="内存不足">
    尝试：

    * 更小的模型
    * 量化版本
    * 关闭其他使用 GPU 的应用程序
  </Accordion>

  <Accordion title="加载缓慢">
    首次加载会下载模型权重。后续加载会更快。
    大型模型 (7B+) 需要 30-60 秒加载。
  </Accordion>
</AccordionGroup>

## 下一步

<CardGroup cols={2}>
  <Card title="对话" href="/chat/conversation">
    开始聊天
  </Card>

  <Card title="参数" href="/chat/parameters">
    调整生成设置
  </Card>
</CardGroup>
