upload model ke space hugging face
Browse files
app.py
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 2 |
+
import torch
|
| 3 |
import gradio as gr
|
| 4 |
|
| 5 |
+
model = AutoModelForCausalLM.from_pretrained("atsnetwork/my-custom-tinyllama-chatbot")
|
| 6 |
+
tokenizer = AutoTokenizer.from_pretrained("atsnetwork/my-custom-tinyllama-chatbot")
|
| 7 |
|
| 8 |
+
def generate_response(prompt):
|
| 9 |
+
inputs = tokenizer(prompt, return_tensors="pt")
|
| 10 |
+
outputs = model.generate(**inputs, max_new_tokens=100)
|
| 11 |
+
return tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 12 |
+
|
| 13 |
+
iface = gr.Interface(fn=generate_response, inputs="text", outputs="text")
|
| 14 |
+
iface.launch()
|