aisah1 commited on
Commit
7469f5d
1 Parent(s): 43deff4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -2
app.py CHANGED
@@ -4,12 +4,22 @@ from os import system
4
  system("pip3 install torch")
5
  system("pip3 install transformers")
6
 
7
- from transformers import AutoTokenizer
8
 
9
  tokenizer = AutoTokenizer.from_pretrained("openai-community/openai-gpt")
 
10
 
11
  def work(inp_text):
12
- out = tokenizer.encode(inp_text)
 
 
 
 
 
 
 
 
 
13
 
14
  return str(out)
15
 
 
4
  system("pip3 install torch")
5
  system("pip3 install transformers")
6
 
7
+ from transformers import AutoTokenizer,OpenAIGPTLMHeadModel
8
 
9
  tokenizer = AutoTokenizer.from_pretrained("openai-community/openai-gpt")
10
+ model = OpenAIGPTLMHeadModel.from_pretrained("openai-community/openai-gpt")
11
 
12
  def work(inp_text):
13
+ out = tokenizer.encode(inp_text,return_tensors="pt")
14
+
15
+ out = model.generate(
16
+ out,
17
+ max_new_tokens=20,
18
+ do_sample=True,
19
+ temperature=0.3,
20
+ )
21
+
22
+ out = tokenizer.decode(out[0])
23
 
24
  return str(out)
25