Spaces:
Sleeping
Sleeping
Download app.py from srinikesh1432/Question_Answering: direct link, hf CLI and curl.
- Browser
- Download file 859 Bytes
-
https://huggingface.co/spaces/srinikesh1432/Question_Answering/resolve/main/app.py
- Command line
-
hf download hf://spaces/srinikesh1432/Question_Answering/app.py
-
curl -L -o app.py https://huggingface.co/spaces/srinikesh1432/Question_Answering/resolve/main/app.py
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() | |