Spaces:
Sleeping
Sleeping
Download app.py from TNK21/Question_Answering: direct link, hf CLI and curl.
- Browser
- Download file 795 Bytes
-
https://huggingface.co/spaces/TNK21/Question_Answering/resolve/main/app.py
- Command line
-
hf download hf://spaces/TNK21/Question_Answering/app.py
-
curl -L -o app.py https://huggingface.co/spaces/TNK21/Question_Answering/resolve/main/app.py
795 Bytes
| import gradio as gr | |
| from transformers import pipeline | |
| # Load the question answering model | |
| qa = pipeline("question-answering") | |
| # Define the function to generate the answer | |
| def generate_answer(context, question): | |
| result = qa(question=question, context=context) | |
| return result["answer"] | |
| # Define the Gradio interface | |
| inputs = [ | |
| gr.components.Textbox(label="Enter some context"), | |
| gr.components.Textbox(label="Enter a question") | |
| ] | |
| outputs = gr.components.Textbox(label="Answer") | |
| title = "Question Answering with Hugging Face" | |
| description = "Answer questions based on a given context using Hugging Face's question answering model" | |
| iface = gr.Interface(fn=generate_answer, inputs=inputs, outputs=outputs, title=title, description=description) | |
| # Launch the Gradio app | |
| iface.launch() |