File size: 410 Bytes
a36358f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import gradio as gr
from transformers import pipeline

qa = pipeline("question-answering", model="distilbert-base-uncased-distilled-squad")

def responder(contexto, pregunta):
    respuesta = qa(question=pregunta, context=contexto)
    return respuesta["answer"]

app = gr.Interface(
    fn=responder,
    inputs=[gr.Textbox(label="Contexto"), gr.Textbox(label="Pregunta")],
    outputs="text"
)

app.launch()