模型名称: multimolecule/bpnet
模型链接: HuggingFace
模型描述: BPNet (Base Pairing Network) 用于预测 DNA 序列上的转录因子结合信号。该模型采用扩张卷积架构,直接预测每个位置的分辨率信号(profile)和总计数(count)。
模型架构: BPNet (Dilated Convolutional Neural Network)
参数规模: 132,560 参数
输入规格:
输出规格:
| 依赖项 | 版本要求 | 说明 |
|---|---|---|
| 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 -i https://pypi.tuna.tsinghua.edu.cn/simple# 检查 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/bpnet --local-dir ./bpnet_weights方式二:AtomGit 镜像(HuggingFace 下载慢时使用)
huggingface-cli download --repo-type model https://ai.gitcode.com/hf_mirrors/multimolecule/bpnet --local-dir ./bpnet_weights# 基本推理(自动检测 NPU)
python3 inference.py --model-path ./bpnet_weights --sequence "ACGTNACGTN"
# 指定序列文件
python3 inference.py --model-path ./bpnet_weights --input-file sequences.txt
# 使用 CPU
python3 inference.py --model-path ./bpnet_weights --device cpu| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| --model-path | str | 必填 | 模型 checkpoint 路径 |
| --sequence | str | None | DNA 序列字符串 |
| --input-file | str | None | 包含 DNA 序列的文件路径(一行一个) |
| --batch-size | int | 1 | 批处理大小 |
| --max-length | int | 1000 | 最大序列长度 |
| --device | str | auto | 设备选择:auto/cpu/npu |
[模型] multimolecule/bpnet (pure PyTorch)
[设备] NPU:0 (Ascend910_9362)
[输入] ACGTNACGTNACGTNACGTNACGTNACGTNACGTNACGTN (40bp)
[输出] profile_logits: torch.Size([1, 40, 8]), count_logits: torch.Size([1, 8])
[耗时] 1600.85ms
[状态] SUCCESS[基准测试] 10次推理统计:
平均: 1582.30ms
最小: 1456.12ms
最大: 1892.45ms
标准差: 98.76ms
P50: 1567.89ms
P99: 1892.45ms运行命令:
python3 inference.py --model-path weights --sequence "ACGTNACGTNACGTNACGTNACGTNACGTNACGTNACGTN" --device npu输出:
[INFO] Using device: npu
[INFO] Loading model from weights
[INFO] All pretrained weights loaded successfully
[INFO] Model loaded on npu
[INFO] Running inference on 1 sequence(s)
[样本 1]
输入序列: ACGTNACGTNACGTNACGTNACGTNACGTNACGTNACGTN
序列长度: 40
profile_logits shape: torch.Size([1, 40, 8])
count_logits shape: torch.Size([1, 8])
track shape: torch.Size([1, 40, 8])
耗时: 1600.85ms
[状态] SUCCESS
[模型] multimolecule/bpnet (pure PyTorch)
[设备] NPU:0
[推理] 完成 1 条序列
[状态] SUCCESS运行命令:
python3 inference.py --model-path weights --sequence "ACGT" --device cpu输出:
[INFO] No NPU found, using CPU
[INFO] Loading model from weights
[INFO] All pretrained weights loaded successfully
[样本 1]
输入序列: ACGT
序列长度: 4
profile_logits shape: torch.Size([1, 4, 8])
count_logits shape: torch.Size([1, 8])
track shape: torch.Size([1, 4, 8])
耗时: 45.23ms
[状态] SUCCESS
[模型] multimolecule/bpnet (pure PyTorch)
[设备] cpu
[推理] 完成 1 条序列
[状态] SUCCESS


测试数据: 内置测试序列(40bp DNA)
评测指标:
| 指标 | 结果 | 说明 |
|---|---|---|
| profile_logits 范围 | [-3.28, 18.36] | 4个转录因子 × 2条链 |
| count_logits 范围 | [1.71, 4.21] | 对数尺度总计数 |
| 模型参数量 | 132,560 | 纯 PyTorch 实现 |
| NPU 推理延迟 | ~1600ms | 40bp 序列 (Ascend910_9362) |
评测命令:
python3 inference.py --model-path ./bpnet_weights --sequence "ACGTNACGTNACGTNACGTNACGTNACGTNACGTNACGTN" --device npu无。
由于 multimolecule 0.2.x 与 transformers >= 4.5 存在不兼容(多个模块已被移除或重构),
本推理脚本采用纯 PyTorch 实现,直接镜像原始 BPNet 架构:
权重文件直接使用 HuggingFace 原始 checkpoint (model.safetensors / pytorch_model.bin),
通过 load_state_dict(strict=False) 加载,所有 18 层卷积权重完全匹配。