Update README.md
Browse files
README.md
CHANGED
@@ -1,52 +1,45 @@
|
|
1 |
-
|
2 |
-
|
|
|
3 |
```python
|
4 |
from genbio_finetune.tasks import Embed
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
collated_batch = model.collate({"sequences": ["ACGT", "ACGT"]})
|
9 |
embedding = model(collated_batch)
|
10 |
print(embedding.shape)
|
11 |
print(embedding)
|
12 |
```
|
13 |
-
|
14 |
```python
|
15 |
import torch
|
16 |
from genbio_finetune.tasks import SequenceClassification
|
17 |
-
|
18 |
-
|
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 |
-
|
26 |
```python
|
27 |
import torch
|
28 |
from genbio_finetune.tasks import TokenClassification
|
29 |
-
|
30 |
-
|
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 |
-
|
38 |
```python
|
39 |
from genbio_finetune.tasks import SequenceRegression
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
collated_batch = model.collate({"sequences": ["ACGT", "ACGT"]})
|
44 |
logits = model(collated_batch)
|
45 |
print(logits)
|
46 |
```
|
47 |
-
|
48 |
```
|
49 |
-
gbft fit --model SequenceClassification --model.backbone
|
50 |
-
gbft test --model SequenceClassification --model.backbone
|
51 |
```
|
52 |
-
For more information, visit: [Model Generator](https://github.com/genbio-ai/
|
|
|
1 |
+
## How to Use
|
2 |
+
### Build any downstream models from this backbone
|
3 |
+
#### Embedding
|
4 |
```python
|
5 |
from genbio_finetune.tasks import Embed
|
6 |
+
model = Embed.from_config({"model.backbone": "dnafm"}).eval()
|
7 |
+
collated_batch = model.collate({"sequences": ["ACGT", "AGCT"]})
|
|
|
|
|
8 |
embedding = model(collated_batch)
|
9 |
print(embedding.shape)
|
10 |
print(embedding)
|
11 |
```
|
12 |
+
#### Sequence Level Classification
|
13 |
```python
|
14 |
import torch
|
15 |
from genbio_finetune.tasks import SequenceClassification
|
16 |
+
model = SequenceClassification.from_config({"model.backbone": "dnafm", "model.n_classes": 2}).eval()
|
17 |
+
collated_batch = model.collate({"sequences": ["ACGT", "AGCT"]})
|
|
|
|
|
18 |
logits = model(collated_batch)
|
19 |
print(logits)
|
20 |
print(torch.argmax(logits, dim=-1))
|
21 |
```
|
22 |
+
#### Token Level Classification
|
23 |
```python
|
24 |
import torch
|
25 |
from genbio_finetune.tasks import TokenClassification
|
26 |
+
model = TokenClassification.from_config({"model.backbone": "dnafm", "model.n_classes": 3}).eval()
|
27 |
+
collated_batch = model.collate({"sequences": ["ACGT", "AGCT"]})
|
|
|
|
|
28 |
logits = model(collated_batch)
|
29 |
print(logits)
|
30 |
print(torch.argmax(logits, dim=-1))
|
31 |
```
|
32 |
+
#### Regression
|
33 |
```python
|
34 |
from genbio_finetune.tasks import SequenceRegression
|
35 |
+
model = SequenceRegression.from_config({"model.backbone": "dnafm"}).eval()
|
36 |
+
collated_batch = model.collate({"sequences": ["ACGT", "AGCT"]})
|
|
|
|
|
37 |
logits = model(collated_batch)
|
38 |
print(logits)
|
39 |
```
|
40 |
+
#### Or use our one-liner CLI to finetune or evaluate any of the above!
|
41 |
```
|
42 |
+
gbft fit --model SequenceClassification --model.backbone dnafm --data SequenceClassification --data.path <hf_or_local_path_to_your_dataset>
|
43 |
+
gbft test --model SequenceClassification --model.backbone dnafm --data SequenceClassification --data.path <hf_or_local_path_to_your_dataset>
|
44 |
```
|
45 |
+
For more information, visit: [Model Generator](https://github.com/genbio-ai/modelgenerator)
|