Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Build any Downstream Tasks from this backbone
|
2 |
+
## Embedding
|
3 |
+
```python
|
4 |
+
from genbio_finetune.tasks import Embed
|
5 |
+
|
6 |
+
model = Embed.from_config({"model.backbone": "dna300m"})
|
7 |
+
|
8 |
+
collated_batch = model.collate({"sequences": ["ACGT", "ACGT"]})
|
9 |
+
embedding = model(collated_batch)
|
10 |
+
print(embedding.shape)
|
11 |
+
print(embedding)
|
12 |
+
```
|
13 |
+
## Sequence Level Classification
|
14 |
+
```python
|
15 |
+
import torch
|
16 |
+
from genbio_finetune.tasks import SequenceClassification
|
17 |
+
|
18 |
+
model = SequenceClassification.from_config({"model.backbone": "dna300m", "model.n_classes": 2})
|
19 |
+
|
20 |
+
collated_batch = model.collate({"sequences": ["ACGT", "ACGT"]})
|
21 |
+
logits = model(collated_batch)
|
22 |
+
print(logits)
|
23 |
+
print(torch.argmax(logits, dim=-1))
|
24 |
+
```
|
25 |
+
## Token Level Classification
|
26 |
+
```python
|
27 |
+
import torch
|
28 |
+
from genbio_finetune.tasks import TokenClassification
|
29 |
+
|
30 |
+
model = TokenClassification.from_config({"model.backbone": "dna300m", "model.n_classes": 3})
|
31 |
+
|
32 |
+
collated_batch = model.collate({"sequences": ["ACGT", "ACGT"]})
|
33 |
+
logits = model(collated_batch)
|
34 |
+
print(logits)
|
35 |
+
print(torch.argmax(logits, dim=-1))
|
36 |
+
```
|
37 |
+
## Regression
|
38 |
+
```python
|
39 |
+
from genbio_finetune.tasks import SequenceRegression
|
40 |
+
|
41 |
+
model = SequenceRegression.from_config({"model.backbone": "dna300m"})
|
42 |
+
|
43 |
+
collated_batch = model.collate({"sequences": ["ACGT", "ACGT"]})
|
44 |
+
logits = model(collated_batch)
|
45 |
+
print(logits)
|
46 |
+
```
|
47 |
+
## And many more!
|
48 |
+
[Model Generator](https://github.com/genbio-ai/test)
|