Initial upload: MitoSeqGen baseline checkpoint (Model 1, CE baseline)
Browse files- README.md +105 -0
- config.json +41 -0
- pytorch_model.pt +3 -0
README.md
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: unknown
|
| 3 |
+
tags:
|
| 4 |
+
- biology
|
| 5 |
+
- genomics
|
| 6 |
+
- mrna
|
| 7 |
+
- codon-optimization
|
| 8 |
+
- mitochondria
|
| 9 |
+
- transformer
|
| 10 |
+
- pytorch
|
| 11 |
+
library_name: pytorch
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
# MitoSeqGen — Mitochondrial Codon-Aware Sequence Generator
|
| 15 |
+
|
| 16 |
+
MitoSeqGen is a sequence-to-sequence Transformer that generates mitochondrial coding
|
| 17 |
+
sequences (CDS) from an input amino-acid (protein) sequence, respecting the
|
| 18 |
+
vertebrate mitochondrial genetic code and codon usage patterns learned from
|
| 19 |
+
mitochondrial genomes.
|
| 20 |
+
|
| 21 |
+
This checkpoint is the **cross-entropy baseline** model (referred to as "Model 1" in
|
| 22 |
+
the project's internal comparisons) — of the variants evaluated so far it has the
|
| 23 |
+
best BLEU / mt-CAI tradeoff and the lowest GC-content drift from natural sequences.
|
| 24 |
+
|
| 25 |
+
- Repo / training code: https://github.com/Maheshbonthada/MItoDNA (private)
|
| 26 |
+
|
| 27 |
+
## Model details
|
| 28 |
+
|
| 29 |
+
- **Architecture:** encoder-decoder Transformer (`MitoSeqTransformer`), amino-acid
|
| 30 |
+
sequence in, codon sequence out.
|
| 31 |
+
- **Parameters:** ~25.2M
|
| 32 |
+
- **d_model:** 384 · **heads:** 6 · **encoder/decoder layers:** 6 each ·
|
| 33 |
+
**feedforward dim:** 1536 · **dropout:** 0.1 · **max position embeddings:** 768
|
| 34 |
+
- **Training objective:** token-level cross-entropy over the codon vocabulary
|
| 35 |
+
- **Training data:** vertebrate mitochondrial genome CDS records, QC-filtered,
|
| 36 |
+
deduplicated, and split by phylogeny into train/val/test (see the training repo's
|
| 37 |
+
`data/` and `src/data/` for the pipeline)
|
| 38 |
+
- **Epochs trained:** 30 (this checkpoint is the best-validation-loss snapshot, epoch 20)
|
| 39 |
+
- **Final validation loss:** 0.901 (train loss 0.940 at epoch 30)
|
| 40 |
+
- **Hardware used for training:** single NVIDIA RTX 3050 (8.6GB VRAM), bf16 mixed precision
|
| 41 |
+
|
| 42 |
+
## Evaluation (n=200 held-out test proteins)
|
| 43 |
+
|
| 44 |
+
| Metric | MitoSeqGen (this model) |
|
| 45 |
+
|---|---|
|
| 46 |
+
| mean mt-CAI | 0.870 |
|
| 47 |
+
| genetic-code compliance rate | 1.00 |
|
| 48 |
+
| mean BLEU vs. natural CDS | 0.313 |
|
| 49 |
+
| mean GC-content delta from natural | 0.042 |
|
| 50 |
+
| mean MFE delta from natural | 34.3 |
|
| 51 |
+
| novel-sequence rate | 1.00 |
|
| 52 |
+
|
| 53 |
+
mt-CAI = mitochondrial codon adaptation index; MFE = minimum free energy (RNA
|
| 54 |
+
secondary structure, via ViennaRNA). Compared against lookup-table, random-synonymous,
|
| 55 |
+
most-frequent-codon, and CodonTransformer-remap baselines in the source repo's
|
| 56 |
+
evaluation reports.
|
| 57 |
+
|
| 58 |
+
## Files
|
| 59 |
+
|
| 60 |
+
- `pytorch_model.pt` — inference-only checkpoint: `{"model_state_dict", "config",
|
| 61 |
+
"epoch", "val_loss"}`. Optimizer/scheduler state was stripped (not needed for
|
| 62 |
+
inference); this is **not** a drop-in replacement for resuming training.
|
| 63 |
+
- `config.json` — the full training config (data paths, model hyperparameters,
|
| 64 |
+
training hyperparameters, hardware settings) for this run.
|
| 65 |
+
|
| 66 |
+
## Usage
|
| 67 |
+
|
| 68 |
+
Requires the `MitoSeqTransformer` class and vocabularies from the training repo
|
| 69 |
+
(`src/models/transformer.py`, `src/genetic_codes.py`). This checkpoint does not
|
| 70 |
+
include a HF `transformers`-compatible wrapper — load it directly with PyTorch:
|
| 71 |
+
|
| 72 |
+
```python
|
| 73 |
+
import torch
|
| 74 |
+
from src.models.transformer import MitoSeqTransformer
|
| 75 |
+
from src.genetic_codes import AA_VOCAB, VOCAB # from the training repo
|
| 76 |
+
|
| 77 |
+
ckpt = torch.load("pytorch_model.pt", map_location="cpu")
|
| 78 |
+
cfg = ckpt["config"]["model"]
|
| 79 |
+
|
| 80 |
+
model = MitoSeqTransformer(
|
| 81 |
+
src_vocab_size=len(AA_VOCAB),
|
| 82 |
+
tgt_vocab_size=len(VOCAB),
|
| 83 |
+
d_model=cfg["d_model"],
|
| 84 |
+
nhead=cfg["nhead"],
|
| 85 |
+
num_encoder_layers=cfg["num_encoder_layers"],
|
| 86 |
+
num_decoder_layers=cfg["num_decoder_layers"],
|
| 87 |
+
dim_feedforward=cfg["dim_feedforward"],
|
| 88 |
+
dropout=cfg["dropout"],
|
| 89 |
+
max_position_embeddings=cfg["max_position_embeddings"],
|
| 90 |
+
)
|
| 91 |
+
model.load_state_dict(ckpt["model_state_dict"])
|
| 92 |
+
model.eval()
|
| 93 |
+
|
| 94 |
+
# then use src.models.generate.generate_cds(model, protein_sequence, device="cpu")
|
| 95 |
+
```
|
| 96 |
+
|
| 97 |
+
## Limitations
|
| 98 |
+
|
| 99 |
+
- Research checkpoint, not benchmarked against a large external test set.
|
| 100 |
+
- Two multi-objective variants (GC-content / mt-CAI regularized) were trained
|
| 101 |
+
alongside this baseline; one regressed on held-out evaluation and a fourth
|
| 102 |
+
(synonym-class-restricted) has not yet been fully evaluated. This baseline was
|
| 103 |
+
selected as the best-performing checkpoint among those evaluated so far, not
|
| 104 |
+
necessarily the final model for the project.
|
| 105 |
+
- License unset — treat as all-rights-reserved until the repo owner adds one.
|
config.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"project": {
|
| 3 |
+
"name": "MitoSeqGen",
|
| 4 |
+
"seed": 42
|
| 5 |
+
},
|
| 6 |
+
"data": {
|
| 7 |
+
"raw_dir": "data/raw",
|
| 8 |
+
"processed_dir": "data/processed",
|
| 9 |
+
"qc_dir": "data/qc_reports",
|
| 10 |
+
"splits_dir": "data/splits",
|
| 11 |
+
"tokenized_file": "mito_cds_tokenized_augmented.json",
|
| 12 |
+
"train_split": "train_augmented.json",
|
| 13 |
+
"val_split": "val.json",
|
| 14 |
+
"test_split": "test.json"
|
| 15 |
+
},
|
| 16 |
+
"model": {
|
| 17 |
+
"d_model": 384,
|
| 18 |
+
"nhead": 6,
|
| 19 |
+
"num_encoder_layers": 6,
|
| 20 |
+
"num_decoder_layers": 6,
|
| 21 |
+
"dim_feedforward": 1536,
|
| 22 |
+
"dropout": 0.1,
|
| 23 |
+
"max_position_embeddings": 768
|
| 24 |
+
},
|
| 25 |
+
"training": {
|
| 26 |
+
"batch_size": 24,
|
| 27 |
+
"gradient_accumulation_steps": 2,
|
| 28 |
+
"learning_rate": 0.0003,
|
| 29 |
+
"weight_decay": 0.01,
|
| 30 |
+
"epochs": 30,
|
| 31 |
+
"warmup_steps": 1000,
|
| 32 |
+
"early_stopping_patience": 10,
|
| 33 |
+
"grad_clip_norm": 1.0
|
| 34 |
+
},
|
| 35 |
+
"hardware": {
|
| 36 |
+
"device": "auto",
|
| 37 |
+
"mixed_precision": "bf16",
|
| 38 |
+
"num_workers": 0,
|
| 39 |
+
"pin_memory": true
|
| 40 |
+
}
|
| 41 |
+
}
|
pytorch_model.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:895b6e24a2e0919ecd1a86bc598d1a7277e09dcfac13e26c9b438969e49fbcbf
|
| 3 |
+
size 100879726
|