mfajcik commited on
Commit
1769f8a
1 Parent(s): ec64de2

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +21 -0
README.md CHANGED
@@ -40,6 +40,27 @@ Not mentioned parameters are the same as for GPT-2.
40
  | scheduler_steps | 200,000 | |
41
  | scheduler_alpha | 0.1 | So LR on last step is 0.1*(vanilla LR) |
42
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
 
44
  ## Evaluation
45
  We observed 10-shot result improvement over the course of training for sentiment analysis, and hellaswag-like commonsense reasoning.
 
40
  | scheduler_steps | 200,000 | |
41
  | scheduler_alpha | 0.1 | So LR on last step is 0.1*(vanilla LR) |
42
 
43
+ ## Usage
44
+ ```python
45
+ from transformers import AutoTokenizer, GPT2LMHeadModel
46
+ import torch
47
+
48
+ t = AutoTokenizer.from_pretrained("BUT-FIT/Czech-GPT-2-XL-133k")
49
+ m = GPT2LMHeadModel.from_pretrained("BUT-FIT/Czech-GPT-2-XL-133k").eval()
50
+
51
+ # Try the model inference
52
+ prompt = "Najznámějším českým spisovatelem "
53
+ input_ids = t.encode(prompt, return_tensors="pt")
54
+ with torch.no_grad():
55
+ generated_text = m.generate(input_ids=input_ids,
56
+ do_sample=True,
57
+ top_p=0.95,
58
+ repetition_penalty=1.0,
59
+ temperature=0.8,
60
+ max_new_tokens=64,
61
+ num_return_sequences=1)
62
+ print(t.decode(generated_text[0], skip_special_tokens=True))
63
+ ```
64
 
65
  ## Evaluation
66
  We observed 10-shot result improvement over the course of training for sentiment analysis, and hellaswag-like commonsense reasoning.