QAModel / app.py
nneka's picture
Update app.py
ac90090 verified
raw
history blame
811 Bytes
from transformers import pipeline
import gradio as gr
# Load the question-answering pipeline using the deepset/roberta-base-squad2 model
qa_model = pipeline("question-answering", model="deepset/roberta-base-squad2")
# Define a function to get the model's response
def get_response(context, question):
answer = qa_model(question=question, context=context)["answer"]
return answer
# Define the interface components
context_textbox = gr.Textbox(lines=10, label="Context")
question_textbox = gr.Textbox(label="Question")
output_label = gr.Label(label="Response: ")
interface = gr.Interface(
fn=get_response,
inputs=[context_textbox, question_textbox],
outputs=output_label,
title="QA System",
description="Ask any questions.",
)
# Launch the interface
interface.launch(share=True)