Instructions to use zxliu54/RNABERT-StruSem-RMI with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use zxliu54/RNABERT-StruSem-RMI with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="zxliu54/RNABERT-StruSem-RMI")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("zxliu54/RNABERT-StruSem-RMI") model = AutoModel.from_pretrained("zxliu54/RNABERT-StruSem-RMI", device_map="auto") - Notebooks
- Google Colab
- Kaggle
File size: 8,733 Bytes
47261a3 43eb826 47261a3 43eb826 735683b 47261a3 735683b 47261a3 43eb826 47261a3 43eb826 735683b 43eb826 47261a3 735683b 43eb826 47261a3 43eb826 47261a3 735683b 47261a3 43eb826 47261a3 43eb826 47261a3 43eb826 735683b 43eb826 735683b 43eb826 735683b 43eb826 47261a3 43eb826 47261a3 735683b 47261a3 43eb826 47261a3 735683b 43eb826 735683b 43eb826 735683b 47261a3 43eb826 47261a3 43eb826 47261a3 43eb826 47261a3 735683b 47261a3 43eb826 47261a3 43eb826 47261a3 43eb826 47261a3 735683b 43eb826 47261a3 43eb826 47261a3 43eb826 47261a3 735683b 47261a3 43eb826 47261a3 43eb826 47261a3 735683b 47261a3 43eb826 47261a3 43eb826 47261a3 735683b 43eb826 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | ---
library_name: transformers
license: agpl-3.0
pipeline_tag: feature-extraction
tags:
- Biology
- RNA
- bert
- rnabert
- StruSem-RMI
---
# RNABERT-StruSem-RMI
## Overview
This repository contains the adapted RNABERT checkpoint used for RNA sequence
feature extraction in StruSem-RMI, a knowledge-enhanced multimodal framework
for RNA–small molecule interaction prediction. The checkpoint is packaged in
a Transformers-compatible `BertModel` format and is provided to facilitate
reproduction of the RNA sequence features described in Supplementary Method S9
of the associated manuscript.
RNABERT was originally developed by Manato Akiyama and Yasubumi Sakakibara.
The checkpoint in this repository is an RNA sequence encoder, not the complete
StruSem-RMI interaction prediction model.
- [StruSem-RMI source code](https://github.com/54Xander/StruSem-RMI)
- [RSID database](http://rsid.hzau.edu.cn)
- [Original RNABERT implementation](https://github.com/mana438/RNABERT)
- [MultiMolecule RNABERT implementation](https://huggingface.co/multimolecule/rnabert)
- [Previously linked RNABERT repository](https://huggingface.co/yangheng/rnabert)
- [Original RNABERT publication](https://doi.org/10.1093/nargab/lqac012)
The upstream checkpoint revision was not recorded in the available local
checkpoint inventory. The checksums below identify the exact local
checkpoint files provided for reproduction.
## Model configuration
| Property | Value |
| --- | --- |
| Architecture | `BertModel` |
| Model type | `bert` |
| Transformer layers | 6 |
| Hidden size | 120 |
| Attention heads | 12 |
| Intermediate size | 40 |
| Vocabulary size | 26 |
| Maximum positional capacity | 440 tokens |
| Parameters | 480,840 |
| Weight data type | float32 |
| Feature representation | `pooler_output` |
## Download and installation
First, prepare the Python environment described in the
[StruSem-RMI repository](https://github.com/54Xander/StruSem-RMI).
From the root of the StruSem-RMI project, run:
```bash
python -m pip install huggingface_hub
hf download zxliu54/RNABERT-StruSem-RMI config.json model.safetensors vocab.txt special_tokens_map.json tokenizer_config.json --local-dir pretrained_models/rnabert
```
The required files may also be downloaded manually from the
[Files and versions](https://huggingface.co/zxliu54/RNABERT-StruSem-RMI/tree/main)
page. Place them in the following directory:
```text
StruSem-RMI/
└── pretrained_models/
└── rnabert/
├── config.json
├── model.safetensors
├── vocab.txt
├── special_tokens_map.json
└── tokenizer_config.json
```
The repository also contains `pytorch_model.bin` as an alternative weight
serialization. The checksums and example in this model card refer to
`model.safetensors`, which is the recommended file for reproducibility.
For version-pinned downloads, use `--revision` with the full commit hash
of the selected repository revision.
## RNA sequence feature extraction
StruSem-RMI uses the `SimpleRnaTokenizer` implemented in
[`create_data.py`](https://github.com/54Xander/StruSem-RMI/blob/main/create_data.py),
rather than a substitute tokenizer. The pretrained encoder is operated in
evaluation mode without gradient computation. The resulting features are
cached before downstream model training, and the encoder parameters are
not updated during that training.
| Setting | Value |
| --- | --- |
| Local checkpoint directory | `pretrained_models/rnabert/` |
| Model loader | `transformers.AutoModel` |
| Tokenizer | `SimpleRnaTokenizer` |
| Maximum RNA input length | 267 tokens (including boundary tokens) |
| Padding | `max_length` |
| Truncation | Enabled |
| Feature representation | `pooler_output` |
| Embedding dimension | 120 |
| Encoder mode | Evaluation mode |
| Feature extraction | Offline, without gradient computation |
The current StruSem-RMI tokenizer uses character-level encoding, uppercase
conversion, and the special-token lookup defaults defined in the project code.
With the supplied vocabulary, the resulting padding, initial-boundary,
final-boundary and unknown-character IDs are 0, 2, 3 and 1, respectively.
These are the project's effective encoding IDs, which differ from some of the
special-token IDs declared in the vocabulary or model configuration. Preserve
the original tokenizer behavior when reproducing the StruSem-RMI features.
### Example
Run the following example from the root of StruSem-RMI after installing
its dependencies and downloading the checkpoint:
```python
import torch
from transformers import AutoModel
from create_data import SimpleRnaTokenizer
path = "pretrained_models/rnabert"
tokenizer = SimpleRnaTokenizer.from_pretrained(path)
model = AutoModel.from_pretrained(
path, local_files_only=True, use_safetensors=True
).eval()
inputs = tokenizer(
"ACGUN",
max_length=267,
padding="max_length",
truncation=True,
return_tensors="pt",
)
with torch.no_grad():
features = model(
input_ids=inputs["input_ids"],
attention_mask=inputs["attention_mask"],
).pooler_output
assert features.shape == (1, 120)
assert torch.isfinite(features).all()
print(features.shape)
```
Expected output:
```text
torch.Size([1, 120])
```
The complete preprocessing, feature caching, training and prediction
procedures are provided in the StruSem-RMI source code.
## Checkpoint integrity
The following SHA-256 values identify the files used for this release:
| File | SHA-256 |
| --- | --- |
| `model.safetensors` | `eb3a6d402126a5f5bf1972e9679a1f22484e73e920b28901618aed4767d31082` |
| `config.json` | `e67e6e33fa63d178e3b7b3921c1a8efa5e10a1db3cee8b017c38c83c87f3fb8f` |
| `vocab.txt` | `686c991af8379cbb812ada930086ad17f820327a99097eb7857ae38ef2da2572` |
The weight checksum matches the RNABERT checksum documented in Supplementary
Method S9 of the associated manuscript.
On Linux, verify the files from the root of StruSem-RMI:
```bash
sha256sum pretrained_models/rnabert/model.safetensors pretrained_models/rnabert/config.json pretrained_models/rnabert/vocab.txt
```
Matching file checksums establish the identity of these files. Reproducing
cached features also requires the original tokenizer implementation,
preprocessing settings and a compatible software environment.
## Intended use
This checkpoint is intended for RNA sequence feature extraction and
reproducible research with StruSem-RMI. It does not independently predict
RNA–small molecule interactions and does not include the trained downstream
interaction classifier.
## Citation
Please cite the original RNABERT publication:
```bibtex
@article{akiyama2022informative,
title={Informative RNA base embedding for RNA structural alignment and clustering by deep representation learning},
author={Akiyama, Manato and Sakakibara, Yasubumi},
journal={NAR Genomics and Bioinformatics},
volume={4},
number={1},
pages={lqac012},
year={2022},
doi={10.1093/nargab/lqac012}
}
```
Please also acknowledge MultiMolecule where its implementation or checkpoint
conversion contributes to the work:
```bibtex
@software{chen_2024_12638419,
author={Chen, Zhiyuan and Zhu, Sophia Y.},
title={MultiMolecule},
year={2024},
doi={10.5281/zenodo.12638419},
url={https://doi.org/10.5281/zenodo.12638419}
}
```
For applications using StruSem-RMI, please also acknowledge the associated
manuscript, *A traceable multimodal database and knowledge-enhanced model
for RNA–small molecule interaction prediction*, and the
[StruSem-RMI repository](https://github.com/54Xander/StruSem-RMI).
## License and attribution
RNABERT is credited to its original authors. The related MultiMolecule
RNABERT distribution and the previously linked `yangheng/rnabert` model
card identify their licensing as AGPL-3.0-or-later.
Relevant upstream resources include the
[MultiMolecule source code](https://github.com/DLS5-Omics/multimolecule),
[RNABERT model documentation](https://multimolecule.danling.org/models/rnabert/),
[RNAcentral data repository](https://huggingface.co/datasets/multimolecule/rnacentral),
and [original RNABERT repository](https://github.com/mana438/RNABERT).
See the [GNU Affero General Public License v3.0](https://www.gnu.org/licenses/agpl-3.0.html)
and the [MultiMolecule License FAQ](https://multimolecule.danling.org/about/license-faq/)
for the applicable terms of the respective upstream distributions. Reuse and
redistribution remain subject to the applicable upstream rights, notices
and corresponding-source requirements.
## Contact
For questions about this adaptation or its use in StruSem-RMI, please use
the [StruSem-RMI GitHub issues page](https://github.com/54Xander/StruSem-RMI/issues).
|