DianLiI commited on
Commit
7536b62
1 Parent(s): d23930a
Files changed (1) hide show
  1. README.md +44 -1
README.md CHANGED
@@ -41,7 +41,50 @@ We evaluate the benefits of pretraining DNA FM 7B by conducting a comprehensive
41
  TODO (@Caleb), we will need to see what results we want to put here.
42
 
43
  ## How to Use
44
- TODO(@Dian Li)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
 
46
 
47
  ## Citation
 
41
  TODO (@Caleb), we will need to see what results we want to put here.
42
 
43
  ## How to Use
44
+ ### Build any downstream models from this backbone
45
+ #### Embedding
46
+ ```python
47
+ from genbio_finetune.tasks import Embed
48
+ model = Embed.from_config({"model.backbone": "dnafm"})
49
+ collated_batch = model.collate({"sequences": ["ACGT", "ACGT"]})
50
+ embedding = model(collated_batch)
51
+ print(embedding.shape)
52
+ print(embedding)
53
+ ```
54
+ #### Sequence Level Classification
55
+ ```python
56
+ import torch
57
+ from genbio_finetune.tasks import SequenceClassification
58
+ model = SequenceClassification.from_config({"model.backbone": "dnafm", "model.n_classes": 2})
59
+ collated_batch = model.collate({"sequences": ["ACGT", "ACGT"]})
60
+ logits = model(collated_batch)
61
+ print(logits)
62
+ print(torch.argmax(logits, dim=-1))
63
+ ```
64
+ #### Token Level Classification
65
+ ```python
66
+ import torch
67
+ from genbio_finetune.tasks import TokenClassification
68
+ model = TokenClassification.from_config({"model.backbone": "dnafm", "model.n_classes": 3})
69
+ collated_batch = model.collate({"sequences": ["ACGT", "ACGT"]})
70
+ logits = model(collated_batch)
71
+ print(logits)
72
+ print(torch.argmax(logits, dim=-1))
73
+ ```
74
+ #### Regression
75
+ ```python
76
+ from genbio_finetune.tasks import SequenceRegression
77
+ model = SequenceRegression.from_config({"model.backbone": "dnafm"})
78
+ collated_batch = model.collate({"sequences": ["ACGT", "ACGT"]})
79
+ logits = model(collated_batch)
80
+ print(logits)
81
+ ```
82
+ #### Or use our one-liner CLI to finetune or evaluate any of the above!
83
+ ```
84
+ gbft fit --model SequenceClassification --model.backbone dnafm --data SequenceClassification --data.path <hf_or_local_path_to_your_dataset>
85
+ gbft test --model SequenceClassification --model.backbone dnafm --data SequenceClassification --data.path <hf_or_local_path_to_your_dataset>
86
+ ```
87
+ For more information, visit: [Model Generator](https://github.com/genbio-ai/test)
88
 
89
 
90
  ## Citation