NABP-LSTM-Att

Model Introduction

NABP-LSTM-Att is a binary classification model that predicts whether a nanobody binds to an antigen using sequence information only.

The model separately encodes the nanobody CDR and antigen sequences, extracts interaction features through one-dimensional convolution, bidirectional LSTM, and a soft attention mechanism, and finally outputs a binding probability between 0 and 1.

Paper: NABP-LSTM-Att: Nanobody–Antigen binding prediction using bidirectional LSTM and soft attention mechanism

Model Description

The default model uses the following inputs and architecture:

  • The nanobody CDR is represented using 3-mers with an input length of 24;
  • The antigen is represented using 1-mers with an input length of 2371;
  • CDR sequence embeddings are added to CDR positional/index embeddings before being passed through a convolutional layer;
  • The antigen sequence is processed through an independent embedding layer and convolutional layer;
  • The two feature streams are concatenated and aggregated using a BiLSTM and soft attention layer;
  • A Sigmoid output layer produces a single binding probability;
  • Binary cross-entropy is used as the training objective.

Use Cases

Use Case Description
Nanobody–antigen binding prediction Predict the probability of binding from CDR and antigen sequence features.
Official test-set evaluation Evaluate the official pretrained model using AUROC and AUPR.
Model retraining Train the model from randomly initialized weights using the precomputed training and validation datasets.
DCU compatibility validation Validate inference, backward propagation, parameter updates, and device placement on DCU.

Usage

1. OneCode

You can use the OneCode online environment for an intelligent one-click AI4S programming experience:

Try OneCode for AI4S Programming

2. Manual Installation

Hardware Requirements

  • Running in the OneScience Hygon DCU environment is recommended;
  • The current adaptation has been validated on BW DCU;
  • Both inference and training support single-device execution.

Download the Model Package

Install the Hugging Face command-line tool and download the model repository:

python -m pip install -U huggingface_hub

hf download OneScience-Group/NABP-LSTM-Att --local-dir ./NABP-LSTM-Att
cd NABP-LSTM-Att

Install the OneScience Base Environment

conda create -n onescience311 python=3.11 -y
conda activate onescience311

python -m pip install "onescience[bio-dcu]" \
  -i http://mirrors.onescience.ai:3141/pypi/simple/ \
  --trusted-host mirrors.onescience.ai

Version Compatibility

This project requires an upgraded DTK and TensorFlow environment.

Load DTK and install the additional dependencies:

module load compiler/dtk/26.04

python -m pip install --upgrade --no-deps -r requirements.txt

Weights and Data Preparation

The Hugging Face model package already contains the precomputed features, k-mer vocabularies, and official pretrained weights required for inference and training.

No additional dataset download is required for the default workflow.

The default assets are:

conf/data/features/cdr_kmer3_ag_kmer1/
weight/cdr_kmer3_ag_kmer1/Model99.h5

Quick Inference

Purpose: Evaluate the complete official test set using the pretrained weights. The script reports AUROC, AUPR, runtime, and throughput, and can optionally save the prediction results.

python scripts/evaluate_test_set.py \
  --batch-size 64 \
  --output output/test_predictions.npz

Full-Dataset Training

Purpose: Train the model from randomly initialized weights using the complete training dataset and evaluate it on the validation set.

By default, training runs for 100 epochs.

Checkpoints are written to:

output/checkpoints/

The official pretrained weights are not overwritten.

Run:

python scripts/train.py

To validate the complete training pipeline with only one epoch, run:

python scripts/train_one_epoch.py \
  --batch-size 64 \
  --output-dir output/one_epoch_run1

Minimal Compatibility Validation

Use the following commands to perform lightweight inference and training validation:

python scripts/verify_minimal_inference.py --samples 8

python scripts/verify_minimal_training.py \
  --batch-size 8 \
  --steps 3

Custom Data

Custom sequences must first be converted into CDR and antigen feature objects that are compatible with the pickle format used by the official dataset.

Scripts for data acquisition, dataset splitting, k-mer TSV generation, and feature encoding are provided in:

scripts/

When rebuilding the dataset from the original SAbDab-nano data, additional external tools such as CD-HIT and Clustal Omega are also required.

OneScience Official Resources

Citation and License


中文说明

模型简介

