Raghavan1988 commited on
Commit
8b1c3de
1 Parent(s): 263a256

update app.py

Browse files

updated app.py

Files changed (1) hide show
  1. app.py +24 -1
app.py CHANGED
@@ -1,7 +1,30 @@
1
  import gradio as gr
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  def greet(name):
4
- return "Hello " + name + "!!"
 
 
 
 
 
 
5
 
6
  iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
  iface.launch()
 
1
  import gradio as gr
2
+ from transformers import AutoModelForCausalLM, AutoTokenizer
3
+ tokenizer = AutoTokenizer.from_pretrained("stabilityai/stablelm-3b-4e1t")
4
+ model = AutoModelForCausalLM.from_pretrained(
5
+ "stabilityai/stablelm-3b-4e1t",
6
+ trust_remote_code=True,
7
+ torch_dtype="auto",
8
+ )
9
+ model.cuda()
10
+ inputs = tokenizer("The weather is always wonderful", return_tensors="pt").to("cuda")
11
+ tokens = model.generate(
12
+ **inputs,
13
+ max_new_tokens=64,
14
+ temperature=0.75,
15
+ top_p=0.95,
16
+ do_sample=True,
17
+ )
18
+ print(tokenizer.decode(tokens[0], skip_special_tokens=True))
19
 
20
  def greet(name):
21
+ inputs = tokenizer("The weather is always wonderful", return_tensors="pt").to("cuda")
22
+ tokens = model.generate(**inputs,max_new_tokens=64,temperature=0.75,top_p=0.95, do_sample=True)
23
+
24
+ return tokens
25
+
26
+
27
+
28
 
29
  iface = gr.Interface(fn=greet, inputs="text", outputs="text")
30
  iface.launch()