hugohrban commited on
Commit
e1ca8ca
·
verified ·
1 Parent(s): 211cb3a

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +30 -2
README.md CHANGED
@@ -1,6 +1,34 @@
1
  ---
2
  license: bsd-3-clause
3
  ---
4
- Base ProGen2-small model.
5
 
6
- [Original repo](https://github.com/salesforce/progen/tree/main/progen2)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: bsd-3-clause
3
  ---
4
+ Mirror of the base ProGen2-small model.
5
 
6
+ [Original repo](https://github.com/salesforce/progen/tree/main/progen2)
7
+
8
+ See also my github [repo](https://github.com/hugohrban/ProGen2-finetuning/tree/main) for an example of finetuning this model.
9
+
10
+ Example usage:
11
+
12
+ ```python
13
+ from transformers import AutoModelForCausalLM
14
+ from transformers import AutoTokenizer
15
+ import torch
16
+ import torch.nn.functional as F
17
+
18
+ # load model and tokenizer
19
+ model = AutoModelForCausalLM.from_pretrained("hugohrban/progen2-small", trust_remote_code=True)
20
+ tokenizer = AutoTokenizer.from_pretrained("hugohrban/progen2-small", trust_remote_code=True)
21
+
22
+ # prepare input
23
+ prompt = "1MEVVIVTGMSGAGK"
24
+ input_ids = torch.tensor(tokenizer.encode(prompt)).to(model.device)
25
+
26
+ # forward pass
27
+ logits = model(input_ids).logits
28
+
29
+ # print output probabilities
30
+ next_token_logits = logits[-1, :]
31
+ next_token_probs = F.softmax(next_token_logits, dim=-1)
32
+ for i, prob in enumerate(next_token_probs):
33
+ print(f"{tokenizer.decode(i)}: {100 * prob:.2f}%")
34
+ ```