QA / app.py
vitorandrade's picture
Update app.py
25c6893 verified
raw
history blame
638 Bytes
import gradio as gr
from transformers import pipeline
# Carrega o modelo de Resposta a Perguntas
qa_model = pipeline("question-answering", model="vsvasconcelos/Phi-2_PT_QA_2_v3")
# Define a função para responder às perguntas
def answer_question(context, question):
if context:
return qa_model(question=question, context=context)['answer']
else:
return qa_model(question=question)['answer']
# Cria a interface Gradio
iface = gr.Interface(
fn=answer_question,
inputs=["text", "text"],
outputs="text",
title="QA Model",
description="Pergunte algo e obtenha uma resposta!"
)
iface.launch()