eduardmihai commited on
Commit
53c65cb
·
1 Parent(s): d56a140
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -1,7 +1,13 @@
1
  import gradio as gr
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- demo.launch()
 
 
 
 
 
1
  import gradio as gr
2
+ from transformers import AutoModelForCausalLM, AutoTokenizer
3
 
4
+ model_name = "TinyLlama/TinyLlama-1.1B-Chat-v1.0"
5
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
6
+ model = AutoModelForCausalLM.from_pretrained(model_name)
7
 
8
+ def generate(prompt):
9
+ inputs = tokenizer(prompt, return_tensors="pt")
10
+ outputs = model.generate(**inputs, max_new_tokens=50)
11
+ return tokenizer.decode(outputs[0], skip_special_tokens=True)
12
+
13
+ gr.Interface(fn=generate, inputs="text", outputs="text").launch()