File size: 647 Bytes
9b93859 8bda67b 9b93859 8bda67b 9b93859 8bda67b 9b93859 8bda67b 561eccb 9b93859 8bda67b 3443437 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | import gradio as gr
from transformers import pipeline, AutoTokenizer, AutoModelForQuestionAnswering
# Hugging Face ๋ชจ๋ธ ๋ก๋
model_name = "distilbert-base-cased-distilled-squad"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForQuestionAnswering.from_pretrained(model_name)
qa_pipeline = pipeline("question-answering", model=model, tokenizer=tokenizer)
# Gradio ์ธํฐํ์ด์ค ์ ์
iface = gr.Interface(
fn=lambda question: qa_pipeline(question=question, context=context)["answer"],
inputs=gr.Textbox(label="Enter a question"),
outputs="text",
live=True,
)
# ์ธํฐํ์ด์ค ์คํ
iface.launch()
|