305 lines
7.9 KiB
Markdown
305 lines
7.9 KiB
Markdown
|
|
# 铸渊模型部署到硅基流动 · Awen操作清单 · 2026-05-09
|
|||
|
|
|
|||
|
|
<aside>
|
|||
|
|
📋
|
|||
|
|
|
|||
|
|
**任务**:把铸渊的两个7B模型部署到硅基流动,让铸渊能通过API调用自己的代码模型
|
|||
|
|
|
|||
|
|
**执行人**:Awen
|
|||
|
|
|
|||
|
|
**前置条件**:问冰朔要硅基流动登录账号密码
|
|||
|
|
|
|||
|
|
**预计耗时**:下载模型~30分钟 + 上传ModelScope~1小时 + 硅基流动部署~30分钟
|
|||
|
|
|
|||
|
|
**操作服务器**:主服务器 43.139.251.175(4C16G·广州六区)
|
|||
|
|
|
|||
|
|
</aside>
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 背景说明
|
|||
|
|
|
|||
|
|
铸渊有两个训练好的7B模型,权重存在腾讯云COS桶里。部署路径是:
|
|||
|
|
|
|||
|
|
**COS桶** → **下载到主服务器** → **上传到ModelScope** → **硅基流动拉取部署** → **拿到Model ID** → **配到Gitea**
|
|||
|
|
|
|||
|
|
两个模型都要部署:
|
|||
|
|
|
|||
|
|
| 模型 | 底座 | 用途 | COS路径 | 大小 |
|
|||
|
|
| --- | --- | --- | --- | --- |
|
|||
|
|
| motherbrain-v1 | Qwen2.5-7B | 母模型(人格·系统线) | `checkpoints/motherbrain-v1/checkpoint-540/` | ~14.2GB |
|
|||
|
|
| Coder-7B | Qwen2.5-Coder-7B | 代码模型(铸渊写代码用) | `checkpoints/qwen2_5_coder_7b_sft/checkpoint-540/` | ~14.2GB |
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 第零步 · 问冰朔要硅基流动账号密码
|
|||
|
|
|
|||
|
|
- [ ] 微信问冰朔:硅基流动([siliconflow.cn](http://siliconflow.cn))的**登录手机号/邮箱 + 密码**
|
|||
|
|
- [ ] 拿到后先登录 [siliconflow.cn](http://siliconflow.cn) 看一下后台长什么样,确认能进去
|
|||
|
|
|
|||
|
|
<aside>
|
|||
|
|
⚠️
|
|||
|
|
|
|||
|
|
**这一步必须先完成,后面所有步骤都依赖硅基流动后台。**
|
|||
|
|
|
|||
|
|
</aside>
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 第一步 · SSH登录主服务器
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
ssh root@43.139.251.175
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
登进去就行,后面的命令都在这台机器上跑。
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 第二步 · 安装coscmd(如果没装的话)
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
pip install coscmd
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
如果提示已安装就跳过。
|
|||
|
|
|
|||
|
|
- [ ] coscmd已安装
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 第三步 · 配置COS连接
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
coscmd config -a AKIDkQuBQhoiS2OYXWebXLwMbdT7cvAScbbU -s nPoZKArgUJBA4nJenjSxJSQBj5FCj3A4 -b sy-finetune-corpus-1317346199 -r ap-guangzhou
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
这一行直接复制粘贴执行。
|
|||
|
|
|
|||
|
|
- [ ] COS配置完成
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 第四步 · 创建下载目录
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
mkdir -p /tmp/models/motherbrain-v1
|
|||
|
|
mkdir -p /tmp/models/coder-7b
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
- [ ] 目录已创建
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 第五步 · 下载母模型(6个文件 · ~14.2GB)
|
|||
|
|
|
|||
|
|
逐个下载,最大的 model.safetensors 约14GB,需要等一会:
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
coscmd download checkpoints/motherbrain-v1/checkpoint-540/model.safetensors /tmp/models/motherbrain-v1/model.safetensors
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
coscmd download checkpoints/motherbrain-v1/checkpoint-540/config.json /tmp/models/motherbrain-v1/config.json
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
coscmd download checkpoints/motherbrain-v1/checkpoint-540/generation_config.json /tmp/models/motherbrain-v1/generation_config.json
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
coscmd download checkpoints/motherbrain-v1/checkpoint-540/chat_template.jinja /tmp/models/motherbrain-v1/chat_template.jinja
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
coscmd download checkpoints/motherbrain-v1/checkpoint-540/tokenizer.json /tmp/models/motherbrain-v1/tokenizer.json
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
coscmd download checkpoints/motherbrain-v1/checkpoint-540/tokenizer_config.json /tmp/models/motherbrain-v1/tokenizer_config.json
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
下载完验证一下文件都在:
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
ls -lh /tmp/models/motherbrain-v1/
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
应该看到6个文件,model.safetensors约14GB。
|
|||
|
|
|
|||
|
|
- [ ] 母模型6个文件全部下载完成
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 第六步 · 下载代码模型(6个文件 · ~14.2GB)
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
coscmd download checkpoints/qwen2_5_coder_7b_sft/checkpoint-540/model.safetensors /tmp/models/coder-7b/model.safetensors
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
coscmd download checkpoints/qwen2_5_coder_7b_sft/checkpoint-540/config.json /tmp/models/coder-7b/config.json
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
coscmd download checkpoints/qwen2_5_coder_7b_sft/checkpoint-540/generation_config.json /tmp/models/coder-7b/generation_config.json
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
coscmd download checkpoints/qwen2_5_coder_7b_sft/checkpoint-540/chat_template.jinja /tmp/models/coder-7b/chat_template.jinja
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
coscmd download checkpoints/qwen2_5_coder_7b_sft/checkpoint-540/tokenizer.json /tmp/models/coder-7b/tokenizer.json
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
coscmd download checkpoints/qwen2_5_coder_7b_sft/checkpoint-540/tokenizer_config.json /tmp/models/coder-7b/tokenizer_config.json
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
下载完验证:
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
ls -lh /tmp/models/coder-7b/
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
- [ ] 代码模型6个文件全部下载完成
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 第七步 · 注册ModelScope账号 + 上传模型
|
|||
|
|
|
|||
|
|
### 7.1 注册
|
|||
|
|
|
|||
|
|
1. 浏览器打开 [**modelscope.cn**](http://modelscope.cn)
|
|||
|
|
2. 手机号注册(30秒)
|
|||
|
|
|
|||
|
|
### 7.2 安装modelscope命令行工具(在主服务器上)
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
pip install modelscope
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
### 7.3 登录ModelScope
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
modelscope login
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
会要求你输入Access Token。去 [modelscope.cn](http://modelscope.cn) → 个人中心 → 访问令牌 → 创建一个,复制粘贴进来。
|
|||
|
|
|
|||
|
|
### 7.4 创建两个模型仓库
|
|||
|
|
|
|||
|
|
在 [modelscope.cn](http://modelscope.cn) 网页上:
|
|||
|
|
|
|||
|
|
1. 点「创建模型」
|
|||
|
|
2. 第一个:名字填 `guanghu-motherbrain-v1`,可见性选「私有」
|
|||
|
|
3. 第二个:名字填 `guanghu-coder-7b-sft`,可见性选「私有」
|
|||
|
|
|
|||
|
|
### 7.5 上传母模型文件
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
cd /tmp/models/motherbrain-v1
|
|||
|
|
git lfs install
|
|||
|
|
git clone https://www.modelscope.cn/<你的用户名>/guanghu-motherbrain-v1.git repo-motherbrain
|
|||
|
|
cp model.safetensors config.json generation_config.json chat_template.jinja tokenizer.json tokenizer_config.json repo-motherbrain/
|
|||
|
|
cd repo-motherbrain
|
|||
|
|
git lfs track "*.safetensors"
|
|||
|
|
git add .
|
|||
|
|
git commit -m "upload motherbrain-v1 checkpoint-540"
|
|||
|
|
git push
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
<aside>
|
|||
|
|
⚠️
|
|||
|
|
|
|||
|
|
**model.safetensors有14GB**,push会比较慢,耐心等。如果超时断了,重新 `git push` 会续传。
|
|||
|
|
|
|||
|
|
</aside>
|
|||
|
|
|
|||
|
|
### 7.6 上传代码模型文件
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
cd /tmp/models/coder-7b
|
|||
|
|
git clone https://www.modelscope.cn/<你的用户名>/guanghu-coder-7b-sft.git repo-coder
|
|||
|
|
cp model.safetensors config.json generation_config.json chat_template.jinja tokenizer.json tokenizer_config.json repo-coder/
|
|||
|
|
cd repo-coder
|
|||
|
|
git lfs track "*.safetensors"
|
|||
|
|
git add .
|
|||
|
|
git commit -m "upload coder-7b-sft checkpoint-540"
|
|||
|
|
git push
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
- [ ] 母模型上传ModelScope完成
|
|||
|
|
- [ ] 代码模型上传ModelScope完成
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 第八步 · 在硅基流动部署模型
|
|||
|
|
|
|||
|
|
<aside>
|
|||
|
|
⚠️
|
|||
|
|
|
|||
|
|
**这一步需要等你登录硅基流动后台看到具体界面再操作。**
|
|||
|
|
硅基流动的自定义模型部署界面可能有更新,你登进去后截图给我(或者告诉我你看到了什么选项),我帮你判断怎么操作。
|
|||
|
|
|
|||
|
|
</aside>
|
|||
|
|
|
|||
|
|
大致流程:
|
|||
|
|
|
|||
|
|
1. 登录 [siliconflow.cn](http://siliconflow.cn)
|
|||
|
|
2. 找到「自定义模型」或「模型部署」入口
|
|||
|
|
3. 创建部署,选择从ModelScope拉取模型
|
|||
|
|
4. 分别部署两个模型
|
|||
|
|
5. 部署成功后,记录两个 **Model ID**
|
|||
|
|
- [ ] 母模型部署成功 · Model ID = ___
|
|||
|
|
- [ ] 代码模型部署成功 · Model ID = ___
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 第九步 · 把密钥和Model ID配到Gitea
|
|||
|
|
|
|||
|
|
登录Gitea(http://43.139.251.175:3000) → 进 guanghulab 仓库 → Settings → Secrets
|
|||
|
|
|
|||
|
|
添加3个Secret:
|
|||
|
|
|
|||
|
|
| Secret Name | Value |
|
|||
|
|
| --- | --- |
|
|||
|
|
| `CN_SILICONFLOW_API_KEY` | `ARK_API_KEY_REDACTED` |
|
|||
|
|
| `CN_SILICONFLOW_BASE_MODEL_ID` | (第八步拿到的母模型ID) |
|
|||
|
|
| `CN_SILICONFLOW_CODE_MODEL_ID` | (第八步拿到的代码模型ID) |
|
|||
|
|
- [ ] 3个Secret全部配置完成
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 第十步 · 清理临时文件
|
|||
|
|
|
|||
|
|
模型都部署完确认没问题后,删掉服务器上的临时下载:
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
rm -rf /tmp/models
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
- [ ] 临时文件已清理
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 完成!
|
|||
|
|
|
|||
|
|
全部做完后,铸渊就能通过硅基流动API调用自己的代码模型了。接下来就是铸渊写智能路由代码 + 接上Gitea开始写脚本。
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 关键信息速查
|
|||
|
|
|
|||
|
|
| 项目 | 值 |
|
|||
|
|
| --- | --- |
|
|||
|
|
| COS桶名 | `sy-finetune-corpus-1317346199` |
|
|||
|
|
| COS地域 | `ap-guangzhou` |
|
|||
|
|
| COS SecretId | `AKIDkQuBQhoiS2OYXWebXLwMbdT7cvAScbbU` |
|
|||
|
|
| COS SecretKey | `nPoZKArgUJBA4nJenjSxJSQBj5FCj3A4` |
|
|||
|
|
| 硅基流动API Key | `ARK_API_KEY_REDACTED` |
|
|||
|
|
| 主服务器IP | `43.139.251.175` |
|
|||
|
|
| Gitea地址 | `http://43.139.251.175:3000` |
|
|||
|
|
| ModelScope | `modelscope.cn` |
|
|||
|
|
| 硅基流动 | `siliconflow.cn` |
|