Views
No views yet
1git clone https://github.com/Boehringer-Ingelheim/SynCodonLM.git
2cd SynCodonLM
3pip install -r requirements.txt #maybe not neccesary depending on your env :)1from SynCodonLM import CodonEmbeddings
2
3model = CodonEmbeddings(model_name='jheuschkel/SynCodonLM-V2-NoTokenType') #this loads the model & tokenizer using our built-in functions
4
5seq = 'ATGTCCACCGGGCGGTGA'
6
7mean_pooled_embedding = model.get_mean_embedding(seq)
8#returns --> tensor of shape [768]
9
10raw_output = model.get_raw_embeddings(seq)
11raw_embedding_final_layer = raw_output.hidden_states[-1] #treat this like a typical Hugging Face model dictionary based output!
12#returns --> tensor of shape [batch size (1), sequence length, 768]1@article{10.1093/nar/gkag166,
2 author = {Heuschkel, James and Kingsley, Laura and Pefaur, Noah and Nixon, Andrew and Cramer, Steven},
3 title = {Advancing codon language modeling with synonymous codon constrained masking},
4 journal = {Nucleic Acids Research},
5 volume = {54},
6 number = {5},
7 pages = {gkag166},
8 year = {2026},
9 month = {02},
10 abstract = {Codon language models offer a promising framework for modeling protein-coding DNA sequences, yet current approaches often conflate codon usage with amino acid semantics, limiting their ability to capture DNA-level biology. We introduce SynCodonLM, a codon language model that enforces a biologically grounded constraint: masked codons are only predicted from synonymous options, guided by the known protein sequence. This design disentangles codon-level from protein-level semantics, enabling the model to learn nucleotide-specific patterns. The constraint is implemented by masking non-synonymous codons from the prediction space prior to softmax. Unlike existing models, which cluster codons by amino acid identity, SynCodonLM clusters by nucleotide properties, revealing structure aligned with DNA-level biology. Furthermore, SynCodonLM outperforms existing models on six of seven benchmarks sensitive to DNA-level features, including messenger RNA and protein expression. Our approach advances domain-specific representation learning and opens avenues for sequence design in synthetic biology, as well as deeper insights into diverse bioprocesses.},
11 issn = {1362-4962},
12 doi = {10.1093/nar/gkag166},
13 url = {https://doi.org/10.1093/nar/gkag166},
14 eprint = {https://academic.oup.com/nar/article-pdf/54/5/gkag166/67103471/gkag166.pdf},
15}
16}