Aityz commited on
Commit
19d7d4f
1 Parent(s): d6c3298

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -0
app.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoTokenizer
3
+ from transformers import AutoModelForCausalLM
4
+ import torch
5
+
6
+ tokenizer = AutoTokenizer.from_pretrained("Aityz/Aityz_model_eli5")
7
+
8
+ model = AutoModelForCausalLM.from_pretrained("Aityz/Aityz_model_eli5")
9
+
10
+ # maxtokens = int(input('What would you like the max tokens to be (default: 100) '))
11
+
12
+ def aityz(input, maxtokens):
13
+ prompt = input
14
+ inputs = tokenizer(prompt, return_tensors="pt").input_ids
15
+ outputs = model.generate(inputs, max_new_tokens=maxtokens, do_sample=True, top_k=50, top_p=0.95)
16
+ output = tokenizer.batch_decode(outputs, skip_special_tokens=True)
17
+ outputstr = ''.join(output)
18
+ return(outputstr)
19
+ demo = gr.Interface(fn=aityz, inputs=["textbox", gr.Slider(1, 1000, value=100)], outputs="textbox")
20
+ demo.launch() # enable share=True for Non Hugging Face Spaces Usage.........