Spaces:
Sleeping
Sleeping
File size: 859 Bytes
4095bfc | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | import gradio as gr
from transformers import pipeline
# Load QA pipeline
qa_pipeline = pipeline("question-answering", model="distilbert-base-uncased-distilled-squad")
def answer_question(context, question):
result = qa_pipeline(question=question, context=context)
return result['answer']
with gr.Blocks() as demo:
gr.Markdown("## 📘 Question Answering App (Extractive QA)")
context = gr.Textbox(
lines=8,
placeholder="Paste a paragraph or article here...",
label="Context Paragraph"
)
question = gr.Textbox(
lines=2,
placeholder="Type your question here...",
label="Question"
)
output = gr.Textbox(label="Answer")
btn = gr.Button("Get Answer")
btn.click(fn=answer_question, inputs=[context, question], outputs=output)
demo.launch()
|