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.
| Variants | Num Layers | Hidden Size | Num Heads | Intermediate Size | Num Parameters (M) | FLOPs (G) | MACs (G) | Max Num Tokens |
|---|---|---|---|---|---|---|---|---|
| dnabert-6mer | 12 | 768 | 12 | 3072 | 89.19 | 96.86 | 48.43 | 512 |
| dnabert-5mer | 86.83 | |||||||
| dnabert-4mer | 86.24 | |||||||
| dnabert-3mer | 86.10 |
multimolecule library. You can install it using pip:pip install multimolecule[!WARNING] Default transformers pipeline does not support K-mer tokenization.
1import multimolecule # you must import multimolecule to register models
2from transformers import pipeline
3
4predictor = pipeline("fill-mask", model="multimolecule/dnabert-4mer")
5output = predictor("ATCG<mask>TGCA")1from multimolecule import DnaBertModel
2from transformers import AutoTokenizer
3
4
5tokenizer = AutoTokenizer.from_pretrained("multimolecule/dnabert-4mer")
6model = DnaBertModel.from_pretrained("multimolecule/dnabert-4mer")
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 DnaBertForSequencePrediction
3from transformers import AutoTokenizer
4
5
6tokenizer = AutoTokenizer.from_pretrained("multimolecule/dnabert-4mer")
7model = DnaBertForSequencePrediction.from_pretrained("multimolecule/dnabert-4mer")
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 DnaBertForTokenPrediction
3from transformers import AutoTokenizer
4
5
6tokenizer = AutoTokenizer.from_pretrained("multimolecule/dnabert-4mer")
7model = DnaBertForTokenPrediction.from_pretrained("multimolecule/dnabert-4mer")
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 DnaBertForContactPrediction
3from transformers import AutoTokenizer
4
5
6tokenizer = AutoTokenizer.from_pretrained("multimolecule/dnabert-4mer")
7model = DnaBertForContactPrediction.from_pretrained("multimolecule/dnabert-4mer")
8
9text = "ATCGATCGATCGATCG"
10input = tokenizer(text, return_tensors="pt")
11label = torch.randint(2, (len(text), len(text)))
12
13output = model(**input, labels=label)<mask> for 80% of masked tokens"TAGCGTAT" will be tokenized as ["TAG", "AGC", "GCG", "CGT", "GTA", "TAT"]. If the nucleotide "C" is masked, the adjacent tokens will also be masked, resulting ["TAG", "<mask>", "<mask>", "<mask>", "GTA", "TAT"].1@ARTICLE{Ji2021-cj,
2 title = "{DNABERT}: pre-trained Bidirectional Encoder Representations
3 from Transformers model for {DNA-language} in genome",
4 author = "Ji, Yanrong and Zhou, Zhihan and Liu, Han and Davuluri, Ramana V",
5 abstract = "MOTIVATION: Deciphering the language of non-coding DNA is one of
6 the fundamental problems in genome research. Gene regulatory
7 code is highly complex due to the existence of polysemy and
8 distant semantic relationship, which previous informatics
9 methods often fail to capture especially in data-scarce
10 scenarios. RESULTS: To address this challenge, we developed a
11 novel pre-trained bidirectional encoder representation, named
12 DNABERT, to capture global and transferrable understanding of
13 genomic DNA sequences based on up and downstream nucleotide
14 contexts. We compared DNABERT to the most widely used programs
15 for genome-wide regulatory elements prediction and demonstrate
16 its ease of use, accuracy and efficiency. We show that the
17 single pre-trained transformers model can simultaneously achieve
18 state-of-the-art performance on prediction of promoters, splice
19 sites and transcription factor binding sites, after easy
20 fine-tuning using small task-specific labeled data. Further,
21 DNABERT enables direct visualization of nucleotide-level
22 importance and semantic relationship within input sequences for
23 better interpretability and accurate identification of conserved
24 sequence motifs and functional genetic variant candidates.
25 Finally, we demonstrate that pre-trained DNABERT with human
26 genome can even be readily applied to other organisms with
27 exceptional performance. We anticipate that the pre-trained
28 DNABERT model can be fined tuned to many other sequence analyses
29 tasks. AVAILABILITY AND IMPLEMENTATION: The source code,
30 pretrained and finetuned model for DNABERT are available at
31 GitHub (https://github.com/jerryji1993/DNABERT). SUPPLEMENTARY
32 INFORMATION: Supplementary data are available at Bioinformatics
33 online.",
34 journal = "Bioinformatics",
35 publisher = "Oxford University Press (OUP)",
36 volume = 37,
37 number = 15,
38 pages = "2112--2120",
39 month = aug,
40 year = 2021,
41 copyright = "https://academic.oup.com/journals/pages/open\_access/funder\_policies/chorus/standard\_publication\_model",
42 language = "en"
43}[!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