赛事: 昇腾 Model Agent 模型适配大赛(第二季) 引擎: torch_npu + transformers(GGUF → safetensors 转换) 硬件: Ascend 910B4 / 800I A2 标签:
npuascendpytorchtransformers
mythos_fast 是 WeiboAI/VibeThinker-3B 基座模型的工具调用 / Agent 任务微调版(GGUF 格式),由社区针对多步工具调用、 函数调用格式与 agent 风格推理轨迹(约 200 万样本)微调后转换而来。本仓库为原始 GGUF 权重在昇腾 NPU 上的推理适配。
| 属性 | 值 |
|---|---|
| 原始模型 | Shadow0482/mythos_fast(GGUF) |
| 基座模型 | WeiboAI/VibeThinker-3B |
| 参数量 | 3.09 B |
| 任务类型 | 文本生成 / 工具调用 / Agent 任务执行 |
| 输入格式 | 文本字符串(含工具定义格式) |
| 输出格式 | 生成的文本 / 函数调用 |
架构:Qwen2ForCausalLM,36 层,hidden=2048,16 heads / 2 KV heads,vocab=151936,
attention_bias=True(GGUF 权重含 q/k/v attention bias 张量)。
pip install -r requirements.txt -i https://repo.huaweicloud.com/repository/pypi/simple/⚠️ 本仓库不包含模型权重(交付件仅
inference.py/readme.md/requirements.txt/assets/), 推理前必须先从原始模型仓单独下载权重。
# 1. 下载模型权重(GGUF 格式,仓库不含权重)
wget https://hf-mirror.com/Shadow0482/mythos_fast/resolve/main/VibeThinker-3B.F16.gguf
# 2. 运行 NPU 推理(首次运行自动将 GGUF 转换为 safetensors)
python3 inference.py --model_path . --device npu:0python3 inference.py --model_path . --device npu:0 --input "The capital of France is" --max_new_tokens 8预期输出:
[Model Agent] NPU 设备就绪: Ascend910B4 (count=1)
[Model Agent] 设置 attention_bias=True(匹配 GGUF 中的 attention bias 张量)
[Model Agent] 加载 mythos_fast (VibeThinker-3B 微调, 3.1B, Qwen2, attention_bias=True)...
[Model Agent] 模型加载完成 -> npu:0 (3.09B params)
[Model Agent] 输入提示: 'The capital of France is'
[Model Agent] 生成文本 (3 tokens):
is.
[Model Agent] 推理完成 -> inference_result.json
[Model Agent] 生成时延: 685.1 ms (4.38 tok/s)python3 inference.py --model_path . --device npu:0 \
--input "You are an AI assistant. Call the get_weather function for Beijing." \
--max_new_tokens 24预期输出:
[Model Agent] 输入提示: 'You are an AI assistant. Call the get_weather function for Beijing.'
[Model Agent] 生成文本 (24 tokens)
[Model Agent] 生成时延: 2099.2 ms (11.43 tok/s).
├── inference.py # NPU 推理脚本(GGUF→safetensors 自动转换)
├── readme.md # 本文件
├── requirements.txt # 依赖清单
└── assets/ # 截图素材本模型由 昇腾 Model Agent 自动完成 NPU 适配:
convert_gguf.py 将 VibeThinker-3B.F16.gguf(5.8GB)转换为
safetensors 格式(435 个张量);gguf 0.18 的 GGUFReader.tensors[i].data 已返回
HF 方向,无需转置。attention_bias=True;
lm_head 与 embed_tokens 共享内存 → 转换时 .clone() 避免保存报错。