Team Ai
Modelpublic

multimolecule/calm

sourceHugging Faceagpl-3.0updated 4mo agoView on Hugging Face
0likes125downloads
Model Card

CaLM

Pre-trained model on protein-coding DNA (cDNA) using a masked language modeling (MLM) objective.

Statement

Codon language embeddings provide strong signals for use in protein engineering is published in Nature Machine Intelligence, which is a Closed Access / Author-Fee journal.

Machine learning has been at the forefront of the movement for free and open access to research. We see no role for closed access or author-fee publication in the future of machine learning research and believe the adoption of these journals as an outlet of record for the machine learning community would be a retrograde step.

The MultiMolecule team is committed to the principles of open access and open science.

We do NOT endorse the publication of manuscripts in Closed Access / Author-Fee journals and encourage the community to support Open Access journals and conferences.

Please consider signing the Statement on Nature Machine Intelligence.

Disclaimer

This is an UNOFFICIAL implementation of the Codon language embeddings provide strong signals for use in protein engineering by Carlos Outeiral, et al.

The OFFICIAL repository of CaLM is at oxpig/CaLM.

[!WARNING] The MultiMolecule team is unable to confirm that the provided model and checkpoints are producing the same intermediate representations as the original implementation. This is because The proposed method is published in a Closed Access / Author-Fee journal.

The team releasing CaLM did not write this model card for this model so this model card has been written by the MultiMolecule team.

Model Details

CaLM is a bert-style model pre-trained on a large corpus of protein-coding DNA sequences in a self-supervised fashion. This means that the model was trained on the raw nucleotides of DNA sequences only, with an automatic process to generate inputs and labels from those texts. Please refer to the Training Details section for more information on the training process.

Model Specification

Num LayersHidden SizeNum HeadsIntermediate SizeNum Parameters (M)FLOPs (G)MACs (G)Max Num Tokens
1276812307285.7596.8648.321024

Links

Usage

The model file depends on the `multimolecule` library. You can install it using pip:

bash
pip install multimolecule

Direct Use

Masked Language Modeling

You can use this model directly with a pipeline for masked language modeling:

python
import multimolecule  # you must import multimolecule to register models
from transformers import pipeline

predictor = pipeline("fill-mask", model="multimolecule/calm")
output = predictor("agc<mask>cattatggcgaaccttggctgctg")

Downstream Use

Extract Features

Here is how to use this model to get the features of a given sequence in PyTorch:

python
from multimolecule import DnaTokenizer, CaLmModel


tokenizer = DnaTokenizer.from_pretrained("multimolecule/calm")
model = CaLmModel.from_pretrained("multimolecule/calm")

text = "GCCAGTCGCTGACAGCCGCGG"
input = tokenizer(text, return_tensors="pt")

output = model(**input)
Sequence Classification / Regression
[!NOTE] This model is not fine-tuned for any specific task. You will need to fine-tune the model on a downstream task to use it for sequence classification or regression.

Here is how to use this model as backbone to fine-tune for a sequence-level task in PyTorch:

python
import torch
from multimolecule import DnaTokenizer, CaLmForSequencePrediction


tokenizer = DnaTokenizer.from_pretrained("multimolecule/calm")
model = CaLmForSequencePrediction.from_pretrained("multimolecule/calm")

text = "GCCAGTCGCTGACAGCCGCGG"
input = tokenizer(text, return_tensors="pt")
label = torch.tensor([1])

output = model(**input, labels=label)
Token Classification / Regression
[!NOTE] This model is not fine-tuned for any specific task. You will need to fine-tune the model on a downstream task to use it for token classification or regression.

Here is how to use this model as backbone to fine-tune for a nucleotide-level task in PyTorch:

python
import torch
from multimolecule import DnaTokenizer, CaLmForTokenPrediction


tokenizer = DnaTokenizer.from_pretrained("multimolecule/calm")
model = CaLmForTokenPrediction.from_pretrained("multimolecule/calm")

text = "GCCAGTCGCTGACAGCCGCGG"
input = tokenizer(text, return_tensors="pt")
label = torch.randint(2, (len(text), ))

output = model(**input, labels=label)
Contact Classification / Regression
[!NOTE] This model is not fine-tuned for any specific task. You will need to fine-tune the model on a downstream task to use it for contact classification or regression.

Here is how to use this model as backbone to fine-tune for a contact-level task in PyTorch:

python
import torch
from multimolecule import DnaTokenizer, CaLmForContactPrediction


tokenizer = DnaTokenizer.from_pretrained("multimolecule/calm")
model = CaLmForContactPrediction.from_pretrained("multimolecule/calm")

