multimolecule / dnabert2

huggingface.co
Total runs: 55.2K
24-hour runs: 2.1K
7-day runs: -1.1K
30-day runs: 50.1K
Model's Last Updated: May 31 2026
fill-mask

Introduction of dnabert2

Model Details of dnabert2

DNABERT-2

Pre-trained model on multi-species genome using a masked language modeling (MLM) objective.

Disclaimer

This is an UNOFFICIAL implementation of the DNABERT-2: Efficient Foundation Model and Benchmark for Multi-Species Genomes by Zhihan Zhou, et al.

The OFFICIAL repository of DNABERT-2 is at MAGICS-LAB/DNABERT_2 .

The MultiMolecule team has confirmed that the provided model and checkpoints are producing the same intermediate representations as the original implementation.

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

Model Details

DNABERT-2 is a bert -style model pre-trained on a large corpus of multi-species genome 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.

Note that DNABERT-2 replaces the k-mer tokenization used in DNABERT with Byte Pair Encoding (BPE), and uses Attention with Linear Biases (ALiBi) instead of learned position embeddings. It also incorporates a Gated Linear Unit (GeGLU) MLP and FlashAttention for improved efficiency.

Model Specification
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.81 512
Links
Usage

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

pip install multimolecule
Direct Use
Masked Language Modeling

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

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

predictor = pipeline("fill-mask", model="multimolecule/dnabert2")
output = predictor("ATCG<mask>TGCA")
Downstream Use
Extract Features

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

from multimolecule import DnaBert2Model
from transformers import AutoTokenizer


tokenizer = AutoTokenizer.from_pretrained("multimolecule/dnabert2")
model = DnaBert2Model.from_pretrained("multimolecule/dnabert2")

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

output = model(**input)
Sequence Classification / Regression

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:

import torch
from multimolecule import DnaBert2ForSequencePrediction
from transformers import AutoTokenizer


tokenizer = AutoTokenizer.from_pretrained("multimolecule/dnabert2")
model = DnaBert2ForSequencePrediction.from_pretrained("multimolecule/dnabert2")

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

output = model(**input, labels=label)
Token Classification / Regression

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:

import torch
from multimolecule import DnaBert2ForTokenPrediction
from transformers import AutoTokenizer


tokenizer = AutoTokenizer.from_pretrained("multimolecule/dnabert2")
model = DnaBert2ForTokenPrediction.from_pretrained("multimolecule/dnabert2")

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

output = model(**input, labels=label)
Contact Classification / Regression

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:

import torch
from multimolecule import DnaBert2ForContactPrediction
from transformers import AutoTokenizer


tokenizer = AutoTokenizer.from_pretrained("multimolecule/dnabert2")
model = DnaBert2ForContactPrediction.from_pretrained("multimolecule/dnabert2")

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

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

DNABERT-2 used Masked Language Modeling (MLM) as the pre-training objective: taking a sequence, the model randomly masks 15% 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 DNABERT-2 model was pre-trained on multi-species genome sequences from GenBank . The dataset encompasses genomes from 135 species, spread across 6 categories. In total, the dataset includes 32.49 billion nucleotide bases, nearly 12 times the volume of the human genome dataset. All sequences with N are excluded, retaining only sequences that consist of A , T , C , and G .

DNABERT-2 uses Byte Pair Encoding (BPE) tokenization with a vocabulary size of 4096. This replaces the k-mer tokenization used in the original DNABERT, providing improved computational and sample efficiency.

Training Procedure
Preprocessing

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

  • 15% of the tokens are masked.
  • In 80% of the cases, the masked tokens are replaced by <mask> .
  • In 10% of the cases, the masked tokens are replaced by a random token (different) from the one they replace.
  • In the 10% remaining cases, the masked tokens are left as is.
Pre-training

The model was trained on 8 NVIDIA RTX 2080 Ti GPUs.

  • Steps: 500,000
  • Optimizer: AdamW
  • \beta_1: 0.9
  • \beta_2: 0.98
  • Learning rate: 1e-6
  • Learning rate warm-up: 30,000 steps
  • Learning rate scheduler: Linear
  • Minimum learning rate: 0
  • Weight decay: 1e-5
Citation
@inproceedings{zhou2024dnabert,
  title={{DNABERT}-2: Efficient Foundation Model and Benchmark For Multi-Species Genomes},
  author={Zhihan Zhou and Yanrong Ji and Weijian Li and Pratik Dutta and Ramana V Davuluri and Han Liu},
  booktitle={The Twelfth International Conference on Learning Representations},
  year={2024},
  url={https://openreview.net/forum?id=oMLQB4EZE1}
}

The artifacts distributed in this repository are part of the MultiMolecule project. If you use MultiMolecule in your research, you must cite the MultiMolecule project as follows:

@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 DNABERT-2 paper for questions or comments on the paper/model.

License

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

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

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

Runs of multimolecule dnabert2 on huggingface.co

55.2K
Total runs
2.1K
24-hour runs
2.0K
3-day runs
-1.1K
7-day runs
50.1K
30-day runs

More Information About dnabert2 huggingface.co Model

More dnabert2 license Visit here:

https://choosealicense.com/licenses/agpl-3.0

dnabert2 huggingface.co

dnabert2 huggingface.co is an AI model on huggingface.co that provides dnabert2's model effect (), which can be used instantly with this multimolecule dnabert2 model. huggingface.co supports a free trial of the dnabert2 model, and also provides paid use of the dnabert2. Support call dnabert2 model through api, including Node.js, Python, http.

multimolecule dnabert2 online free

dnabert2 huggingface.co is an online trial and call api platform, which integrates dnabert2's modeling effects, including api services, and provides a free online trial of dnabert2, you can try dnabert2 online for free by clicking the link below.

multimolecule dnabert2 online free url in huggingface.co:

https://huggingface.co/multimolecule/dnabert2

dnabert2 install

dnabert2 is an open source model from GitHub that offers a free installation service, and any user can find dnabert2 on GitHub to install. At the same time, huggingface.co provides the effect of dnabert2 install, users can directly use dnabert2 installed effect in huggingface.co for debugging and trial. It also supports api for free installation.

dnabert2 install url in huggingface.co:

https://huggingface.co/multimolecule/dnabert2

Url of dnabert2

Provider of dnabert2 huggingface.co

multimolecule
ORGANIZATIONS

Other API from multimolecule

huggingface.co

Total runs: 12.8K
Run Growth: -20.9K
Growth Rate: -164.14%
Updated:February 02 2026
huggingface.co

Total runs: 1.2K
Run Growth: 107
Growth Rate: 9.01%
Updated:February 02 2026
huggingface.co

Total runs: 310
Run Growth: -7.4K
Growth Rate: -2388.71%
Updated:February 02 2026
huggingface.co

Total runs: 303
Run Growth: 124
Growth Rate: 40.92%
Updated:February 02 2026
huggingface.co

Total runs: 165
Run Growth: -537
Growth Rate: -325.45%
Updated:February 02 2026
huggingface.co

Total runs: 48
Run Growth: 0
Growth Rate: 0.00%
Updated:December 16 2024
huggingface.co

Total runs: 31
Run Growth: 27
Growth Rate: 87.10%
Updated:May 31 2026
huggingface.co

Total runs: 0
Run Growth: 0
Growth Rate: 0.00%
Updated:September 14 2024
huggingface.co

Total runs: 0
Run Growth: 0
Growth Rate: 0.00%
Updated:September 14 2024