Instructions to use zhihan1996/DNABERT-2-117M with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use zhihan1996/DNABERT-2-117M with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("zhihan1996/DNABERT-2-117M", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update README.md
#43
by graybirdowner - opened
README.md
CHANGED
|
@@ -14,7 +14,7 @@ We sincerely appreciate the MosaicML team for the [MosaicBERT](https://openrevie
|
|
| 14 |
|
| 15 |
DNABERT-2 is a transformer-based genome foundation model trained on multi-species genome.
|
| 16 |
|
| 17 |
-
To load the model from huggingface:
|
| 18 |
```
|
| 19 |
import torch
|
| 20 |
from transformers import AutoTokenizer, AutoModel
|
|
@@ -22,6 +22,14 @@ from transformers import AutoTokenizer, AutoModel
|
|
| 22 |
tokenizer = AutoTokenizer.from_pretrained("zhihan1996/DNABERT-2-117M", trust_remote_code=True)
|
| 23 |
model = AutoModel.from_pretrained("zhihan1996/DNABERT-2-117M", trust_remote_code=True)
|
| 24 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
To calculate the embedding of a dna sequence
|
| 27 |
```
|
|
|
|
| 14 |
|
| 15 |
DNABERT-2 is a transformer-based genome foundation model trained on multi-species genome.
|
| 16 |
|
| 17 |
+
To load the model from huggingface(version 4.28):
|
| 18 |
```
|
| 19 |
import torch
|
| 20 |
from transformers import AutoTokenizer, AutoModel
|
|
|
|
| 22 |
tokenizer = AutoTokenizer.from_pretrained("zhihan1996/DNABERT-2-117M", trust_remote_code=True)
|
| 23 |
model = AutoModel.from_pretrained("zhihan1996/DNABERT-2-117M", trust_remote_code=True)
|
| 24 |
```
|
| 25 |
+
To load the model from huggingface (version > 4.28):
|
| 26 |
+
```
|
| 27 |
+
from transformers.models.bert.configuration_bert import BertConfig
|
| 28 |
+
from transformers import AutoModel
|
| 29 |
+
|
| 30 |
+
config = BertConfig.from_pretrained("zhihan1996/DNABERT-2-117M")
|
| 31 |
+
model = AutoModel.from_pretrained("zhihan1996/DNABERT-2-117M", trust_remote_code=True, config=config)
|
| 32 |
+
```
|
| 33 |
|
| 34 |
To calculate the embedding of a dna sequence
|
| 35 |
```
|