Views
No views yet
[!TIP] The MultiMolecule team has confirmed that the provided model and checkpoints are producing the same intermediate representations as the original implementation.
| Num Layers | Hidden Size | Num Heads | Intermediate Size | Num Parameters (M) | FLOPs (G) | MACs (G) | Max Num Tokens |
|---|---|---|---|---|---|---|---|
| 12 | 768 | 12 | 3072 | 117.07 | 125.83 | 62.92 | 512 |
multimolecule library. You can install it using pip:pip install multimolecule1import multimolecule # you must import multimolecule to register models
2from transformers import pipeline
3
4predictor = pipeline("fill-mask", model="multimolecule/dnabert2")
5output = predictor("ATCG<mask>TGCA")1from multimolecule import DnaBert2Model
2from transformers import AutoTokenizer
3
4
5tokenizer = AutoTokenizer.from_pretrained("multimolecule/dnabert2")
6model = DnaBert2Model.from_pretrained("multimolecule/dnabert2")
7
8text = "ATCGATCGATCGATCG"
9input = tokenizer(text, return_tensors="pt")
10
11output = model(**input)[!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.
1import torch
2from multimolecule import DnaBert2ForSequencePrediction
3from transformers import AutoTokenizer
4
5
6tokenizer = AutoTokenizer.from_pretrained("multimolecule/dnabert2")
7model = DnaBert2ForSequencePrediction.from_pretrained("multimolecule/dnabert2")
8
9text = "ATCGATCGATCGATCG"
10input = tokenizer(text, return_tensors="pt")
11label = torch.tensor([1])
12
13output = model(**input, labels=label)[!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.
1import torch
2from multimolecule import DnaBert2ForTokenPrediction
3from transformers import AutoTokenizer
4
5
6tokenizer = AutoTokenizer.from_pretrained("multimolecule/dnabert2")
7model = DnaBert2ForTokenPrediction.from_pretrained("multimolecule/dnabert2")
8
9text = "ATCGATCGATCGATCG"
10input = tokenizer(text, return_tensors="pt")
11label = torch.randint(2, (len(text), ))
12
13output = model(**input, labels=label)[!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.
1import torch
2from multimolecule import DnaBert2ForContactPrediction
3from transformers import AutoTokenizer
4
5
6tokenizer = AutoTokenizer.from_pretrained("multimolecule/dnabert2")
7model = DnaBert2ForContactPrediction.from_pretrained("multimolecule/dnabert2")
8
9text = "ATCGATCGATCGATCG"
10input = tokenizer(text, return_tensors="pt")
11label = torch.randint(2, (len(text), len(text)))
12
13output = model(**input, labels=label)N are excluded, retaining only sequences that consist of A, T, C, and G.<mask> for 80% of masked tokens1@inproceedings{zhou2024dnabert,
2 title={{DNABERT}-2: Efficient Foundation Model and Benchmark For Multi-Species Genomes},
3 author={Zhihan Zhou and Yanrong Ji and Weijian Li and Pratik Dutta and Ramana V Davuluri and Han Liu},
4 booktitle={The Twelfth International Conference on Learning Representations},
5 year={2024},
6 url={https://openreview.net/forum?id=oMLQB4EZE1}
7}[!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:
1@software{chen_2024_12638419,
2 author = {Chen, Zhiyuan and Zhu, Sophia Y.},
3 title = {MultiMolecule},
4 doi = {10.5281/zenodo.12638419},
5 publisher = {Zenodo},
6 url = {https://doi.org/10.5281/zenodo.12638419},
7 year = 2024,
8 month = may,
9 day = 4
10}SPDX-License-Identifier: AGPL-3.0-or-later