模型地址: stable-ai/LimiX-16M(HuggingFace 镜像 hf-mirror.com) 适配引擎: torch_npu(昇腾 NPU PyTorch 后端,官方 LimiXPredictor 设备无关改造) 适配状态: ✅ 已在昇腾 NPU 上跑通推理
| 字段 | 内容 |
|---|---|
| 模型名称 | stable-ai_LimiX-16M# |
| 模型链接 | stable-ai/LimiX-16M |
| 模型描述 | 通用模型(自动探测类型):按权重结构与 tokenizer 存在情况选择加载方式 |
| 模型架构 | Transformer |
| 参数规模 | 未知 |
| 任务类型 | 按探测结果(自动) |
| 硬件 | NPU(hardware: NPU) |
| 特性 | 说明 |
|---|---|
| 任务类型 | 按探测结果(自动) |
| 推理引擎 | torch_npu(昇腾 NPU PyTorch 后端,transformers 直载) |
| 设备 | npu:0 |
| 精度 | bfloat16(torch_dtype) |
| 项 | 规格 |
|---|---|
| NPU | 昇腾 Ascend 910(Atlas 系列) |
| 显存 | 单卡 HBM 64 GB |
| 依赖项 | 版本要求 | 说明 |
|---|---|---|
| Python | >= 3.10 | 推荐 3.11 |
| torch / torch_npu | 2.1.0+ | 昇腾 NPU 必选(版本需与 CANN 匹配) |
| transformers | >= 4.45.0 | HuggingFace 库 |
| 昇腾驱动 | CANN 8.0.RC2+ | 推荐最新版 |
安装命令:
npu-smi info # 确认 NPU 健康状态为 OK
pip install -r requirements.txt从 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')"
# 确认 NPU 设备健康状态为 OK
npu-smi info
# 安装项目依赖
pip install -r requirements.txtpython inference.py --model-path weights/LimiX-16M.ckpt --device npu:0| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| --model-path | str | 自动下载 | LimiX-16M.ckpt 权重路径 |
| --device | str | npu:0 | 推理设备(npu:0 / cuda:0 / cpu) |
| --config | str | config/cls_default_noretrieval.json | 推理配置(内嵌源码中) |
运行命令:
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| 指标 | 实测值 | 说明 |
|---|---|---|
| 端到端耗时 | 0.665 s | 285 样本少样本分类 |
| 指标 | 实测值 | 说明 |
|---|---|---|
| accuracy | 0.985965 | breast_cancer 285 样本 |
| roc_auc | 0.998963 | breast_cancer |
| 参数设备占比 | 183/183 | npu:0 |