NABP-LSTM-Att 是一种仅使用序列信息预测纳米抗体是否与抗原结合的二分类模型。

该模型分别对纳米抗体 CDR 序列和抗原序列编码,通过一维卷积、双向 LSTM 和软注意力机制提取相互作用特征,最终输出介于 0 和 1 之间的结合概率。

论文NABP-LSTM-Att:使用双向 LSTM 和软注意力机制预测纳米抗体与抗原的结合

模型描述

默认模型采用以下输入和架构。

  • 纳米抗体 CDR 使用 3-mers 表示,输入长度为 24。
  • 抗原使用 1-mers 表示,输入长度为 2371。
  • CDR 序列嵌入与 CDR 位置/索引嵌入相加,再送入卷积层。
  • 抗原序列经独立的嵌入层和卷积层处理。
  • 拼接两个特征流,并使用 BiLSTM 和软注意力层聚合。
  • Sigmoid 输出层生成单个结合概率。
  • 使用二元交叉熵作为训练目标。

使用场景

使用场景 说明
纳米抗体与抗原结合预测 根据 CDR 和抗原的序列特征预测结合概率。
官方测试集评估 使用 AUROC 和 AUPR 评估官方预训练模型。
模型重新训练 使用预计算的训练和验证数据集,从随机初始化的权重开始训练模型。
DCU 兼容性验证 验证 DCU 上的推理(inference)、反向传播、参数更新和设备放置。

使用方法

1. OneCode

可使用 OneCode 在线环境体验智能一键 AI4S 编程。

使用 OneCode 体验 AI4S 编程

2. 手动安装

硬件要求

  • 建议在 OneScience Hygon DCU 环境中运行。
  • 当前适配已在 BW DCU 上验证。
  • 推理和训练均支持单设备运行。

下载模型包

安装 Hugging Face 命令行工具并下载模型仓库。

python -m pip install -U huggingface_hub

hf download OneScience-Group/NABP-LSTM-Att --local-dir ./NABP-LSTM-Att
cd NABP-LSTM-Att

安装 OneScience 基础环境

conda create -n onescience311 python=3.11 -y
conda activate onescience311

python -m pip install "onescience[bio-dcu]" \
  -i http://mirrors.onescience.ai:3141/pypi/simple/ \
  --trusted-host mirrors.onescience.ai

版本兼容性

本项目要求升级 DTK 和 TensorFlow 环境。

加载 DTK 并安装其他依赖。

module load compiler/dtk/26.04

python -m pip install --upgrade --no-deps -r requirements.txt

权重与数据准备

Hugging Face 模型包已包含推理和训练所需的预计算特征、k-mer 词表及官方预训练权重。

默认流程无需另行下载数据集。

默认资源如下。

conf/data/features/cdr_kmer3_ag_kmer1/
weight/cdr_kmer3_ag_kmer1/Model99.h5

快速推理

用途:使用预训练权重评估完整的官方测试集。脚本报告 AUROC、AUPR、运行时间和吞吐量,也可按需保存预测结果。

python scripts/evaluate_test_set.py \
  --batch-size 64 \
  --output output/test_predictions.npz

完整数据集训练

用途:使用完整训练数据集从随机初始化的权重开始训练模型,并在验证集上评估。

默认训练 100 轮。

模型权重(检查点)(checkpoints)写入以下位置。

output/checkpoints/

官方预训练权重不会被覆盖。

运行以下命令。

python scripts/train.py

如需仅训练一轮以验证完整训练流程,请运行以下命令。

python scripts/train_one_epoch.py \
  --batch-size 64 \
  --output-dir output/one_epoch_run1

最小兼容性验证

使用以下命令进行轻量级推理和训练验证。

python scripts/verify_minimal_inference.py --samples 8

python scripts/verify_minimal_training.py \
  --batch-size 8 \
  --steps 3

自定义数据

自定义序列必须先转换为与官方数据集所用 pickle 格式兼容的 CDR 及抗原特征对象。

以下位置提供用于数据获取、数据集划分、生成 k-mer TSV 及特征编码的脚本。

scripts/

从原始 SAbDab-nano 数据重新构建数据集时,还需要 CD-HIT 和 Clustal Omega 等外部工具。

OneScience 官方资源

引用与许可证

Downloads last month
21
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support