Downloads · 30 days
0
leminhhung0101/RNA_model
RNA_model is a machine learning model from leminhhung0101. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
EviRNA-NOVA is a multimodal RNA 3D structure prediction research pipeline that combines nucleotide sequence information, RibonanzaNet2 representations, MSA-derived features, secondary-structure/base-pair priors, a Pai…
Downloads · 30 days
0
Access
Public
Updated Sep 7, 2026
Repo size
634 MB
Likes
0
Public
Click a slice to open those files.
.bin405 MB · 64%
From the Hugging Face model README
EviRNA-NOVA is a multimodal RNA 3D structure prediction research pipeline that combines nucleotide sequence information, RibonanzaNet2 representations, MSA-derived features, secondary-structure/base-pair priors, a Pairformer-style backbone, and flow-based coordinate generation.
The current codebase is designed primarily for:
Status: Research / experimental. This is not a clinical model or a validated RNA structure tool for high-stakes biological decision-making.
The main input is an RNA sequence:
AUGCGGAUACCGUAAGCU...
EviRNA-NOVA builds multiple evidence sources:
RNA sequence
│
├── Sequence embedding
├── RibonanzaNet2 single features
├── RibonanzaNet2 pair features
├── MSA features
├── Secondary-structure / base-pair priors
└── Template evidence (when available)
│
▼
Dynamic Evidence Router
│
▼
Pairformer
│
▼
Geometry heads
│
▼
E(3)-aware / flow module
│
▼
3D coordinates
The final output is one or more RNA structures:
[N, 3]
where N is the number of nucleotides and the three dimensions correspond to x, y, z coordinates.
The RNA sequence is encoded into nucleotide indices and residue-level embeddings.
Main nucleotide symbols:
A
C
G
U
N / unknown
The sequence branch provides residue representations and basic pair priors.
RibonanzaNet2 is used as a frozen feature extractor.
For an RNA of length N, the pipeline produces:
single feature : [N, D_single]
pair feature : [N, N, D_pair]
The current NOVA configuration typically uses projected dimensions:
D_single = 128
D_pair = 16
RibonanzaNet2 features must be generated for the actual new RNA sequences during inference. They must not be replaced with random or reused features from unrelated targets.
If the test folder contains:
MSA/
the pipeline can use multiple sequence alignments to construct:
If no MSA is available, the inference-only pipeline can use a query-only fallback so that the model can still run.
The pipeline constructs priors such as:
A-U
U-A
G-C
C-G
G-U
U-G
These can be combined with MSA compatibility and an external base-pair map when available.
This information becomes an independent evidence source for each nucleotide pair (i, j).
The model does not simply concatenate all modalities.
For each nucleotide pair (i, j), the router learns weights for evidence sources such as:
Sequence
RibonanzaNet2
MSA
Template
Secondary structure
Conceptually:
[ z_{ij} = \sum_k w^{(k)}{ij} E^{(k)}{ij} ]
with:
[ \sum_k w^{(k)}_{ij} = 1 ]
This allows the model to dynamically change how much it trusts each modality for different nucleotide pairs.
The fused pair representation is processed through multiple Pairformer blocks.
The backbone may include:
A typical Tesla T4 profile is approximately:
d_node ≈ 160
d_pair ≈ 96
pair blocks ≈ 8
recycles ≈ 2
Larger profiles can use wider representations and more blocks on stronger GPUs.
The Pairformer representation is supervised through several geometry-related tasks:
distance
distogram
contact
base-pair
stacking
orientation
pair confidence
For example, the predicted pairwise distance is:
[ \hat d_{ij} ]
and the ground-truth distance is:
[ d_{ij} = |x_i - x_j| ]
The distogram head predicts a probability distribution over distance bins rather than only a single continuous value.
NOVA uses a flow-style coordinate generation module.
During training:
native coordinates x1
+
starting/noisy coordinates x0
↓
intermediate xt
↓
predict velocity
↓
flow loss
A simple interpolation is:
[ x_t = (1-t)x_0 + tx_1 ]
with target velocity:
[ v^* = x_1 - x_0 ]
The model learns:
[ v_\theta(x_t,t) ]
to move a noisy or initial structure toward the target RNA structure.
The default training curriculum contains five stages:
| Stage | Epochs | Purpose |
|---|---|---|
S1_geometry_warmup | 8 | Geometry / Pairformer warm-up |
S2_flow_warmup | 6 | Flow training |
S3_joint_geometry_flow | 16 | Joint geometry + flow |
S4_teacher_distillation | 8 | Teacher/KD stage when a teacher is available |
S5_temporal_safe_finetune | 10 | Final fine-tuning |
Default total:
48 epochs
If the code is launched with --epochs N, the curriculum may be proportionally rescaled.
The implementation is designed to avoid several common mixed-precision failures on Tesla T4 GPUs.
FP16 / AMP
is used for Transformer, Pairformer, and MLP operations to reduce memory usage.
The following operations are forced to FP32:
SVD
Kabsch alignment
torch.cdist
coordinate geometry
distance-target construction
This avoids failures such as:
svd_cuda_gesvdjBatched not implemented for 'Half'
Confidence-related binary classification uses:
binary_cross_entropy_with_logits
instead of applying BCE directly to a sigmoid output inside autocast.
Pairformer blocks support activation checkpointing to reduce VRAM usage.
An important checkpointing issue was addressed in later versions: checkpoint closures should not capture loop variables such as blk through a lambda.
Avoid:
checkpoint(lambda x, z: blk(x, z, ...), ...)
when the captured block may change before backward recomputation.
The implementation instead checkpoints the actual module/block directly so that forward and backward recomputation use the same graph.
The training pipeline was originally designed around files such as:
train_sequences.csv
train_labels.csv
validation_sequences.csv
validation_labels.csv
MSA/
PDB_RNA/
extra/
The split policy is:
This is intended to reduce data leakage.
Pairwise representations become expensive as sequence length grows because memory scales approximately with:
[ O(N^2) ]
Training commonly uses:
crop_len = 256
crop_stride = 192
For inference, long RNAs can be processed using a windowed strategy:
Recommended inference scripts include:
EviRNA_NOVA_INFERENCE_ONLY_NEW_FOLDER_V19.py
or the direct-path variant:
EviRNA_NOVA_INFERENCE_DIRECT_PATHS_V20.py
Inference-only execution does not require:
NOVA_history.csv
split_fit_targets.csv
split_calib_targets.csv
curriculum_fit_windows.csv
curriculum_calib_windows.csv
training evidence_cache.pkl
optimizer state
scheduler state
Only the following are required:
1. new test folder
2. NOVA checkpoint
3. RibonanzaNet2 checkpoint
4. output directory / GPU runtime
Minimum structure:
MY_NEW_TEST/
└── test_sequences.csv
Recommended structure:
MY_NEW_TEST/
├── test_sequences.csv
├── MSA/
│ ├── RNA001.a3m
│ ├── RNA002.a3m
│ └── ...
├── BP/ # optional
└── sample_submission.csv # optional
test_sequences.csvtarget_id,sequence
RNA001,GGGAAACCCUUUGGG
RNA002,AUGCGGAUACCGUAAGCU
RNA003,GGCUAUAGCUCAGUUGGU
The trained model checkpoint is typically named:
NOVA_last.pt
or:
NOVA_best.pt
For inference, the checkpoint should contain at least:
state_dict
nova_cfg
foundation_single_dim
foundation_pair_dim
Additional fields such as:
optimizer_state
scheduler_state
scaler_state
stage
stage_epoch
are useful for training continuation but are not required for inference.
The NOVA checkpoint does not include the full RibonanzaNet2 model.
Inference on new RNA sequences therefore requires a separate RibonanzaNet2 checkpoint.
A compatible bundle may look like:
ribonanzanet2_checkpoint/
├── Network.py
├── pairwise.yaml
└── pytorch_model_fsdp.bin
If Kaggle is offline, this bundle must be added as an input before inference.
The script:
EviRNA_NOVA_INFERENCE_DIRECT_PATHS_V20.py
is designed so that the main paths are edited directly near the top of the file.
Example:
DIRECT_TEST_FOLDER = (
"/kaggle/input/datasets/USERNAME/MY_NEW_TEST"
)
DIRECT_NOVA_CHECKPOINT = (
"/kaggle/input/datasets/USERNAME/NOVA_MODEL/NOVA_last.pt"
)
DIRECT_RNET2_CHECKPOINT = (
"/kaggle/input/datasets/USERNAME/RIBONANZANET2/"
"ribonanzanet2_checkpoint"
)
DIRECT_OUT_DIR = (
"/kaggle/working/EVIRNA_NOVA_INFERENCE"
)
Then run:
!CUDA_VISIBLE_DEVICES=0 \
python EviRNA_NOVA_INFERENCE_DIRECT_PATHS_V20.py
A typical output directory is:
EVIRNA_NOVA_INFERENCE/
│
├── test_manifest.csv
│
├── rnet2_features_new_test/
│ ├── RNA001.npz
│ ├── RNA002.npz
│ └── ...
│
├── evidence_new_test.pkl
├── prediction_top5.csv
├── submission.csv
├── prediction_summary.csv
├── router_audit.csv
└── inference_manifest.json
prediction_top5.csvEach nucleotide can have five candidate coordinate sets:
ID
resname
resid
x_1 y_1 z_1
x_2 y_2 z_2
x_3 y_3 z_3
x_4 y_4 z_4
x_5 y_5 z_5
prediction_summary.csvThis file may include:
target_id
length
inference_mode
number_of_windows
candidate_score_1
...
candidate_score_5
router_audit.csvThis file can be used to inspect evidence usage:
sequence
RibonanzaNet2
MSA
template
secondary_structure
RibonanzaNet2 cache from an old dataset must not be reused for unrelated new RNA sequences.
The inference pipeline creates:
OUT_DIR/
└── rnet2_features_new_test/
Each RNA receives a file such as:
RNA001.npz
containing:
single
pair
If inference is interrupted, valid feature files can be reused on the next run.
To force complete feature regeneration, enable the corresponding rebuild option, for example:
force_rnet2_rebuild = True
Inference can be run with:
CUDA_VISIBLE_DEVICES=0
Recommended settings are approximately:
AMP ON
NOVA batch 1
Pairformer window 256
RNet2 adaptive chunk 128–192
Conformers 5
Flow steps 48
Very long RNAs may still require aggressive chunking because pairwise representations scale quadratically with sequence length.
Two T4 GPUs do not behave as one unified 32 GB GPU.
A single RNA target is still limited by the VRAM of the GPU processing that target.
For many independent targets, inference can be sharded:
GPU0 -> targets 0,2,4,...
GPU1 -> targets 1,3,5,...
For 4×L4 training, DistributedDataParallel is preferable to nn.DataParallel.
data
→ build evidence
→ RibonanzaNet2
→ S1-S5
→ NOVA_best.pt
NOVA_last.pt
→ restore model/optimizer/scheduler/scaler
→ continue stage/epoch
new test folder
→ new RibonanzaNet2 features
→ NOVA checkpoint
→ 5 conformers
If the goal is only to predict new RNA data, the inference-only script should be used instead of resume-training scripts.
Several implementation issues were identified and fixed during development.
Unsafe pattern:
binary_cross_entropy(sigmoid(logits), target)
Preferred:
binary_cross_entropy_with_logits(logits, target)
Unsafe on some Tesla T4 configurations:
torch.linalg.svd(H_half)
Preferred:
torch.linalg.svd(H.float())
Multiplying invalid values by zero is not sufficient because:
NaN * 0 = NaN
Coordinates must be sanitized before:
cdist
Kabsch
geometry losses
Avoid checkpointing closures that may capture the wrong block:
checkpoint(lambda ...: blk(...))
inside a changing loop.
CUDA OOM must not be treated as an API mismatch.
Once the correct RibonanzaNet2 encoder API is identified, OOM should trigger:
re-raise / adaptive chunking
rather than repeatedly trying unrelated call signatures.
For reproducible inference, save:
NOVA checkpoint
RibonanzaNet2 checkpoint
inference script
test_sequences.csv
MSA files
random seed
PyTorch version
CUDA version
GPU name
prediction_summary.csv
inference_manifest.json
Current limitations include:
1. Prepare test_sequences.csv
↓
2. Add MSA if available
↓
3. Load RibonanzaNet2
↓
4. Extract NEW RibonanzaNet2 features
↓
5. Build SS/BP evidence
↓
6. Load NOVA checkpoint
↓
7. Run direct or windowed inference
↓
8. Generate 5 conformers
↓
9. Rank/diversify conformers
↓
10. Save prediction_top5.csv
EviRNA-NOVA can be summarized as:
[ \boxed{ \text{Sequence} + \text{RibonanzaNet2} + \text{MSA} + \text{SS/BP} + \text{Template (optional)} \rightarrow \text{Dynamic Evidence Fusion} \rightarrow \text{Pairformer} \rightarrow \text{Geometry} \rightarrow \text{Flow} \rightarrow \text{RNA 3D} } ]
The core design goal is to combine multiple evidence sources rather than relying on a single modality, while producing multiple candidate RNA structures for top-k structural prediction.
The current pipeline is an internal / experimental research implementation.
Before public release, the repository should include: