Spaces:
Sleeping
Sleeping
File size: 795 Bytes
553bbde 92d92e2 553bbde 92d92e2 553bbde 92d92e2 |
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 |
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() |