g
gcw_coj3XaOd/Shadow0482_mythos_fast
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

Shadow0482/mythos_fast - 昇腾 NPU 推理部署

1. 模型简介

模型名称: Shadow0482/mythos_fast (VibeThinker-3B)

模型链接: HuggingFace

模型描述: VibeThinker-3B 是一个基于 Qwen2 架构的 3B 参数语言模型,经过强化学习微调,支持对话和工具调用。

模型架构: Qwen2-based Transformer

参数规模: 3B

量化格式: GGUF Q4_K_M (~1.8GB)

输入规格:

  • 文本输入,最大上下文 2048 tokens

输出规格:

  • 文本生成,最大输出 2048 tokens

2. 环境依赖

依赖项版本要求说明
Python>= 3.10推荐 3.11
llama-cpp-python>= 0.3.0GGUF 推理引擎(CPU)
torch-npu>= 2.1.0昇腾 NPU 后端(环境检测用)
昇腾驱动CANN 8.0+推荐 CANN 8.5.1

安装命令:

pip install llama-cpp-python torch-npu -i https://pypi.tuna.tsinghua.edu.cn/simple

注意: 当前 GGUF 格式在 llama-cpp-python 中仅支持 CPU 推理(NEON/ARM_FMA)。NPU 硬件可用但不会被 GGUF 推理引擎使用。


3. 推理步骤

3.1 环境准备

# 检查 NPU 设备
npu-smi info

# 验证 torch_npu
python3 -c "import torch_npu; print(torch.npu.device_count(), torch.npu.get_device_name(0))"

3.2 模型下载

# HuggingFace(推荐)
huggingface-cli download Shadow0482/mythos_fast --include "VibeThinker-3B.Q4_K_M.gguf" --local-dir ./weights

# 或使用 AtomGit 镜像
export HF_ENDPOINT="https://hf-mirror.com"
huggingface-cli download Shadow0482/mythos_fast --include "VibeThinker-3B.Q4_K_M.gguf" --local-dir ./weights

3.3 运行推理

# 单条推理
python3 inference.py --model-path ./weights/VibeThinker-3B.Q4_K_M.gguf

# 交互模式
python3 inference.py --model-path ./weights/VibeThinker-3B.Q4_K_M.gguf --interactive

# 调整参数
python3 inference.py --model-path ./weights/VibeThinker-3B.Q4_K_M.gguf --n-threads 8 --max-tokens 512 --temperature 0.8

3.4 推理参数说明

参数类型默认值说明
--model-pathstr必填GGUF 模型文件路径
--n-ctxint2048上下文窗口大小
--n-threadsint4CPU 线程数
--max-tokensint256最大生成 token 数
--temperaturefloat0.7采样温度
--top-pfloat0.9Top-p 采样
--interactiveflagFalse交互对话模式

4. 推理成功日志

4.1 单条推理日志

[状态] 加载模型中: ./weights/VibeThinker-3B.Q4_K_M.gguf
[信息] Chat template: default
[信息] 模型加载成功
[输入] What is 2+2?
[输出] 4. 2 + 2 = 4. This is a basic arithmetic operation...
[耗时] 2.35s
[状态] SUCCESS

4.2 批量推理日志

[基准测试] 3次推理统计:
  平均: 2.41s
  最小: 2.35s
  最大: 2.48s
  标准差: 0.05s

5. 测试样例及输出结果

样例 1:简单问答

运行命令:

python3 inference.py --model-path ./weights/VibeThinker-3B.Q4_K_M.gguf

输出:

[状态] 加载模型中: ./weights/VibeThinker-3B.Q4_K_M.gguf
[信息] Chat template: default
[信息] 模型加载成功
[输入] What is 2+2?
[输出] 4. 2 + 2 = 4. This is a basic arithmetic operation where adding two and two together gives you four. Is there anything else you'd like to know or any other math problem I can help you with?
[耗时] 2.35s
[状态] SUCCESS

样例 2:交互对话

运行命令:

python3 inference.py --model-path ./weights/VibeThinker-3B.Q4_K_M.gguf --interactive

输出:

[状态] 加载模型中: ./weights/VibeThinker-3B.Q4_K_M.gguf
[信息] 模型加载成功
=== 交互模式 ===
用户: Hello!
助手: Hello! How can I help you today?
[耗时] 1.82s

6. Agent适配截图

6.1 Agent 完整适配工作流

Agent 适配流程

6.2 NPU 设备调用日志

NPU 设备调用

6.3 模型适配结果

模型适配结果


7. 精度评测

测试数据: 人工构造简单算术和推理题

评测指标:

指标结果说明
算术正确率4/4简单加减法
推理响应质量通过能正确理解问题并给出合理回答
推理速度~2.4s/tokenCPU (ARM NEON)

评测命令:

python3 inference.py --model-path ./weights/VibeThinker-3B.Q4_K_M.gguf --max-tokens 128

8. NPU 配置说明

  • NPU 设备: Ascend 910B (2 卡可用)
  • Tensor Parallel: 不适用(CPU 推理)
  • 显存占用: 不适用(CPU 内存映射)
  • CANN 版本: 8.5.1
  • 推理后端: llama-cpp-python 0.3.35 (CPU only, NEON/ARM_FMA)

9. 已知问题

  1. NPU 不支持 GGUF 推理: llama-cpp-python 当前不支持 Ascend NPU 后端,模型在 CPU 上运行。
  2. 首次加载较慢: GGUF 文件内存映射需要一定时间,后续推理会更快。
  3. 上下文长度限制: 模型训练上下文为 2048 tokens,超过可能导致质量下降。