srinikesh1432's picture
Upload 2 files
4095bfc verified
raw
history blame contribute delete
859 Bytes
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()