app.py
Browse files
app.py
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
3 |
+
|
4 |
+
# โหลดโมเดลและโทเคนไนเซอร์
|
5 |
+
model_name = "scb10x/llama-3-typhoon-v1.5-8b"
|
6 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
7 |
+
model = AutoModelForCausalLM.from_pretrained(model_name)
|
8 |
+
|
9 |
+
def ask_question(question):
|
10 |
+
inputs = tokenizer(question, return_tensors="pt")
|
11 |
+
outputs = model.generate(**inputs, max_length=500)
|
12 |
+
answer = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
13 |
+
return answer
|
14 |
+
|
15 |
+
iface = gr.Interface(fn=ask_question, inputs="text", outputs="text", title="LLaMA Chatbot")
|
16 |
+
|
17 |
+
iface.launch()
|