Spaces:
Runtime error
Runtime error
File size: 596 Bytes
0abb7ea 43e499d 91c5c87 0abb7ea 91c5c87 0abb7ea 91c5c87 0abb7ea 91c5c87 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
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()
|