Synthyra
Research

Research

6 min read

cdsBERT: Why Codons Still Matter for Protein AI

cdsBERT rebuilds a pretrained protein language model around a codon vocabulary using token embedding seeding, masked language modeling, and knowledge distillation. Synonymous codon embeddings separate in ways that correlate with usage bias across phylogeny.

Logan Hallee

September 15, 2023

Enzyme commission prediction accuracy for cdsBERT and ProtBERT before and after knowledge distillation
Full enzyme commission number prediction from frozen embeddings. The codon model starts well behind its amino acid counterpart and passes it after distillation.

Most protein models read proteins as amino acid strings. That is a reasonable simplification: amino acids are the direct building blocks, and they determine most of structure and function.

Biology does not start there. It starts with coding sequence. Three DNA letters form a codon, and up to six different codons encode the same amino acid. Mutations that swap one synonymous codon for another are conventionally called silent.

Silent is a claim about the protein product, not about the cell. Codon usage affects translation speed, organism-specific expression, mRNA secondary structure, and in some documented cases the folded structure of the protein itself. Two genes can encode an identical amino acid sequence while carrying quite different regulatory and evolutionary information.

cdsBERT asks a narrow version of that question. If you give a protein language model access to codons instead of amino acids, does it learn anything it did not have before?

Rebuilding a model's vocabulary

You cannot simply retrain from scratch on codons; the compute is prohibitive and the data is far scarcer than amino acid data. So the approach uses a transfer procedure called MELD, in three stages.

The three stages

Seed. Expand ProtBERT-BFD's token embedding matrix from 30 entries to 69, covering 64 codons plus five special tokens. Every synonymous codon is initialized with the embedding of the amino acid it encodes, so the model starts at parity with its parent rather than at random. Stop codons, having no amino acid, are initialized randomly.

Learn. Masked language modeling on coding sequences from the NIH Consensus CDS project and over 300 additional genomes from Ensembl.

Distill. Contrastive knowledge distillation against a frozen Ankh-base teacher, using 500,000 sequences, with a trainable linear layer bridging Ankh's 768 dimensions to cdsBERT's 1,024.

The seeding step is the interesting one. Because all six serine codons begin at exactly the same point in embedding space, any distance between them afterwards was learned from data. The initialization doubles as a control.

A practical aside with a pleasing solution: storing codons as three-character strings triples the dataset size, so a single-character code is defined for all 64 codons. Human-optimal codons keep their uppercase amino acid letter, second-most-frequent synonyms get the lowercase version, and stop codons map to ), }, and ], which has the side effect of making every open reading frame visible as matching brackets.

Does the codon vocabulary help?

The evaluation is enzyme commission number prediction from frozen embeddings, using both a k-nearest-neighbour classifier and a support vector machine over ten-fold cross-validation.

Enzyme commission prediction accuracy for four models under two classifiers
Figure 1. Full enzyme commission number prediction from averaged final-layer embeddings, ten-fold cross-validated. The plus suffix marks models that went through knowledge distillation. cdsBERT before distillation is the leftmost bar in each group.

The trajectory matters more than any single bar. Straight after masked language modeling, cdsBERT is worse than the model it was seeded from: 62.4 percent against ProtBERT's 74.7 percent. The likely explanation is that the model is undertrained on its new vocabulary, which is credible given that the coding sequence corpus was large enough that a single epoch was never completed.

Knowledge distillation closes the gap and then some. cdsBERT+ reaches 78.7 percent, a relative gain of 16.3 percent, overtaking the original ProtBERT. ProtBERT given the same distillation treatment improves only to 78.1 percent.

Full enzyme commission prediction

62.4%

cdsBERT after masked language modeling

Below its own seed model

78.7%

cdsBERT after distillation

Best of the authors' variants

78.1%

ProtBERT after the same distillation

The controlled comparison

That 0.6 point margin is the entire codon effect under a controlled comparison. The advantage holds across all k-nearest-neighbour metrics and support vector machine accuracy, while ProtBERT+ actually wins on support vector machine precision, recall, and F1. Ankh-base beats every variant.

