File size: 607 Bytes
9a2d345
8e54fd5
 
 
 
 
 
 
bc8b6c7
8e54fd5
fc84913
8e54fd5
ebf3181
8e54fd5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import gradio as gr
from transformers import pipeline
import torch

def answer_question(question, answer_text):
  model_checkpoint = "MarcBrun/ixambert-finetuned-squad"
  question_answerer = pipeline("question-answering", model=model_checkpoint)

  answer = question_answerer(question=question, context=answer_text)
  
  return answer["answer"]

iface = gr.Interface(fn=answer_question, inputs=[gr.inputs.Textbox(lines=1, placeholder="Question Here...", label="Question"),gr.inputs.Textbox(lines=5, placeholder="Context Here...", label="Context")], outputs=gr.outputs.Textbox(label="Answer"))
iface.launch()