Downloads · 30 days
21
6% of all-time downloads
Unjuno/moss-dna-gpt-20m-patens
moss-dna-gpt-20m-patens is a text generation model from Unjuno. Use it when you need the model to write or continue text. It is set up for pytorch. The card lists the license as mit.
This is a custom PyTorch model, not a Hugging Face Transformers AutoModel-compatible checkpoint. Loading it requires the mossdnagpt package from github.com/Unjuno/moss-dna-gpt.
Downloads · 30 days
21
6% of all-time downloads
All-time downloads
356
Public
Parameters
21.7M
87 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors86.8 MB · 100%
From the Hugging Face model README
This is a custom PyTorch model, not a Hugging Face Transformers
AutoModel-compatible checkpoint.
Loading it requires themoss_dna_gptpackage from github.com/Unjuno/moss-dna-gpt.
Experimental 20M-parameter decoder-only Transformer trained for DNA next-base prediction on Physcomitrium patens (moss) genomic sequence.
Key result: The model achieves 1.41665 bits/base on a held-out sequence-level test split, outperforming all Markov baselines (including Interpolated Markov Model up to order 5) by 24.9% in next-base prediction cross-entropy.
This repository does not provide a Hugging Face Transformers pipeline.
Use the custom PyTorch loading code below.
# Clone and install the package
git clone https://github.com/Unjuno/moss-dna-gpt.git
cd moss-dna-gpt
pip install -e ".[hf]"
import torch
from safetensors.torch import load_file
from moss_dna_gpt.model import GPT, GPTConfig
from moss_dna_gpt.tokenizer import DnaTokenizer
from moss_dna_gpt.sampling import sample
device = "cuda" if torch.cuda.is_available() else "cpu"
# Load config
config = GPTConfig(
vocab_size=9, block_size=1024, n_layer=12,
n_head=8, n_embd=384, dropout=0.1, bias=True,
)
# Load weights
model = GPT(config).to(device)
state_dict = load_file("model.safetensors")
model.load_state_dict(state_dict)
model.eval()
# Generate
tokenizer = DnaTokenizer()
prefix = "ACGTACGTACGT"
ids = tokenizer.encode(prefix, unknown="n")
idx = torch.tensor([ids], dtype=torch.long, device=device)
allowed = [tokenizer.stoi[b] for b in tokenizer.dna_tokens]
out = sample(model, idx, max_new_tokens=128, temperature=0.8, top_k=4, allowed_token_ids=allowed)
print(tokenizer.decode(out[0].tolist(), skip_special=True))
Evaluation on held-out sequence-level test windows (177,723,392 tokens):
| Model | Bits/base | Nats/base |
|---|---|---|
| Markov order 0 | 1.92504 | 1.33434 |
| Markov order 1 | 1.90902 | 1.32323 |
| Markov order 2 | 1.90315 | 1.31917 |
| Markov order 3 | 1.89569 | 1.31399 |
| Dinucleotide shuffled (order 5) | 1.90728 | 1.32203 |
| K3 shuffled (order 5) | 1.90049 | 1.31732 |
| IMM (interpolated 0..5) | 1.88614 | 1.30738 |
| Markov order 5 | 1.88614 | 1.30738 |
| DNA-GPT 20M (step 8M) | 1.41665 | 0.98195 |
Note on evaluation settings. The final step-8M evaluation used the full test set (~177M tokens). The intermediate curve points used a smaller subset (
eval_batches=200). Learning-curve points and the release metric are not directly interchangeable due to different evaluation batch sizes. The canonical release claim is 1.41665 bits/base fromresults/eval_markov_20m_step8000000.json.
The learning curve shows DNA-GPT surpassing all Markov baselines within the first 750K steps:

| File | Description |
|---|---|
README.md | Model card (this file) |
model.safetensors | Model weights in safetensors format |
config.json | Model configuration |
metadata.json | Training metadata |
loss.csv | Training/validation loss log |
eval_curve.json | Evaluation curve (bits/base vs step) |
learning_curve.png | Publication-quality learning curve figure |
@software{moss_dna_gpt_2026,
author = {Unjuno},
title = {moss-dna-gpt: Minimal DNA Language Model for Moss Genome},
year = {2026},
url = {https://github.com/Unjuno/moss-dna-gpt}
}