Spaces:
Sleeping
Sleeping
Commit
·
53c65cb
1
Parent(s):
d56a140
My Model
Browse files
app.py
CHANGED
@@ -1,7 +1,13 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
|
4 |
-
|
|
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
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()
|