hugohrban commited on
Commit
5f0626f
·
verified ·
1 Parent(s): 0bbce28

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +28 -1
README.md CHANGED
@@ -2,7 +2,34 @@
2
  license: bsd-3-clause
3
  tags:
4
  - protein
 
5
  ---
6
  This is the one-directional model trained on 7 protein families.
7
 
8
- Check out the [github repo](https://github.com/hugohrban/ProGen2-finetuning) for more information.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  license: bsd-3-clause
3
  tags:
4
  - protein
5
+ - progen2
6
  ---
7
  This is the one-directional model trained on 7 protein families.
8
 
9
+ Check out the [github repo](https://github.com/hugohrban/ProGen2-finetuning) for more information.
10
+
11
+ Example usage:
12
+
13
+ ```python
14
+ from transformers import AutoModelForCausalLM
15
+ from transformers import AutoTokenizer
16
+ import torch
17
+ import torch.nn.functional as F
18
+
19
+ # load model and tokenizer
20
+ model = AutoModelForCausalLM.from_pretrained("hugohrban/progen2-small-mix7", trust_remote_code=True)
21
+ tokenizer = AutoTokenizer.from_pretrained("hugohrban/progen2-small-mix7", trust_remote_code=True)
22
+
23
+ # prepare input
24
+ prompt = "<|pf03668|>1MEVVIVTGMSGAGK"
25
+ input_ids = torch.tensor(tokenizer.encode(prompt)).to(model.device)
26
+
27
+ # forward pass
28
+ logits = model(input_ids).logits
29
+
30
+ # print output probabilities
31
+ next_token_logits = logits[-1, :]
32
+ next_token_probs = F.softmax(next_token_logits, dim=-1)
33
+ for i, prob in enumerate(next_token_probs):
34
+ print(f"{tokenizer.decode(i)}: {100 * prob:.2f}%")
35
+ ```