# CodonFM-5B
CodonFM is a family of open RNA foundation models that read protein-coding sequences at **codon**
resolution. Most protein models treat synonymous codons (the different three-letter words that
encode the same amino acid) as interchangeable, discarding the signal they carry. CodonFM keeps
it, learning the context-dependent grammar of codon usage from evolution-scale data.
That grammar is shaped by GC content, tRNA availability, RNA structure and host or tissue context,
and it shows up in translation efficiency, RNA stability, protein folding and pathogenic
synonymous variants. From coding sequence alone, CodonFM recovers synonymous variant effects,
missense pathogenicity and mRNA properties.
CodonFM-5B is the largest member of the family. It is released together with
[CodonFM-5B-CDWT](https://huggingface.co/nvidia/CodonFM-Encodon-5B-CDWT-v1), which is pretrained with
codon-frequency-weighted masking instead of uniform random masking. To learn more see
[What are the two training objectives?](#what-are-the-two-training-objectives)
## Why codon resolution matters
A synonymous substitution is often called a silent mutation, because the protein it encodes is
unchanged. It is rarely silent in practice. Swapping a common leucine codon for a rare one leaves
the amino acid sequence identical while changing how the transcript folds, how quickly the
ribosome moves along it, and whether the finished protein folds correctly.
A model that tokenises to amino acids cannot represent the left-hand side of that picture, so it
cannot reason about any of the consequences on the right.
The second problem is scale. Because most amino acids have several codons, the same protein can be
encoded by an immense number of different coding sequences without altering a single residue. A
wet-lab cycle tests a few dozen constructs, so the search has always been settled by frequency
tables or expert intuition. Getting
it right matters: a major cliff in RNA-based therapeutic design is reaching good protein expression
at tolerable doses, and an exceptionally well-designed protein still fails if it cannot be produced
in the cell type you need it in.
## What makes CodonFM work
## Where to start
| If you want to | Go to |
|---|---|
| Run something now | [Quick start](#quick-start) |
| Choose between the two 5B models | [Which model should I use?](#which-model-should-i-use) |
| Score variants starting from sequencing data | [From a sequencer to scored variants](#from-a-sequencer-to-scored-variants) |
| Know exactly what the model takes and returns | [What are the inputs and outputs for the model?](#what-are-the-inputs-and-outputs-for-the-model) |
| See the evidence that scale helps | [What scaling to 5B buys you](#what-scaling-to-5b-buys-you) |
## Model Architecture
| Model Name | Parameters |
|---|---|
| Encodon-80M | 7.68 × 10⁷ |
| Encodon-600M | 6.09 × 10⁸ |
| Encodon-1B | 9.11 × 10⁸ |
| Encodon-Cdwt-1B | 9.11 × 10⁸ |
| Encodon-5B | 4.85 × 10⁹ |
| Encodon-5B-CDWT | 4.85 × 10⁹ |
## Which model should I use?
| Model | Params | Masking | Benefits |
|---|---|---|---|
| [CodonFM-5B](https://huggingface.co/nvidia/CodonFM-Encodon-5B-v1) ★ | 5B | Random | Best for zero-shot prediction valuable for codon optimization and mRNA design, expression prediction and somatic variant analysis |
| [CodonFM-5B-CDWT](https://huggingface.co/nvidia/CodonFM-Encodon-5B-CDWT-v1) | 5B | Codon-frequency-weighted | Valuable for species-specific differences and **germline** variants. |
| [Encodon-1B](https://huggingface.co/nvidia/NV-CodonFM-Encodon-1B-v1) | 911M | Random | Smaller model needed for fine-tuning or post-training |
| [Encodon-Cdwt-1B](https://huggingface.co/nvidia/NV-CodonFM-Encodon-Cdwt-1B-v1) | 911M | Codon-frequency-weighted | Smaller model needed for fine-tuning or post-training and more valuable for species-specific differences |
| [Encodon-600M](https://huggingface.co/nvidia/NV-CodonFM-Encodon-600M-v1) | 609M | Random | Smaller model for fine-tuning or post-training |
| [Encodon-80M](https://huggingface.co/nvidia/NV-CodonFM-Encodon-80M-v1) | 77M | Random | Smallest model for fine-tuning or post-training |
All CodonFM models are listed in the [CodonFM collection](https://huggingface.co/collections/nvidia/codonfm).
## What are the two training objectives?
Each pretraining method for the 5B models offers unique advantages for the resulting models.
**CodonFM-5B** uses uniform random masking of codons, where all codons are weighted equally, regardless of how often they appear in the pretraining corpus.
**CodonFM-5B-CDWT** weights the masking according to usage bias instead: the rarer a codon is
within its taxonomic group, the more often it is hidden during training. This pushes the model to
learn rare-codon usage in certain sub-contexts of sequences, which allowed it to better capture
species-specific functional codon selection and improved germline pathogenicity scoring.
## What are the inputs and outputs for the model?
Because CodonFM can be used for a variety of capabilities, the model can be used in a number of tasks illustrated in the notebooks.
### Input
A protein-coding sequence (CDS): uppercase `A`/`C`/`G`/`T`.
The model tokenises by codon (sequences must be divisible by 3), with a default context window of 2048 tokens including the start and separator tokens.
### Files in
- **Input Type(s):** Text (mRNA Sequence)
- **Input Format:** fasta files converted to memmaps
- **Input Parameters:** 1D
- **Other Properties Related to Input:** mRNA sequence represented as a string of codons, of maximum length 2046. Longer sequences are automatically truncated to this length
### Files out
- **Output Type(s):** Other: mRNA Sequence
- **Output Format:** Text
- **Output Parameters:** 2D
- **Other Properties Related to Output:** Numeric 2D tensor with floating-point values representing probabilities of a given codon at each masked position within the sequence
### What a variant score does not tell you
The likelihood ratio says how probable the alternate codon is in context, and a larger positive
value means the model finds it less plausible. It does **not** predict whether expression goes
up or down, and it is a research signal rather than a clinical call.
## Quick start
### 1. Set up the environment
```bash
git clone https://github.com/NVIDIA-BioNeMo/CodonFM
cd CodonFM
bash run_dev.sh
```
`run_dev.sh` builds the development image from the repository's `Dockerfile` and drops you into a
shell, with GPU access and your local code mounted at `/workspace`. It needs Docker and the
NVIDIA container toolkit. Pass `--data-dir` and `--checkpoints-dir` to mount your own paths.
### 2. Download the weights
```bash
hf download nvidia/CodonFM-Encodon-5B-v1 --local-dir ./encodon_5b
```
That gives you `CodonFM-Encodon-5B-v1.safetensors` and `config.json`. Point `model_path` at the
`.safetensors` file itself, not at the directory: the loader rejects a directory, and it reads
`config.json` from alongside the file.
### 3. Score a synonymous variant
Does a silent mutation matter? This scores a GAA → GAG substitution, where both codons encode glutamate,
by the ratio of the model's likelihoods for the two codons in context.
```python
import torch
from src.inference.encodon import EncodonInference
from src.data.preprocess.mutation_pred import mlm_process_item
model = EncodonInference(
model_path="./encodon_5b/CodonFM-Encodon-5B-v1.safetensors",
task_type="mutation_prediction",
)
model.configure_model()
model = model.to("cuda").eval()
cds = "ATGGAATTTTAA"
variant = mlm_process_item(
ref_seq=cds,
codon_position=1, # Zero-based codon index.
ref_codon="GAA",
alt_codon="GAG",
context_length=2048,
tokenizer=model.tokenizer,
mask_mutation=True,
)
batch = {
k: torch.as_tensor(v, device="cuda").unsqueeze(0)
for k, v in variant.items()
}
with torch.inference_mode():
score = model.predict_mutation(batch).likelihood_ratios.item()
print(f"Synonymous variant score: {score:.6f}")
```
### 4. Extract embeddings
The third thing the model gives you is a vector per sequence: the `[CLS]` representation from
the final layer. These are the input to your own regressor when you have assay data of your own
and want to predict translation efficiency, expression or stability from sequence.
```python
import numpy as np
import torch
from src.inference.encodon import EncodonInference
from src.data.preprocess.codon_sequence import process_item
model = EncodonInference(
model_path="./encodon_5b/CodonFM-Encodon-5B-v1.safetensors",
task_type="embedding_prediction",
)
model.configure_model()
model = model.to("cuda").eval()
sequences = ["ATGGAATTTTAA", "ATGGAGTTTTAA"]
items = [process_item(s, context_length=2048, tokenizer=model.tokenizer)
for s in sequences]
batch = {k: torch.as_tensor(np.stack([it[k] for it in items]), device="cuda")
for k in items[0]}
with torch.inference_mode():
embeddings = model.extract_embeddings(batch).embeddings
print(embeddings.shape) # (2, 4096): one 4096-wide vector per sequence
```
Extracting them is only half the job. The repository's notebooks
`4-EnCodon-Downstream-Task-riboNN`, `5-EnCodon-Downstream-Task-mRFP-expression` and
`6-EnCodon-Downstream-Task-mRNA-stability` show the other half: fitting a light regressor on
frozen embeddings, which is how the benchmarks above were produced.
For variant scoring at scale and the downstream expression tasks, see the
[notebooks](https://github.com/NVIDIA-BioNeMo/CodonFM/tree/main/notebooks) in the repository.
## From a sequencer to scored variants
The quick start above begins with a coding sequence, which assumes you already have one. Most
work starts further back, with reads off a sequencer, and getting from there to a CDS is the bulk
of the job.
The [variant effect prediction notebook](https://github.com/NVIDIA-AI-Blueprints/genomics-analysis/blob/main/notebooks/variant_effect_prediction.ipynb)
in the [Genomic Analysis Blueprint](https://build.nvidia.com/nvidia/genomics-analysis), written by
Gary Burnett and Fan Cao, covers that whole span on GPU:
| Stage | What happens |
|---|---|
| 1. Variant calling | Raw Illumina FASTQ reads aligned to the human reference with Parabricks BWA, then variants called with DeepVariant |
| 2. Gene annotation | GENCODE processed to pull out protein-coding sequences, and the called variants mapped onto genes and transcripts |
| 3. Effect prediction | Each variant scored with CodonFM, synonymous ones included |
Stage three is what this page documents. Stages one and two are what make it usable on data you
actually have, rather than on a coding sequence you were already holding.
It runs on GPU and needs the Parabricks container. The dataset that ships with it is small, a
worked example rather than a realistic cohort.
## What scaling to 5B buys you
### Scale buys comprehension
Validation loss keeps falling with model size, and the 5B models separate clearly from the rest
of the family rather than converging with them.
*Figure 1. Larger EnCodon models achieve lower validation loss as training continues.*
That shows up directly as fewer synonymous mix-ups. Codon confusion, how often the model
mispredicts one synonymous codon for another, falls steadily with scale across almost every
amino acid.
*Figure 2. Synonymous codon confusion across model scales. Darker green is a lower confusion
score, so larger models show a firmer grip on codon usage.*
### Variant interpretation
Across 129,384 synonymous variants in ClinVar, the 5B models give the highest AUROC for
separating pathogenic from benign, and **5B-CDWT leads**, so the rare-codon weighting earns its
place on this germline task.
*Figure 3. CodonFM 5B CDWT and 5B achieve the highest AUROC for separating pathogenic from
benign synonymous variants in ClinVar.*
The same holds for somatic mutations. Across 1,471 cancer-observed synonymous variants matched
between COSMIC and gnomAD, the larger models beat both the PhyloP conservation score and the best
published model on this benchmark. CodonFM also recovers known loss-of-function synonymous
mutations in *KRAS*.
*Figure 4. Across 1,471 curated cancer-observed synonymous variants, larger EnCodon models
outperform the PhyloP conservation score and the best state-of-the-art model on this test.*
Separately, on de novo variant prioritization across three trio-sequenced disease cohorts,
including 42,607 autism cases and 2,871 congenital heart disease probands, CodonFM gives the
best separation of disease from control, from coding sequence alone.
### mRNA design
Random forests trained on **frozen** 5B embeddings beat the strongest published nucleotide models on both
translation efficiency (>140 human and mouse cell types drawn from 3,819 ribosome profiling
datasets) and protein expression (1,459 synonymous CDS variants with an *E. coli* readout), with
no fine-tuning.
*Figure 5. Random forest performance on frozen zero-shot embeddings, for translation efficiency
(RiboNN Spearman ρ) and mRFP protein expression (Spearman ρ on a held-out test set). The 5B models
lead on both.*
### Where it gets used
## Where to go next
| If you want to | Go here |
|---|---|
| Run CodonFM on your own sequencing data | [From a sequencer to scored variants](#from-a-sequencer-to-scored-variants), above |
| Reproduce the benchmarks above | The [evaluation notebooks](https://github.com/NVIDIA-BioNeMo/CodonFM/tree/main/notebooks): zero-shot variant scoring, translation efficiency, expression and stability |
| Understand the method | The [preprint](https://research.nvidia.com/labs/dbr/assets/data/manuscripts/nv-codonfm-preprint.pdf) |
| Use a smaller or earlier model | The [CodonFM collection](https://huggingface.co/collections/nvidia/codonfm) |
| Read the background | The [original CodonFM blog](https://developer.nvidia.com/blog/introducing-the-codonfm-open-model-for-rna-design-and-analysis/) |
## Hardware and software
| | |
|---|---|
| **GPU memory** | The checkpoint is FP32, so the weights alone occupy 19.4 GB before activations. Plan for a 40 GB card or larger |
| **Tested on** | NVIDIA A100. Supported microarchitecture compatibility: NVIDIA Ampere and NVIDIA Hopper |
| **Base image** | `nvcr.io/nvidia/pytorch:26.09-py3`, pinned by digest in the repository's Dockerfile. Python 3.12 |
| **OS** | Linux |
## Limitations
- CodonFM models protein-coding sequences only. It does not model UTRs, introns or non-coding RNA,
so regulatory effects outside the CDS are out of scope.
- Context is capped at 2,046 codons; longer transcripts are truncated.
- Predictions are computational hypotheses. Designed sequences and variant calls need
experimental validation before use in research or clinical decisions.
- Training data excludes human-affecting pathogen sequences, for biosafety.
The formal model card, with the full Model Card++ bias, explainability, safety and privacy
subcards, is on [NGC](https://catalog.ngc.nvidia.com/orgs/nvidia/teams/clara/models/nv_codonfm_encodon).
## Ethical Considerations
NVIDIA believes Trustworthy AI is a shared responsibility and we have established policies and practices to enable development for a wide array of AI applications. When downloaded or used in accordance with our terms of service, developers should work with their internal model team to ensure this model meets requirements for the relevant industry and use case and addresses unforeseen product misuse.
For more detailed information on ethical considerations for this model, please see the Model Card++ Bias, Explainability, Safety & Security, and Privacy Subcards.
Users are responsible for ensuring the physical properties of model-generated molecules are appropriately evaluated and comply with applicable safety regulations and ethical standards.
CodonFM optimizes or scores a coding sequence that the user supplies. It does not propose biological payloads, and it provides no guidance on synthesizability or immunogenicity. Determining whether a designed sequence can be manufactured, and how it will behave in a biological system, remains the responsibility of the user.
Users designing sequences for synthesis are encouraged to screen them with [SecureDNA](https://securedna.org/). SecureDNA screens DNA, so RNA sequences should have U converted to T before submission; and it detects hazards by exact match against a database of known hazardous sequences and their predicted functional variants, so it will not flag a genuinely novel agent with no homology to a listed hazard. This is guidance for users rather than a control that NVIDIA applies to model outputs.
Please report model quality, risk, security vulnerabilities or NVIDIA AI Concerns [here](https://www.nvidia.com/en-us/support/submit-security-vulnerability/).
## License
Code is released under Apache-2.0. Model weights are governed by the
[NVIDIA Open Model License Agreement](https://www.nvidia.com/en-us/agreements/enterprise-software/nvidia-open-model-license/).
Ready for commercial and non-commercial use.
## Citation
```bibtex
@article{codonfm_2025,
author = {Darabi+, Sajad and Cao+, Fan and Naghipourfar+, Mohsen and Rabhi, Sara and
Sethia, Ankit and Gion, Kyle and Grewal, Jasleen and Cohen, Jonathan and
Greenleaf, William and Goodarzi*, Hani and Sundaram*, Laksshman},
title = {{Learning the language of codon translation with CodonFM}},
url = {https://research.nvidia.com/labs/dbr/assets/data/manuscripts/nv-codonfm-preprint.pdf},
year = {2025}
}
```
Sajad Darabi, Fan Cao and Mohsen Naghipourfar are equal contributing first authors.
Corresponding authors: Hani Goodarzi and Laksshman Sundaram.
## Contact
Questions and correspondence: nv-codonfm@nvidia.com