模型名称: YuchenShen/FoMo-0D
模型链接: HuggingFace
模型描述: FoMo-0D 是一个零样本表格异常检测模型,使用自定义 Transformer 架构和 Router Attention 机制,能够在没有任务特定训练的情况下检测表格数据中的异常点。
模型架构: Custom Transformer + Router Attention (Router-Attn Transformer)
参数规模: 4,886,786 (~4.9M)
输入规格:
[batch_size, seq_len, num_features] = [B, 5000, 100]输出规格:
[batch_size, num_class] = [B, 2]| 依赖项 | 版本要求 | 说明 |
|---|---|---|
| Python | >= 3.10 | 推荐 3.11 |
| torch | >= 2.1.0 | PyTorch 框架 |
| torch_npu | >= 2.1.0 | 昇腾 NPU 后端 |
| safetensors | >= 0.4.0 | 安全张量格式加载 |
| 昇腾驱动 | CANN 8.0+ | 推荐 CANN 8.5.1 |
安装命令:
pip install torch torch-npu safetensors# 检查 NPU 设备
npu-smi info
# 验证 torch_npu
python3 -c "import torch_npu; print(torch.npu.device_count(), torch.npu.get_device_name(0))"方式一:HuggingFace(推荐)
huggingface-cli download YuchenShen/FoMo-0D --local-dir ./FoMo-0D方式二:AtomGit 镜像(HuggingFace 下载慢时使用)
huggingface-cli download --repo-type model \
https://ai.gitcode.com/hf_mirrors/YuchenShen/FoMo-0D \
--local-dir ./FoMo-0Dcd /tmp/adapt_yuchenshen_fomo-0d
python3 inference.py --model-path /opt/atomgit/FoMo-0D| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| --model-path | str | 必填 | 模型 checkpoint 路径(包含 model.safetensors 和 config.json) |
| --device | str | npu | 运行设备(npu/cpu) |
| --batch-size | int | 1 | 批处理大小 |
[模型] YuchenShen/FoMo-0D
[设备] Ascend910_9362 (npu:0)
[输入] shape=[1, 5000, 100], dtype=torch.float32
[输出] logits=[0.0621, 0.0257], probs=[0.5091, 0.4909]
[预测] 正常 (inlier) (class=0)
[耗时] 3406.4ms
[状态] SUCCESS[输入] shape=[4, 5000, 100], dtype=torch.float32
[0] pred=正常, probs=[0.5164, 0.4836]
[1] pred=正常, probs=[0.5047, 0.4953]
[2] pred=正常, probs=[0.5193, 0.4807]
[3] pred=正常, probs=[0.5237, 0.4763]
[总耗时] 305.4ms运行命令:
python3 inference.py --model-path /opt/atomgit/FoMo-0D输出:
=== 样例 1: 单条推理 ===
输入: shape=[1, 5000, 100], dtype=torch.float32
输出: logits=[0.06210486218333244, 0.025744102895259857]
probs=[0.5090892314910889, 0.4909108281135559]
预测=正常 (inlier) (class=0)
耗时=3406.4ms
[状态] SUCCESS输出:
=== 样例 2: 批量推理 (batch=4) ===
输入: shape=[4, 5000, 100], dtype=torch.float32
[0] pred=正常, probs=[0.5164, 0.4836]
[1] pred=正常, probs=[0.5047, 0.4953]
[2] pred=正常, probs=[0.5193, 0.4807]
[3] pred=正常, probs=[0.5237, 0.4763]
总耗时: 305.4ms输出:
=== 样例 3: 确定性输入验证 ===
输入: seed=42, shape=[1, 5000, 100]
输出: logits=[0.039788294583559036, 0.05050046369433403]
probs=[0.4973219633102417, 0.5026779770851135]
预测class=1
[状态] SUCCESS


测试数据: 随机生成的正态分布张量(模拟正常表格数据)
评测指标:
| 指标 | 结果 | 说明 |
|---|---|---|
| 单条推理耗时 | 3406.4ms | seq_len=5000, features=100, NPU |
| 批量推理耗时 (batch=4) | 305.4ms | 约 76.4ms/sample |
| 确定性输出 | 通过 | seed=42 时输出可复现 |
评测命令:
python3 inference.py --model-path /opt/atomgit/FoMo-0D无。模型已通过 Stage A (Dummy)、Stage B (Real Weight) 和端到端推理验证。