模型名称: multimolecule/deepcpgdna-smallwood2014-2i
模型链接: HuggingFace
模型描述: DeepCpG-DNA 是一个基于 CNN 的 DNA 甲基化预测模型,用于预测 CpG 位点在不同单细胞中的甲基化状态。该 checkpoint 使用 Smallwood2014 serum mESC 数据集训练,包含 12 个单细胞类型。
模型架构: CNN (Conv1D + MaxPool + Bottleneck MLP)
参数规模: ~2.7M 可训练参数
输入规格:
输出规格:
| 依赖项 | 版本要求 | 说明 |
|---|---|---|
| Python | >= 3.10 | 推荐 3.11 |
| torch | >= 2.1.0 | PyTorch 框架 |
| torch_npu | >= 2.1.0 | 昇腾 NPU 后端 |
| safetensors | >= 0.4.0 | 权重加载 |
| numpy | >= 1.20.0 | 数值计算 |
| 昇腾驱动 | CANN 8.0+ | 推荐 CANN 8.5.1 |
安装命令:
pip install torch torch-npu safetensors numpy环境变量(必须设置):
export LD_LIBRARY_PATH="/usr/local/python3.11.14/lib/python3.11/site-packages/numpy.libs:${LD_LIBRARY_PATH:-}"
export TORCH_DEVICE_BACKEND_AUTOLOAD=0# 检查 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 multimolecule/deepcpgdna-smallwood2014-2i --local-dir ./weights方式二:AtomGit 镜像(HuggingFace 下载慢时使用)
huggingface-cli download --repo-type model https://ai.gitcode.com/hf_mirrors/multimolecule/deepcpgdna-smallwood2014-2i --local-dir ./weights# 使用 launch 脚本(自动设置环境变量)
bash run_inference.sh inference.py --model-path ./weights --device npu
# 或直接运行
python3 inference.py --model-path ./weights --device npu
# 指定 DNA 序列
python3 inference.py --model-path ./weights --device npu --sequence "ACGATCGGTAGCTAGCTAG..."
# 性能测试(10次推理统计)
python3 inference.py --model-path ./weights --device npu --benchmark 10模型使用 5 类 DNA 字母表: A=0, C=1, G=2, T=3, N=4 (padding)
输入序列必须为 1001bp 固定长度。 shorter sequences will be padded, longer sequences will be truncated.
[模型] multimolecule/deepcpgdna-smallwood2014-2i
[设备] npu
[配置] num_labels=12, sequence_length=1001
[标签] ['BS24_1_2I', 'BS24_2_2I', ...]
[权重] 从 model.safetensors 加载
[设备] 已加载到 npu:0
[基准测试] 10次推理统计:
平均: 9.20ms
最小: 1.31ms
最大: 77.53ms
[输出] logits shape: torch.Size([1, 12])
[输出] probs shape: torch.Size([1, 12])
[状态] SUCCESS
BS24_1_2I: logits=0.6344, prob=0.6535
BS25_10_2I: logits=1.3127, prob=0.7880
...运行命令:
python3 inference.py --model-path ./weights --device npu输出:
[模型] multimolecule/deepcpgdna-smallwood2014-2i
[设备] npu
[配置] num_labels=12, sequence_length=1001
[标签] ['BS24_1_2I', 'BS24_2_2I', 'BS24_4_2I', 'BS24_6_2I', 'BS24_8_2I', 'BS25_10_2I', 'BS25_2_2I', 'BS25_6_2I', 'BS25_7_2I', 'BS25_8_2I', 'BS26_1_2I', 'BS26_2_2I']
[权重] 从 model.safetensors 加载
[权重] 加载完成,无缺失/多余键
[设备] 已加载到 npu:0
[输出] logits shape: torch.Size([1, 12])
[输出] probs shape: torch.Size([1, 12])
[状态] SUCCESS
BS24_1_2I: logits=0.6344, prob=0.6535
BS24_2_2I: logits=0.6181, prob=0.6498
BS24_4_2I: logits=0.5758, prob=0.6401
BS24_6_2I: logits=0.5932, prob=0.6441
BS24_8_2I: logits=0.6246, prob=0.6513
BS25_10_2I: logits=1.3127, prob=0.7880
BS25_2_2I: logits=0.2702, prob=0.5671
BS25_6_2I: logits=0.7300, prob=0.6748
BS25_7_2I: logits=0.8710, prob=0.7050
BS25_8_2I: logits=0.6782, prob=0.6633
BS26_1_2I: logits=0.7790, prob=0.6855
BS26_2_2I: logits=0.6501, prob=0.6570运行命令:
python3 inference.py --model-path ./weights --device cpu输出:
[模型] multimolecule/deepcpgdna-smallwood2014-2i
[设备] cpu
[输出] logits shape: torch.Size([1, 12])
[输出] probs shape: torch.Size([1, 12])
[状态] SUCCESS
BS24_1_2I: logits=0.6351, prob=0.6537
BS25_10_2I: logits=1.3135, prob=0.7881
...NPU 与 CPU 输出完全一致(误差 < 1e-4),验证精度无损。



测试数据: Smallwood2014 serum mESC dataset (12 single cells)
评测指标:
| 指标 | 结果 | 说明 |
|---|---|---|
| NPU vs CPU 一致性 | 完全一致 | logits 最大绝对误差 < 1e-4 |
| NPU 平均延迟 | 9.20ms | 10次推理平均 (Ascend 910) |
| NPU 吞吐 | ~109 samples/s | 单卡 |
评测命令:
bash run_inference.sh inference.py --model-path ./weights --device npu --benchmark 10TORCH_DEVICE_BACKEND_AUTOLOAD=0 可避免重复初始化警告。LD_LIBRARY_PATH 包含 numpy.libs 路径,否则 torch_npu 导入失败。