FoMo-0D(Foundation Model for 0-Dimensional data)是零样本异常检测基础模型 (4.9M 参数,PFNs 架构,NeurIPS 2025),无需训练即可对表格数据进行异常检测。
本项目完成其在**华为昇腾 NPU(Ascend 910B)**上的推理适配与验证。
| 项目 | 说明 |
|---|---|
| 网络 | FoMo0DHub(PFNs 先验拟合网络) |
| 参数量 | 4.9M |
| 输入 | train_x / test_x(形状 (seq, batch, features)) |
| 输出 | 异常分数 (test_seq, batch, n_class=2) |
| 权重格式 | ckpt(best.ckpt) |
# 需先从 GitHub clone 官方代码库(含 fomo_hub.py 模型定义)
git -c http.version=HTTP/1.1 clone --depth 1 \
https://gh-proxy.com/https://github.com/A-Chicharito-S/FoMo-0D.git /tmp/FoMo-0Dcd /workspace/FoMo-0D
/workspace/tf4venv/bin/python inference.py \
--model_path YuchenShen/FoMo-0D --repo_code /tmp/FoMo-0D \
--n_train 5000 --n_test 10 --bs 3 --device npu:0| 参数 | 说明 | 默认值 |
|---|---|---|
--model_path | HF repo id 或本地目录 | YuchenShen/FoMo-0D |
--repo_code | GitHub 官方代码目录 | /tmp/FoMo-0D |
--n_train | 训练序列长度 | 5000 |
--n_test | 测试序列长度 | 10 |
--bs | batch size | 3 |
--device | 推理设备(npu:0 / cpu) | npu:0 |
--output | 结果保存文件(可选,npy) | stdout |
输入:train (5000,3,100) / test (10,3,100)
[info] model on npu:0: 4.9M
[info] input: train (5000,3,100) / test (10,3,100)
============================================================
[info] 输出形状: (10, 3, 2) (test_seq, batch, n_class=2)
============================================================FoMo-0D 在 NPU 上完成零样本异常检测(输出 (10,3,2) 异常分数), NPU 推理链路完整跑通。
fomo_hub.py),
需先 clone 代码库(GitHub 直连超时,用 gh-proxy 镜像)。FoMo0DHub.from_pretrained(repo_id) 加载权重后 .to('npu:0') 迁移。model(train_x=..., test_x=...)(PFNs 先验拟合格式)。resolve_device():NPU 可用性检测,失败自动回退 CPU。*.ckpt 已加入 .gitignore。.
├── README.md # 模型卡片(本文件)
├── inference.py # NPU 推理脚本
└── assets/ # 适配过程截图素材