nashtur commited on
Commit
2164109
1 Parent(s): 943caa2

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +0 -35
README.md CHANGED
@@ -8,38 +8,3 @@ tags:
8
 
9
 
10
 
11
- ## Model in Action 🚀
12
- ```
13
- import torch
14
- from transformers import PegasusForConditionalGeneration, PegasusTokenizer
15
- model_name = 'nashtur/postbox'
16
- torch_device = 'cuda' if torch.cuda.is_available() else 'cpu'
17
- tokenizer = PegasusTokenizer.from_pretrained(model_name)
18
- model = PegasusForConditionalGeneration.from_pretrained(model_name).to(torch_device)
19
-
20
- def get_response(input_text,num_return_sequences,num_beams):
21
- batch = tokenizer([input_text],truncation=True,padding='longest',max_length=60, return_tensors="pt").to(torch_device)
22
- translated = model.generate(**batch,max_length=60,num_beams=num_beams, num_return_sequences=num_return_sequences, temperature=1.5)
23
- tgt_text = tokenizer.batch_decode(translated, skip_special_tokens=True)
24
- return tgt_text
25
- ```
26
- #### Example:
27
- ```
28
- num_beams = 10
29
- num_return_sequences = 10
30
- context = "The ultimate test of your knowledge is your capacity to convey it to another."
31
- get_response(context,num_return_sequences,num_beams)
32
- # output:
33
- ['The test of your knowledge is your ability to convey it.',
34
- 'The ability to convey your knowledge is the ultimate test of your knowledge.',
35
- 'The ability to convey your knowledge is the most important test of your knowledge.',
36
- 'Your capacity to convey your knowledge is the ultimate test of it.',
37
- 'The test of your knowledge is your ability to communicate it.',
38
- 'Your capacity to convey your knowledge is the ultimate test of your knowledge.',
39
- 'Your capacity to convey your knowledge to another is the ultimate test of your knowledge.',
40
- 'Your capacity to convey your knowledge is the most important test of your knowledge.',
41
- 'The test of your knowledge is how well you can convey it.',
42
- 'Your capacity to convey your knowledge is the ultimate test.']
43
- ```
44
-
45
-
 
8
 
9
 
10