weixin_62994174/stable-ai_LimiX-16M
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

stable-ai_LimiX-16M# 昇腾NPU部署文档

模型地址: stable-ai/LimiX-16M(HuggingFace 镜像 hf-mirror.com) 适配引擎: torch_npu(昇腾 NPU PyTorch 后端,官方 LimiXPredictor 设备无关改造) 适配状态: ✅ 已在昇腾 NPU 上跑通推理


1. 模型简介

1.1 模型信息

字段内容
模型名称stable-ai_LimiX-16M#
模型链接stable-ai/LimiX-16M
模型描述通用模型(自动探测类型):按权重结构与 tokenizer 存在情况选择加载方式
模型架构Transformer
参数规模未知
任务类型按探测结果(自动)
硬件NPU(hardware: NPU)

1.2 核心特性

特性说明
任务类型按探测结果(自动)
推理引擎torch_npu(昇腾 NPU PyTorch 后端,transformers 直载)
设备npu:0
精度bfloat16(torch_dtype)

2. 环境依赖

2.1 硬件环境

项规格
NPU昇腾 Ascend 910(Atlas 系列)
显存单卡 HBM 64 GB

2.2 Python 依赖

依赖项版本要求说明
Python>= 3.10推荐 3.11
torch / torch_npu2.1.0+昇腾 NPU 必选(版本需与 CANN 匹配)
transformers>= 4.45.0HuggingFace 库
昇腾驱动CANN 8.0.RC2+推荐最新版

安装命令:

npu-smi info                        # 确认 NPU 健康状态为 OK
pip install -r requirements.txt

3. 推理步骤

3.1 下载权重

从 HuggingFace 镜像下载模型权重(国内推荐使用 hf-mirror.com 加速):

pip install huggingface_hub
export HF_ENDPOINT=https://hf-mirror.com
huggingface-cli download stable-ai/LimiX-16M --local-dir ./weights --local-dir-use-symlinks False

备选镜像: 若 HuggingFace 镜像不可用,可改用 ModelScope(魔搭)下载:

pip install modelscope
python -c "from modelscope import snapshot_download; snapshot_download('stable-ai/LimiX-16M', cache_dir='./weights')"

3.2 环境准备

# 确认 NPU 设备健康状态为 OK
npu-smi info

# 安装项目依赖
pip install -r requirements.txt

3.3 运行推理

python inference.py --model-path weights/LimiX-16M.ckpt --device npu:0

3.4 推理参数说明

参数类型默认值说明
--model-pathstr自动下载LimiX-16M.ckpt 权重路径
--devicestrnpu:0推理设备(npu:0 / cuda:0 / cpu)
--configstrconfig/cls_default_noretrieval.json推理配置(内嵌源码中)

4. 测试样例及输出结果

样例 1:breast_cancer 少样本表格分类(NPU 实测)

运行命令:

python inference.py --model-path weights/LimiX-16M.ckpt --device npu:0

输入:

sklearn breast_cancer 数据集(30 特征),train_test_split(test_size=0.5) 划分 284/285

输出(NPU 真实推理结果,npu:0):

model_path : weights/LimiX-16M.ckpt
config_path: .../config/cls_default_noretrieval.json
device     : npu:0
n_test_samples : 285
proba_shape    : [285, 2]
params_on_device: 183/183
accuracy       : 0.985965
roc_auc        : 0.998963
inference_time_s: 0.6648
proba_head     : [[0.2219, 0.7781], [1.0000, 0.0000], [1.0000, 0.0000], [0.0000, 1.0000], [0.0000, 1.0000]]
STATUS: NPU_OK

5. 性能参考

指标实测值说明
端到端耗时0.665 s285 样本少样本分类

6. 精度评测

指标实测值说明
accuracy0.985965breast_cancer 285 样本
roc_auc0.998963breast_cancer
参数设备占比183/183npu:0

8. 注意事项

  • 推理脚本中通过 torch_npu / vllm-ascend / sglang 调用 NPU
  • 如有精度差异请在 README 中注明对比数据
  • 本交付件不含模型权重,权重请从 未知来源 获取
  • 本模型适配的完整对话记录见 logs/agent_conversation.jsonl,NPU 设备调用见 logs/npu_device_calls.log