t3 / app.py
MIRNA-MOUKHTAR2025's picture
Upload 2 files
4ac26d6 verified
raw
history blame contribute delete
620 Bytes
import gradio as gr
from transformers import pipeline
# Load a pre-trained QA model
qa_pipeline = pipeline("question-answering", model="deepset/roberta-base-squad2")
# Define a function to get answers
def answer_question(context, question):
result = qa_pipeline(question=question, context=context)
return result['answer']
# Create Gradio Interface
interface = gr.Interface(
fn=answer_question,
inputs=["text", "text"],
outputs="text",
title="Question Answering Model",
description="Ask a question based on the given context."
)
# Launch the app
interface.launch()