File size: 638 Bytes
9d27398
25c6893
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9d27398
 
25c6893
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

# 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()