abhattac commited on
Commit
23f4335
1 Parent(s): e008d28

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -0
app.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoTokenizer, AutoModelForCasualLM
3
+
4
+ tokenizer = AutoTokenizer.from_pretrained("togethercomputer/GPT-NeoXT-Chat-Base-20B")
5
+ model = AutoModelForCausalLM.from_pretrained("togethercomputer/GPT-NeoXT-Chat-Base-20B", torch_dtype=torch.bfloat16)
6
+
7
+ def gpt(prompt):
8
+ inputs = tokenizer("<human>: Hello!\n<bot>:", return_tensors='pt').to(model.device)
9
+ outputs = model.generate(**inputs, max_new_tokens=10, do_sample=True, temperature=0.8)
10
+ output_str = tokenizer.decode(outputs[0])
11
+ print(output_str)
12
+ return output_str
13
+
14
+ grInterface = gr.Interface(
15
+ fn=gpt,
16
+ inputs="text",
17
+ outputs="text"
18
+ )
19
+ grInterface.launch()