模型名称: multimolecule/basenji
模型链接: HuggingFace
模型描述: Basenji 是一个深度一维卷积神经网络(1D dilated CNN),用于从长 DNA 序列预测基因组调控活性。模型输入约 131kb 的 DNA 序列窗口,经过卷积+池化 stem 和扩张残差卷积塔,输出每个 128bp bin 的基因组覆盖度预测(5313 条轨道)。
模型架构: 1D Dilated Residual CNN (Basenji2)
参数规模: 30,092,548 (~30M)
输入规格:
(batch_size, 131072)输出规格:
(batch_size, 896, 5313)(896 个 bins × 5313 条基因组轨道)| 依赖项 | 版本要求 | 说明 |
|---|---|---|
| Python | >= 3.10 | 推荐 3.11 |
| torch | >= 2.1.0 | PyTorch 框架 |
| torch_npu | >= 2.1.0 | 昇腾 NPU 后端 |
| transformers | >= 5.0.0 | HuggingFace Transformers |
| multimolecule | >= 0.12.0 | MultiMolecule 基因组学模型库 |
| numpy | >= 1.20.0 | 数值计算 |
| 昇腾驱动 | CANN 8.0+ | 推荐 CANN 8.5.1 |
| NPU 硬件 | Ascend 910 | 验证设备: Ascend910_9362 |
安装命令:
pip install torch torch_npu transformers multimolecule numpy# 检查 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/basenji --local-dir ./model方式二:AtomGit 镜像(HuggingFace 下载慢时使用)
git clone https://ai.gitcode.com/hf_mirrors/multimolecule/basenji.git ./model# 基础推理(默认 seq_len=131072)
python inference.py --model-path ./model
# 指定序列长度(更短序列可减少内存占用)
python inference.py --model-path ./model --sequence-length 65536
# 指定 NPU 设备
python inference.py --model-path ./model --device 0| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| --model-path | str | 必填 | 模型 checkpoint 路径 |
| --sequence-length | int | 131072 | DNA 序列长度(bp) |
| --device | int | 0 | NPU 设备索引 |
[模型] multimolecule/basenji
[设备] Ascend910_9362 (npu:0)
[输入] DNA sequence, shape=(1, 131072)
[输出] Genomic coverage, shape=(1, 896, 5313)
[耗时] 0.25s
[状态] SUCCESS[基准测试] 2次推理统计:
平均: 0.01s
最小: 0.01s
最大: 0.01s运行命令:
python inference.py --model-path ./model --sequence-length 131072输出:
[INFO] Device: Ascend910_9362
[INFO] NPU device count: 2
[INFO] Loading model from ./model ...
Loading weights: 100%|██████████| 182/182 [00:00<00:00, 2744.61it/s]
[INFO] Model loaded: 30,092,548 parameters
[INFO] Input shape: torch.Size([1, 131072])
[INFO] Running inference ...
============================================================
[RESULTS]
Input shape : torch.Size([1, 131072])
Output logits : torch.Size([1, 896, 5313])
Coverage : torch.Size([1, 896, 5313])
Inference time : 0.25s
Throughput : 3.9738 samples/sec
Logits mean : -3.3901
Logits std : 1.3340
Coverage mean : 0.0756
Coverage max : 16.0691
[状态] SUCCESS
============================================================运行命令:
python inference.py --model-path ./model --sequence-length 65536输出:
[INFO] Running batch inference (batch_size=2) ...
Batch input shape : torch.Size([2, 65536])
Batch output : torch.Size([2, 384, 5313])
Batch time : 0.01s
[状态] SUCCESS


测试数据: ENCODE/FANTOM5/GTEx 基因组覆盖度轨道(5313 条实验数据)
评测指标:
| 指标 | 结果 | 说明 |
|---|---|---|
| 参数数量 | 30,092,548 | ~30M |
| FLOPs | 234.85 G | 单次 131072bp 窗口 |
| MACs | 117.19 G | 单次 131072bp 窗口 |
| 推理耗时 (NPU) | 0.25s | Ascend910_9362, seq_len=131072 |
| 覆盖度均值 | 0.0756 | softplus 激活后 |
| 覆盖度最大值 | 16.0691 | softplus 激活后 |
评测命令:
python inference.py --model-path ./model --sequence-length 131072无。模型所有算子均为标准 PyTorch 算子,在 Ascend NPU 上可直接运行。
@article{kelley2018sequential,
author = {Kelley, David R. and Reshef, Yakir A. and Bileschi, Maxwell and Belanger, David and McLean, Cory Y. and Snoek, Jasper},
title = {Sequential regulatory activity prediction across chromosomes with deep convolutional and recurrent neural networks},
journal = {Genome Research},
year = 2018,
volume = 28,
number = 5,
pages = {739--750},
doi = {10.1101/gr.227819.117},
publisher = {Cold Spring Harbor Laboratory}
}