Fill-Mask
Transformers
PyTorch
English
caduceus
DNA
genomics
fish
Caduceus
masked-language-model
nucleotide-modeling
foundation-model
reverse-complement
custom-code
FishCaduceus
custom_code
Instructions to use FishCaduceus/FishCaduceus-20L-512 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use FishCaduceus/FishCaduceus-20L-512 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("fill-mask", model="FishCaduceus/FishCaduceus-20L-512", trust_remote_code=True)# Load model directly from transformers import AutoModelForMaskedLM model = AutoModelForMaskedLM.from_pretrained("FishCaduceus/FishCaduceus-20L-512", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
File size: 7,520 Bytes
b22c7b7 30cd90f b22c7b7 30cd90f | 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 | ---
language:
- en
license: apache-2.0
library_name: transformers
pipeline_tag: fill-mask
tags:
- DNA
- genomics
- fish
- Caduceus
- masked-language-model
- nucleotide-modeling
- foundation-model
- reverse-complement
- custom-code
- FishCaduceus
---
# FishCaduceus-20L-512
`FishCaduceus-20L-512` is a fish-specific DNA language model in the **FishCaduceus** family. It was pretrained on fish genomic sequences using a masked language modeling objective and is intended for nucleotide-level representation learning, transfer learning, and sequence-based analyses in fish genomics.
This repository contains the pretrained `FishCaduceus-20L-512` checkpoint.
## Model description
FishCaduceus is a family of Caduceus-based DNA language models developed for fish genomes. The models operate at single-nucleotide resolution and use bidirectional state-space sequence modeling together with reverse-complement-aware components.
The model learns to recover masked nucleotides from their surrounding genomic context. Its hidden representations can also be used as input features for downstream fish genomics tasks.
## Model family
| Model | Number of layers | Hidden dimension | Pretraining context length |
|---|---:|---:|---:|
| **FishCaduceus-20L-512** | **20** | **384** | **512 nt** |
| FishCaduceus-28L-512 | 28 | 768 | 512 nt |
| FishCaduceus-28L-1024 | 28 | 768 | 1024 nt |
## Architecture
- **Backbone**: Caduceus-based bidirectional state-space DNA language model
- **Training objective**: masked language modeling
- **Tokenization**: single-nucleotide character-level tokenization
- **Vocabulary size**: 8
- **Number of layers**: 20
- **Hidden dimension (`d_model`)**: 384
- **Pretraining context length**: 512 nucleotides
- **Selected training checkpoint**: step 35,000
- **Framework**: PyTorch and Hugging Face Transformers
- **Model type**: custom Transformers model (`trust_remote_code=True`)
The context length above describes the sequence length used during pretraining. Users should apply truncation or windowing appropriate for the selected model variant.
## Training data
The model was pretrained on curated fish genomic sequences obtained from publicly available genome resources. The genomes were processed through a unified quality-control and sequence-preparation workflow before construction of the masked-language-modeling corpus.
Detailed information about the included fish species, genome assemblies, preprocessing criteria, and dataset splits will be provided in the accompanying FishCaduceus dataset card and manuscript.
## Training objective
FishCaduceus was pretrained using masked language modeling. Selected nucleotide positions were masked, and the model was optimized to predict the original nucleotide from the surrounding sequence context.
Because the tokenizer operates at single-nucleotide resolution, model outputs can be used for nucleotide-level probability estimation and sequence representation learning.
## Intended uses
The model is intended for research applications including:
- nucleotide-level genomic sequence representation learning
- masked nucleotide prediction
- extraction of frozen sequence embeddings
- transfer learning and downstream fine-tuning
- fish genomic annotation tasks
- comparative and evolutionary genomics
- exploratory variant-effect and regulatory-sequence analyses
## Out-of-scope uses
The model is not intended to:
- provide clinical or diagnostic decisions
- replace experimental validation
- establish biological causality from sequence scores alone
- be used as the sole basis for decisions affecting human or animal health
## Limitations
- The model was developed primarily from fish genomic sequences, so performance may be lower for distant taxonomic groups.
- Predictions reflect patterns learned from the pretraining corpus and do not by themselves demonstrate biological function or causality.
- Performance may vary across species, genomic regions, sequence lengths, and downstream task definitions.
- Long genomic sequences should be divided into windows compatible with the selected model's pretraining context length.
- This repository contains custom modeling code. Review the repository code before loading it with `trust_remote_code=True`.
## How to use
Install the dependencies listed in `requirements.txt` before loading the model.
### Load the tokenizer and model
```python
from transformers import AutoModelForMaskedLM, AutoTokenizer
model_id = "FishCaduceus/FishCaduceus-20L-512"
tokenizer = AutoTokenizer.from_pretrained(
model_id,
trust_remote_code=True,
)
model = AutoModelForMaskedLM.from_pretrained(
model_id,
trust_remote_code=True,
)
model.eval()
```
### Masked nucleotide prediction
```python
import torch
from transformers import AutoModelForMaskedLM, AutoTokenizer
model_id = "FishCaduceus/FishCaduceus-20L-512"
sequence = "ACGTACGT[MASK]ACGTACGT"
tokenizer = AutoTokenizer.from_pretrained(
model_id,
trust_remote_code=True,
)
model = AutoModelForMaskedLM.from_pretrained(
model_id,
trust_remote_code=True,
)
model.eval()
inputs = tokenizer(sequence, return_tensors="pt")
with torch.inference_mode():
outputs = model(**inputs)
mask_rows, mask_cols = (
inputs["input_ids"] == tokenizer.mask_token_id
).nonzero(as_tuple=True)
base_tokens = ["A", "C", "G", "T"]
base_ids = tokenizer.convert_tokens_to_ids(base_tokens)
mask_logits = outputs.logits[mask_rows[0], mask_cols[0], base_ids]
base_probabilities = torch.softmax(mask_logits, dim=-1)
print(dict(zip(base_tokens, base_probabilities.tolist())))
```
### Extract sequence representations
```python
import torch
from transformers import AutoModelForMaskedLM, AutoTokenizer
model_id = "FishCaduceus/FishCaduceus-20L-512"
sequence = "ACGTACGTACGTACGT"
tokenizer = AutoTokenizer.from_pretrained(
model_id,
trust_remote_code=True,
)
model = AutoModelForMaskedLM.from_pretrained(
model_id,
trust_remote_code=True,
)
model.eval()
inputs = tokenizer(
sequence,
return_tensors="pt",
truncation=True,
max_length=512,
)
with torch.inference_mode():
outputs = model(
**inputs,
output_hidden_states=True,
)
token_embeddings = outputs.hidden_states[-1]
sequence_embedding = token_embeddings.mean(dim=1)
print("Token embeddings:", token_embeddings.shape)
print("Sequence embedding:", sequence_embedding.shape)
```
## Repository files
The repository includes the files required to load the custom FishCaduceus model and tokenizer:
- `config.json`
- model weights (`pytorch_model.bin` or `model.safetensors`)
- `configuration_caduceus.py`
- `modeling_caduceus.py`
- `modeling_rcps.py`
- `tokenization_caduceus.py`
- `tokenizer.json`
- `tokenizer_config.json`
- `special_tokens_map.json`
- `requirements.txt`
- `README.md`
## Citation
The FishCaduceus manuscript is in preparation. Citation information will be added after publication.
Users of the model should also acknowledge the original Caduceus architecture and other upstream software components where appropriate.
## Acknowledgements
FishCaduceus builds on the Caduceus architecture and related open-source sequence-modeling software. The model was developed for research on fish genomes at the Institute of Hydrobiology, Chinese Academy of Sciences.
## License
This repository is released under the Apache License 2.0. Users are responsible for complying with the licenses of all upstream software dependencies.
## Contact
For questions, please contact: xqxia@ihb.ac.cn
|