模型名称: multimolecule/scbasset
模型链接: HuggingFace
模型描述: scBasset 是一个基于 1D 卷积神经网络的单细胞染色质可及性预测模型。输入 DNA 序列(1344bp),输出 2034 个细胞类型的可及性分数。
模型架构: ScBassetForSequencePrediction (8-layer 1D-CNN + BatchNorm + Bottleneck + Linear head)
参数规模: 4,585,978 (~4.6M)
输入规格:
(batch_size, 1344),dtype: int64输出规格:
(batch_size, 2034),dtype: float32| 依赖项 | 版本要求 | 说明 |
|---|---|---|
| Python | >= 3.10 | 推荐 3.11 |
| torch | >= 2.1.0 | PyTorch 框架 |
| torch_npu | >= 2.1.0 | 昇腾 NPU 后端 |
| transformers | >= 4.0.0 | HuggingFace Transformers(需兼容 shim) |
| multimolecule | >= 0.2.0 | 模型定义与权重加载 |
| safetensors | >= 0.4.0 | 安全张量格式 |
| numpy | < 2.0 | 数值计算 |
| 昇腾驱动 | CANN 8.0+ | 推荐 CANN 8.5.1 |
安装命令:
pip install torch_npu==2.9.0.post1 transformers==4.57.6 multimolecule>=0.2.0 safetensors numpy==1.26.4注意:
multimolecule 0.2.x依赖transformers.initialization模块(transformers >= 4.5 中已移除)。 运行推理前需注入兼容 shim,或在sitecustomize.py中配置。
# 检查 NPU 设备
npu-smi info
# 验证 torch_npu
python3 -c "import torch_npu; print(torch.npu.device_count(), torch.npu.get_device_name(0))"模型权重文件位于 weights/ 目录:
config.json — 模型配置model.safetensors — 模型权重(56 个张量,~17.5MB)tokenizer_config.json — tokenizer 配置special_tokens_map.json — 特殊 token 映射vocab.txt — 词汇表# 单条序列推理
python3 inference.py --model-path weights --sequence "ACGTACGTACGT..."
# 从 FASTA 文件推理
python3 inference.py --model-path weights --fasta input.fasta
# 批量推理
python3 inference.py --model-path weights --batch-sequences seqs.txt --batch-size 16| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| --model-path | str | 必填 | 模型 checkpoint 路径 |
| --sequence | str | None | 单条 DNA 序列 |
| --fasta | str | None | FASTA 格式文件路径 |
| --batch-sequences | str | None | 每行一条 DNA 序列的文本文件 |
| --batch-size | int | 8 | 推理批大小 |
| --top-k | int | 5 | 输出 Top-K 细胞类型 |
[模型] ScBasset (multimolecule/scbasset)
[设备] Ascend NPU (npu:0)
[权重] weights
[序列数] 3, 每条长度=1344bp
[批大小] 8
[参数量] 4,585,978
[耗时] 0.15s (50.6ms/seq)
[输出] logits shape: torch.Size([3, 2034]) (batch=3, num_labels=2034)
[状态] SUCCESS[批量统计]
平均logit: -3.7341
Std: 1.3085
Min: -9.3728, Max: 0.3686运行命令:
python3 inference.py --model-path weights --sequence "ATATATATATATATATATATATATATATATATATATATATATATATATATATATATATATATAT"输出:
[模型] ScBasset (multimolecule/scbasset)
[设备] Ascend NPU (npu:0)
[权重] weights
[序列数] 1, 每条长度=1344bp
[批大小] 8
[参数量] 4,585,978
[耗时] 0.02s (21.3ms/seq)
[输出] logits shape: torch.Size([1, 2034])
[状态] SUCCESS运行命令:
python3 inference.py --model-path weights --sequence "GCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGC"输出:
[输出] logits shape: torch.Size([1, 2034])
[状态] SUCCESS运行命令:
python3 inference.py --model-path weights --sequence "ACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGT"输出:
[序列数] 3, 每条长度=1344bp
[输出] logits shape: torch.Size([3, 2034])
[状态] SUCCESS
Top-5 可及性预测 (seq 1):
#1: cell_type_id=1224, logit=0.3686
#2: cell_type_id=770, logit=0.1096
#3: cell_type_id=1868, logit=-0.0648
#4: cell_type_id=489, logit=-0.1637
#5: cell_type_id=1189, logit=-0.2123


测试数据: 合成 DNA 序列(AT-rich、GC-rich、随机混合),长度 1344bp
评测指标:
| 指标 | 结果 | 说明 |
|---|---|---|
| 参数量 | 4,585,978 | 模型总参数 |
| 推理延迟 | ~50ms/seq (batch=1, NPU) | 单条推理耗时 |
| AT vs GC 差异 | 3.33 (mean abs diff) | 不同序列产生不同预测 |
| 输出范围 | [-12.75, 3.71] | 全量推理 logits 范围 |
评测命令:
python3 inference.py --model-path weights --sequence "ATATAT..."实际输出:
[输出] logits shape: torch.Size([1, 2034])
[状态] SUCCESSnum_labels=1:该值为 legacy 设置,实际模型输出 2034 维(对应 2034 个细胞类型)。head 层为 sequence_head.decoder,权重 shape (2034, 32)。multimolecule 0.2.x 依赖 transformers.initialization 模块(transformers >= 4.5 中已移除),运行时需通过 sitecustomize.py 注入兼容 shim,或在同进程中手动注入。