Further distillation against either Ankh-base or Ankh-large produced no additional gain, suggesting both models had hit a ceiling set by architecture, size, or the modest 2,629-sequence enzyme dataset.

What moved, and why

The more interesting analysis is not the benchmark but the embeddings themselves.

Measuring mean squared error between weight matrices before and after each stage shows a clean division of labor. During masked language modeling, the token embedding matrix changed most, meaning the model was learning what its new tokens mean. During distillation, the intermediate linear layers and attention changed most, meaning the model was learning how to use them in context.

Because synonymous codons started identical, any separation is learned. Projecting the 64 codon embeddings into two dimensions shows them grouped by the physicochemical properties of their amino acids, with visible separation among synonyms. A pairwise distance map shows 21 distinct blocks along the diagonal, one per amino acid family, confirming synonyms stay related while no longer being identical.

The central result is a correlation. Comparing how far each codon's embedding moved against roughly 13,000 measurements of average codon usage across broad phylogeny gives a statistically significant medium negative relationship: codons used more frequently moved less.

In plain terms

The model was never told which codons are common. It was told to predict masked codons in real coding sequences. Frequently used codons behave predictably enough that the amino acid's embedding remains a good description of them, so they stay put. Rare codons carry more idiosyncratic context, so the model pushes them further away.

The other correlations examined, between embedding movement, taxonomic prediction influence, and DNA-type prediction influence, were intuitive in direction but mostly negligible in size. Only usage against movement, and usage against DNA-type ranking, reached significance.

What this does not show

The authors' summary: "the precise amount of information added by codon sequences over amino acid counterparts is yet unknown, we conclude there is an addition of information." Silent mutations affect translation speed, mRNA structure, and phylogenetic prediction, and the vast majority of protein information is still summarized by the amino acid vocabulary. A codon vocabulary is worth a slight performance increase, not a transformation.

Terms used here

Codon. Three consecutive DNA or RNA bases specifying one amino acid. There are 64 codons for 20 amino acids plus stop signals.
Synonymous codons. Different codons encoding the same amino acid. Swapping them leaves the protein sequence unchanged.
Codon usage bias. The uneven frequency with which organisms use synonymous codons. It varies systematically across species and across genes.
Knowledge distillation. Training a student model to match a stronger teacher's representations, transferring capability without retraining from scratch.
Token embedding matrix. The lookup table mapping each vocabulary token to its initial vector. Extending a model's vocabulary means extending this matrix.

What it set up

Two things carried forward from this work.

The vocabulary-extension procedure itself. Seeding new tokens from semantically related existing ones, then recovering capability through distillation, is the same move later used to graft an annotation vocabulary onto a sequence model in the Annotation Vocabulary work. The trick generalizes past codons.

And the data bottleneck, identified as the real conclusion. High-quality coding sequence mappings for large protein repositories like UniProt largely do not exist. A codon foundation model is not blocked on architecture. It is blocked on someone assembling the corpus.

Source

cdsBERT: Extending Protein Language Models with Codon Awareness

Logan Hallee, Nikolaos Rafailidis, Jason P. Gleghorn

Preprint, 2023. Weights available on Hugging Face at GleghornLab/cdsBERT.

Continue reading

Related research

Research · April 9, 2026

Dual Triangle Attention: Position Sense for Bidirectional Models

Split each attention head into a past-facing half and a future-facing half, and a bidirectional transformer stops being blind to word order without any positional embeddings at all.

Research · August 21, 2025

Protify: Model Choice As An Experiment

Across 32 protein tasks, 13 different models won at least once and none of the wins were statistically significant. Picking a protein language model is an experiment, not a preference.

Synthyra

Optimize the outcome, not the interface.

Biological design programs selected on the predicted state of the system, not the quality of one contact.

Platform

DiscoverDemosModelsAPI

Company

NewsOur VisionTeamContactOpen sourceSign in

© 2026 Synthyra. All rights reserved.

TermsPrivacy