模型名称: multimolecule/aparent2
模型链接: HuggingFace
模型描述: APARENT2 是一个残差卷积神经网络,用于预测人类 3' UTR 选择性多聚腺苷酸化(APA)和切割强度。该网络完全由卷积层和位置级局部连接的文库偏置层组成,不使用全连接层。
模型架构: Residual Convolutional Network (APARENT2)
参数规模: 188,965 参数
输入规格:
input_ids: (batch_size, 205) int64 - RNA token IDs(5类:A/C/G/U/N)attention_mask: (batch_size, 205) int64 - 可选 mask(batch_size, 5, 205) float32输出规格:
logits: (batch_size, 206) float32 - APA 切割分布分数(含"无切割"bucket)pooler_output: (batch_size, 206) float32 - 与 logits 相同last_hidden_state: (batch_size, 205, 32) float32 - 特征图| 依赖项 | 版本要求 | 说明 |
|---|---|---|
| Python | >= 3.10 | 推荐 3.11 |
| torch | >= 2.1.0 | PyTorch 框架 |
| torch-npu | >= 2.1.0 | 昇腾 NPU 后端 |
| transformers | >= 5.0.0 | HuggingFace Transformers(需兼容补丁) |
| multimolecule | >= 0.2.1 | 生物分子深度学习框架 |
| danling | >= 0.2.0 | 深度学习工具包 |
| sentencepiece | >= 0.1.99 | Tokenizer 依赖 |
| protobuf | >= 3.20.0 | Protocol Buffers |
| numpy | < 2 | 数值计算 |
| 昇腾驱动 | CANN 8.0+ | 推荐 CANN 8.5.1 |
安装命令:
pip install torch-npu==2.9.0.post1 transformers>=5.15.0 multimolecule>=0.2.1 danling>=0.2.0 sentencepiece>=0.1.99 protobuf>=3.20.0 "numpy<2"# 检查 NPU 设备
npu-smi info
# 验证 torch_npu
python3 -c "import torch_npu; print(torch.npu.device_count(), torch.npu.get_device_name(0))"APARENT2 模型使用 multimolecule 包加载,支持从预训练权重或随机初始化运行:
# 克隆模型仓库(含权重)
git clone https://gitcode.com/hf_mirrors/multimolecule/aparent2.git
# 或使用 HuggingFace 下载
huggingface-cli download multimolecule/aparent2 --local-dir ./aparent2_model# 基本推理(使用随机初始化权重)
python inference.py
# 指定预训练权重路径
python inference.py --model-path ./aparent2_model
# 自定义序列(205 nt)
python inference.py --sequence "ACGUACGUACGUACGUACGUACGUACGUACGUACGUACGUACGUACGUACGUACGUACGUACGUACGUACGUACGUACGUACGUACGUACGUACGUACGUACGUACGUACGUACGUACGUACGUACGUACGUAC"# 批量推理(默认 batch_size=4)
python inference.py --batch-size 8
# 指定 NPU 设备
python inference.py --device npu:1# 100次推理基准测试
python inference.py --iterations 100| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| --model-path | str | None | 模型 checkpoint 路径(可选) |
| --device | str | npu:0 | NPU 设备 |
| --sequence | str | N70+AAUAAA+N129 | 205 nt RNA 序列 |
| --batch-size | int | 4 | 批量大小 |
| --iterations | int | 100 | 基准测试迭代次数 |
| --library-index | int | 11 | 训练子文库索引 |
[Model] multimolecule/aparent2
[Device] Ascend910_9362 (npu:0)
[Input] sequence length: 205 nt
[Output] logits.shape = torch.Size([1, 206])
[Output] pooler_output.shape = torch.Size([1, 206])
[Output] last_hidden_state.shape = torch.Size([1, 205, 32])
[Time] 210.44 ms
[Status] SUCCESS[Inference] Batch inference (4 sequences)...
[Output] batch logits.shape = torch.Size([4, 206])
[Time] 9.71 ms
[Status] BATCH SUCCESS[Benchmark] 100 forward passes...
[Benchmark] 100次推理统计:
平均: 7.70 ms
最小: 7.08 ms
最大: 9.09 ms
标准差: 0.28 ms
P50: 7.67 ms
P99: 9.09 ms运行命令:
python inference.py --sequence "ACGUACGUACGUACGUACGUACGUACGUACGUACGUACGUACGUACGUACGUACGUACGUACGUACGUACGUACGUACGUACGUACGUACGUACGUACGUACGUACGUACGUACGUACGUACGUACGUACGUAC"输出:
[Model] multimolecule/aparent2
[Device] Ascend910_9362 (npu:0)
[Parameters] 188,965
[Input] sequence length: 205 nt
[Inference] Single sequence...
[Output] logits.shape = torch.Size([1, 206])
[Output] pooler_output.shape = torch.Size([1, 206])
[Output] last_hidden_state.shape = torch.Size([1, 205, 32])
[Time] 210.44 ms
[Status] SUCCESS运行命令:
python inference.py --batch-size 4输出:
[Inference] Batch inference (4 sequences)...
[Output] batch logits.shape = torch.Size([4, 206])
[Status] BATCH SUCCESS运行命令:
python inference.py --iterations 100输出:
[Benchmark] 100 forward passes...
[Benchmark] 100次推理统计:
平均: 7.70 ms
最小: 7.08 ms
最大: 9.09 ms
标准差: 0.28 ms
P50: 7.67 ms
P99: 9.09 ms


注意: 由于网络限制,无法从 HuggingFace 或 AtomGit 下载预训练权重。以下评测使用模型随机初始化权重进行架构验证。
测试数据: 合成 RNA 序列(205 nt,含 APA 信号 AAUAAA)
评测指标:
| 指标 | 结果 | 说明 |
|---|---|---|
| 模型参数量 | 188,965 | 总可训练参数 |
| 推理延迟 (单条) | ~210 ms | 首次推理(含模型编译) |
| 推理延迟 (稳定) | ~7.7 ms | 100次推理平均值 |
| 输出维度 | 206 | 205位点 + "无切割"bucket |
| NPU 利用率 | Ascend910_9362 | 2卡可用 |
评测命令:
python inference.py --iterations 100实际输出:
[Cleavage Distribution]
Max cleavage position: 0
Max probability: 0.488993
No-cleavage probability: 0.020268find_pruneable_heads_and_indices 在 transformers >= 4.45 中移除,需 monkey-patch 补丁。已内置在 inference.py 中。RnaTokenizer 需要从 HuggingFace 下载,网络受限时 inference.py 会自动使用手动 one-hot 编码。