mythos_fast 是 WeiboAI/VibeThinker-3B 的 tool-use / agent 微调版本(Qwen2 架构,3B 参数),以 GGUF Q4_K_M 量化发布, 支持工具调用与多步推理任务。本项目通过 transformers 加载 GGUF 权重, 完成其在**华为昇腾 NPU(Ascend 910B)**上的推理适配与验证。
| 项目 | 说明 |
|---|---|
| 网络 | Qwen2ForCausalLM |
| 参数量 | 3.09B(GGUF Q4_K_M 反量化后) |
| 输入 | 文本 prompt(tokenizer: Qwen2) |
| 输出 | 文本续写(agent/tool-use 格式) |
| 权重格式 | GGUF(VibeThinker-3B.Q4_K_M.gguf,1.8GB) |
pip install transformers torch torch_npu safetensors sentencepiece \
-i https://repo.huaweicloud.com/repository/pypi/simple/cd /workspace/Shadow0482_mythos_fast
export HF_ENDPOINT=https://hf-mirror.com
/usr/local/python3.11.14/bin/python3 inference.py \
--model_path /workspace/Shadow0482_mythos_fast_src \
--gguf_file VibeThinker-3B.Q4_K_M.gguf \
--device npu:0| 参数 | 说明 | 默认值 |
|---|---|---|
--model_path | GGUF 权重目录 | .../Shadow0482_mythos_fast_src |
--gguf_file | GGUF 文件名 | VibeThinker-3B.Q4_K_M.gguf |
--tokenizer | tokenizer repo(Qwen2) | Qwen/Qwen2-1.5B |
--prompt | 生成提示词 | tool-use 示例 |
--max_new_tokens | 生成 token 数 | 64 |
--device | 推理设备(npu:0 / cpu) | npu:0 |
[info] 模型加载完成 (62s): Qwen2ForCausalLM 3.09B -> npu:0
[info] input tokens: 17
============================================================
[info] 生成 64 tokens, 耗时 2.1s (32 ms/token)
============================================================mythos_fast(Qwen2-3B GGUF)在 NPU 上完成文本生成(约 32 ms/token), NPU 推理链路完整跑通,生成结果与 CPU 一致(Q4_K_M 量化行为一致)。
AutoModelForCausalLM.from_pretrained(..., gguf_file=...)
将 Q4_K_M 反量化为 Qwen2ForCausalLM。Qwen/Qwen2-1.5B tokenizer
(GGUF 内置 ggml tokenizer 也可用)。.to('npu:0') + torch.no_grad() 生成,NPU 支持 bf16/fp16。resolve_device():NPU 可用性检测,失败自动回退 CPU。*.gguf 已加入 .gitignore。.
├── README.md # 模型卡片(本文件)
├── inference.py # NPU 推理脚本
└── assets/ # 适配过程截图素材