AidGenSE 手动上传模型及配置
介绍
该文档用于详述如何上传模型并使用 AidGenSE 启动 OpenAI HTTP 服务
准备工作
在进行模型上传和加载前,请确保以下条件:
- 安装AidGenSE 相关依赖,请参考AidGenSE 安装
- 完整的模型文件夹(包括 .gguf、.bin 或 .aidem 模型文件及配置文件)
- 了解当前平台支持的模型类型和限制,请参考AidGenSE 支持情况
模型资源准备
GGUF 格式模型
推荐文件结构如下:
bash
qwen2.5-1.5b-instruct-q4_k_m/
|__ qwen2.5-1.5b-instruct-q4_k_m.gguf
|__ qwen2.5-1.5b-instruct-q4_k_m.json ← 模型配置文件(需手动编写)配置文件模板:
LLM 模型:
json
{
"backend_type": "llamacpp",
"model": {
"path": "<模型文件绝对路径>"
}
}VLM 模型(相比 LLM 增加 mmproj 字段):
json
{
"backend_type": "llamacpp",
"model": {
"path": "<模型文件绝对路径>",
"mmproj": "<mmproj 文件绝对路径>"
}
}💡注意
mmproj 为可选字段,用于指定 VLM 模型的多模态投影器文件路径。
高通 QNN Bin 格式模型
推荐结构如下:
bash
qwen2.5-1.5b-instruct-8550-bin/
|__ *.serialized.bin (多个)
|__ qwen2.5-1.5b-instruct-htp.json ← 配置主文件
|__ qwen2.5-1.5b-instruct-tokenizer.json
|__ htp_backend_ext_config.json💡注意
Model Farm上的大模型资源是按照标准结构组织的,高通大模型配置文件相关信息可以参考 Qualcomm Genie。
特别说明
qwen2.5-1.5b-instruct-htp.json 为主要配置文件,其中相关文件路径需要设置为绝对路径,例子如下:
json
"tokenizer": {
"path": "/opt/aidlux/app/aid-openai-api/res/models/qwen2.5-1.5B-instruct-8550-bin/qwen2.5-1.5b-instruct-tokenizer.json"
},
"ctx-bins": [
"/opt/aidlux/app/aid-openai-api/res/models/qwen2.5-1.5B-instruct-8550-bin/qwen2.5-1.5b-instruct_qnn229_qcs8550_4096_1_of_3.serialized.bin",
"/opt/aidlux/app/aid-openai-api/res/models/qwen2.5-1.5B-instruct-8550-bin/qwen2.5-1.5b-instruct_qnn229_qcs8550_4096_2_of_3.serialized.bin",
"/opt/aidlux/app/aid-openai-api/res/models/qwen2.5-1.5B-instruct-8550-bin/qwen2.5-1.5b-instruct_qnn229_qcs8550_4096_3_of_3.serialized.bin"
],
"extensions": "/opt/aidlux/app/aid-openai-api/res/models/qwen2.5-1.5B-instruct-8550-bin/htp_backend_ext_config.json"APLUX aidem 加密格式
推荐文件结构如下:
bash
qwen2.5-1.5b-instruct-q4_k_m/
|__ *.aidem (多个)
|__ qwen2.5-1.5b-instruct.json ← 模型配置文件(需手动编写)配置文件模板:
LLM 模型:
json
{
"backend_type": "genie",
"model_type": "llm",
"config_version": 5,
"htp_config_path": "<HTP 配置文件路径或空>",
"model": {
"path": ["<模型文件绝对路径>"]
}
}VLM 模型:
json
{
"backend_type": "genie",
"model_type": "vlm",
"config_version": 5,
"htp_config_path": "<HTP 配置文件路径或空>",
"model": {
"path": []
},
"vlm_model": {
"type": "qwen2.5",
"vision_model_path": "<vision 模型文件绝对路径>",
"pos_embed_cos_path": "<position_ids_cos.raw 绝对路径>",
"pos_embed_sin_path": "<position_ids_sin.raw 绝对路径>",
"vocab_embed_path": "<embedding_weights.raw 绝对路径>",
"window_attention_mask_path": "<window_attention_mask.raw 绝对路径>",
"full_attention_mask_path": "<full_attention_mask.raw 绝对路径>",
"llm_path_list": ["<llm 分片文件绝对路径>"],
"qwen2.5": {
"img_h": 336,
"img_w": 504,
"img_c": 3,
"T": 2,
"patch_size": 14,
"temporal_patch_size": 2,
"merge_size": 2
}
}
}💡注意
type 字段目前支持以下 4 种类型:qwen2.5、qwen3、locateanything、magevl。
Embedding 模型:
json
{
"backend_type": "genie",
"model_type": "embedding",
"config_version": 5,
"htp_config_path": "<HTP 配置文件路径或空>",
"embedding_model": {
"path": ["<模型文件绝对路径>"]
}
}配置文件设置
通过编辑 api_cfg.json 配置模型资源
bash
vi /opt/aidlux/app/aid-openai-api/api_cfg.json增加模型:
json
{
...
"prompt_template_list": [
...
"<对话模板类型>": "对话模板格式"
],
"model_cfg_list": [
...
{
"model_id": "<模型ID>",
"model_create": "<时间戳>",
"model_owner": "<创建者>",
"cfg_path": "<模型 config 文件绝对路径>",
"prompt_template_type": "<对话模板类型>"
}
]
}字段说明:
model_id:模型标识,唯一 ID,用于运行时指定模型,例如qwen2.5-1.5b-instruct-q4_k_mmodel_create:模型注册时间戳,可使用命令printf "%s%03d\n" "$(date +%s)" "$((10#$(date +%N) / 1000000))"生成,单位为毫秒model_owner:模型所有者名称,可自定义,例如"aplux"cfg_path:模型主配置文件绝对路径prompt_template_type:对话提示模板类型,常见取值如"qwen1.5"、"qwen2"、"deepseek",应与模型训练格式匹配
使用命令查看添加的模型
bash
# 使用aidllm list api命令查看模型是否已经加入aidllm
aidllm list api
qwen2.5-7b-instruct
aplux_qwen2-7B
qwen2.5-7b-instruct-q4_k_m
qwen2.5-7B-8550
qwen2.5-1.5b-instruct-q4_k_m
qwen2.5-1.5B-instruct-8550-bin
# 使用aidllm start api -m qwen2.5-1.5b-instruct-q4_k_m 指定运行模型,查看模型是否能够运行
aidllm start api -m qwen2.5-1.5b-instruct-q4_k_m当前文档适配 aidgense V3.3.1