text = "GCCAGTCGCTGACAGCCGCGG"
input = tokenizer(text, return_tensors="pt")
label = torch.randint(2, (len(text), len(text)))

output = model(**input, labels=label)

Training Details

CaLM used Masked Language Modeling (MLM) as the pre-training objective: taking a sequence, the model randomly masks 25% of the tokens in the input then runs the entire masked sentence through the model and has to predict the masked tokens. This is comparable to the Cloze task in language modeling.

Training Data

The CaLM model was pre-trained coding sequences of all organisms available on the European Nucleotide Archive (ENA). European Nucleotide Archive provides a comprehensive record of the world’s nucleotide sequencing information, covering raw sequencing data, sequence assembly information and functional annotation.

CaLM collected coding sequences of all organisms from ENA on April 2022, including 114,214,475 sequences. Only high level assembly information (dataclass CON) were used. Sequences matching the following criteria were filtered out:

  • —Unknown nucleotides: remove sequences with N, Y, or R
  • —Start codon: require ATG
  • —Stop codons: remove sequences with interstitial stop codons
  • —Sequence length: require a multiple of three nucleotides

To reduce redundancy, CaLM grouped the entries by organism, and apply CD-HIT (CD-HIT-EST) with a cut-off at 40% sequence identity to the translated protein sequences.

The final dataset contains 9,858,385 cDNA sequences.

The original checkpoint uses RNA codon spelling internally, but MultiMolecule converts the checkpoint to DNA codon order and exposes CaLM with [DnaTokenizer][multimolecule.DnaTokenizer]. DnaTokenizer will convert "U"s to "T"s by default; you may disable this behaviour by passing replace_U_with_T=False.

Training Procedure

Preprocessing

CaLM used masked language modeling (MLM) as the pre-training objective. The masking procedure is similar to the one used in BERT:

  • —Mask rate: 25%
  • —Replacement: <mask> for 80% of masked tokens
  • —Replacement: random token for 10% of masked tokens
  • —Replacement: unchanged token for 10% of masked tokens
Pre-training

The model was trained on 4 NVIDIA Quadro RTX4000 GPUs with 8GiB memories.

  • —Batch Size: 1,000
  • —Epochs: 14
  • —Optimizer: AdamW
  • —Learning rate: 1e-4
  • —Learning rate scheduler: Cosine
  • —Learning rate warm-up: 1,000 steps

Citation

bibtex
@article {outeiral2022coodn,
	author = {Outeiral, Carlos and Deane, Charlotte M.},
	title = {Codon language embeddings provide strong signals for protein engineering},
	elocation-id = {2022.12.15.519894},
	year = {2022},
	doi = {10.1101/2022.12.15.519894},
	publisher = {Cold Spring Harbor Laboratory},
	abstract = {Protein representations from deep language models have yielded state-of-the-art performance across many tasks in computational protein engineering. In recent years, progress has primarily focused on parameter count, with recent models{\textquoteright} capacities surpassing the size of the very datasets they were trained on. Here, we propose an alternative direction. We show that large language models trained on codons, instead of amino acid sequences, provide high-quality representations that outperform comparable state-of-the-art models across a variety of tasks. In some tasks, like species recognition, prediction of protein and transcript abundance, or melting point estimation, we show that a language model trained on codons outperforms every other published protein language model, including some that contain over 50 times more parameters. These results suggest that, in addition to commonly studied scale and model complexity, the information content of biological data provides an orthogonal direction to improve the power of machine learning in biology.Competing Interest StatementThe authors have declared no competing interest.},
	URL = {https://www.biorxiv.org/content/early/2022/12/19/2022.12.15.519894},
	eprint = {https://www.biorxiv.org/content/early/2022/12/19/2022.12.15.519894.full.pdf},
	journal = {bioRxiv}
}
[!NOTE] The artifacts distributed in this repository are part of the MultiMolecule project. If MultiMolecule supports your research, please cite the MultiMolecule project as follows:
bibtex
@software{chen_2024_12638419,
  author    = {Chen, Zhiyuan and Zhu, Sophia Y.},
  title     = {MultiMolecule},
  doi       = {10.5281/zenodo.12638419},
  publisher = {Zenodo},
  url       = {https://doi.org/10.5281/zenodo.12638419},
  year      = 2024,
  month     = may,
  day       = 4
}

Contact

Please use GitHub issues of MultiMolecule for any questions or comments on the model card.

Please contact the authors of the CaLM paper for questions or comments on the paper/model.

License

This model implementation is licensed under the GNU Affero General Public License.

For additional terms and clarifications, please refer to our License FAQ.

spdx
SPDX-License-Identifier: AGPL-3.0-or-later