Spaces:
Runtime error
Runtime error
import gradio as gr | |
from transformers import AutoModelForCausalLM, AutoTokenizer | |
# 載入模型和分詞器 | |
model_name = "taide/Llama3-TAIDE-LX-8B-Chat-Alpha1" | |
model = AutoModelForCausalLM.from_pretrained(model_name) | |
tokenizer = AutoTokenizer.from_pretrained(model_name) | |
def chat_function(input_text): | |
inputs = tokenizer(input_text, return_tensors="pt") | |
output = model.generate(**inputs) | |
response = tokenizer.decode(output[0], skip_special_tokens=True) | |
return response | |
# 創建 Gradio 介面 | |
iface = gr.Interface(fn=chat_function, inputs="text", outputs="text") | |
iface.launch() | |